chain-insights 0.49.0 → 0.49.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 b9914489b5a6d6feab5c28e2d06bd0d15daa2b02 (npm run build:claude-view); refresh with scripts/refresh-claude-view.mjs, never edit by hand -->
1
+ <!-- Chain Insights UI f7f3e907b22fca2d9aa45c62920b2db21ca03072 (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,12 +6,12 @@
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 v_=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),b_=function(e,t){return new URL(e,t).href},Gf={},w_=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=b_(l,r),l in Gf)return;Gf[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":v_,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 __(e){return e}function k_(e){return e}function ls(){return e=>e}function S_(e){}function x_(e){throw new Error("Unexpected value in exhaustive check")}function E_(e){}function Wo(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 gu(e,t="|"){return e.map(n=>nc(n)).join(t)}function Ko(e,t){return typeof t=="bigint"?t.toString():t}class $_{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 $_(e)}function Qu(e){return e==null}function bn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ec(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 jf=Symbol("evaluating");function Gp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jf)return r===void 0&&(r=jf,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function T_(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $t(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ds(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function nn(e){return ds(e._zod.def)??e._zod.def.shape}function jp(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $t(this,t,r),r},enumerable:!0,configurable:!0})}function Zp(e,t,n){t in e?$t(e,t,n):e[t]=n}function Dn(e,t,n,r){const i=nn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?jp(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):Zp(e,o,r?r(s.value,o):s.value))}}function C_(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?jp(e,n,()=>t[n]):Zp(e,n,r.value))}}function ct(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function A_(e){return ct(e._zod.def)}function I_(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function N_(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 z_(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 St(e){return JSON.stringify(e)}function Bp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const tc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Vp=ai(()=>{if(gt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function rn(e){if(Yn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ui(e){return rn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function R_(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const L_=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}`)}},Jo=new Set(["string","number","symbol"]),Hp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function on(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oe(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function A(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 P_(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 nc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function qp(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const rc={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]},ic={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Wp(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 Dn(o,e,fs(e,t)),Oe(e,ct(n,{shape:o,checks:[]}))}function fs(e,t){const n=nn(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 Kp(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(fs(e,t)),s={};return Dn(s,e,Reflect.ownKeys(nn(e)).filter(a=>!o.has(a))),Oe(e,ct(n,{shape:s,checks:[]}))}function Jp(e,t){if(!rn(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=nn(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 Oe(e,ct(e._zod.def,{shape:Yp(e,t)}))}function Yp(e,t){const n={};return Dn(n,e,Reflect.ownKeys(nn(e))),C_(n,t),n}function Xp(e,t){if(!rn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Oe(e,ct(e._zod.def,{shape:Yp(e,t)}))}function Qp(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={};Dn(n,e,Reflect.ownKeys(nn(e))),Dn(n,t,Reflect.ownKeys(nn(t)));const r=ct(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Oe(e,r)}function yu(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(fs(t,n)):void 0,u={};return Dn(u,t,Reflect.ownKeys(nn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),Oe(t,ct(t._zod.def,{shape:u,checks:[]}))}function em(e,t,n){const r=n?new Set(fs(t,n)):void 0,i={};return Dn(i,t,Reflect.ownKeys(nn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),Oe(t,ct(t._zod.def,{shape:i}))}function vt(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 tm(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 zt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Hn(e){return typeof e=="string"?e:e?.message}function vu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Pt(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:Hn(e.inst?._zod.def?.error?.(e))??Hn(o?.(e))??Hn(t?.error?.(e))??Hn(n.customError?.(e))??Hn(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 hs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const D_=/[\uD800-\uDBFF]/;function ci(e){const t=e.length;if(!D_.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 ps(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nm(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 Xn(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function O_(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function rm(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 im(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function M_(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return rm(t+n)}function F_(e){return im(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function U_(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 G_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class j_{constructor(...t){}}function om(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Z_(e,n,r.value)}}function sn(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 sn(e,t,n,!1)}function li(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return sn(this,n,r(this))},set(i){sn(this,n,i)}})}return t}function Z_(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:sn(this,t,n.bind(this))},set(r){sn(this,t,r)}})}function B_(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Ga,gn=!1;const V_={configurable:!0,get(){gn=!0}};function ye(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Ga!==e._zod){Ga=void 0;return}Ga=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,V_);const i=gn;gn=!1;try{const o=n(this);return gn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),gn=gn||i,o}catch(o){throw delete this[t],gn=gn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function sm(e,t,n,r){const i=B_(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 oc="~constantCatch";function sc(e){const t=()=>e;return t[oc]=!0,t}const ac=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:ic,CONSTANT_CATCH:oc,Class:j_,NUMBER_FORMAT_RANGES:rc,aborted:vt,allowsEval:Vp,assert:E_,assertEqual:__,assertIs:S_,assertNever:x_,assertNotEqual:k_,assignProp:$t,attachSchema:vu,base64ToUint8Array:rm,base64urlToUint8Array:M_,cached:ai,captureStackTrace:tc,cleanEnum:O_,cleanRegex:bn,clone:Oe,cloneDef:A_,codePointLength:ci,constantCatch:sc,createTransparentProxy:P_,defineLazy:Gp,defineLazyInternal:ye,derived:li,esc:St,escapeRegex:on,explicitlyAborted:tm,extend:Jp,finalizeIssue:Pt,floatSafeRemainder:ec,getElementAtPath:I_,getEnumValues:Wo,getLengthableOrigin:ps,getParsedType:L_,getSizableOrigin:hs,hexToUint8Array:U_,hide:ms,installLazyProp:sm,isObject:Yn,isPlainObject:rn,issue:Xn,joinValues:gu,jsonStringifyReplacer:Ko,members:om,merge:Qp,mergeDefs:ct,normalizeParams:A,nullish:Qu,numKeys:R_,objectClone:T_,omit:Kp,optionalKeys:qp,own:sn,parsedType:nm,partial:yu,pick:Wp,prefixIssues:zt,primitiveTypes:Hp,promiseAllObject:N_,propertyKeyTypes:Jo,randomString:z_,rawShape:ds,required:em,safeExtend:Xp,shallowClone:ui,slugify:Bp,stringifyPrimitive:nc,toZod:ls,uint8ArrayToBase64:im,uint8ArrayToBase64url:F_,uint8ArrayToHex:G_,unwrapMessage:Hn},Symbol.toStringTag,{value:"Module"}));var Zf;const uc=Object.freeze({status:"aborted"}),ja={value:void 0,enumerable:!1};let Bf="captureStackTrace"in Error?Error:null;function H_(e){const t=Bf;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Bf=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function k(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{ja.value=new o(h);try{Object.defineProperty(f,"_zod",ja)}finally{ja.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),g=f._zod.constr.prototype;let w=m;for(;w&&w!==g;)w=Object.getPrototypeOf(w);const y=w??m;a.has(y)||(a.add(y),om(y,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?H_(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const g of p)g();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 cc=Symbol("zod_brand");class en extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Zf=globalThis).__zod_globalConfig??(Zf.__zod_globalConfig={});const gt=globalThis.__zod_globalConfig;function Ye(e){return e&&Object.assign(gt,e),gt}function q_(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ko,2)),e.message}function W_(e){this._zod.message=e}const K_={get:q_,set:W_,enumerable:!0,configurable:!0},Za={value:void 0,enumerable:!1},Vf=new WeakSet([Object.prototype,Error.prototype]),am=(e,t)=>{e.name="$ZodError",Za.value=t,Object.defineProperty(e,"issues",Za),Za.value=void 0,Object.defineProperty(e,"message",K_);const n=Object.getPrototypeOf(e);Vf.has(n)||(Vf.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})}}))},um=k("$ZodError",am),Tt=k("$ZodError",am,void 0,{Parent:Error});function J_(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 ys(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?J_(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function vs(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 lc(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 cm(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 dc(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 ${cm(r.path)}`);return t.join(`
10
- `)}function bs(e,t){return{callee:t?.callee??e,Err:t?.Err}}const di=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 en;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Pt(c,s,Ye())));throw tc(u,o?.callee??t),u}return a.value};return t},bu=di(Tt),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=>Pt(c,s,Ye())));throw tc(u,o?.callee??t),u}return a.value};return t},wu=fi(Tt),hi=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 en;return o.issues.length?dm(e,o.issues,i):{success:!0,data:o.value}},lm=hi(Tt);function dm(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Pt(i,n,Ye()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const pi=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?dm(e,o.issues,i):{success:!0,data:o.value}},Y_=pi(Tt),X_=Symbol.for("zod.compile.invalid"),Q_=Symbol.for("zod.compile.fallback"),ws=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==X_)return!0;if(r.definite===!0&&n===void 0)return!1}return ek(e,t,n)});function ek(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[Q_]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new en;return o.issues.length===0}const _s=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},fc=e=>{const t=di(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,bs(n,s))};return n},tk=fc(Tt),hc=e=>{const t=di(e),n=(r,i,o,s)=>t(r,i,o,bs(n,s));return n},nk=hc(Tt),pc=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,bs(n,s))};return n},rk=pc(Tt),mc=e=>{const t=fi(e),n=async(r,i,o,s)=>await t(r,i,o,bs(n,s));return n},ik=mc(Tt),gc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return hi(e)(t,n,i)},ok=gc(Tt),yc=e=>(t,n,r)=>hi(e)(t,n,r),sk=yc(Tt),vc=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return pi(e)(t,n,i)},ak=vc(Tt),bc=e=>async(t,n,r)=>pi(e)(t,n,r),uk=bc(Tt),fm=/^[cC][0-9a-z]{6,}$/,hm=/^[0-9a-z]+$/,pm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,mm=/^[0-9a-vA-V]{20}$/,gm=/^[A-Za-z0-9]{27}$/,ym=/^[a-zA-Z0-9_-]{21}$/;function vm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const bm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ck=/^[-+]?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)?)??$/,wm=/^([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})$/,Qn=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)$/,lk=Qn(4),dk=Qn(6),fk=Qn(7),_m=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hk=/^[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])?)*$/,pk=/^(([^<>()\[\]\\.,;:\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,}))$/,km=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,mk=km,gk=/^[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])?)*$/,yk="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Sm(){return new RegExp(yk,"u")}const xm=/^(?:(?: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])$/,Em=/^(([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}|:))$/,$m=e=>{const t=on(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Tm=/^((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])$/,Cm=/^(([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])$/,Am=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Im=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nm=/^(?=.{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])?)*\.?$/,zm=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,wc=/^https?$/,Rm=/^\+[1-9]\d{6,14}$/,_c=/^\d(?:[ -]?\d){11,18}$/,Lm=/^(?: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)$/,kc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Pm="(?:(?:\\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 vk(e){return new RegExp(`^${e}$`)}const Dm=vk(Pm);function _u(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 Om(e){return new RegExp(`^${_u(e)}$`)}function Mm(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${_u({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${_u({precision:e.precision})}`:n;return new RegExp(`^${Pm}T(?:${r})$`)}const Fm=/^[\s\S]{0,}$/,Um=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Gm=/^-?\d+n?$/,Sc=/^-?\d+$/,dr=/^-?\d+(?:\.\d+)?$/,jm=/^(?:true|false)$/i,Zm=/^null$/i,Bm=/^undefined$/i,Vm=/^[^A-Z]*$/,Hm=/^[^a-z]*$/,qm=/^[0-9a-fA-F]*$/;function mi(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function gi(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const bk=/^[0-9a-fA-F]{32}$/,wk=mi(22,"=="),_k=gi(22),kk=/^[0-9a-fA-F]{40}$/,Sk=mi(27,"="),xk=gi(27),Ek=/^[0-9a-fA-F]{64}$/,$k=mi(43,"="),Tk=gi(43),Ck=/^[0-9a-fA-F]{96}$/,Ak=mi(64,""),Ik=gi(64),Nk=/^[0-9a-fA-F]{128}$/,zk=mi(86,"=="),Rk=gi(86),ks=Object.freeze(Object.defineProperty({__proto__:null,anyString:Fm,base64:Am,base64url:Im,bigint:Gm,boolean:jm,browserEmail:gk,cidrv4:Tm,cidrv6:Cm,creditCard:_c,cuid:fm,cuid2:hm,currencyCode:Lm,date:Dm,datetime:Mm,domain:zm,duration:bm,e164:Rm,email:_m,emoji:Sm,extendedDuration:ck,guid:wm,hex:qm,hostname:Nm,html5Email:hk,httpProtocol:wc,iban:kc,idnEmail:mk,integer:Sc,ipv4:xm,ipv6:Em,ksuid:gm,lowercase:Vm,mac:$m,md5_base64:wk,md5_base64url:_k,md5_hex:bk,nanoid:ym,nanoidOfLength:vm,null:Zm,number:dr,rfc5322Email:pk,sha1_base64:Sk,sha1_base64url:xk,sha1_hex:kk,sha256_base64:$k,sha256_base64url:Tk,sha256_hex:Ek,sha384_base64:Ak,sha384_base64url:Ik,sha384_hex:Ck,sha512_base64:zk,sha512_base64url:Rk,sha512_hex:Nk,string:Um,time:Om,ulid:pm,undefined:Bm,unicodeEmail:km,uppercase:Hm,uuid:Qn,uuid4:lk,uuid6:dk,uuid7:fk,xid:mm},Symbol.toStringTag,{value:"Module"})),Me=k("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),xc=e=>{const t=e.value;return!Qu(t)&&t.size!==void 0},Ec=e=>{const t=e.value;return!Qu(t)&&t.length!==void 0},Yo={number:"number",bigint:"bigint",object:"date"},$c=k("$ZodCheckLessThan",(e,t)=>{Me.init(e,t);const n=Yo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Yo[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})}}),Tc=k("$ZodCheckGreaterThan",(e,t)=>{Me.init(e,t);const n=Yo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Yo[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})}}),Wm=k("$ZodCheckMultipleOf",(e,t)=>{Me.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):ec(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})}}),Km=k("$ZodCheckNumberFormat",(e,t)=>{Me.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=rc[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})}}),Jm=k("$ZodCheckBigIntFormat",(e,t)=>{Me.init(e,t);const[n,r]=ic[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})}}),Ym=k("$ZodCheckMaxSize",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:hs(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Xm=k("$ZodCheckMinSize",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:hs(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Qm=k("$ZodCheckSizeEquals",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),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:hs(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})}}),eg=k("$ZodCheckMaxLength",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?ci(i):o)<=t.maximum)return;const a=ps(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tg=k("$ZodCheckMinLength",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?ci(i):o)>=t.minimum)return;const a=ps(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ng=k("$ZodCheckLengthEquals",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?ci(i):o;if(s===t.length)return;const a=ps(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})}}),yi=k("$ZodCheckStringFormat",(e,t)=>{var n,r;Me.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=()=>{})}),rg=k("$ZodCheckRegex",(e,t)=>{yi.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})}}),ig=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Vm),yi.init(e,t)}),og=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Hm),yi.init(e,t)}),sg=k("$ZodCheckIncludes",(e,t)=>{Me.init(e,t);const n=on(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})}}),ag=k("$ZodCheckStartsWith",(e,t)=>{Me.init(e,t);const n=new RegExp(`^${on(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})}}),ug=k("$ZodCheckEndsWith",(e,t)=>{Me.init(e,t);const n=new RegExp(`.*${on(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 Xo(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues))}const cg=k("$ZodCheckProperty",(e,t)=>{Me.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=>Xo(i,n,t.property));Xo(r,n,t.property)}}),lg=k("$ZodCheckProperties",(e,t)=>{Me.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=>Xo(c,r,s)))):Xo(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),dg=k("$ZodCheckMimeType",(e,t)=>{Me.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})}}),fg=k("$ZodCheckOverwrite",(e,t)=>{Me.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Cc{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 v_=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),b_=function(e,t){return new URL(e,t).href},Gf={},w_=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=b_(l,r),l in Gf)return;Gf[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":v_,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 __(e){return e}function k_(e){return e}function ls(){return e=>e}function S_(e){}function E_(e){throw new Error("Unexpected value in exhaustive check")}function x_(e){}function Wo(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 gu(e,t="|"){return e.map(n=>nc(n)).join(t)}function Ko(e,t){return typeof t=="bigint"?t.toString():t}class $_{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 $_(e)}function Qu(e){return e==null}function bn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ec(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 jf=Symbol("evaluating");function Gp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jf)return r===void 0&&(r=jf,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function T_(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $t(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ds(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function nn(e){return ds(e._zod.def)??e._zod.def.shape}function jp(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $t(this,t,r),r},enumerable:!0,configurable:!0})}function Zp(e,t,n){t in e?$t(e,t,n):e[t]=n}function Dn(e,t,n,r){const i=nn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?jp(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):Zp(e,o,r?r(s.value,o):s.value))}}function C_(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?jp(e,n,()=>t[n]):Zp(e,n,r.value))}}function ct(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function A_(e){return ct(e._zod.def)}function I_(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function N_(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 R_(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 St(e){return JSON.stringify(e)}function Bp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const tc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Vp=ai(()=>{if(gt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function rn(e){if(Yn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ui(e){return rn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function z_(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const L_=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}`)}},Jo=new Set(["string","number","symbol"]),Hp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function on(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oe(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function A(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 P_(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 nc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function qp(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const rc={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]},ic={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Wp(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 Dn(o,e,fs(e,t)),Oe(e,ct(n,{shape:o,checks:[]}))}function fs(e,t){const n=nn(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 Kp(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(fs(e,t)),s={};return Dn(s,e,Reflect.ownKeys(nn(e)).filter(a=>!o.has(a))),Oe(e,ct(n,{shape:s,checks:[]}))}function Jp(e,t){if(!rn(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=nn(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 Oe(e,ct(e._zod.def,{shape:Yp(e,t)}))}function Yp(e,t){const n={};return Dn(n,e,Reflect.ownKeys(nn(e))),C_(n,t),n}function Xp(e,t){if(!rn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Oe(e,ct(e._zod.def,{shape:Yp(e,t)}))}function Qp(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={};Dn(n,e,Reflect.ownKeys(nn(e))),Dn(n,t,Reflect.ownKeys(nn(t)));const r=ct(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Oe(e,r)}function yu(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(fs(t,n)):void 0,u={};return Dn(u,t,Reflect.ownKeys(nn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),Oe(t,ct(t._zod.def,{shape:u,checks:[]}))}function em(e,t,n){const r=n?new Set(fs(t,n)):void 0,i={};return Dn(i,t,Reflect.ownKeys(nn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),Oe(t,ct(t._zod.def,{shape:i}))}function vt(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 tm(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 Rt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Hn(e){return typeof e=="string"?e:e?.message}function vu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Pt(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:Hn(e.inst?._zod.def?.error?.(e))??Hn(o?.(e))??Hn(t?.error?.(e))??Hn(n.customError?.(e))??Hn(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 hs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const D_=/[\uD800-\uDBFF]/;function ci(e){const t=e.length;if(!D_.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 ps(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nm(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 Xn(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function O_(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function rm(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 im(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function M_(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return rm(t+n)}function F_(e){return im(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function U_(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 G_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class j_{constructor(...t){}}function om(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Z_(e,n,r.value)}}function sn(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 sn(e,t,n,!1)}function li(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return sn(this,n,r(this))},set(i){sn(this,n,i)}})}return t}function Z_(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:sn(this,t,n.bind(this))},set(r){sn(this,t,r)}})}function B_(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Ga,gn=!1;const V_={configurable:!0,get(){gn=!0}};function ye(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Ga!==e._zod){Ga=void 0;return}Ga=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,V_);const i=gn;gn=!1;try{const o=n(this);return gn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),gn=gn||i,o}catch(o){throw delete this[t],gn=gn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function sm(e,t,n,r){const i=B_(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 oc="~constantCatch";function sc(e){const t=()=>e;return t[oc]=!0,t}const ac=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:ic,CONSTANT_CATCH:oc,Class:j_,NUMBER_FORMAT_RANGES:rc,aborted:vt,allowsEval:Vp,assert:x_,assertEqual:__,assertIs:S_,assertNever:E_,assertNotEqual:k_,assignProp:$t,attachSchema:vu,base64ToUint8Array:rm,base64urlToUint8Array:M_,cached:ai,captureStackTrace:tc,cleanEnum:O_,cleanRegex:bn,clone:Oe,cloneDef:A_,codePointLength:ci,constantCatch:sc,createTransparentProxy:P_,defineLazy:Gp,defineLazyInternal:ye,derived:li,esc:St,escapeRegex:on,explicitlyAborted:tm,extend:Jp,finalizeIssue:Pt,floatSafeRemainder:ec,getElementAtPath:I_,getEnumValues:Wo,getLengthableOrigin:ps,getParsedType:L_,getSizableOrigin:hs,hexToUint8Array:U_,hide:ms,installLazyProp:sm,isObject:Yn,isPlainObject:rn,issue:Xn,joinValues:gu,jsonStringifyReplacer:Ko,members:om,merge:Qp,mergeDefs:ct,normalizeParams:A,nullish:Qu,numKeys:z_,objectClone:T_,omit:Kp,optionalKeys:qp,own:sn,parsedType:nm,partial:yu,pick:Wp,prefixIssues:Rt,primitiveTypes:Hp,promiseAllObject:N_,propertyKeyTypes:Jo,randomString:R_,rawShape:ds,required:em,safeExtend:Xp,shallowClone:ui,slugify:Bp,stringifyPrimitive:nc,toZod:ls,uint8ArrayToBase64:im,uint8ArrayToBase64url:F_,uint8ArrayToHex:G_,unwrapMessage:Hn},Symbol.toStringTag,{value:"Module"}));var Zf;const uc=Object.freeze({status:"aborted"}),ja={value:void 0,enumerable:!1};let Bf="captureStackTrace"in Error?Error:null;function H_(e){const t=Bf;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Bf=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function k(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{ja.value=new o(h);try{Object.defineProperty(f,"_zod",ja)}finally{ja.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),g=f._zod.constr.prototype;let w=m;for(;w&&w!==g;)w=Object.getPrototypeOf(w);const y=w??m;a.has(y)||(a.add(y),om(y,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?H_(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const g of p)g();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 cc=Symbol("zod_brand");class en extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Zf=globalThis).__zod_globalConfig??(Zf.__zod_globalConfig={});const gt=globalThis.__zod_globalConfig;function Ye(e){return e&&Object.assign(gt,e),gt}function q_(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ko,2)),e.message}function W_(e){this._zod.message=e}const K_={get:q_,set:W_,enumerable:!0,configurable:!0},Za={value:void 0,enumerable:!1},Vf=new WeakSet([Object.prototype,Error.prototype]),am=(e,t)=>{e.name="$ZodError",Za.value=t,Object.defineProperty(e,"issues",Za),Za.value=void 0,Object.defineProperty(e,"message",K_);const n=Object.getPrototypeOf(e);Vf.has(n)||(Vf.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})}}))},um=k("$ZodError",am),Tt=k("$ZodError",am,void 0,{Parent:Error});function J_(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 ys(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?J_(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function vs(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 lc(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 cm(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 dc(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 ${cm(r.path)}`);return t.join(`
10
+ `)}function bs(e,t){return{callee:t?.callee??e,Err:t?.Err}}const di=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 en;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Pt(c,s,Ye())));throw tc(u,o?.callee??t),u}return a.value};return t},bu=di(Tt),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=>Pt(c,s,Ye())));throw tc(u,o?.callee??t),u}return a.value};return t},wu=fi(Tt),hi=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 en;return o.issues.length?dm(e,o.issues,i):{success:!0,data:o.value}},lm=hi(Tt);function dm(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Pt(i,n,Ye()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const pi=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?dm(e,o.issues,i):{success:!0,data:o.value}},Y_=pi(Tt),X_=Symbol.for("zod.compile.invalid"),Q_=Symbol.for("zod.compile.fallback"),ws=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==X_)return!0;if(r.definite===!0&&n===void 0)return!1}return ek(e,t,n)});function ek(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[Q_]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new en;return o.issues.length===0}const _s=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},fc=e=>{const t=di(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,bs(n,s))};return n},tk=fc(Tt),hc=e=>{const t=di(e),n=(r,i,o,s)=>t(r,i,o,bs(n,s));return n},nk=hc(Tt),pc=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,bs(n,s))};return n},rk=pc(Tt),mc=e=>{const t=fi(e),n=async(r,i,o,s)=>await t(r,i,o,bs(n,s));return n},ik=mc(Tt),gc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return hi(e)(t,n,i)},ok=gc(Tt),yc=e=>(t,n,r)=>hi(e)(t,n,r),sk=yc(Tt),vc=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return pi(e)(t,n,i)},ak=vc(Tt),bc=e=>async(t,n,r)=>pi(e)(t,n,r),uk=bc(Tt),fm=/^[cC][0-9a-z]{6,}$/,hm=/^[0-9a-z]+$/,pm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,mm=/^[0-9a-vA-V]{20}$/,gm=/^[A-Za-z0-9]{27}$/,ym=/^[a-zA-Z0-9_-]{21}$/;function vm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const bm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ck=/^[-+]?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)?)??$/,wm=/^([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})$/,Qn=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)$/,lk=Qn(4),dk=Qn(6),fk=Qn(7),_m=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hk=/^[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])?)*$/,pk=/^(([^<>()\[\]\\.,;:\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,}))$/,km=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,mk=km,gk=/^[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])?)*$/,yk="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Sm(){return new RegExp(yk,"u")}const Em=/^(?:(?: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])$/,xm=/^(([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}|:))$/,$m=e=>{const t=on(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Tm=/^((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])$/,Cm=/^(([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])$/,Am=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Im=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nm=/^(?=.{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])?)*\.?$/,Rm=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,wc=/^https?$/,zm=/^\+[1-9]\d{6,14}$/,_c=/^\d(?:[ -]?\d){11,18}$/,Lm=/^(?: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)$/,kc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Pm="(?:(?:\\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 vk(e){return new RegExp(`^${e}$`)}const Dm=vk(Pm);function _u(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 Om(e){return new RegExp(`^${_u(e)}$`)}function Mm(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${_u({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${_u({precision:e.precision})}`:n;return new RegExp(`^${Pm}T(?:${r})$`)}const Fm=/^[\s\S]{0,}$/,Um=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Gm=/^-?\d+n?$/,Sc=/^-?\d+$/,dr=/^-?\d+(?:\.\d+)?$/,jm=/^(?:true|false)$/i,Zm=/^null$/i,Bm=/^undefined$/i,Vm=/^[^A-Z]*$/,Hm=/^[^a-z]*$/,qm=/^[0-9a-fA-F]*$/;function mi(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function gi(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const bk=/^[0-9a-fA-F]{32}$/,wk=mi(22,"=="),_k=gi(22),kk=/^[0-9a-fA-F]{40}$/,Sk=mi(27,"="),Ek=gi(27),xk=/^[0-9a-fA-F]{64}$/,$k=mi(43,"="),Tk=gi(43),Ck=/^[0-9a-fA-F]{96}$/,Ak=mi(64,""),Ik=gi(64),Nk=/^[0-9a-fA-F]{128}$/,Rk=mi(86,"=="),zk=gi(86),ks=Object.freeze(Object.defineProperty({__proto__:null,anyString:Fm,base64:Am,base64url:Im,bigint:Gm,boolean:jm,browserEmail:gk,cidrv4:Tm,cidrv6:Cm,creditCard:_c,cuid:fm,cuid2:hm,currencyCode:Lm,date:Dm,datetime:Mm,domain:Rm,duration:bm,e164:zm,email:_m,emoji:Sm,extendedDuration:ck,guid:wm,hex:qm,hostname:Nm,html5Email:hk,httpProtocol:wc,iban:kc,idnEmail:mk,integer:Sc,ipv4:Em,ipv6:xm,ksuid:gm,lowercase:Vm,mac:$m,md5_base64:wk,md5_base64url:_k,md5_hex:bk,nanoid:ym,nanoidOfLength:vm,null:Zm,number:dr,rfc5322Email:pk,sha1_base64:Sk,sha1_base64url:Ek,sha1_hex:kk,sha256_base64:$k,sha256_base64url:Tk,sha256_hex:xk,sha384_base64:Ak,sha384_base64url:Ik,sha384_hex:Ck,sha512_base64:Rk,sha512_base64url:zk,sha512_hex:Nk,string:Um,time:Om,ulid:pm,undefined:Bm,unicodeEmail:km,uppercase:Hm,uuid:Qn,uuid4:lk,uuid6:dk,uuid7:fk,xid:mm},Symbol.toStringTag,{value:"Module"})),Me=k("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ec=e=>{const t=e.value;return!Qu(t)&&t.size!==void 0},xc=e=>{const t=e.value;return!Qu(t)&&t.length!==void 0},Yo={number:"number",bigint:"bigint",object:"date"},$c=k("$ZodCheckLessThan",(e,t)=>{Me.init(e,t);const n=Yo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Yo[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})}}),Tc=k("$ZodCheckGreaterThan",(e,t)=>{Me.init(e,t);const n=Yo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Yo[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})}}),Wm=k("$ZodCheckMultipleOf",(e,t)=>{Me.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):ec(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})}}),Km=k("$ZodCheckNumberFormat",(e,t)=>{Me.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=rc[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})}}),Jm=k("$ZodCheckBigIntFormat",(e,t)=>{Me.init(e,t);const[n,r]=ic[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})}}),Ym=k("$ZodCheckMaxSize",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:hs(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Xm=k("$ZodCheckMinSize",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:hs(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Qm=k("$ZodCheckSizeEquals",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=Ec),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:hs(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})}}),eg=k("$ZodCheckMaxLength",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?ci(i):o)<=t.maximum)return;const a=ps(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tg=k("$ZodCheckMinLength",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?ci(i):o)>=t.minimum)return;const a=ps(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ng=k("$ZodCheckLengthEquals",(e,t)=>{var n;Me.init(e,t),(n=e._zod.def).when??(n.when=xc),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?ci(i):o;if(s===t.length)return;const a=ps(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})}}),yi=k("$ZodCheckStringFormat",(e,t)=>{var n,r;Me.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=()=>{})}),rg=k("$ZodCheckRegex",(e,t)=>{yi.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})}}),ig=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Vm),yi.init(e,t)}),og=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Hm),yi.init(e,t)}),sg=k("$ZodCheckIncludes",(e,t)=>{Me.init(e,t);const n=on(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})}}),ag=k("$ZodCheckStartsWith",(e,t)=>{Me.init(e,t);const n=new RegExp(`^${on(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})}}),ug=k("$ZodCheckEndsWith",(e,t)=>{Me.init(e,t);const n=new RegExp(`.*${on(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 Xo(e,t,n){e.issues.length&&t.issues.push(...Rt(n,e.issues))}const cg=k("$ZodCheckProperty",(e,t)=>{Me.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=>Xo(i,n,t.property));Xo(r,n,t.property)}}),lg=k("$ZodCheckProperties",(e,t)=>{Me.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=>Xo(c,r,s)))):Xo(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),dg=k("$ZodCheckMimeType",(e,t)=>{Me.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})}}),fg=k("$ZodCheckOverwrite",(e,t)=>{Me.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Cc{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 hg={major:4,minor:6,patch:5},le=k("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hg;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=vt(a),d;for(const f of u){if(f._zod.def.when){if(tm(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 en;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(vu(a.issues,h,e),l||(l=vt(a,h)))});else{if(a.issues.length===h)continue;vu(a.issues,h,e),l||(l=vt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(vt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new en;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 en;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return ms(this,"~standard",Ac(this))},set"~standard"(e){sn(this,"~standard",e)}}),pg=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Pt(n,t,Ye()))}:{value:e.value};async function Lk(e,t){const n={async:!0};return pg(await e._zod.run({value:t,issues:[]},n),n)}function Ac(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return pg(r,n)}catch{}return Lk(e,t)},vendor:"zod",version:1}}const vi=k("$ZodString",(e,t)=>{le.init(e,t),e._zod.pattern=t.pattern??Fm,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}}),Pe=k("$ZodStringFormat",(e,t)=>{yi.init(e,t),vi.init(e,t)}),mg=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wm),Pe.init(e,t)}),gg=k("$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=Qn(r))}else t.pattern??(t.pattern=Qn());Pe.init(e,t)}),yg=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_m),Pe.init(e,t)}),Ic=1,Xr=2;function Nc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function zc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Nc(e)||Xr:vg(e,t)}function vg(e,t){if(!t.normalize&&t.protocol?.source===wc.source&&!/^https?:\/\//i.test(e))return Ic;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??Xr}return new URL(e)}catch{return Xr}}const Pk=/[\t\n\r]/g;function Qo(e){return e.replace(Pk,"")}function Rc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const bg=k("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=zc(r,t);if(i===Ic){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Xr){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Qo(r);return}t.hostname&&!Rc(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&&!Lc(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:Qo(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wg=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sm()),Pe.init(e,t)}),_g=k("$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?ym:vm(t.length)),Pe.init(e,t)}),kg=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fm),Pe.init(e,t)}),Sg=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=hm),Pe.init(e,t)}),xg=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=pm),Pe.init(e,t)}),Eg=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mm),Pe.init(e,t)}),$g=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=gm),Pe.init(e,t)}),Tg=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Mm(t)),Pe.init(e,t)}),Cg=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dm),Pe.init(e,t)}),Ag=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Om(t)),Pe.init(e,t)}),Ig=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=bm),Pe.init(e,t)}),Ng=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=xm),Pe.init(e,t)}),Dk=/^[0-9a-fA-F:.]+$/;function Ss(e){return Dk.test(e)?Nc(`http://[${e}]`):!1}const zg=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Em),Pe.init(e,t),e._zod.check=n=>{Ss(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Rg=k("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=$m(t.delimiter)),Pe.init(e,t)}),Lg=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tm),Pe.init(e,t)});function Pc(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:Ss(n)}const Pg=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Cm),Pe.init(e,t),e._zod.check=n=>{Pc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function xs(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Dc=/^[0-9a-zA-Z+/]*={0,2}$/,Dg=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Dc),Pe.init(e,t),e._zod.check=n=>{xs(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Es=/^[A-Za-z0-9_-]*$/;function Oc(e){if(!Es.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xs(n)}const Og=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Es),Pe.init(e,t),e._zod.check=n=>{Oc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mg=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Rm),Pe.init(e,t)}),Ok=/[- ]/g;function Mk(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 Mc(e){return _c.test(e)?Mk(e.replace(Ok,"")):!1}const Fg=k("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=_c),Pe.init(e,t),e._zod.check=n=>{Mc(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function Fk(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 Fc(e){return kc.test(e)?Fk(e):!1}const Ug=k("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=kc),Pe.init(e,t),e._zod.check=n=>{Fc(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Uc(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 Gg=k("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{Uc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),jg=k("$ZodCustomStringFormat",(e,t)=>{Pe.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})}}),Gc=k("$ZodNumber",(e,t)=>{le.init(e,t),e._zod.pattern=dr,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}}),Zg=k("$ZodNumberFormat",(e,t)=>{Km.init(e,t),Gc.init(e,t)}),jc=k("$ZodBoolean",(e,t)=>{le.init(e,t),e._zod.pattern=jm,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}}),Zc=k("$ZodBigInt",(e,t)=>{le.init(e,t),e._zod.pattern=Gm,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}}),Bg=k("$ZodBigIntFormat",(e,t)=>{Jm.init(e,t),Zc.init(e,t)}),Vg=k("$ZodSymbol",(e,t)=>{le.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}}),Hg=k("$ZodUndefined",(e,t)=>{le.init(e,t),e._zod.pattern=Bm,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}}),qg=k("$ZodNull",(e,t)=>{le.init(e,t),e._zod.pattern=Zm,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}}),Wg=k("$ZodAny",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),Kg=k("$ZodUnknown",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),Jg=k("$ZodNever",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Yg=k("$ZodVoid",(e,t)=>{le.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}}),Xg=k("$ZodDate",(e,t)=>{le.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 Hf(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}const Qg=k("$ZodArray",(e,t)=>{le.init(e,t);const n=gt.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=>Hf(d,r,u)));else if(Hf(l,r,u),a&&l.issues.length!==0&&vt(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(...zt(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 Uk=[];function ey(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Uk,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=qp(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function ty(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(vt(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(g=>es(g,n,p,t,d,f))):es(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 ny=k("$ZodObject",(e,t)=>{le.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(()=>ey(t));ye(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)||$t(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=Yn,s=t.catchall;let a;const u=gt.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 g of a.allKeys){if(p&&c.issues.length!==m){if(vt(c,m))break;m=c.issues.length}if(g==="__proto__")continue;const w=h[g],y=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[g],issues:[]},l);v instanceof Promise?f.push(v.then(S=>es(S,c,g,d,y,b))):es(v,c,g,d,y,b)}return s?ty(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),ry=k("$ZodObjectJIT",(e,t)=>{ny.init(e,t);const n=e._zod.parse,r=ai(()=>ey(t)),i=gt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,g=new Cc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=S=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,y=(S,_)=>`
14
+ };`)(...Object.values(this.closed))}}const hg={major:4,minor:6,patch:5},le=k("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hg;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=vt(a),d;for(const f of u){if(f._zod.def.when){if(tm(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 en;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(vu(a.issues,h,e),l||(l=vt(a,h)))});else{if(a.issues.length===h)continue;vu(a.issues,h,e),l||(l=vt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(vt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new en;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 en;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return ms(this,"~standard",Ac(this))},set"~standard"(e){sn(this,"~standard",e)}}),pg=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Pt(n,t,Ye()))}:{value:e.value};async function Lk(e,t){const n={async:!0};return pg(await e._zod.run({value:t,issues:[]},n),n)}function Ac(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return pg(r,n)}catch{}return Lk(e,t)},vendor:"zod",version:1}}const vi=k("$ZodString",(e,t)=>{le.init(e,t),e._zod.pattern=t.pattern??Fm,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}}),Pe=k("$ZodStringFormat",(e,t)=>{yi.init(e,t),vi.init(e,t)}),mg=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wm),Pe.init(e,t)}),gg=k("$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=Qn(r))}else t.pattern??(t.pattern=Qn());Pe.init(e,t)}),yg=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_m),Pe.init(e,t)}),Ic=1,Xr=2;function Nc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Rc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Nc(e)||Xr:vg(e,t)}function vg(e,t){if(!t.normalize&&t.protocol?.source===wc.source&&!/^https?:\/\//i.test(e))return Ic;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??Xr}return new URL(e)}catch{return Xr}}const Pk=/[\t\n\r]/g;function Qo(e){return e.replace(Pk,"")}function zc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const bg=k("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=Rc(r,t);if(i===Ic){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Xr){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Qo(r);return}t.hostname&&!zc(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&&!Lc(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:Qo(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wg=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sm()),Pe.init(e,t)}),_g=k("$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?ym:vm(t.length)),Pe.init(e,t)}),kg=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fm),Pe.init(e,t)}),Sg=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=hm),Pe.init(e,t)}),Eg=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=pm),Pe.init(e,t)}),xg=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=mm),Pe.init(e,t)}),$g=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=gm),Pe.init(e,t)}),Tg=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Mm(t)),Pe.init(e,t)}),Cg=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dm),Pe.init(e,t)}),Ag=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Om(t)),Pe.init(e,t)}),Ig=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=bm),Pe.init(e,t)}),Ng=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Em),Pe.init(e,t)}),Dk=/^[0-9a-fA-F:.]+$/;function Ss(e){return Dk.test(e)?Nc(`http://[${e}]`):!1}const Rg=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=xm),Pe.init(e,t),e._zod.check=n=>{Ss(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),zg=k("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=$m(t.delimiter)),Pe.init(e,t)}),Lg=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tm),Pe.init(e,t)});function Pc(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:Ss(n)}const Pg=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Cm),Pe.init(e,t),e._zod.check=n=>{Pc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Es(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Dc=/^[0-9a-zA-Z+/]*={0,2}$/,Dg=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Dc),Pe.init(e,t),e._zod.check=n=>{Es(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),xs=/^[A-Za-z0-9_-]*$/;function Oc(e){if(!xs.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Es(n)}const Og=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xs),Pe.init(e,t),e._zod.check=n=>{Oc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mg=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=zm),Pe.init(e,t)}),Ok=/[- ]/g;function Mk(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 Mc(e){return _c.test(e)?Mk(e.replace(Ok,"")):!1}const Fg=k("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=_c),Pe.init(e,t),e._zod.check=n=>{Mc(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function Fk(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 Fc(e){return kc.test(e)?Fk(e):!1}const Ug=k("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=kc),Pe.init(e,t),e._zod.check=n=>{Fc(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Uc(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 Gg=k("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{Uc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),jg=k("$ZodCustomStringFormat",(e,t)=>{Pe.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})}}),Gc=k("$ZodNumber",(e,t)=>{le.init(e,t),e._zod.pattern=dr,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}}),Zg=k("$ZodNumberFormat",(e,t)=>{Km.init(e,t),Gc.init(e,t)}),jc=k("$ZodBoolean",(e,t)=>{le.init(e,t),e._zod.pattern=jm,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}}),Zc=k("$ZodBigInt",(e,t)=>{le.init(e,t),e._zod.pattern=Gm,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}}),Bg=k("$ZodBigIntFormat",(e,t)=>{Jm.init(e,t),Zc.init(e,t)}),Vg=k("$ZodSymbol",(e,t)=>{le.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}}),Hg=k("$ZodUndefined",(e,t)=>{le.init(e,t),e._zod.pattern=Bm,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}}),qg=k("$ZodNull",(e,t)=>{le.init(e,t),e._zod.pattern=Zm,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}}),Wg=k("$ZodAny",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),Kg=k("$ZodUnknown",(e,t)=>{le.init(e,t),e._zod.parse=n=>n}),Jg=k("$ZodNever",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Yg=k("$ZodVoid",(e,t)=>{le.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}}),Xg=k("$ZodDate",(e,t)=>{le.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 Hf(e,t,n){e.issues.length&&t.issues.push(...Rt(n,e.issues)),t.value[n]=e.value}const Qg=k("$ZodArray",(e,t)=>{le.init(e,t);const n=gt.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=>Hf(d,r,u)));else if(Hf(l,r,u),a&&l.issues.length!==0&&vt(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(...Rt(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 Uk=[];function ey(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Uk,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=qp(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function ty(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(vt(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(g=>es(g,n,p,t,d,f))):es(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 ny=k("$ZodObject",(e,t)=>{le.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(()=>ey(t));ye(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)||$t(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=Yn,s=t.catchall;let a;const u=gt.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 g of a.allKeys){if(p&&c.issues.length!==m){if(vt(c,m))break;m=c.issues.length}if(g==="__proto__")continue;const w=h[g],y=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[g],issues:[]},l);v instanceof Promise?f.push(v.then(S=>es(S,c,g,d,y,b))):es(v,c,g,d,y,b)}return s?ty(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),ry=k("$ZodObjectJIT",(e,t)=>{ny.init(e,t);const n=e._zod.parse,r=ai(()=>ey(t)),i=gt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,g=new Cc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=S=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,y=(S,_)=>`
15
15
  let ${S}_ab = false;
16
16
  for (let i = 0; i < ${S}.issues.length; i++) {
17
17
  const iss = ${S}.issues[i];
@@ -22,8 +22,8 @@ ${n.join(`
22
22
  if (${S}_ab && ctx && ctx.abortEarly) {
23
23
  payload.value = newResult;
24
24
  return payload;
25
- }`;g.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const S of p.allKeys)b[S]=`key_${v++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const S of p.allKeys){if(S==="__proto__")continue;const _=b[S],$=typeof S=="symbol"?`syms[${m.indexOf(S)}]`:St(S),R=`${$} in input`,P=h[S],O=P?._zod?.optin,Y=O!==void 0,he=P?._zod?.optout==="optional";if(g.write(`const ${_} = ${w($)};`),Y&&he){const Se=O==="optional"?`${_}_present`:`${_}.value !== undefined || ${_}_present`;g.write(`
26
- const ${_}_present = ${R};
25
+ }`;g.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const S of p.allKeys)b[S]=`key_${v++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const S of p.allKeys){if(S==="__proto__")continue;const _=b[S],$=typeof S=="symbol"?`syms[${m.indexOf(S)}]`:St(S),z=`${$} in input`,P=h[S],O=P?._zod?.optin,Y=O!==void 0,he=P?._zod?.optout==="optional";if(g.write(`const ${_} = ${w($)};`),Y&&he){const Se=O==="optional"?`${_}_present`:`${_}.value !== undefined || ${_}_present`;g.write(`
26
+ const ${_}_present = ${z};
27
27
  if (!${_}.issues.length || ${_}_present) {
28
28
  if (${_}.issues.length) {${y(_,$)}
29
29
  }
@@ -37,11 +37,11 @@ ${n.join(`
37
37
  if (${_}.issues.length) {${y(_,$)}
38
38
  }
39
39
  `),O==="defaulted"?g.write(`newResult[${$}] = ${_}.value;`):g.write(`
40
- if (${_}.value !== undefined || ${R}) {
40
+ if (${_}.value !== undefined || ${z}) {
41
41
  newResult[${$}] = ${_}.value;
42
42
  }
43
43
  `)):g.write(`
44
- const ${_}_present = ${R};
44
+ const ${_}_present = ${z};
45
45
  if (${_}.issues.length) {${y(_,$)}
46
46
  }
47
47
  if (!${_}_present && !${_}.issues.length) {
@@ -61,19 +61,19 @@ ${n.join(`
61
61
  newResult[${$}] = ${_}.value;
62
62
  }
63
63
 
64
- `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let s;const a=Yn,u=!gt.jitless,l=u&&Vp.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?ty([],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 qf(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=>!vt(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=>Pt(s,r,Ye())))}),t)}const $s=k("$ZodUnion",(e,t)=>{le.init(e,t),ye(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),ye(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ye(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)))}),ye(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=>bn(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=>qf(a,r,e,i)):qf(s,r,e,i)}});function Wf(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=>Pt(s,r,Ye())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const iy=k("$ZodXor",(e,t)=>{$s.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=>Wf(a,r,e,i)):Wf(s,r,e,i)}});function Bc(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=oy(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 oy(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 sy=k("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$s.init(e,t);const n=e._zod.parse;ye(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)||$t(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=ds(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(()=>oy(t));e._zod.parse=(i,o)=>{const s=i.value;if(!Yn(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)}}),ay=k("$ZodIntersection",(e,t)=>{le.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])=>Kf(n,u,c)):Kf(n,o,s)}});function Qr(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(rn(e)&&rn(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=Qr(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=Qr(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 Kf(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=Qr(t.value,n.value);if(!u.valid){if(vt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const Vc=k("$ZodTuple",(e,t)=>{le.init(e,t);const n=t.items,r=gt.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=Jf(n,"optin"),c=Jf(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=vt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const g of p){if(d&&i.issues.length!==m){if(vt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:g,issues:[]},o);w instanceof Promise?a.push(w.then(y=>Yf(y,i,h))):Yf(w,i,h)}}return a.length?Promise.all(a).then(()=>Xf(l,i,n,s,c)):Xf(l,i,n,s,c)}});function Jf(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 Yf(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}function Xf(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(...zt(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 uy=k("$ZodRecord",(e,t)=>{le.init(e,t);const n=gt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!rn(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=>Pt(p,i,Ye())),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(...zt(l,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(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"&&dr.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=>Pt(p,i,Ye())),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(...zt(c,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(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}}),cy=k("$ZodMap",(e,t)=>{le.init(e,t);const n=gt.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(vt(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])=>{Qf(h,p,r,c,o,e,i)})):Qf(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function Qf(e,t,n,r,i,o,s){e.issues.length&&(Jo.has(typeof r)?n.issues.push(...zt(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Pt(a,s,Ye()))})),t.issues.length&&(Jo.has(typeof r)?n.issues.push(...zt(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Pt(a,s,Ye()))})),n.value.set(e.value,t.value)}const ly=k("$ZodSet",(e,t)=>{le.init(e,t);const n=gt.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(vt(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=>eh(d,r))):eh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function eh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const dy=k("$ZodEnum",(e,t)=>{le.init(e,t);const n=Wo(t.entries),r=new Set(n);e._zod.values=r,ye(e,"pattern",i=>{const o=Wo(i.def.entries).filter(s=>Jo.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>on(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}}),fy=k("$ZodLiteral",(e,t)=>{le.init(e,t);const n=new Set(t.values);e._zod.values=n,ye(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?on(o):o?on(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}}),hy=k("$ZodFile",(e,t)=>{le.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}}),py=k("$ZodTransform",(e,t)=>{le.init(e,t),e._zod.optin="optional",gt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs(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 en;return n.value=i,n}});function th(e,t){return e.value=t.issues.length?void 0:t.value,e}const Hc=k("$ZodOptional",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",ye(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),ye(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${bn(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=>th(n,o)):th(n,i)}return t.innerType._zod.run(n,r)}}),my=k("$ZodExactOptional",(e,t)=>{Hc.init(e,t),ye(e,"values",n=>n.def.innerType._zod.values),ye(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),gy=k("$ZodNullable",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin),ye(e,"optout",n=>n.def.innerType._zod.optout),ye(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${bn(r.source)}|null)$`):void 0}),ye(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)}),yy=k("$ZodDefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",ye(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=>nh(o,t)):nh(i,t)}});function nh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const vy=k("$ZodPrefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",ye(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))}),by=k("$ZodNonOptional",(e,t)=>{le.init(e,t),ye(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=>rh(o,e)):rh(i,e)}});function rh(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 wy=k("$ZodSuccess",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs("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 ih(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Pt(i,r,Ye()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const _y=k("$ZodCatch",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),ye(e,"optout",n=>n.def.innerType._zod.optout),ye(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=>ih(n,o,t,r)):ih(n,i,t,r)}}),ky=k("$ZodNaN",(e,t)=>{le.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)}),qc=k("$ZodPipe",(e,t)=>{le.init(e,t),ye(e,"values",n=>n.def.in._zod.values),ye(e,"optin",n=>n.def.in._zod.optin),ye(e,"optout",n=>n.def.out._zod.optout),ye(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=>wo(s,t.in,r)):wo(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>wo(o,t.out,r)):wo(i,t.out,r)}});function wo(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 Wc=k("$ZodCodec",(e,t)=>{le.init(e,t),ye(e,"values",n=>n.def.in._zod.values),ye(e,"optin",n=>n.def.in._zod.optin),ye(e,"optout",n=>n.def.out._zod.optout),ye(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=>_o(s,t,r)):_o(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>_o(s,t,r)):_o(o,t,r)}}});function _o(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=>ko(e,o,t.out,n)):ko(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>ko(e,o,t.in,n)):ko(e,i,t.in,n)}}function ko(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Sy=k("$ZodPreprocess",(e,t)=>{qc.init(e,t)}),xy=k("$ZodReadonly",(e,t)=>{le.init(e,t),ye(e,"propValues",n=>n.def.innerType._zod.propValues),ye(e,"values",n=>n.def.innerType._zod.values),ye(e,"optin",n=>n.def.innerType?._zod?.optin),ye(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(oh):oh(i)}});function oh(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Gk(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 Um({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===dr?Sc:s)?.source}function ku(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=ku(r);return n&&i&&o&&o!==i?n.replace(bn(i),()=>bn(o)):n}if(t.options){const i=t.options.map(ku);if(i.every(Boolean))return`^(${i.map(o=>bn(o)).join("|")})$`}return Gk(e)}const Ey=k("$ZodTemplateLiteral",(e,t)=>{le.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=ku(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(bn(i))}else if(r===null||Hp.has(typeof r))n.push(on(`${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)}),$y=k("$ZodFunction",(e,t)=>(le.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?bu(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?bu(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 wu(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await wu(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 Vc({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)),Ty=k("$ZodPromise",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),Kc=k("$ZodLazy",(e,t)=>{le.init(e,t),Gp(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),ye(e,"pattern",n=>n.innerType?._zod?.pattern),ye(e,"propValues",n=>n.innerType?._zod?.propValues),ye(e,"optin",n=>n.innerType?._zod?.optin??void 0),ye(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Cy=k("$ZodCustom",(e,t)=>{Me.init(e,t),le.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=>sh(o,n,r,e));sh(i,n,r,e)}});function sh(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(Xn(i))}}class Ay extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Su="~memo",ah=[];function Iy(e){return e!==null&&typeof e=="object"}function Ba(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Ny=new WeakMap,Kn=0,Vo=1,qr=2;function Wr(e,t,n){const r=Ny.get(e);if(r!==void 0)return r?qr:Kn;if(t.has(e))return qr;t.add(e);let i=Kn;const o=l=>{if(i!==qr&&l?._zod){const d=Wr(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=Kn;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?Vo:p.value?._zod?Wr(p.value,t,n):Kn;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=ds(u);a(l?s(l):Vo),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?Wr(l,t,!1):Vo);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),jk(e,i)}function jk(e,t){return t!==Vo&&Ny.set(e,t===qr),t}function Jc(e){return Wr(e,new Set,!0)!==Kn}function Zk(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let So;const xo=[],Bk={alloc(e,t,n){const r=So;if(!r)return n;So=void 0;const i={value:n,issues:null};return r.set(t.value,i),xo.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"&&Yc(o,i.value))throw new Ay;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 w=Wr(e,new Set,!1);if(w===Kn)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===qr||r?n=!0:r=!0}const l=u.value;if(!Iy(l))return s(u,c);let d=c[Su];d||(d={buckets:new WeakMap,backEdges:void 0},c[Su]=d);let f;i===c?f=o:(f=Zk(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(...Ba(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;So=f;const p=xo.length,m=s(u,c);So=void 0;const g=xo.length>p?xo.pop():void 0;return m instanceof Promise?m.then(w=>(g&&(g.issues=w.issues.length?Ba(w.issues):ah),w)):(g&&(g.issues=m.issues.length?Ba(m.issues):ah),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Ts(){return Bk}function Yc(e,t){const n=e[Su]?.backEdges;return n!==void 0&&Iy(t)&&n.has(t)}const Xc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var uh;const Qc=Symbol("ZodOutput"),el=Symbol("ZodInput");class zy{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 Cs(){return new zy}(uh=globalThis).__zod_globalRegistry??(uh.__zod_globalRegistry=Cs());const kt=globalThis.__zod_globalRegistry,yt=Symbol.for("zod.compile.invalid"),ch=Symbol.for("zod.compile.fallback");class an extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class ke 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 Vk(e,t){try{return Is(e,{assertOnly:!0})}catch{return t}}function tl(e,t){try{const n=Is(e),r=As(e,n);return r._zod.bag.validator=Vk(e,n),r}catch(n){if(t?.strict)throw n;return e}}function As(e,t){if(Jc(e))throw new ke("a schema whose subtree contains a reference cycle");const n=Oe(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[ch]||a&&Yc(a,s.value))return i(s,a);const u=t(s.value);return u!==yt?(s.value=u,s):(a&&(a[ch]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||Hk(n,e,t),n}function Hk(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!==yt?{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!==yt?u:o(s,a)}}}function Is(e,t){let n=!0;try{n=Jc(e)}catch{}if(n)throw new ke("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Cc(["input"]),o=Ue(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[yt,...r.constants.values()],u=i.content.join(`
64
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let s;const a=Yn,u=!gt.jitless,l=u&&Vp.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?ty([],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 qf(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=>!vt(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=>Pt(s,r,Ye())))}),t)}const $s=k("$ZodUnion",(e,t)=>{le.init(e,t),ye(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),ye(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ye(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)))}),ye(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=>bn(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=>qf(a,r,e,i)):qf(s,r,e,i)}});function Wf(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=>Pt(s,r,Ye())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const iy=k("$ZodXor",(e,t)=>{$s.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=>Wf(a,r,e,i)):Wf(s,r,e,i)}});function Bc(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=oy(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 oy(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 sy=k("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$s.init(e,t);const n=e._zod.parse;ye(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)||$t(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=ds(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(()=>oy(t));e._zod.parse=(i,o)=>{const s=i.value;if(!Yn(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)}}),ay=k("$ZodIntersection",(e,t)=>{le.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])=>Kf(n,u,c)):Kf(n,o,s)}});function Qr(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(rn(e)&&rn(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=Qr(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=Qr(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 Kf(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=Qr(t.value,n.value);if(!u.valid){if(vt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const Vc=k("$ZodTuple",(e,t)=>{le.init(e,t);const n=t.items,r=gt.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=Jf(n,"optin"),c=Jf(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=vt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const g of p){if(d&&i.issues.length!==m){if(vt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:g,issues:[]},o);w instanceof Promise?a.push(w.then(y=>Yf(y,i,h))):Yf(w,i,h)}}return a.length?Promise.all(a).then(()=>Xf(l,i,n,s,c)):Xf(l,i,n,s,c)}});function Jf(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 Yf(e,t,n){e.issues.length&&t.issues.push(...Rt(n,e.issues)),t.value[n]=e.value}function Xf(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(...Rt(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 uy=k("$ZodRecord",(e,t)=>{le.init(e,t);const n=gt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!rn(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=>Pt(p,i,Ye())),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(...Rt(l,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...Rt(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"&&dr.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=>Pt(p,i,Ye())),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(...Rt(c,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...Rt(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}}),cy=k("$ZodMap",(e,t)=>{le.init(e,t);const n=gt.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(vt(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])=>{Qf(h,p,r,c,o,e,i)})):Qf(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function Qf(e,t,n,r,i,o,s){e.issues.length&&(Jo.has(typeof r)?n.issues.push(...Rt(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Pt(a,s,Ye()))})),t.issues.length&&(Jo.has(typeof r)?n.issues.push(...Rt(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Pt(a,s,Ye()))})),n.value.set(e.value,t.value)}const ly=k("$ZodSet",(e,t)=>{le.init(e,t);const n=gt.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(vt(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=>eh(d,r))):eh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function eh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const dy=k("$ZodEnum",(e,t)=>{le.init(e,t);const n=Wo(t.entries),r=new Set(n);e._zod.values=r,ye(e,"pattern",i=>{const o=Wo(i.def.entries).filter(s=>Jo.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>on(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}}),fy=k("$ZodLiteral",(e,t)=>{le.init(e,t);const n=new Set(t.values);e._zod.values=n,ye(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?on(o):o?on(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}}),hy=k("$ZodFile",(e,t)=>{le.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}}),py=k("$ZodTransform",(e,t)=>{le.init(e,t),e._zod.optin="optional",gt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs(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 en;return n.value=i,n}});function th(e,t){return e.value=t.issues.length?void 0:t.value,e}const Hc=k("$ZodOptional",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",ye(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),ye(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${bn(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=>th(n,o)):th(n,i)}return t.innerType._zod.run(n,r)}}),my=k("$ZodExactOptional",(e,t)=>{Hc.init(e,t),ye(e,"values",n=>n.def.innerType._zod.values),ye(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),gy=k("$ZodNullable",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin),ye(e,"optout",n=>n.def.innerType._zod.optout),ye(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${bn(r.source)}|null)$`):void 0}),ye(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)}),yy=k("$ZodDefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",ye(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=>nh(o,t)):nh(i,t)}});function nh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const vy=k("$ZodPrefault",(e,t)=>{le.init(e,t),e._zod.optin="defaulted",ye(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))}),by=k("$ZodNonOptional",(e,t)=>{le.init(e,t),ye(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=>rh(o,e)):rh(i,e)}});function rh(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 wy=k("$ZodSuccess",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs("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 ih(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Pt(i,r,Ye()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const _y=k("$ZodCatch",(e,t)=>{le.init(e,t),ye(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),ye(e,"optout",n=>n.def.innerType._zod.optout),ye(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=>ih(n,o,t,r)):ih(n,i,t,r)}}),ky=k("$ZodNaN",(e,t)=>{le.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)}),qc=k("$ZodPipe",(e,t)=>{le.init(e,t),ye(e,"values",n=>n.def.in._zod.values),ye(e,"optin",n=>n.def.in._zod.optin),ye(e,"optout",n=>n.def.out._zod.optout),ye(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=>wo(s,t.in,r)):wo(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>wo(o,t.out,r)):wo(i,t.out,r)}});function wo(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 Wc=k("$ZodCodec",(e,t)=>{le.init(e,t),ye(e,"values",n=>n.def.in._zod.values),ye(e,"optin",n=>n.def.in._zod.optin),ye(e,"optout",n=>n.def.out._zod.optout),ye(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=>_o(s,t,r)):_o(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>_o(s,t,r)):_o(o,t,r)}}});function _o(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=>ko(e,o,t.out,n)):ko(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>ko(e,o,t.in,n)):ko(e,i,t.in,n)}}function ko(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Sy=k("$ZodPreprocess",(e,t)=>{qc.init(e,t)}),Ey=k("$ZodReadonly",(e,t)=>{le.init(e,t),ye(e,"propValues",n=>n.def.innerType._zod.propValues),ye(e,"values",n=>n.def.innerType._zod.values),ye(e,"optin",n=>n.def.innerType?._zod?.optin),ye(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(oh):oh(i)}});function oh(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Gk(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 Um({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===dr?Sc:s)?.source}function ku(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=ku(r);return n&&i&&o&&o!==i?n.replace(bn(i),()=>bn(o)):n}if(t.options){const i=t.options.map(ku);if(i.every(Boolean))return`^(${i.map(o=>bn(o)).join("|")})$`}return Gk(e)}const xy=k("$ZodTemplateLiteral",(e,t)=>{le.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=ku(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(bn(i))}else if(r===null||Hp.has(typeof r))n.push(on(`${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)}),$y=k("$ZodFunction",(e,t)=>(le.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?bu(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?bu(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 wu(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await wu(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 Vc({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)),Ty=k("$ZodPromise",(e,t)=>{le.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),Kc=k("$ZodLazy",(e,t)=>{le.init(e,t),Gp(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),ye(e,"pattern",n=>n.innerType?._zod?.pattern),ye(e,"propValues",n=>n.innerType?._zod?.propValues),ye(e,"optin",n=>n.innerType?._zod?.optin??void 0),ye(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Cy=k("$ZodCustom",(e,t)=>{Me.init(e,t),le.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=>sh(o,n,r,e));sh(i,n,r,e)}});function sh(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(Xn(i))}}class Ay extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Su="~memo",ah=[];function Iy(e){return e!==null&&typeof e=="object"}function Ba(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Ny=new WeakMap,Kn=0,Vo=1,qr=2;function Wr(e,t,n){const r=Ny.get(e);if(r!==void 0)return r?qr:Kn;if(t.has(e))return qr;t.add(e);let i=Kn;const o=l=>{if(i!==qr&&l?._zod){const d=Wr(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=Kn;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?Vo:p.value?._zod?Wr(p.value,t,n):Kn;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=ds(u);a(l?s(l):Vo),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?Wr(l,t,!1):Vo);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),jk(e,i)}function jk(e,t){return t!==Vo&&Ny.set(e,t===qr),t}function Jc(e){return Wr(e,new Set,!0)!==Kn}function Zk(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let So;const Eo=[],Bk={alloc(e,t,n){const r=So;if(!r)return n;So=void 0;const i={value:n,issues:null};return r.set(t.value,i),Eo.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"&&Yc(o,i.value))throw new Ay;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 w=Wr(e,new Set,!1);if(w===Kn)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===qr||r?n=!0:r=!0}const l=u.value;if(!Iy(l))return s(u,c);let d=c[Su];d||(d={buckets:new WeakMap,backEdges:void 0},c[Su]=d);let f;i===c?f=o:(f=Zk(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(...Ba(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;So=f;const p=Eo.length,m=s(u,c);So=void 0;const g=Eo.length>p?Eo.pop():void 0;return m instanceof Promise?m.then(w=>(g&&(g.issues=w.issues.length?Ba(w.issues):ah),w)):(g&&(g.issues=m.issues.length?Ba(m.issues):ah),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Ts(){return Bk}function Yc(e,t){const n=e[Su]?.backEdges;return n!==void 0&&Iy(t)&&n.has(t)}const Xc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var uh;const Qc=Symbol("ZodOutput"),el=Symbol("ZodInput");class Ry{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 Cs(){return new Ry}(uh=globalThis).__zod_globalRegistry??(uh.__zod_globalRegistry=Cs());const kt=globalThis.__zod_globalRegistry,yt=Symbol.for("zod.compile.invalid"),ch=Symbol.for("zod.compile.fallback");class an extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class ke 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 Vk(e,t){try{return Is(e,{assertOnly:!0})}catch{return t}}function tl(e,t){try{const n=Is(e),r=As(e,n);return r._zod.bag.validator=Vk(e,n),r}catch(n){if(t?.strict)throw n;return e}}function As(e,t){if(Jc(e))throw new ke("a schema whose subtree contains a reference cycle");const n=Oe(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[ch]||a&&Yc(a,s.value))return i(s,a);const u=t(s.value);return u!==yt?(s.value=u,s):(a&&(a[ch]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||Hk(n,e,t),n}function Hk(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!==yt?{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!==yt?u:o(s,a)}}}function Is(e,t){let n=!0;try{n=Jc(e)}catch{}if(n)throw new ke("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Cc(["input"]),o=Ue(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[yt,...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 ke(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function se(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 On(e,t){return e.definite=!1,se(e,t)}function ne(e){return`v${e.varCounter++}`}function qk(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return yt;const r=n;return r.issues.length===0?r.value:yt}function lt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return Ue(e,t,n,r,i)}catch(c){if(!(c instanceof ke)||!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,Wk(e,t,n,r)}}function Wk(e,t,n,r){t.definite=!1;const i=se(t,n),o=se(t,qk),s=ne(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const Kk=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function Jk(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&&!Kk.has(a.check))throw new ke('check with a custom "when" condition');switch(a.check){case"greater_than":Yk(e,t,a,o);break;case"less_than":Xk(e,t,a,o);break;case"multiple_of":Qk(e,t,a,o);break;case"number_format":Ly(e,a,o);break;case"min_length":{const u=Nn(a.minimum,"min_length"),c=Va(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Nn(a.maximum,"max_length"),c=Va(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Nn(a.length,"length_equals"),c=Va(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 < ${Nn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Nn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Nn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Py(e,t,a,o);break;case"custom":o=oS(e,t,s,o);break;case"bigint_format":eS(e,a,o);break;case"mime_type":tS(e,t,a,o);break;case"property":rS(e,t,a,o);break;case"properties":nS(e,t,a,o);break;case"overwrite":{const u=ne(t);iS(e,t,s,o,u),o=u;break}default:throw new ke(`check type ${a.check}`)}}return o}function Va(e,t,n,r){const i=se(t,ci),o=ne(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Nn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new ke(`${t} bound of type ${typeof e}`);return`${e}`}function Ry(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new ke("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ke("comparison check with Invalid Date bound");return se(e,t)}throw new ke(`comparison check bound of type ${typeof t}`)}function Yk(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${Ry(t,n.value)}) return INVALID;`)}function Xk(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${Ry(t,n.value)}) return INVALID;`)}function Qk(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new ke("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=se(t,ec);e.write(`if (${i}(${r}, ${Nn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Ly(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 ke(`number format ${r}`)}}function eS(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 ke(`bigint format ${r}`)}}function tS(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=se(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function nS(e,t,n,r){if(n.when)throw new ke('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"?se(t,o):St(o),a=ne(t);e.write(`const ${a} = ${r}[${s}];`),lt(e,t,i[o],a,!1)}}function rS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Ue(e,t,n.schema,i)}function iS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new ke("overwrite check without a transform function");if(Mn(o))throw new an("z.compile: async overwrite transforms are not supported");const s=se(t,o);e.write(`const ${i} = ${s}(${r});`)}function xu(){throw new en}function nl(e){this.issues.push(e)}function oS(e,t,n,r){const i=n._zod.def;if(i.fn){if(Mn(i.fn))throw new an("z.compile: async .refine() predicates are not supported");const o=On(t,i.fn),s=se(t,xu),a=ne(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(Mn(n._zod.check))throw new an("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=On(t,c=>{const l={value:c,issues:[],addIssue:nl};return o(l)instanceof Promise&&xu(),l.issues.length===0?l.value:yt}),u=ne(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new ke("custom check without a predicate or check function")}const sS=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 Py(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=se(t,xs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=se(t,Oc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=se(t,Uc),l=se(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=se(t,Ss);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=se(t,Pc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=se(t,Mc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=se(t,Fc);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=se(t,zc),l=se(t,n),d=ne(t),f=ne(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=se(t,Rc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=se(t,Lc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=ne(t),p=s.normalize?`${f}.href`:`${se(t,Qo)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Mn(a))throw new ke(`async string format ${o}`);const c=se(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(sS.has(o)&&n.pattern){const c=se(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 ke("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(${St(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${St(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${St(c)}) return INVALID;`);break}default:throw new ke(`string format ${u}`)}return r}function Ue(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new ke(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=aS(e,t,n,r,a);break;case"number":u=uS(e,n,r);break;case"boolean":u=cS(e,r);break;case"bigint":u=lS(e,n,r);break;case"symbol":u=dS(e,r);break;case"undefined":u=fS(e,r);break;case"null":u=hS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=pS(e,r);break;case"nan":u=mS(e,r);break;case"date":u=gS(e,r);break;case"object":u=yS(e,t,n,r,a);break;case"optional":u=vS(e,t,n,r,a);break;case"nullable":u=_S(e,t,n,r,a);break;case"array":u=kS(e,t,n,r,a);break;case"literal":u=SS(e,t,n,r);break;case"enum":u=xS(e,t,n,r);break;case"readonly":{const c=dh(e,t,n,r),l=ne(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":dh(e,t,n,r),u="true";break;case"default":case"prefault":u=ES(e,t,n,r);break;case"nonoptional":u=$S(e,t,n,r);break;case"tuple":u=TS(e,t,n,r);break;case"union":u=CS(e,t,n,r);break;case"intersection":u=NS(e,t,n,r);break;case"record":u=zS(e,t,n,r);break;case"map":u=LS(e,t,n,r);break;case"set":u=PS(e,t,n,r);break;case"file":u=DS(e,r);break;case"template_literal":u=OS(e,t,n,r);break;case"lazy":u=MS(e,t,n,r);break;case"pipe":u=FS(e,t,n,r);break;case"custom":u=US(e,t,n,r);break;case"transform":u=ZS(e,t,n,r);break;case"catch":u=jS(e,t,n,r);break;default:throw new ke(`schema type ${s}`)}return u===null?null:Jk(e,t,n,u)}function aS(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:Py(e,t,o,r,i)}function uS(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&&Ly(e,{format:r.format},n),n}function cS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function lS(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 dS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function fS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function hS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function pS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function mS(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function gS(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function yS(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=y=>typeof y=="symbol"?se(t,y):St(y),d=y=>typeof y=="symbol"?`[${l(y)}]`:St(y),f=s;if(a.includes("__proto__"))throw new ke('object shape key "__proto__"');const h=new Map;for(const y of c){const b=f[y],v=l(y),S=ne(t);if(e.write(`const ${S} = ${r}[${v}];`),b._zod.optin!==void 0){const _=ne(t);e.write(`let ${_} = (() => {`),e.indented($=>{const R=lt($,t,b,S);$.write(`return ${R};`)}),e.write("})();"),b._zod.optout==="optional"?(e.write(`if (${_} === INVALID) {`),e.indented($=>{$.write(`if (${v} in ${r}) return INVALID;`),$.write(`${_} = undefined;`)}),e.write("}")):e.write(`if (${_} === INVALID) return INVALID;`),h.set(y,_)}else{wS(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=lt(e,t,b,S,i);_!==null&&h.set(y,_)}}const p=o.catchall;let m="none";if(p){const y=p._zod.def.type;if(y==="never"){const b=a.map(v=>`k !== ${St(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(y==="unknown"||y==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const g=ne(t),w=c.some(y=>lh(f[y])||Eu(f[y]));if(!i){if(m==="schema"){const y=a.length>0?se(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`);const v=ne(t);b.write(`const ${v} = ${r}[k];`),lt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${g} = {};`);for(const y of c){const b=l(y),v=h.get(y);Eu(f[y])?e.write(`if (${b} in ${r}) ${g}[${b}] = ${v};`):lh(f[y])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${g}[${b}] = ${v};`):e.write(`${g}[${b}] = ${v};`)}}else{const y=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${g} = { ${y} };`)}if(m!=="none"){const y=a.length>0?se(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`),m==="passthrough")b.write(`${g}[k] = ${r}[k];`);else{const v=ne(t);b.write(`const ${v} = ${r}[k];`);const S=lt(b,t,p,v);b.write(`${g}[k] = ${S};`)}}),e.write("}")}return g}function vS(e,t,n,r,i=!0){const o=n._zod.def;if(bS(n))return Ue(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=ne(t),u=ne(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Ue(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=Ue(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?ne(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Ue(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function bS(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function wS(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 Eu(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function lh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&qn(e)}function qn(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?qn(t.innerType):!0;case"union":return t.options?t.options.some(qn):!0;case"intersection":return!t.left||!t.right||qn(t.left)||qn(t.right);case"pipe":return t.out?qn(t.out):!0;default:return!0}}function _S(e,t,n,r,i=!0){const o=n._zod.def,s=i?ne(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Ue(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function kS(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?ne(t):null,a=ne(t),u=ne(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=lt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function SS(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=se(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=se(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${St(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 ke(`literal type ${typeof s}`);return r}function xS(e,t,n,r){const i=n._zod.values;if(!i)throw new ke("enum schema without enumerated values");const o=se(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function dh(e,t,n,r){const i=n._zod.def;return Ue(e,t,i.innerType,r)}function ES(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 Ue(e,t,i.innerType,r);const u=se(t,s),c=ne(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Ue(e,t,i.innerType,c)}const a=ne(t);if(s){const u=se(t,s),c=se(t,ui);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=Ue(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=Ue(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function $S(e,t,n,r){const i=n._zod.def,o=Ue(e,t,i.innerType,r),s=ne(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function TS(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=fh(o,"optin"),u=fh(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=ne(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=ne(t);h.write(`const ${p} = ${r}[${l}];`);const m=lt(h,t,d,p);h.write(`${c}[${l}] = ${m};`)}),f.write("} else {"),f.indented(h=>{if(Eu(d)){h.write(`${c}.length = ${l};`);return}const p=ne(t),m=ne(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(g=>{const w=lt(g,t,d,p);g.write(`return ${w};`)}),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=ne(t);e.write(`const ${f} = ${r}[${l}];`);const h=lt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=ne(t),d=ne(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const h=lt(f,t,s,d);f.write(`${c}[${l}] = ${h};`)}),e.write("}")}return c}function fh(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 CS(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return AS(e,t,i,r);if(i.inclusive===!1)throw new ke("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Ue(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=se(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=ne(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=Ue(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function AS(e,t,n,r){if(n.unionFallback)throw new ke("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=ne(t),o=ne(t);e.write(`const ${i} = ${r}?.[${St(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 ke("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new ke(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>IS(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Ue(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function IS(e,t,n){if(typeof n=="string")return`${t} === ${St(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=se(e,n);return`${t} === ${r}`}throw new ke(`literal discriminator value ${String(n)}`)}function NS(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=lt(e,t,i.left,r),s=lt(e,t,i.right,r),a=se(t,Qr),u=ne(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function zS(e,t,n,r){const i=n._zod.def,o=se(t,rn);e.write(`if (!${o}(${r})) return INVALID;`);const s=ne(t),a=ne(t),u=ne(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 ke(`record key value ${String(m)}`);const g=typeof m=="number"?m.toString():m;if(g==="__proto__")throw new ke('record key "__proto__"');h.push(g);const w=se(t,m),y=Ue(e,t,i.keyType,w),b=ne(t);e.write(`const ${b} = ${r}[${RS(t,g)}];`);const v=lt(e,t,i.valueType,b);e.write(`${s}[${y}] = ${v};`)}const p=se(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=Is(i.keyType);p.definite===!1&&(t.definite=!1);const m=se(t,p),g=se(t,dr),w=ne(t);return hh(e,t,r,a,y=>{y.write(`let ${w} = ${m}(${a});`),y.write(`if (${w} === INVALID && typeof ${a} === "string" && ${g}.test(${a})) ${w} = ${m}(Number(${a}));`),h?y.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):y.write(`if (${w} === INVALID) return INVALID;`),y.write(`if (${w} === "__proto__") continue;`);const b=ne(t);y.write(`const ${b} = ${r}[${a}];`);const v=lt(y,t,i.valueType,b);y.write(`${s}[${w}] = ${v};`)}),s}return hh(e,t,r,a,h=>{h.write(`const ${u} = ${r}[${a}];`);const p=lt(h,t,i.valueType,u);h.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function hh(e,t,n,r,i,o){const s=se(t,Object.prototype.propertyIsEnumerable),a=ne(t),u=ne(t),c=ne(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 RS(e,t){return typeof t=="string"?St(t):se(e,t)}function LS(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=ne(t),s=ne(t),a=ne(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Ue(u,t,i.keyType,s),l=Ue(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function PS(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=ne(t),s=ne(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Ue(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function DS(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function OS(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=se(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function MS(e,t,n,r){const i=n._zod.def,o=On(t,i.getter),s=se(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=ne(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function FS(e,t,n,r){const i=n._zod.def,o=Ue(e,t,i.in,r);if(i.transform){if(Mn(i.transform))throw new an("z.compile: async transforms in pipes are not supported");const s=i.transform,u=On(t,l=>{const d={value:l,issues:[],addIssue:nl},f=s(l,d);return f instanceof Promise?yt:d.issues.length===0?f:yt}),c=ne(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Ue(e,t,i.out,c)}else return Ue(e,t,i.out,o)}function Mn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function US(e,t,n,r){const i=n._zod.def;if(i.fn){if(Mn(i.fn))throw new an("z.compile: async custom predicates are not supported");const o=On(t,i.fn),s=se(t,xu),a=ne(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new ke("custom schema without a predicate function");return r}function GS(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return yt;const i=r;return i.issues.length===0?i.value:t()}function jS(e,t,n,r){const i=n._zod.def;if(!i.catchValue[oc])throw new ke("catch with a callback (only a constant catch value compiles)",!1);const o=ne(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=lt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=se(t,i.innerType),a=On(t,i.catchValue),u=se(t,GS);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 ZS(e,t,n,r){const i=n._zod.def;if(i.transform){if(Mn(i.transform))throw new an("z.compile: async transforms are not supported");const o=i.transform,a=On(t,c=>{const l={value:c,issues:[],addIssue:nl},d=o(c,l);return d instanceof Promise?yt:l.issues.length===0?d:yt}),u=ne(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Ns(e){return e.checks&&(e.checks=[...e.checks]),e}function Dy(e,t){return new e(Ns({type:"string",...A(t)}))}function Oy(e,t){return new e(Ns({type:"string",coerce:!0,...A(t)}))}function rl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...A(t)})}function il(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...A(t)})}function ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...A(t)})}function sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(t)})}function al(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(t)})}function ul(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(t)})}function zs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...A(t)})}function cl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...A(t)})}function ll(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(t)})}function dl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...A(t)})}function fl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(t)})}function hl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...A(t)})}function pl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...A(t)})}function ml(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(t)})}function gl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(t)})}function yl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(t)})}function My(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...A(t)})}function vl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(t)})}function bl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(t)})}function wl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...A(t)})}function _l(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...A(t)})}function kl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...A(t)})}function Fy(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...A(t)})}function Uy(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...A(t)})}function Sl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...A(t)})}const xl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function El(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(t)})}function $l(e,t){return new e({type:"string",format:"date",check:"string_format",...A(t)})}function Tl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...A(t)})}function Cl(e,t){return new e({type:"string",format:"duration",check:"string_format",...A(t)})}function Gy(e,t){return new e(Ns({type:"number",checks:[],...A(t)}))}function jy(e,t){return new e(Ns({type:"number",coerce:!0,checks:[],...A(t)}))}function Zy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...A(t)})}function By(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...A(t)})}function Vy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...A(t)})}function Hy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...A(t)})}function qy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...A(t)})}function Wy(e,t){return new e({type:"boolean",...A(t)})}function Ky(e,t){return new e({type:"boolean",coerce:!0,...A(t)})}function Jy(e,t){return new e({type:"bigint",...A(t)})}function Yy(e,t){return new e({type:"bigint",coerce:!0,...A(t)})}function Xy(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...A(t)})}function Qy(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...A(t)})}function ev(e,t){return new e({type:"symbol",...A(t)})}function tv(e,t){return new e({type:"undefined",...A(t)})}function nv(e,t){return new e({type:"null",...A(t)})}function rv(e){return new e({type:"any"})}function iv(e){return new e({type:"unknown"})}function ov(e,t){return new e({type:"never",...A(t)})}function sv(e,t){return new e({type:"void",...A(t)})}function av(e,t){return new e({type:"date",...A(t)})}function uv(e,t){return new e({type:"date",coerce:!0,...A(t)})}function cv(e,t){return new e({type:"nan",...A(t)})}function un(e,t){return new $c({check:"less_than",...A(t),value:e,inclusive:!1})}function xt(e,t){return new $c({check:"less_than",...A(t),value:e,inclusive:!0})}function cn(e,t){return new Tc({check:"greater_than",...A(t),value:e,inclusive:!1})}function Et(e,t){return new Tc({check:"greater_than",...A(t),value:e,inclusive:!0})}function Rs(e){return cn(0,e)}function Ls(e){return un(0,e)}function Ps(e){return xt(0,e)}function Ds(e){return Et(0,e)}function Fn(e,t){return new Wm({check:"multiple_of",...A(t),value:e})}function Zn(e,t){return new Ym({check:"max_size",...A(t),maximum:e})}function ln(e,t){return new Xm({check:"min_size",...A(t),minimum:e})}function fr(e,t){return new Qm({check:"size_equals",...A(t),size:e})}function hr(e,t){return new eg({check:"max_length",...A(t),maximum:e})}function kn(e,t){return new tg({check:"min_length",...A(t),minimum:e})}function pr(e,t){return new ng({check:"length_equals",...A(t),length:e})}function bi(e,t){return new rg({check:"string_format",format:"regex",...A(t),pattern:e})}function wi(e){return new ig({check:"string_format",format:"lowercase",...A(e)})}function _i(e){return new og({check:"string_format",format:"uppercase",...A(e)})}function ki(e,t){return new sg({check:"string_format",format:"includes",...A(t),includes:e})}function Si(e,t){return new ag({check:"string_format",format:"starts_with",...A(t),prefix:e})}function xi(e,t){return new ug({check:"string_format",format:"ends_with",...A(t),suffix:e})}function Os(e,t,n){return new cg({check:"property",property:e,schema:t,...A(n)})}function Ei(e,t){return new lg({check:"properties",shape:e,...A(t)})}function $i(e,t){return new dg({check:"mime_type",mime:e,...A(t)})}function Yt(e){return new fg({check:"overwrite",tx:e})}function Ti(e){return Yt(t=>t.normalize(e))}function Ci(){return Yt(e=>e.trim())}function Ai(){return Yt(e=>e.toLowerCase())}function Ii(){return Yt(e=>e.toUpperCase())}function Ni(){return Yt(e=>Bp(e))}function lv(e,t,n){return new e({type:"array",element:t,...A(n)})}function BS(e,t,n){return new e({type:"union",options:t,...A(n)})}function VS(e,t,n){return new e({type:"union",options:t,inclusive:!1,...A(n)})}function HS(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...A(r)})}function qS(e,t,n){return new e({type:"intersection",left:t,right:n})}function WS(e,t,n,r){const i=n instanceof le,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...A(o)})}function KS(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...A(r)})}function JS(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...A(r)})}function YS(e,t,n){return new e({type:"set",valueType:t,...A(n)})}function XS(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...A(n)})}function QS(e,t,n){return new e({type:"enum",entries:t,...A(n)})}function ex(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...A(n)})}function dv(e,t){return new e({type:"file",...A(t)})}function tx(e,t){return new e({type:"transform",transform:t})}function nx(e,t){return new e({type:"optional",innerType:t})}function rx(e,t){return new e({type:"nullable",innerType:t})}function ix(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():ui(n)}})}function ox(e,t,n){return new e({type:"nonoptional",innerType:t,...A(n)})}function sx(e,t){return new e({type:"success",innerType:t})}function ax(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:sc(n)})}function ux(e,t,n){return new e({type:"pipe",in:t,out:n})}function cx(e,t){return new e({type:"readonly",innerType:t})}function lx(e,t,n){return new e({type:"template_literal",parts:t,...A(n)})}function dx(e,t){return new e({type:"lazy",getter:t})}function fx(e,t){return new e({type:"promise",innerType:t})}function fv(e,t,n){const r=A(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function hv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...A(n)})}function pv(e,t){const n=mv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Xn(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(Xn(o))}},e(r.value,r)),t);return n}function mv(e,t){const n=new Me({check:"custom",...A(t)});return n._zod.check=e,n}function gv(e){const t=new Me({check:"describe"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function yv(e){const t=new Me({check:"meta"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,...e})}],t._zod.check=()=>{},t}function vv(e,t){const n=A(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??Wc,u=e.Boolean??jc,c=e.String??vi,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 mr(e,t,n,r={}){const i=A(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 Kr(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$t(e,r,n[r]);return e}function er(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??kt,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 Qe(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 Re(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),Re(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Kr(s.schema,u),t.io==="input"&&pt(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 ph(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function tr(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}/${ph(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+ph(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 f;try{f=new l(...s,d)(...a)}catch(h){throw new ke(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function se(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 On(e,t){return e.definite=!1,se(e,t)}function ne(e){return`v${e.varCounter++}`}function qk(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return yt;const r=n;return r.issues.length===0?r.value:yt}function lt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return Ue(e,t,n,r,i)}catch(c){if(!(c instanceof ke)||!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,Wk(e,t,n,r)}}function Wk(e,t,n,r){t.definite=!1;const i=se(t,n),o=se(t,qk),s=ne(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const Kk=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function Jk(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&&!Kk.has(a.check))throw new ke('check with a custom "when" condition');switch(a.check){case"greater_than":Yk(e,t,a,o);break;case"less_than":Xk(e,t,a,o);break;case"multiple_of":Qk(e,t,a,o);break;case"number_format":Ly(e,a,o);break;case"min_length":{const u=Nn(a.minimum,"min_length"),c=Va(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Nn(a.maximum,"max_length"),c=Va(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Nn(a.length,"length_equals"),c=Va(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 < ${Nn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Nn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Nn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Py(e,t,a,o);break;case"custom":o=oS(e,t,s,o);break;case"bigint_format":eS(e,a,o);break;case"mime_type":tS(e,t,a,o);break;case"property":rS(e,t,a,o);break;case"properties":nS(e,t,a,o);break;case"overwrite":{const u=ne(t);iS(e,t,s,o,u),o=u;break}default:throw new ke(`check type ${a.check}`)}}return o}function Va(e,t,n,r){const i=se(t,ci),o=ne(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Nn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new ke(`${t} bound of type ${typeof e}`);return`${e}`}function zy(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new ke("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ke("comparison check with Invalid Date bound");return se(e,t)}throw new ke(`comparison check bound of type ${typeof t}`)}function Yk(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${zy(t,n.value)}) return INVALID;`)}function Xk(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${zy(t,n.value)}) return INVALID;`)}function Qk(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new ke("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=se(t,ec);e.write(`if (${i}(${r}, ${Nn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Ly(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 ke(`number format ${r}`)}}function eS(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 ke(`bigint format ${r}`)}}function tS(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=se(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function nS(e,t,n,r){if(n.when)throw new ke('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"?se(t,o):St(o),a=ne(t);e.write(`const ${a} = ${r}[${s}];`),lt(e,t,i[o],a,!1)}}function rS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Ue(e,t,n.schema,i)}function iS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new ke("overwrite check without a transform function");if(Mn(o))throw new an("z.compile: async overwrite transforms are not supported");const s=se(t,o);e.write(`const ${i} = ${s}(${r});`)}function Eu(){throw new en}function nl(e){this.issues.push(e)}function oS(e,t,n,r){const i=n._zod.def;if(i.fn){if(Mn(i.fn))throw new an("z.compile: async .refine() predicates are not supported");const o=On(t,i.fn),s=se(t,Eu),a=ne(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(Mn(n._zod.check))throw new an("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=On(t,c=>{const l={value:c,issues:[],addIssue:nl};return o(l)instanceof Promise&&Eu(),l.issues.length===0?l.value:yt}),u=ne(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new ke("custom check without a predicate or check function")}const sS=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 Py(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=se(t,Es);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=se(t,Oc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=se(t,Uc),l=se(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=se(t,Ss);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=se(t,Pc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=se(t,Mc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=se(t,Fc);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=se(t,Rc),l=se(t,n),d=ne(t),f=ne(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=se(t,zc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=se(t,Lc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=ne(t),p=s.normalize?`${f}.href`:`${se(t,Qo)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Mn(a))throw new ke(`async string format ${o}`);const c=se(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(sS.has(o)&&n.pattern){const c=se(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 ke("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(${St(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${St(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${St(c)}) return INVALID;`);break}default:throw new ke(`string format ${u}`)}return r}function Ue(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new ke(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=aS(e,t,n,r,a);break;case"number":u=uS(e,n,r);break;case"boolean":u=cS(e,r);break;case"bigint":u=lS(e,n,r);break;case"symbol":u=dS(e,r);break;case"undefined":u=fS(e,r);break;case"null":u=hS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=pS(e,r);break;case"nan":u=mS(e,r);break;case"date":u=gS(e,r);break;case"object":u=yS(e,t,n,r,a);break;case"optional":u=vS(e,t,n,r,a);break;case"nullable":u=_S(e,t,n,r,a);break;case"array":u=kS(e,t,n,r,a);break;case"literal":u=SS(e,t,n,r);break;case"enum":u=ES(e,t,n,r);break;case"readonly":{const c=dh(e,t,n,r),l=ne(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":dh(e,t,n,r),u="true";break;case"default":case"prefault":u=xS(e,t,n,r);break;case"nonoptional":u=$S(e,t,n,r);break;case"tuple":u=TS(e,t,n,r);break;case"union":u=CS(e,t,n,r);break;case"intersection":u=NS(e,t,n,r);break;case"record":u=RS(e,t,n,r);break;case"map":u=LS(e,t,n,r);break;case"set":u=PS(e,t,n,r);break;case"file":u=DS(e,r);break;case"template_literal":u=OS(e,t,n,r);break;case"lazy":u=MS(e,t,n,r);break;case"pipe":u=FS(e,t,n,r);break;case"custom":u=US(e,t,n,r);break;case"transform":u=ZS(e,t,n,r);break;case"catch":u=jS(e,t,n,r);break;default:throw new ke(`schema type ${s}`)}return u===null?null:Jk(e,t,n,u)}function aS(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:Py(e,t,o,r,i)}function uS(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&&Ly(e,{format:r.format},n),n}function cS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function lS(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 dS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function fS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function hS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function pS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function mS(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function gS(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function yS(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=y=>typeof y=="symbol"?se(t,y):St(y),d=y=>typeof y=="symbol"?`[${l(y)}]`:St(y),f=s;if(a.includes("__proto__"))throw new ke('object shape key "__proto__"');const h=new Map;for(const y of c){const b=f[y],v=l(y),S=ne(t);if(e.write(`const ${S} = ${r}[${v}];`),b._zod.optin!==void 0){const _=ne(t);e.write(`let ${_} = (() => {`),e.indented($=>{const z=lt($,t,b,S);$.write(`return ${z};`)}),e.write("})();"),b._zod.optout==="optional"?(e.write(`if (${_} === INVALID) {`),e.indented($=>{$.write(`if (${v} in ${r}) return INVALID;`),$.write(`${_} = undefined;`)}),e.write("}")):e.write(`if (${_} === INVALID) return INVALID;`),h.set(y,_)}else{wS(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=lt(e,t,b,S,i);_!==null&&h.set(y,_)}}const p=o.catchall;let m="none";if(p){const y=p._zod.def.type;if(y==="never"){const b=a.map(v=>`k !== ${St(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(y==="unknown"||y==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const g=ne(t),w=c.some(y=>lh(f[y])||xu(f[y]));if(!i){if(m==="schema"){const y=a.length>0?se(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`);const v=ne(t);b.write(`const ${v} = ${r}[k];`),lt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${g} = {};`);for(const y of c){const b=l(y),v=h.get(y);xu(f[y])?e.write(`if (${b} in ${r}) ${g}[${b}] = ${v};`):lh(f[y])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${g}[${b}] = ${v};`):e.write(`${g}[${b}] = ${v};`)}}else{const y=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${g} = { ${y} };`)}if(m!=="none"){const y=a.length>0?se(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),y&&b.write(`if (${y}.has(k)) continue;`),m==="passthrough")b.write(`${g}[k] = ${r}[k];`);else{const v=ne(t);b.write(`const ${v} = ${r}[k];`);const S=lt(b,t,p,v);b.write(`${g}[k] = ${S};`)}}),e.write("}")}return g}function vS(e,t,n,r,i=!0){const o=n._zod.def;if(bS(n))return Ue(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=ne(t),u=ne(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Ue(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=Ue(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?ne(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Ue(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function bS(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function wS(e){return e._zod.optin===void 0&&Rn(e)}function Rn(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?Rn(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?Rn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Rn):!0;case"intersection":return!t.left||!t.right?!0:Rn(t.left)&&Rn(t.right);case"pipe":return t.in?Rn(t.in):!0;default:return!0}}function xu(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function lh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&qn(e)}function qn(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?qn(t.innerType):!0;case"union":return t.options?t.options.some(qn):!0;case"intersection":return!t.left||!t.right||qn(t.left)||qn(t.right);case"pipe":return t.out?qn(t.out):!0;default:return!0}}function _S(e,t,n,r,i=!0){const o=n._zod.def,s=i?ne(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Ue(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function kS(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?ne(t):null,a=ne(t),u=ne(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=lt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function SS(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=se(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=se(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${St(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 ke(`literal type ${typeof s}`);return r}function ES(e,t,n,r){const i=n._zod.values;if(!i)throw new ke("enum schema without enumerated values");const o=se(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function dh(e,t,n,r){const i=n._zod.def;return Ue(e,t,i.innerType,r)}function xS(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 Ue(e,t,i.innerType,r);const u=se(t,s),c=ne(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Ue(e,t,i.innerType,c)}const a=ne(t);if(s){const u=se(t,s),c=se(t,ui);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=Ue(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=Ue(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function $S(e,t,n,r){const i=n._zod.def,o=Ue(e,t,i.innerType,r),s=ne(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function TS(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=fh(o,"optin"),u=fh(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=ne(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=ne(t);h.write(`const ${p} = ${r}[${l}];`);const m=lt(h,t,d,p);h.write(`${c}[${l}] = ${m};`)}),f.write("} else {"),f.indented(h=>{if(xu(d)){h.write(`${c}.length = ${l};`);return}const p=ne(t),m=ne(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(g=>{const w=lt(g,t,d,p);g.write(`return ${w};`)}),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=ne(t);e.write(`const ${f} = ${r}[${l}];`);const h=lt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=ne(t),d=ne(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const h=lt(f,t,s,d);f.write(`${c}[${l}] = ${h};`)}),e.write("}")}return c}function fh(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 CS(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return AS(e,t,i,r);if(i.inclusive===!1)throw new ke("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Ue(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=se(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=ne(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=Ue(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function AS(e,t,n,r){if(n.unionFallback)throw new ke("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=ne(t),o=ne(t);e.write(`const ${i} = ${r}?.[${St(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 ke("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new ke(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>IS(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Ue(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function IS(e,t,n){if(typeof n=="string")return`${t} === ${St(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=se(e,n);return`${t} === ${r}`}throw new ke(`literal discriminator value ${String(n)}`)}function NS(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=lt(e,t,i.left,r),s=lt(e,t,i.right,r),a=se(t,Qr),u=ne(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function RS(e,t,n,r){const i=n._zod.def,o=se(t,rn);e.write(`if (!${o}(${r})) return INVALID;`);const s=ne(t),a=ne(t),u=ne(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 ke(`record key value ${String(m)}`);const g=typeof m=="number"?m.toString():m;if(g==="__proto__")throw new ke('record key "__proto__"');h.push(g);const w=se(t,m),y=Ue(e,t,i.keyType,w),b=ne(t);e.write(`const ${b} = ${r}[${zS(t,g)}];`);const v=lt(e,t,i.valueType,b);e.write(`${s}[${y}] = ${v};`)}const p=se(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=Is(i.keyType);p.definite===!1&&(t.definite=!1);const m=se(t,p),g=se(t,dr),w=ne(t);return hh(e,t,r,a,y=>{y.write(`let ${w} = ${m}(${a});`),y.write(`if (${w} === INVALID && typeof ${a} === "string" && ${g}.test(${a})) ${w} = ${m}(Number(${a}));`),h?y.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):y.write(`if (${w} === INVALID) return INVALID;`),y.write(`if (${w} === "__proto__") continue;`);const b=ne(t);y.write(`const ${b} = ${r}[${a}];`);const v=lt(y,t,i.valueType,b);y.write(`${s}[${w}] = ${v};`)}),s}return hh(e,t,r,a,h=>{h.write(`const ${u} = ${r}[${a}];`);const p=lt(h,t,i.valueType,u);h.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function hh(e,t,n,r,i,o){const s=se(t,Object.prototype.propertyIsEnumerable),a=ne(t),u=ne(t),c=ne(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 zS(e,t){return typeof t=="string"?St(t):se(e,t)}function LS(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=ne(t),s=ne(t),a=ne(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Ue(u,t,i.keyType,s),l=Ue(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function PS(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=ne(t),s=ne(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Ue(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function DS(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function OS(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=se(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function MS(e,t,n,r){const i=n._zod.def,o=On(t,i.getter),s=se(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=ne(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function FS(e,t,n,r){const i=n._zod.def,o=Ue(e,t,i.in,r);if(i.transform){if(Mn(i.transform))throw new an("z.compile: async transforms in pipes are not supported");const s=i.transform,u=On(t,l=>{const d={value:l,issues:[],addIssue:nl},f=s(l,d);return f instanceof Promise?yt:d.issues.length===0?f:yt}),c=ne(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Ue(e,t,i.out,c)}else return Ue(e,t,i.out,o)}function Mn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function US(e,t,n,r){const i=n._zod.def;if(i.fn){if(Mn(i.fn))throw new an("z.compile: async custom predicates are not supported");const o=On(t,i.fn),s=se(t,Eu),a=ne(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new ke("custom schema without a predicate function");return r}function GS(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return yt;const i=r;return i.issues.length===0?i.value:t()}function jS(e,t,n,r){const i=n._zod.def;if(!i.catchValue[oc])throw new ke("catch with a callback (only a constant catch value compiles)",!1);const o=ne(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=lt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=se(t,i.innerType),a=On(t,i.catchValue),u=se(t,GS);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 ZS(e,t,n,r){const i=n._zod.def;if(i.transform){if(Mn(i.transform))throw new an("z.compile: async transforms are not supported");const o=i.transform,a=On(t,c=>{const l={value:c,issues:[],addIssue:nl},d=o(c,l);return d instanceof Promise?yt:l.issues.length===0?d:yt}),u=ne(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Ns(e){return e.checks&&(e.checks=[...e.checks]),e}function Dy(e,t){return new e(Ns({type:"string",...A(t)}))}function Oy(e,t){return new e(Ns({type:"string",coerce:!0,...A(t)}))}function rl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...A(t)})}function il(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...A(t)})}function ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...A(t)})}function sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(t)})}function al(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(t)})}function ul(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(t)})}function Rs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...A(t)})}function cl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...A(t)})}function ll(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(t)})}function dl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...A(t)})}function fl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(t)})}function hl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...A(t)})}function pl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...A(t)})}function ml(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(t)})}function gl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(t)})}function yl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(t)})}function My(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...A(t)})}function vl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(t)})}function bl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(t)})}function wl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...A(t)})}function _l(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...A(t)})}function kl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...A(t)})}function Fy(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...A(t)})}function Uy(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...A(t)})}function Sl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...A(t)})}const El={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function xl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(t)})}function $l(e,t){return new e({type:"string",format:"date",check:"string_format",...A(t)})}function Tl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...A(t)})}function Cl(e,t){return new e({type:"string",format:"duration",check:"string_format",...A(t)})}function Gy(e,t){return new e(Ns({type:"number",checks:[],...A(t)}))}function jy(e,t){return new e(Ns({type:"number",coerce:!0,checks:[],...A(t)}))}function Zy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...A(t)})}function By(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...A(t)})}function Vy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...A(t)})}function Hy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...A(t)})}function qy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...A(t)})}function Wy(e,t){return new e({type:"boolean",...A(t)})}function Ky(e,t){return new e({type:"boolean",coerce:!0,...A(t)})}function Jy(e,t){return new e({type:"bigint",...A(t)})}function Yy(e,t){return new e({type:"bigint",coerce:!0,...A(t)})}function Xy(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...A(t)})}function Qy(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...A(t)})}function ev(e,t){return new e({type:"symbol",...A(t)})}function tv(e,t){return new e({type:"undefined",...A(t)})}function nv(e,t){return new e({type:"null",...A(t)})}function rv(e){return new e({type:"any"})}function iv(e){return new e({type:"unknown"})}function ov(e,t){return new e({type:"never",...A(t)})}function sv(e,t){return new e({type:"void",...A(t)})}function av(e,t){return new e({type:"date",...A(t)})}function uv(e,t){return new e({type:"date",coerce:!0,...A(t)})}function cv(e,t){return new e({type:"nan",...A(t)})}function un(e,t){return new $c({check:"less_than",...A(t),value:e,inclusive:!1})}function Et(e,t){return new $c({check:"less_than",...A(t),value:e,inclusive:!0})}function cn(e,t){return new Tc({check:"greater_than",...A(t),value:e,inclusive:!1})}function xt(e,t){return new Tc({check:"greater_than",...A(t),value:e,inclusive:!0})}function zs(e){return cn(0,e)}function Ls(e){return un(0,e)}function Ps(e){return Et(0,e)}function Ds(e){return xt(0,e)}function Fn(e,t){return new Wm({check:"multiple_of",...A(t),value:e})}function Zn(e,t){return new Ym({check:"max_size",...A(t),maximum:e})}function ln(e,t){return new Xm({check:"min_size",...A(t),minimum:e})}function fr(e,t){return new Qm({check:"size_equals",...A(t),size:e})}function hr(e,t){return new eg({check:"max_length",...A(t),maximum:e})}function kn(e,t){return new tg({check:"min_length",...A(t),minimum:e})}function pr(e,t){return new ng({check:"length_equals",...A(t),length:e})}function bi(e,t){return new rg({check:"string_format",format:"regex",...A(t),pattern:e})}function wi(e){return new ig({check:"string_format",format:"lowercase",...A(e)})}function _i(e){return new og({check:"string_format",format:"uppercase",...A(e)})}function ki(e,t){return new sg({check:"string_format",format:"includes",...A(t),includes:e})}function Si(e,t){return new ag({check:"string_format",format:"starts_with",...A(t),prefix:e})}function Ei(e,t){return new ug({check:"string_format",format:"ends_with",...A(t),suffix:e})}function Os(e,t,n){return new cg({check:"property",property:e,schema:t,...A(n)})}function xi(e,t){return new lg({check:"properties",shape:e,...A(t)})}function $i(e,t){return new dg({check:"mime_type",mime:e,...A(t)})}function Yt(e){return new fg({check:"overwrite",tx:e})}function Ti(e){return Yt(t=>t.normalize(e))}function Ci(){return Yt(e=>e.trim())}function Ai(){return Yt(e=>e.toLowerCase())}function Ii(){return Yt(e=>e.toUpperCase())}function Ni(){return Yt(e=>Bp(e))}function lv(e,t,n){return new e({type:"array",element:t,...A(n)})}function BS(e,t,n){return new e({type:"union",options:t,...A(n)})}function VS(e,t,n){return new e({type:"union",options:t,inclusive:!1,...A(n)})}function HS(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...A(r)})}function qS(e,t,n){return new e({type:"intersection",left:t,right:n})}function WS(e,t,n,r){const i=n instanceof le,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...A(o)})}function KS(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...A(r)})}function JS(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...A(r)})}function YS(e,t,n){return new e({type:"set",valueType:t,...A(n)})}function XS(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...A(n)})}function QS(e,t,n){return new e({type:"enum",entries:t,...A(n)})}function eE(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...A(n)})}function dv(e,t){return new e({type:"file",...A(t)})}function tE(e,t){return new e({type:"transform",transform:t})}function nE(e,t){return new e({type:"optional",innerType:t})}function rE(e,t){return new e({type:"nullable",innerType:t})}function iE(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():ui(n)}})}function oE(e,t,n){return new e({type:"nonoptional",innerType:t,...A(n)})}function sE(e,t){return new e({type:"success",innerType:t})}function aE(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:sc(n)})}function uE(e,t,n){return new e({type:"pipe",in:t,out:n})}function cE(e,t){return new e({type:"readonly",innerType:t})}function lE(e,t,n){return new e({type:"template_literal",parts:t,...A(n)})}function dE(e,t){return new e({type:"lazy",getter:t})}function fE(e,t){return new e({type:"promise",innerType:t})}function fv(e,t,n){const r=A(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function hv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...A(n)})}function pv(e,t){const n=mv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Xn(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(Xn(o))}},e(r.value,r)),t);return n}function mv(e,t){const n=new Me({check:"custom",...A(t)});return n._zod.check=e,n}function gv(e){const t=new Me({check:"describe"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function yv(e){const t=new Me({check:"meta"});return t._zod.onattach=[n=>{const r=kt.get(n)??{};kt.add(n,{...r,...e})}],t._zod.check=()=>{},t}function vv(e,t){const n=A(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??Wc,u=e.Boolean??jc,c=e.String??vi,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 mr(e,t,n,r={}){const i=A(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 Kr(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$t(e,r,n[r]);return e}function er(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??kt,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 Qe(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 ze(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),ze(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Kr(s.schema,u),t.io==="input"&&pt(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 ph(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function tr(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}/${ph(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+ph(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 bv(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;bv(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 wv=new Set(["type","properties","required","additionalProperties"]),mh=["oneOf","anyOf"];function gh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function $u(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!wv.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]??gh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:$u(a)??{allOf:a};$t(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=gh(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 hx(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of wv)if(i in e)return;const n=t.filter(i=>mh.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=$u(t);else{const i=n[0],o=mh.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=>$u([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,Kr(e,r))}function nr(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)):Kr(c,p),Kr(c,l),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(p.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}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())bv(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)??[])hx(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)}Kr(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,$t(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:ei(t,"input",e.processors),output:ei(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function pt(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 pt(r.element,n);if(r.type==="set")return pt(r.valueType,n);if(r.type==="lazy")return pt(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 pt(r.innerType,n);if(r.type==="intersection")return pt(r.left,n)||pt(r.right,n);if(r.type==="record"||r.type==="map")return pt(r.keyType,n)||pt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:pt(r.in,n)||pt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(pt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(pt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(pt(i,n))return!0;return!!(r.rest&&pt(r.rest,n))}return!1}const _v=(e,t={})=>n=>{const r=er({...n,processors:t});return Re(e,r),tr(r,e),nr(r,e)},ei=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=er({...i??{},target:o,io:t,processors:n});return Re(e,s),tr(s,e),nr(s,e)},rr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ir=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},yh=(e,t)=>{rr(e,"minimum",t),ir(e,"maximum",t)},kv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Sv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},xv=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Ev=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},vh=(e,t)=>rr(e,"minimum",t.minimum),bh=(e,t)=>ir(e,"maximum",t.maximum),wh=e=>(t,n)=>{Ev(t,n.format);const[r,i]=e[n.format];rr(t,"minimum",r),ir(t,"maximum",i)},px={greater_than:(e,t)=>rr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ir(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>kv(e,t.value),number_format:wh(rc),bigint_format:wh(ic),min_length:vh,max_length:bh,length_equals:(e,t)=>yh(e,t.length),min_size:vh,max_size:bh,size_equals:(e,t)=>yh(e,t.size),string_format:(e,t)=>{Ev(e,t.format),t.pattern&&Sv(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)=>xv(e,t.mime)};function Xe(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)px[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&rr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&rr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&ir(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&ir(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&kv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&xv(t,i.mime);for(const o of i.patterns??[])Sv(t,o);return t}const mx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gx=new Map([[Dc,Am],[Es,Im]]),$v=e=>gx.get(e)??e,Tv=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=Xe(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=mx[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($v);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}))])}},Cv=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=Xe(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 w of a)Number.isFinite(w)&&w!==0?p.add(Math.abs(w)):Qe(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...g]=p;m!==void 0&&(i.multipleOf=m),g.length&&(i.allOf=[...i.allOf??[],...g.map(w=>({multipleOf:w}))])}},Av=(e,t,n,r)=>{n.type="boolean"},Iv=(e,t,n,r)=>{Qe(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Nv=(e,t,n,r)=>{Qe(e,t,n,r,"Symbols cannot be represented in JSON Schema")},zv=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Rv=(e,t,n,r)=>{Qe(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Lv=(e,t,n,r)=>{Qe(e,t,n,r,"Void cannot be represented in JSON Schema")},Pv=(e,t,n,r)=>{n.not={}},Dv=(e,t,n,r)=>{},Ov=(e,t,n,r)=>{},Mv=(e,t,n,r)=>{Qe(e,t,n,r,"Date cannot be represented in JSON Schema")},Fv=(e,t,n,r)=>{const i=e._zod.def,o=Wo(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},Uv=(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(Qe(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(Qe(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},Gv=(e,t,n,r)=>{Qe(e,t,n,r,"NaN cannot be represented in JSON Schema")},jv=(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},Zv=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=Xe(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})))},Bv=(e,t,n,r)=>{n.type="boolean"},Vv=(e,t,n,r)=>{Qe(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Hv=(e,t,n,r)=>{Qe(e,t,n,r,"Function types cannot be represented in JSON Schema")},qv=(e,t,n,r)=>{Qe(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Wv=(e,t,n,r)=>{Qe(e,t,n,r,"Map cannot be represented in JSON Schema")},Kv=(e,t,n,r)=>{Qe(e,t,n,r,"Set cannot be represented in JSON Schema")},Jv=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=Xe(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Re(o.element,t,{...r,path:[...r.path,"items"]})};function ti(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ti(t.out):t.type==="catch"?ti(t.innerType):e._zod.optin}const Yv=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&Qe(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)$t(i.properties,c,Re(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"?ti(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=Re(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Al=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>Re(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},Xv=(e,t,n,r)=>{const i=e._zod.def,o=Re(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=Re(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)},Qv=(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,g)=>Re(m,t,{...r,path:[...r.path,s,g]})),c=o.rest?Re(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"?ti(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}=Xe(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Tu(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=Tu(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const g=m.map(w=>Tu(e,w,n));g.some((w,y)=>w!==m[y])&&(t={...t,[p]:g})}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")?dr:Sc).source)),h}const Cu=new WeakMap;function yx(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 Cu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Tu(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 eb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=Xe(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=Re(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)$t(i.patternProperties,$v(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=Re(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Cu.get(t);l||(l=[],Cu.set(t,l),t.deferred.push(()=>yx(t))),l.push(e)}i.additionalProperties=Re(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&ti(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))}},tb=(e,t,n,r)=>{const i=e._zod.def,o=Re(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"}]},nb=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Il=Symbol();function rb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(Qe(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Il):JSON.parse(s)}const ib=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=rb(i.defaultValue,e,t,n,r);s!==Il&&(n.default=s)},ob=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=rb(i.defaultValue,e,t,n,r);s!==Il&&(n._prefault=s)},sb=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{Qe(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},ab=(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;Re(s,t,r);const a=t.seen.get(e);a.ref=s},ub=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},cb=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Nl=(e,t,n,r)=>{const i=e._zod.def;Re(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},lb=(e,t,n,r)=>{const i=e._zod.innerType;Re(i,t,r);const o=t.seen.get(e);o.ref=i},Au={string:Tv,number:Cv,boolean:Av,bigint:Iv,symbol:Nv,null:zv,undefined:Rv,void:Lv,never:Pv,any:Dv,unknown:Ov,date:Mv,enum:Fv,literal:Uv,nan:Gv,template_literal:jv,file:Zv,success:Bv,custom:Vv,function:Hv,transform:qv,map:Wv,set:Kv,array:Jv,object:Yv,union:Al,intersection:Xv,tuple:Qv,record:eb,nullable:tb,nonoptional:nb,default:ib,prefault:ob,catch:sb,pipe:ab,readonly:ub,promise:cb,optional:Nl,lazy:lb};function zl(e,t){if("_idmap"in e){const r=e,i=er({...t,processors:Au}),o={};for(const u of r._idmap.entries()){const[c,l]=u;Re(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;tr(i,l),$t(s,c,nr(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=er({...t,processors:Au});return Re(e,n),tr(n,e),nr(n,e)}class vx{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=er({processors:Au,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 Re(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,tr(this.ctx,t);const r=nr(this.ctx,t),{"~standard":i,...o}=r;return o}}const bx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),db=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Wg,$ZodArray:Qg,$ZodAsyncError:en,$ZodBase64:Dg,$ZodBase64URL:Og,$ZodBigInt:Zc,$ZodBigIntFormat:Bg,$ZodBoolean:jc,$ZodCIDRv4:Lg,$ZodCIDRv6:Pg,$ZodCUID:kg,$ZodCUID2:Sg,$ZodCatch:_y,$ZodCheck:Me,$ZodCheckBigIntFormat:Jm,$ZodCheckEndsWith:ug,$ZodCheckGreaterThan:Tc,$ZodCheckIncludes:sg,$ZodCheckLengthEquals:ng,$ZodCheckLessThan:$c,$ZodCheckLowerCase:ig,$ZodCheckMaxLength:eg,$ZodCheckMaxSize:Ym,$ZodCheckMimeType:dg,$ZodCheckMinLength:tg,$ZodCheckMinSize:Xm,$ZodCheckMultipleOf:Wm,$ZodCheckNumberFormat:Km,$ZodCheckOverwrite:fg,$ZodCheckProperties:lg,$ZodCheckProperty:cg,$ZodCheckRegex:rg,$ZodCheckSizeEquals:Qm,$ZodCheckStartsWith:ag,$ZodCheckStringFormat:yi,$ZodCheckUpperCase:og,$ZodCodec:Wc,$ZodCreditCard:Fg,$ZodCustom:Cy,$ZodCustomStringFormat:jg,$ZodCyclicError:Ay,$ZodDate:Xg,$ZodDefault:yy,$ZodDiscriminatedUnion:sy,$ZodE164:Mg,$ZodEmail:yg,$ZodEmoji:wg,$ZodEncodeError:gs,$ZodEnum:dy,$ZodError:um,$ZodExactOptional:my,$ZodFile:hy,$ZodFunction:$y,$ZodGUID:mg,$ZodIBAN:Ug,$ZodIPv4:Ng,$ZodIPv6:zg,$ZodISODate:Cg,$ZodISODateTime:Tg,$ZodISODuration:Ig,$ZodISOTime:Ag,$ZodIntersection:ay,$ZodJWT:Gg,$ZodKSUID:$g,$ZodLazy:Kc,$ZodLiteral:fy,$ZodMAC:Rg,$ZodMap:cy,$ZodNaN:ky,$ZodNanoID:_g,$ZodNever:Jg,$ZodNonOptional:by,$ZodNull:qg,$ZodNullable:gy,$ZodNumber:Gc,$ZodNumberFormat:Zg,$ZodObject:ny,$ZodObjectJIT:ry,$ZodOptional:Hc,$ZodPipe:qc,$ZodPrefault:vy,$ZodPreprocess:Sy,$ZodPromise:Ty,$ZodReadonly:xy,$ZodRealError:Tt,$ZodRecord:uy,$ZodRegistry:zy,$ZodSet:ly,$ZodString:vi,$ZodStringFormat:Pe,$ZodSuccess:wy,$ZodSymbol:Vg,$ZodTemplateLiteral:Ey,$ZodTransform:py,$ZodTuple:Vc,$ZodType:le,$ZodULID:xg,$ZodURL:bg,$ZodUUID:gg,$ZodUndefined:Hg,$ZodUnion:$s,$ZodUnknown:Kg,$ZodVoid:Yg,$ZodXID:Eg,$ZodXor:iy,$brand:cc,$constructor:k,$input:el,$output:Qc,Doc:Cc,INVALID:yt,JSONSchema:bx,JSONSchemaGenerator:vx,NEVER:uc,TimePrecision:xl,URL_BAD_FORMAT:Ic,URL_UNPARSEABLE:Xr,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,_any:rv,_array:lv,_base64:wl,_base64url:_l,_bigint:Jy,_boolean:Wy,_catch:ax,_check:mv,_cidrv4:vl,_cidrv6:bl,_coercedBigint:Yy,_coercedBoolean:Ky,_coercedDate:uv,_coercedNumber:jy,_coercedString:Oy,_creditCard:Fy,_cuid:dl,_cuid2:fl,_custom:fv,_date:av,_decode:hc,_decodeAsync:mc,_default:ix,_discriminatedUnion:HS,_e164:kl,_email:rl,_emoji:cl,_encode:fc,_encodeAsync:pc,_endsWith:xi,_enum:XS,_file:dv,_float32:By,_float64:Vy,_gt:cn,_gte:Et,_guid:il,_iban:Uy,_includes:ki,_int:Zy,_int32:Hy,_int64:Xy,_intersection:qS,_ipv4:gl,_ipv6:yl,_isoDate:$l,_isoDateTime:El,_isoDuration:Cl,_isoTime:Tl,_jwt:Sl,_ksuid:ml,_lazy:dx,_length:pr,_literal:ex,_lowercase:wi,_lt:un,_lte:xt,_mac:My,_map:JS,_max:xt,_maxLength:hr,_maxSize:Zn,_mime:$i,_min:Et,_minLength:kn,_minSize:ln,_multipleOf:Fn,_nan:cv,_nanoid:ll,_nativeEnum:QS,_negative:Ls,_never:ov,_nonnegative:Ds,_nonoptional:ox,_nonpositive:Ps,_normalize:Ti,_null:nv,_nullable:rx,_number:Gy,_optional:nx,_overwrite:Yt,_parse:di,_parseAsync:fi,_pipe:ux,_positive:Rs,_promise:fx,_properties:Ei,_property:Os,_readonly:cx,_record:KS,_refine:hv,_regex:bi,_safeDecode:yc,_safeDecodeAsync:bc,_safeEncode:gc,_safeEncodeAsync:vc,_safeParse:hi,_safeParseAsync:pi,_set:YS,_size:fr,_slugify:Ni,_startsWith:Si,_string:Dy,_stringFormat:mr,_stringbool:vv,_success:sx,_superRefine:pv,_symbol:ev,_templateLiteral:lx,_toLowerCase:Ai,_toUpperCase:Ii,_transform:tx,_trim:Ci,_tuple:WS,_uint32:qy,_uint64:Qy,_ulid:hl,_undefined:tv,_union:BS,_unknown:iv,_uppercase:_i,_url:zs,_uuid:ol,_uuidv4:sl,_uuidv6:al,_uuidv7:ul,_void:sv,_xid:pl,_xor:VS,base64Charset:Dc,base64urlCharset:Es,canParseURL:Nc,clone:Oe,compile:tl,compileFn:Is,config:Ye,createStandardJSONSchemaMethod:ei,createToJSONSchemaMethod:_v,decode:nk,decodeAsync:ik,describe:gv,encode:tk,encodeAsync:rk,extractDefs:tr,finalize:nr,flattenError:ys,formatError:vs,getDiscriminatedOption:Bc,globalConfig:gt,globalRegistry:kt,handleUnrepresentable:Qe,initializeContext:er,isBackEdge:Yc,isRecursiveSchema:Jc,isValidBase64:xs,isValidBase64URL:Oc,isValidCIDRv6:Pc,isValidCreditCard:Mc,isValidIBAN:Fc,isValidIPv6:Ss,isValidJWT:Uc,locales:Xc,memoizer:Ts,mergeValues:Qr,meta:yv,parse:bu,parseAsync:wu,parseURLObject:vg,prettifyError:dc,process:Re,processSchema:Re,regexes:ks,registry:Cs,safeDecode:sk,safeDecodeAsync:uk,safeEncode:ok,safeEncodeAsync:ak,safeParse:lm,safeParseAsync:Y_,standardProps:Ac,stripTabAndNewline:Qo,toDotPath:cm,toJSONSchema:zl,toZod:ls,treeifyError:lc,urlHostnameOk:Rc,urlProtocolOk:Lc,util:ac,validate:ws,validateAsync:_s,validateURL:zc,version:hg,withParser:As},Symbol.toStringTag,{value:"Module"})),_h=Symbol("z.visit/resolving");function Rl(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===_h)return new Kc({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,_h);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?Oe(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:Oe(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?Oe(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:Oe(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:Oe(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?Oe(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:Oe(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:Oe(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:Oe(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:Oe(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return Oe(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 Ll(e){return!!e._zod}function fb(e,t){return Ll(e)?lm(e,t):e.safeParse(t)}function wx(e){if(!e)return;let t;if(Ll(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function _x(e){if(Ll(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 kx=()=>{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=nm(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 ${nc(o.values[0])}`:`Invalid option: expected one of ${gu(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":""}: ${gu(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 Sx(){return{localeError:kx()}}const xx=Object.freeze(Object.defineProperty({__proto__:null,endsWith:xi,gt:cn,gte:Et,includes:ki,length:pr,lowercase:wi,lt:un,lte:xt,maxLength:hr,maxSize:Zn,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,negative:Ls,nonnegative:Ds,nonpositive:Ps,normalize:Ti,overwrite:Yt,positive:Rs,properties:Ei,property:Os,regex:bi,size:fr,slugify:Ni,startsWith:Si,toLowerCase:Ai,toUpperCase:Ii,trim:Ci,uppercase:_i},Symbol.toStringTag,{value:"Module"})),kh=new WeakSet([Object.prototype,Error.prototype]);function Eo(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 hb=(e,t)=>{um.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);kh.has(n)||(kh.add(n),Eo(n,"format",r=>i=>vs(r,i)),Eo(n,"flatten",r=>i=>ys(r,i)),Eo(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,Ko,2)}),Eo(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,Ko,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},pb=k("ZodError",hb),bt=k("ZodError",hb,void 0,{Parent:Error}),Pl=di(bt),Dl=fi(bt),Ol=hi(bt),Ml=pi(bt),Fl=fc(bt),Ul=hc(bt),Gl=pc(bt),jl=mc(bt),Zl=gc(bt),Bl=yc(bt),Vl=vc(bt),Hl=bc(bt);function Ex(){gt.localeError||Ye(Sx())}function Bn(){gt.memoizer||Ye({memoizer:Ts()})}const fe=k("ZodType",(e,t)=>(Ex(),le.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ct(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 Oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ea(e,t))},superRefine(e,t){return this.check($a(e,t))},overwrite(e){return this.check(Yt(e))},optional(){return De(this)},exactOptional(){return oa(this)},nullable(){return sr(this)},nullish(){return De(sr(this))},nonoptional(e){return da(this,e)},array(){return oe(this)},or(e){return ge([this,e])},and(e){return Tr(this,e)},transform(e){return ri(this,to(e))},default(e){return ua(this,e)},prefault(e){return la(this,e)},catch(e){return pa(this,e)},pipe(e){return ri(this,e)},readonly(){return va(this)},describe(e){const t=this.clone();return kt.add(t,{description:e}),t},meta(...e){if(e.length===0)return kt.get(this);const t=this.clone();return kt.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",{...Ac(this),jsonSchema:{input:ei(this,"input"),output:ei(this,"output")}})},set"~standard"(e){sn(this,"~standard",e)},parse:function e(t,n){return Pl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Dl(this,t,n,{callee:e})},safeParse(e,t){return Ol(this,e,t)},async safeParseAsync(e,t){return Ml(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){sn(this,"spa",e)},validate(e,t){return ws(this,e,t)},validateAsync(e,t){return _s(this,e,t)},encode:function e(t,n){return Fl(this,t,n,{callee:e})},decode:function e(t,n){return Ul(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await jl(this,t,n,{callee:e})},safeEncode(e,t){return Zl(this,e,t)},safeDecode(e,t){return Bl(this,e,t)},async safeEncodeAsync(e,t){return Vl(this,e,t)},async safeDecodeAsync(e,t){return Hl(this,e,t)},toJSONSchema(e){return _v(this,{})(e)},get description(){return kt.get(this)?.description},get _def(){return this._zod.def}}),zi=k("_ZodString",(e,t)=>{vi.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tv(e,n,r)},li({format:e=>Xe(e).format??null,minLength:e=>Xe(e).minimum??null,maxLength:e=>Xe(e).maximum??null},{regex(...e){return this.check(bi(...e))},includes(...e){return this.check(ki(...e))},startsWith(...e){return this.check(Si(...e))},endsWith(...e){return this.check(xi(...e))},min(...e){return this.check(kn(...e))},max(...e){return this.check(hr(...e))},length(...e){return this.check(pr(...e))},nonempty(...e){return this.check(kn(1,...e))},lowercase(e){return this.check(wi(e))},uppercase(e){return this.check(_i(e))},trim(){return this.check(Ci())},normalize(...e){return this.check(Ti(...e))},toLowerCase(){return this.check(Ai())},toUpperCase(){return this.check(Ii())},slugify(){return this.check(Ni())}})),gr=k("ZodString",(e,t)=>{vi.init(e,t),zi.init(e,t)},{email(e){return this.check(rl(Ri,e))},url(e){return this.check(zs(_r,e))},jwt(e){return this.check(Sl(Ki,e))},emoji(e){return this.check(cl(Pi,e))},guid(e){return this.check(il(Li,e))},uuid(e){return this.check(ol(Bt,e))},uuidv4(e){return this.check(sl(Bt,e))},uuidv6(e){return this.check(al(Bt,e))},uuidv7(e){return this.check(ul(Bt,e))},nanoid(e){return this.check(ll(Di,e))},cuid(e){return this.check(dl(Oi,e))},cuid2(e){return this.check(fl(Mi,e))},ulid(e){return this.check(hl(Fi,e))},base64(e){return this.check(wl(Hi,e))},base64url(e){return this.check(_l(qi,e))},xid(e){return this.check(pl(Ui,e))},ksuid(e){return this.check(ml(Gi,e))},ipv4(e){return this.check(gl(ji,e))},ipv6(e){return this.check(yl(Zi,e))},cidrv4(e){return this.check(vl(Bi,e))},cidrv6(e){return this.check(bl(Vi,e))},e164(e){return this.check(kl(Wi,e))},datetime(e){return this.check(El(yr,e))},date(e){return this.check($l(vr,e))},time(e){return this.check(Tl(br,e))},duration(e){return this.check(Cl(wr,e))}});function x(e){return Dy(gr,e)}const ze=k("ZodStringFormat",(e,t)=>{Pe.init(e,t),zi.init(e,t)}),yr=k("ZodISODateTime",(e,t)=>{Tg.init(e,t),ze.init(e,t)}),vr=k("ZodISODate",(e,t)=>{Cg.init(e,t),ze.init(e,t)}),br=k("ZodISOTime",(e,t)=>{Ag.init(e,t),ze.init(e,t)}),wr=k("ZodISODuration",(e,t)=>{Ig.init(e,t),ze.init(e,t)}),Ri=k("ZodEmail",(e,t)=>{yg.init(e,t),ze.init(e,t)});function ql(e){return rl(Ri,e)}const Li=k("ZodGUID",(e,t)=>{mg.init(e,t),ze.init(e,t)});function Wl(e){return il(Li,e)}const Bt=k("ZodUUID",(e,t)=>{gg.init(e,t),ze.init(e,t)});function Kl(e){return ol(Bt,e)}function Jl(e){return sl(Bt,e)}function Yl(e){return al(Bt,e)}function Xl(e){return ul(Bt,e)}const _r=k("ZodURL",(e,t)=>{bg.init(e,t),ze.init(e,t)});function Ql(e){return zs(_r,e)}function ed(e){return zs(_r,{protocol:wc,hostname:zm,...A(e)})}const Pi=k("ZodEmoji",(e,t)=>{wg.init(e,t),ze.init(e,t)});function td(e){return cl(Pi,e)}const Di=k("ZodNanoID",(e,t)=>{_g.init(e,t),ze.init(e,t)});function nd(e){return ll(Di,e)}const Oi=k("ZodCUID",(e,t)=>{kg.init(e,t),ze.init(e,t)});function rd(e){return dl(Oi,e)}const Mi=k("ZodCUID2",(e,t)=>{Sg.init(e,t),ze.init(e,t)});function id(e){return fl(Mi,e)}const Fi=k("ZodULID",(e,t)=>{xg.init(e,t),ze.init(e,t)});function od(e){return hl(Fi,e)}const Ui=k("ZodXID",(e,t)=>{Eg.init(e,t),ze.init(e,t)});function sd(e){return pl(Ui,e)}const Gi=k("ZodKSUID",(e,t)=>{$g.init(e,t),ze.init(e,t)});function ad(e){return ml(Gi,e)}const ji=k("ZodIPv4",(e,t)=>{Ng.init(e,t),ze.init(e,t)});function ud(e){return gl(ji,e)}const Ms=k("ZodMAC",(e,t)=>{Rg.init(e,t),ze.init(e,t)});function cd(e){return My(Ms,e)}const Zi=k("ZodIPv6",(e,t)=>{zg.init(e,t),ze.init(e,t)});function ld(e){return yl(Zi,e)}const Bi=k("ZodCIDRv4",(e,t)=>{Lg.init(e,t),ze.init(e,t)});function dd(e){return vl(Bi,e)}const Vi=k("ZodCIDRv6",(e,t)=>{Pg.init(e,t),ze.init(e,t)});function fd(e){return bl(Vi,e)}const Hi=k("ZodBase64",(e,t)=>{Dg.init(e,t),ze.init(e,t)});function hd(e){return wl(Hi,e)}const qi=k("ZodBase64URL",(e,t)=>{Og.init(e,t),ze.init(e,t)});function pd(e){return _l(qi,e)}const Wi=k("ZodE164",(e,t)=>{Mg.init(e,t),ze.init(e,t)});function md(e){return kl(Wi,e)}const Fs=k("ZodCreditCard",(e,t)=>{Fg.init(e,t),ze.init(e,t)});function gd(e){return Fy(Fs,e)}const Us=k("ZodIBAN",(e,t)=>{Ug.init(e,t),ze.init(e,t)});function yd(e){return Uy(Us,e)}const Ki=k("ZodJWT",(e,t)=>{Gg.init(e,t),ze.init(e,t)});function vd(e){return Sl(Ki,e)}const Sn=k("ZodCustomStringFormat",(e,t)=>{jg.init(e,t),ze.init(e,t)});function bd(e,t,n={}){return mr(Sn,e,t,n)}function wd(e){return mr(Sn,"hostname",Nm,e)}function _d(e){return mr(Sn,"hex",qm,e)}function kd(e){return mr(Sn,"currency_code",Lm,e)}function Sd(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=ks[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return mr(Sn,r,i,t)}const kr=k("ZodNumber",(e,t)=>{Gc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Cv(e,n,r,i),e.isFinite=!0},li({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=Xe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=Xe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=Xe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Xe(e).format??null},{gt(e,t){return this.check(cn(e,t))},gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},lt(e,t){return this.check(un(e,t))},lte(e,t){return this.check(xt(e,t))},max(e,t){return this.check(xt(e,t))},int(e){return this.check(ni(e))},safe(e){return this.check(ni(e))},positive(e){return this.check(cn(0,e))},nonnegative(e){return this.check(Et(0,e))},negative(e){return this.check(un(0,e))},nonpositive(e){return this.check(xt(0,e))},multipleOf(e,t){return this.check(Fn(e,t))},step(e,t){return this.check(Fn(e,t))},finite(){return this}}));function de(e){return Gy(kr,e)}const xn=k("ZodNumberFormat",(e,t)=>{Zg.init(e,t),kr.init(e,t)});function ni(e){return Zy(xn,e)}function xd(e){return By(xn,e)}function Ed(e){return Vy(xn,e)}function $d(e){return Hy(xn,e)}function Td(e){return qy(xn,e)}const Sr=k("ZodBoolean",(e,t)=>{jc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Av(e,n,r)});function Ne(e){return Wy(Sr,e)}const xr=k("ZodBigInt",(e,t)=>{Zc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Iv(e,n,r,i)},li({minValue:e=>Xe(e).minimum??null,maxValue:e=>Xe(e).maximum??null,format:e=>Xe(e).format??null},{gte(e,t){return this.check(Et(e,t))},min(e,t){return this.check(Et(e,t))},gt(e,t){return this.check(cn(e,t))},lt(e,t){return this.check(un(e,t))},lte(e,t){return this.check(xt(e,t))},max(e,t){return this.check(xt(e,t))},positive(e){return this.check(cn(BigInt(0),e))},negative(e){return this.check(un(BigInt(0),e))},nonpositive(e){return this.check(xt(BigInt(0),e))},nonnegative(e){return this.check(Et(BigInt(0),e))},multipleOf(e,t){return this.check(Fn(e,t))}}));function Cd(e){return Jy(xr,e)}const Ji=k("ZodBigIntFormat",(e,t)=>{Bg.init(e,t),xr.init(e,t)});function Ad(e){return Xy(Ji,e)}function Id(e){return Qy(Ji,e)}const Gs=k("ZodSymbol",(e,t)=>{Vg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nv(e,n,r,i)});function Nd(e){return ev(Gs,e)}const js=k("ZodUndefined",(e,t)=>{Hg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rv(e,n,r,i)});function or(e){return tv(js,e)}const Zs=k("ZodNull",(e,t)=>{qg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zv(e,n,r)});function Yi(e){return nv(Zs,e)}const Bs=k("ZodAny",(e,t)=>{Wg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Dv()});function Xi(){return rv(Bs)}const Vs=k("ZodUnknown",(e,t)=>{Kg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ov()});function Ae(){return iv(Vs)}const Hs=k("ZodNever",(e,t)=>{Jg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pv(e,n,r)});function Un(e){return ov(Hs,e)}const qs=k("ZodVoid",(e,t)=>{Yg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lv(e,n,r,i)});function zd(e){return sv(qs,e)}const Qi=k("ZodDate",(e,t)=>{Xg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mv(e,n,r,i),e.min=(n,r)=>e.check(Et(n,r)),e.max=(n,r)=>e.check(xt(n,r))},li({minDate:e=>{const{minimum:t}=Xe(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=Xe(e);return t?new Date(t):null}},{}));function Rd(e){return av(Qi,e)}const Ws=k("ZodArray",(e,t)=>{Bn(),Qg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jv(e,n,r,i),e.element=t.element},{min(e,t){return this.check(kn(e,t))},nonempty(e){return this.check(kn(1,e))},max(e,t){return this.check(hr(e,t))},length(e,t){return this.check(pr(e,t))},unwrap(){return this.element}});function oe(e,t){return lv(Ws,e,t)}function Ld(e){const t=e._zod.def.shape;return rt(Object.keys(t))}const Er=k("ZodObject",(e,t)=>{Bn(),ry.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yv(e,n,r,i),sm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return rt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ct(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ct(this._zod.def,{catchall:Ae()}))},loose(){return this.clone(ct(this._zod.def,{catchall:Ae()}))},strict(){return this.clone(ct(this._zod.def,{catchall:Un()}))},strip(){return this.clone(ct(this._zod.def,{catchall:void 0}))},extend(e){return Jp(this,e)},safeExtend(e){return Xp(this,e)},merge(e){return Qp(this,e)},pick(e){return Wp(this,e)},omit(e){return Kp(this,e)},partial(...e){return yu(Cr,this,e[0])},exactPartial(...e){return yu(no,this,e[0],"exactPartial")},required(...e){return em(ro,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...A(t)};return new Er(n)}function Pd(e,t){return new Er({type:"object",shape:e,catchall:Un(),...A(t)})}function nt(e,t){return new Er({type:"object",shape:e,catchall:Ae(),...A(t)})}const $r=k("ZodUnion",(e,t)=>{$s.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Al(e,n,r,i),e.options=t.options});function ge(e,t){return new $r({type:"union",options:e,...A(t)})}const Ks=k("ZodXor",(e,t)=>{$r.init(e,t),iy.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Al(e,n,r,i),e.options=t.options});function Dd(e,t){return new Ks({type:"union",options:e,inclusive:!1,...A(t)})}const Js=k("ZodDiscriminatedUnion",(e,t)=>{$r.init(e,t),sy.init(e,t)});function eo(e,t,n){return new Js({type:"union",options:t,discriminator:e,...A(n)})}const Ys=k("ZodIntersection",(e,t)=>{ay.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xv(e,n,r,i)});function Tr(e,t){return new Ys({type:"intersection",left:e,right:t})}const Xs=k("ZodTuple",(e,t)=>{Bn(),Vc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qv(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 Cr({type:"optional",innerType:t}))})}});function Qs(e,t,n){const r=t instanceof le,i=r?n:t,o=r?t:null;return new Xs({type:"tuple",items:e,rest:o,...A(i)})}const Gn=k("ZodRecord",(e,t)=>{Bn(),uy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function be(e,t,n){return!t||!t._zod?new Gn({type:"record",keyType:x(),valueType:e,...A(t)}):new Gn({type:"record",keyType:e,valueType:t,...A(n)})}function Od(e,t,n){return new Gn({type:"record",keyType:e,valueType:t,...A(n),partial:!0})}function Md(e,t,n){return new Gn({type:"record",keyType:e,valueType:t,mode:"loose",...A(n)})}const ea=k("ZodMap",(e,t)=>{Bn(),cy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wv(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(ln(...n)),e.nonempty=n=>e.check(ln(1,n)),e.max=(...n)=>e.check(Zn(...n)),e.size=(...n)=>e.check(fr(...n))});function Fd(e,t,n){return new ea({type:"map",keyType:e,valueType:t,...A(n)})}const ta=k("ZodSet",(e,t)=>{Bn(),ly.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r,i),e.min=(...n)=>e.check(ln(...n)),e.nonempty=n=>e.check(ln(1,n)),e.max=(...n)=>e.check(Zn(...n)),e.size=(...n)=>e.check(fr(...n))});function Ud(e,t){return new ta({type:"set",valueType:e,...A(t)})}const jn=k("ZodEnum",(e,t)=>{dy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(r,i,o)=>Fv(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 jn({...t,checks:[],...A(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 jn({...t,checks:[],...A(i),entries:o})}});function rt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new jn({type:"enum",entries:n,...A(t)})}function Gd(e,t){return new jn({type:"enum",entries:e,...A(t)})}const na=k("ZodLiteral",(e,t)=>{fy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uv(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(e,t){return new na({type:"literal",values:Array.isArray(e)?e:[e],...A(t)})}const ra=k("ZodFile",(e,t)=>{hy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zv(e,n,r),e.min=(n,r)=>e.check(ln(n,r)),e.max=(n,r)=>e.check(Zn(n,r)),e.mime=(n,r)=>e.check($i(Array.isArray(n)?n:[n],r))});function jd(e){return dv(ra,e)}const ia=k("ZodTransform",(e,t)=>{Bn(),py.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qv(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Xn(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(Xn(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function to(e){return new ia({type:"transform",transform:e})}const Cr=k("ZodOptional",(e,t)=>{Hc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function De(e){return new Cr({type:"optional",innerType:e})}const no=k("ZodExactOptional",(e,t)=>{my.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function oa(e){return new no({type:"optional",innerType:e})}const sa=k("ZodNullable",(e,t)=>{gy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function sr(e){return new sa({type:"nullable",innerType:e})}function Zd(e){return De(sr(e))}const aa=k("ZodDefault",(e,t)=>{yy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ua(e,t){return new aa({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ui(t)}})}const ca=k("ZodPrefault",(e,t)=>{vy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function la(e,t){return new ca({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ui(t)}})}const ro=k("ZodNonOptional",(e,t)=>{by.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function da(e,t){return new ro({type:"nonoptional",innerType:e,...A(t)})}const fa=k("ZodSuccess",(e,t)=>{wy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bv(e,n,r),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new fa({type:"success",innerType:e})}const ha=k("ZodCatch",(e,t)=>{_y.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pa(e,t){return new ha({type:"catch",innerType:e,catchValue:typeof t=="function"?t:sc(t)})}const ma=k("ZodNaN",(e,t)=>{ky.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gv(e,n,r,i)});function Vd(e){return cv(ma,e)}const Ar=k("ZodPipe",(e,t)=>{qc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r,i),e.in=t.in,e.out=t.out});function ri(e,t){return new Ar({type:"pipe",in:e,out:t})}const Ir=k("ZodCodec",(e,t)=>{Ar.init(e,t),Wc.init(e,t)});function Hd(e,t,n){return new Ir({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function qd(e){const t=e._zod.def;return new Ir({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const ga=k("ZodPreprocess",(e,t)=>{Ar.init(e,t),Sy.init(e,t)}),ya=k("ZodReadonly",(e,t)=>{xy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e){return new ya({type:"readonly",innerType:e})}const ba=k("ZodTemplateLiteral",(e,t)=>{Ey.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jv(e,n,r)});function Wd(e,t){return new ba({type:"template_literal",parts:e,...A(t)})}const wa=k("ZodLazy",(e,t)=>{Kc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function _a(e){return new wa({type:"lazy",getter:e})}const ka=k("ZodPromise",(e,t)=>{Ty.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Kd(e){return new ka({type:"promise",innerType:e})}const Sa=k("ZodFunction",(e,t)=>{$y.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hv(e,n,r,i)});function ar(e){return new Sa({type:"function",input:Array.isArray(e?.input)?Qs(e?.input):e?.input??oe(Ae()),output:e?.output??Ae()})}const Nr=k("ZodCustom",(e,t)=>{Cy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r,i)});function Jd(e){const t=new Me({check:"custom"});return t._zod.check=e,t}function xa(e,t){return fv(Nr,e??(()=>!0),t)}function Ea(e,t={}){return hv(Nr,e,t)}function $a(e,t){return pv(e,t)}const Yd=gv,Xd=yv,Ta=k("ZodInstanceOf",(e,t)=>{Nr.init(e,t)},{properties(e,t){return this.check(Ei(e,t))}});function Qd(e,t={}){const n=new Ta({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...A(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 ef=(...e)=>vv({Codec:Ir,Boolean:Sr,String:gr},...e);function tf(e){const t=_a(()=>ge([x(e),de(),Ne(),Yi(),oe(t),be(x(),t)]));return t}function io(e,t){return new ga({type:"pipe",in:to(e),out:t})}const $x=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:xr,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:Ri,ZodEmoji:Pi,ZodEnum:jn,ZodExactOptional:no,ZodFile:ra,ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:xn,ZodObject:Er,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:ze,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:zi,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,codec:Hd,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:xa,date:Rd,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,enum:rt,exactOptional:oa,file:jd,float32:xd,float64:Ed,function:ar,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,literal:E,looseObject:nt,looseRecord:Md,mac:cd,map:Fd,meta:Xd,nan:Vd,nanoid:nd,nativeEnum:Gd,never:Un,nonoptional:da,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,partialRecord:Od,pipe:ri,prefault:la,preprocess:io,promise:Kd,readonly:va,record:be,refine:Ea,set:Ud,strictObject:Pd,string:x,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,transform:to,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,url:Ql,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,void:zd,xid:sd,xor:Dd},Symbol.toStringTag,{value:"Module"})),mb={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 gb(e){Ye({customError:e})}function yb(){return Ye().customError}var ts;ts||(ts={});function vb(e){return El(yr,e)}function Tx(e){return $l(vr,e)}function Cx(e){return Tl(br,e)}function Ax(e){return Cl(wr,e)}const nf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,date:Tx,datetime:vb,duration:Ax,time:Cx},Symbol.toStringTag,{value:"Module"})),j={...$x,...xx,iso:nf},Ix=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 Nx(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 Sh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function zx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Rx(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 Lx(e,t){return j.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 Iu(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=Iu(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=Iu(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 Px=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Dx=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Jr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Jr):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>Px.has(t)?Jr(n):!Dx.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Jr))}function xh(e){return e===1?"element":"elements"}function Ox(e,t){return j.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=Iu(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 ${xh(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 ${xh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function Eh(e,t){if(e!==!1)return e===void 0||e===!0?j.any():mt(e,t)}const Mx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function bb(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return j.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 j.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=Rx(i,t),s=mt(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 j.null();if(i.length===0)return j.never();if(i.length===1)return j.literal(i[0]);if(i.every(s=>typeof s=="string"))return j.enum(i);const o=i.map(s=>j.literal(s));return o.length<2?o[0]:j.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return j.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return bb(s,t)});return i.length===0?j.never():i.length===1?i[0]:j.union(i)}if(!n)return j.any();let r;switch(n){case"string":{let i=j.string();if(e.format){const o=e.format;o==="email"?i=i.check(j.email()):o==="uri"||o==="uri-reference"?i=i.check(j.url()):o==="uuid"||o==="guid"?i=i.check(j.uuid()):o==="date-time"?i=i.check(j.iso.datetime({offset:!0})):o==="date"?i=i.check(j.iso.date()):o==="time"?i=i.check(j.regex(Mx)):o==="duration"?i=i.check(j.iso.duration()):o==="hostname"?i=i.check(j.hostname()):o==="ipv4"?i=i.check(j.ipv4()):o==="ipv6"?i=i.check(j.ipv6()):o==="mac"?i=i.check(j.mac()):o==="cidr"?i=i.check(j.cidrv4()):o==="cidr-v6"?i=i.check(j.cidrv6()):o==="base64"?i=i.check(j.base64()):o==="base64url"?i=i.check(j.base64url()):o==="e164"?i=i.check(j.e164()):o==="credit_card"?i=i.check(j.creditCard()):o==="iban"?i=i.check(j.iban()):o==="jwt"?i=i.check(j.jwt()):o==="emoji"?i=i.check(j.emoji()):o==="nanoid"?i=i.check(j.nanoid()):o==="cuid"?i=i.check(j.cuid()):o==="cuid2"?i=i.check(j.cuid2()):o==="ulid"?i=i.check(j.ulid()):o==="xid"?i=i.check(j.xid()):o==="ksuid"&&(i=i.check(j.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"?j.number().int():j.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=j.boolean();break}case"null":{r=j.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?mt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=mt(f,t);$t(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 g=mt(d[m],t),w=j.string().regex(new RegExp(m));h.push(j.looseRecord(w,g))}const p=[];if(Object.keys(i).length>0&&p.push(j.object(i).passthrough()),p.push(...h),p.length===0)r=j.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=j.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)m=j.intersection(m,p[g]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),g=f.map(y=>new RegExp(y)),w=r;r=r.check(y=>{if(!rn(y.value))return;const b=[];for(const v of Object.keys(y.value))m.includes(v)||g.some(S=>S.test(v))||b.push(v);b.length&&y.issues.push({code:"unrecognized_keys",keys:b,input:y.value,inst:w})})}}else{const d=j.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=mt(f,t)}r=Lx(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=>mt(d,t)),u=Sh(a,s),c=Array.isArray(o)?void 0:Eh(o,t),l=j.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(j.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>mt(d,t)),u=Sh(a,s),c=Eh(e.additionalItems,t),l=j.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(j.maxLength(e.maxItems)))}else if(o!==void 0){const s=mt(o,t);let a=j.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=j.array(j.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=Ox(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?mt(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 mt(e,t){if(typeof e=="boolean")return e?j.any():j.never();let n=bb(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=>mt(c,t)),u=j.union(a);n=r?j.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>mt(c,t)),u=j.xor(a);n=r?j.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:j.any();else{let a=r?n:mt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=j.intersection(a,mt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=j.nullable(n)),e.readOnly===!0&&(n=j.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&&!Jr(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&&!Jr(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))Ix.has(a)||$t(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function wb(e,t){if(typeof e=="boolean")return e?j.any():j.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=Nx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??kt};return mt(n,o)}function _b(e){return Rl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:ge(n.options)}})}function Fx(e,t){if(!t?.length)return e;const n=e._zod.def;return Oe(e,ct(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function kb(e){return Fx(e.out,e.checks)}function Ux(e){return e.in._zod.traits.has("$ZodTransform")?kb(e):e.in}function Sb(e){return Rl(e,{pipe:t=>Ux(t._zod.def),default:(t,n)=>n?De(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function xb(e){return Rl(e,{pipe:t=>kb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function Gx(e){return Oy(gr,e)}function jx(e){return jy(kr,e)}function Zx(e){return Ky(Sr,e)}function Bx(e){return Yy(xr,e)}function Vx(e){return uv(Qi,e)}const Eb=Object.freeze(Object.defineProperty({__proto__:null,bigint:Bx,boolean:Zx,date:Vx,number:jx,string:Gx},Symbol.toStringTag,{value:"Module"})),$h=Object.freeze(Object.defineProperty({__proto__:null,$brand:cc,$input:el,$output:Qc,INVALID:yt,NEVER:uc,TimePrecision:xl,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:xr,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:Ri,ZodEmoji:Pi,ZodEnum:jn,ZodError:pb,ZodExactOptional:no,ZodFile:ra,get ZodFirstPartyTypeKind(){return ts},ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodIssueCode:mb,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:xn,ZodObject:Er,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRealError:bt,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:ze,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:zi,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,clone:Oe,codec:Hd,coerce:Eb,compile:tl,config:Ye,core:db,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:xa,date:Rd,decode:Ul,decodeAsync:jl,deepPartial:_b,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,encode:Fl,encodeAsync:Gl,endsWith:xi,enum:rt,exactOptional:oa,file:jd,flattenError:ys,float32:xd,float64:Ed,formatError:vs,fromJSONSchema:wb,function:ar,getDiscriminatedOption:Bc,getErrorMap:yb,globalRegistry:kt,gt:cn,gte:Et,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,includes:ki,input:Sb,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,iso:nf,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,length:pr,literal:E,locales:Xc,looseObject:nt,looseRecord:Md,lowercase:wi,lt:un,lte:xt,mac:cd,map:Fd,maxLength:hr,maxSize:Zn,memoizer:Ts,meta:Xd,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,nan:Vd,nanoid:nd,nativeEnum:Gd,negative:Ls,never:Un,nonnegative:Ds,nonoptional:da,nonpositive:Ps,normalize:Ti,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,output:xb,overwrite:Yt,parse:Pl,parseAsync:Dl,partialRecord:Od,pipe:ri,positive:Rs,prefault:la,preprocess:io,prettifyError:dc,promise:Kd,properties:Ei,property:Os,readonly:va,record:be,refine:Ea,regex:bi,regexes:ks,registry:Cs,safeDecode:Bl,safeDecodeAsync:Hl,safeEncode:Zl,safeEncodeAsync:Vl,safeParse:Ol,safeParseAsync:Ml,set:Ud,setErrorMap:gb,size:fr,slugify:Ni,startsWith:Si,strictObject:Pd,string:x,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,toJSONSchema:zl,toLowerCase:Ai,toUpperCase:Ii,toZod:ls,transform:to,treeifyError:lc,trim:Ci,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,uppercase:_i,url:Ql,util:ac,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,validate:ws,validateAsync:_s,void:zd,withParser:As,xid:sd,xor:Dd},Symbol.toStringTag,{value:"Module"})),Hx=Object.freeze(Object.defineProperty({__proto__:null,$brand:cc,$input:el,$output:Qc,INVALID:yt,NEVER:uc,TimePrecision:xl,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:xr,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:Ri,ZodEmoji:Pi,ZodEnum:jn,ZodError:pb,ZodExactOptional:no,ZodFile:ra,get ZodFirstPartyTypeKind(){return ts},ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodIssueCode:mb,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:xn,ZodObject:Er,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRealError:bt,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:ze,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:zi,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,clone:Oe,codec:Hd,coerce:Eb,compile:tl,config:Ye,core:db,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:xa,date:Rd,decode:Ul,decodeAsync:jl,deepPartial:_b,default:$h,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,encode:Fl,encodeAsync:Gl,endsWith:xi,enum:rt,exactOptional:oa,file:jd,flattenError:ys,float32:xd,float64:Ed,formatError:vs,fromJSONSchema:wb,function:ar,getDiscriminatedOption:Bc,getErrorMap:yb,globalRegistry:kt,gt:cn,gte:Et,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,includes:ki,input:Sb,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,iso:nf,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,length:pr,literal:E,locales:Xc,looseObject:nt,looseRecord:Md,lowercase:wi,lt:un,lte:xt,mac:cd,map:Fd,maxLength:hr,maxSize:Zn,memoizer:Ts,meta:Xd,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,nan:Vd,nanoid:nd,nativeEnum:Gd,negative:Ls,never:Un,nonnegative:Ds,nonoptional:da,nonpositive:Ps,normalize:Ti,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,output:xb,overwrite:Yt,parse:Pl,parseAsync:Dl,partialRecord:Od,pipe:ri,positive:Rs,prefault:la,preprocess:io,prettifyError:dc,promise:Kd,properties:Ei,property:Os,readonly:va,record:be,refine:Ea,regex:bi,regexes:ks,registry:Cs,safeDecode:Bl,safeDecodeAsync:Hl,safeEncode:Zl,safeEncodeAsync:Vl,safeParse:Ol,safeParseAsync:Ml,set:Ud,setErrorMap:gb,size:fr,slugify:Ni,startsWith:Si,strictObject:Pd,string:x,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,toJSONSchema:zl,toLowerCase:Ai,toUpperCase:Ii,toZod:ls,transform:to,treeifyError:lc,trim:Ci,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,uppercase:_i,url:Ql,util:ac,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,validate:ws,validateAsync:_s,void:zd,withParser:As,xid:sd,xor:Dd,z:$h},Symbol.toStringTag,{value:"Module"})),Rn="io.modelcontextprotocol/related-task",Ca="2.0",Je=xa(e=>e!==null&&(typeof e=="object"||typeof e=="function")),$b=ge([x(),de().int()]),Tb=x();nt({ttl:de().optional(),pollInterval:de().optional()});const qx=T({ttl:de().optional()}),Wx=T({taskId:x()}),rf=nt({progressToken:$b.optional(),[Rn]:Wx.optional()}),Ct=T({_meta:rf.optional()}),oo=Ct.extend({task:qx.optional()}),Kx=e=>oo.safeParse(e).success,it=T({method:x(),params:Ct.loose().optional()}),Dt=T({_meta:rf.optional()}),Ot=T({method:x(),params:Dt.loose().optional()}),ot=nt({_meta:rf.optional()}),so=ge([x(),de().int()]),Cb=T({jsonrpc:E(Ca),id:so,...it.shape}).strict(),Th=e=>Cb.safeParse(e).success,Ab=T({jsonrpc:E(Ca),...Ot.shape}).strict(),Jx=e=>Ab.safeParse(e).success,of=T({jsonrpc:E(Ca),id:so,result:ot}).strict(),$o=e=>of.safeParse(e).success;var Ce;(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"})(Ce||(Ce={}));const sf=T({jsonrpc:E(Ca),id:so.optional(),error:T({code:de().int(),message:x(),data:Ae().optional()})}).strict(),Yx=e=>sf.safeParse(e).success,Xx=ge([Cb,Ab,of,sf]);ge([of,sf]);const af=ot.strict(),Qx=Dt.extend({requestId:so.optional(),reason:x().optional()}),uf=Ot.extend({method:E("notifications/cancelled"),params:Qx}),eE=T({src:x(),mimeType:x().optional(),sizes:oe(x()).optional(),theme:rt(["light","dark"]).optional()}),ao=T({icons:oe(eE).optional()}),ur=T({name:x(),title:x().optional()}),Aa=ur.extend({...ur.shape,...ao.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),tE=Tr(T({applyDefaults:Ne().optional()}),be(x(),Ae())),nE=io(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Tr(T({form:tE.optional(),url:Je.optional()}),be(x(),Ae()).optional())),rE=nt({list:Je.optional(),cancel:Je.optional(),requests:nt({sampling:nt({createMessage:Je.optional()}).optional(),elicitation:nt({create:Je.optional()}).optional()}).optional()}),iE=nt({list:Je.optional(),cancel:Je.optional(),requests:nt({tools:nt({call:Je.optional()}).optional()}).optional()}),oE=T({experimental:be(x(),Je).optional(),sampling:T({context:Je.optional(),tools:Je.optional()}).optional(),elicitation:nE.optional(),roots:T({listChanged:Ne().optional()}).optional(),tasks:rE.optional(),extensions:be(x(),Je).optional()}),sE=Ct.extend({protocolVersion:x(),capabilities:oE,clientInfo:Aa}),aE=it.extend({method:E("initialize"),params:sE}),uE=T({experimental:be(x(),Je).optional(),logging:Je.optional(),completions:Je.optional(),prompts:T({listChanged:Ne().optional()}).optional(),resources:T({subscribe:Ne().optional(),listChanged:Ne().optional()}).optional(),tools:T({listChanged:Ne().optional()}).optional(),tasks:iE.optional(),extensions:be(x(),Je).optional()}),cE=ot.extend({protocolVersion:x(),capabilities:uE,serverInfo:Aa,instructions:x().optional()}),lE=Ot.extend({method:E("notifications/initialized"),params:Dt.optional()}),Ia=it.extend({method:E("ping"),params:Ct.optional()}),dE=T({progress:de(),total:De(de()),message:De(x())}),fE=T({...Dt.shape,...dE.shape,progressToken:$b}),cf=Ot.extend({method:E("notifications/progress"),params:fE}),hE=Ct.extend({cursor:Tb.optional()}),uo=it.extend({params:hE.optional()}),co=ot.extend({nextCursor:Tb.optional()}),pE=rt(["working","input_required","completed","failed","cancelled"]),lo=T({taskId:x(),status:pE,ttl:ge([de(),Yi()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:De(de()),statusMessage:De(x())}),lf=ot.extend({task:lo}),mE=Dt.merge(lo),ns=Ot.extend({method:E("notifications/tasks/status"),params:mE}),df=it.extend({method:E("tasks/get"),params:Ct.extend({taskId:x()})}),ff=ot.merge(lo),hf=it.extend({method:E("tasks/result"),params:Ct.extend({taskId:x()})});ot.loose();const pf=uo.extend({method:E("tasks/list")}),mf=co.extend({tasks:oe(lo)}),gf=it.extend({method:E("tasks/cancel"),params:Ct.extend({taskId:x()})}),gE=ot.merge(lo),Ib=T({uri:x(),mimeType:De(x()),_meta:be(x(),Ae()).optional()}),Nb=Ib.extend({text:x()}),yf=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),zb=Ib.extend({blob:yf}),fo=rt(["user","assistant"]),zr=T({audience:oe(fo).optional(),priority:de().min(0).max(1).optional(),lastModified:vb({offset:!0}).optional()}),Rb=T({...ur.shape,...ao.shape,uri:x(),description:De(x()),mimeType:De(x()),size:De(de()),annotations:zr.optional(),_meta:De(nt({}))}),yE=T({...ur.shape,...ao.shape,uriTemplate:x(),description:De(x()),mimeType:De(x()),annotations:zr.optional(),_meta:De(nt({}))}),vE=uo.extend({method:E("resources/list")}),Lb=co.extend({resources:oe(Rb)}),bE=uo.extend({method:E("resources/templates/list")}),wE=co.extend({resourceTemplates:oe(yE)}),vf=Ct.extend({uri:x()}),_E=vf,kE=it.extend({method:E("resources/read"),params:_E}),Pb=ot.extend({contents:oe(ge([Nb,zb]))}),SE=Ot.extend({method:E("notifications/resources/list_changed"),params:Dt.optional()}),xE=vf,EE=it.extend({method:E("resources/subscribe"),params:xE}),$E=vf,TE=it.extend({method:E("resources/unsubscribe"),params:$E}),CE=Dt.extend({uri:x()}),AE=Ot.extend({method:E("notifications/resources/updated"),params:CE}),IE=T({name:x(),description:De(x()),required:De(Ne())}),NE=T({...ur.shape,...ao.shape,description:De(x()),arguments:De(oe(IE)),_meta:De(nt({}))}),zE=uo.extend({method:E("prompts/list")}),RE=co.extend({prompts:oe(NE)}),LE=Ct.extend({name:x(),arguments:be(x(),x()).optional()}),PE=it.extend({method:E("prompts/get"),params:LE}),bf=T({type:E("text"),text:x(),annotations:zr.optional(),_meta:be(x(),Ae()).optional()}),wf=T({type:E("image"),data:yf,mimeType:x(),annotations:zr.optional(),_meta:be(x(),Ae()).optional()}),_f=T({type:E("audio"),data:yf,mimeType:x(),annotations:zr.optional(),_meta:be(x(),Ae()).optional()}),DE=T({type:E("tool_use"),name:x(),id:x(),input:be(x(),Ae()),_meta:be(x(),Ae()).optional()}),Db=T({type:E("resource"),resource:ge([Nb,zb]),annotations:zr.optional(),_meta:be(x(),Ae()).optional()}),Ob=Rb.extend({type:E("resource_link")}),ho=ge([bf,wf,_f,Ob,Db]),OE=T({role:fo,content:ho}),ME=ot.extend({description:x().optional(),messages:oe(OE)}),FE=Ot.extend({method:E("notifications/prompts/list_changed"),params:Dt.optional()}),UE=T({title:x().optional(),readOnlyHint:Ne().optional(),destructiveHint:Ne().optional(),idempotentHint:Ne().optional(),openWorldHint:Ne().optional()}),GE=T({taskSupport:rt(["required","optional","forbidden"]).optional()}),kf=T({...ur.shape,...ao.shape,description:x().optional(),inputSchema:T({type:E("object"),properties:be(x(),Je).optional(),required:oe(x()).optional()}).catchall(Ae()),outputSchema:T({type:E("object"),properties:be(x(),Je).optional(),required:oe(x()).optional()}).catchall(Ae()).optional(),annotations:UE.optional(),execution:GE.optional(),_meta:be(x(),Ae()).optional()}),Mb=uo.extend({method:E("tools/list")}),jE=co.extend({tools:oe(kf)}),Na=ot.extend({content:oe(ho).default([]),structuredContent:be(x(),Ae()).optional(),isError:Ne().optional()});Na.or(ot.extend({toolResult:Ae()}));const ZE=oo.extend({name:x(),arguments:be(x(),Ae()).optional()}),Fb=it.extend({method:E("tools/call"),params:ZE}),BE=Ot.extend({method:E("notifications/tools/list_changed"),params:Dt.optional()});T({autoRefresh:Ne().default(!0),debounceMs:de().int().nonnegative().default(300)});const Ub=rt(["debug","info","notice","warning","error","critical","alert","emergency"]),VE=Ct.extend({level:Ub}),HE=it.extend({method:E("logging/setLevel"),params:VE}),qE=Dt.extend({level:Ub,logger:x().optional(),data:Ae()}),WE=Ot.extend({method:E("notifications/message"),params:qE}),KE=T({name:x().optional()}),JE=T({hints:oe(KE).optional(),costPriority:de().min(0).max(1).optional(),speedPriority:de().min(0).max(1).optional(),intelligencePriority:de().min(0).max(1).optional()}),YE=T({mode:rt(["auto","required","none"]).optional()}),XE=T({type:E("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:oe(ho).default([]),structuredContent:T({}).loose().optional(),isError:Ne().optional(),_meta:be(x(),Ae()).optional()}),QE=eo("type",[bf,wf,_f]),rs=eo("type",[bf,wf,_f,DE,XE]),e0=T({role:fo,content:ge([rs,oe(rs)]),_meta:be(x(),Ae()).optional()}),t0=oo.extend({messages:oe(e0),modelPreferences:JE.optional(),systemPrompt:x().optional(),includeContext:rt(["none","thisServer","allServers"]).optional(),temperature:de().optional(),maxTokens:de().int(),stopSequences:oe(x()).optional(),metadata:Je.optional(),tools:oe(kf).optional(),toolChoice:YE.optional()}),n0=it.extend({method:E("sampling/createMessage"),params:t0}),Gb=ot.extend({model:x(),stopReason:De(rt(["endTurn","stopSequence","maxTokens"]).or(x())),role:fo,content:QE}),jb=ot.extend({model:x(),stopReason:De(rt(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:fo,content:ge([rs,oe(rs)])}),r0=T({type:E("boolean"),title:x().optional(),description:x().optional(),default:Ne().optional()}),i0=T({type:E("string"),title:x().optional(),description:x().optional(),minLength:de().optional(),maxLength:de().optional(),format:rt(["email","uri","date","date-time"]).optional(),default:x().optional()}),o0=T({type:rt(["number","integer"]),title:x().optional(),description:x().optional(),minimum:de().optional(),maximum:de().optional(),default:de().optional()}),s0=T({type:E("string"),title:x().optional(),description:x().optional(),enum:oe(x()),default:x().optional()}),a0=T({type:E("string"),title:x().optional(),description:x().optional(),oneOf:oe(T({const:x(),title:x()})),default:x().optional()}),u0=T({type:E("string"),title:x().optional(),description:x().optional(),enum:oe(x()),enumNames:oe(x()).optional(),default:x().optional()}),c0=ge([s0,a0]),l0=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:de().optional(),maxItems:de().optional(),items:T({type:E("string"),enum:oe(x())}),default:oe(x()).optional()}),d0=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:de().optional(),maxItems:de().optional(),items:T({anyOf:oe(T({const:x(),title:x()}))}),default:oe(x()).optional()}),f0=ge([l0,d0]),h0=ge([u0,c0,f0]),p0=ge([h0,r0,i0,o0]),m0=oo.extend({mode:E("form").optional(),message:x(),requestedSchema:T({type:E("object"),properties:be(x(),p0),required:oe(x()).optional()})}),g0=oo.extend({mode:E("url"),message:x(),elicitationId:x(),url:x().url()}),y0=ge([m0,g0]),v0=it.extend({method:E("elicitation/create"),params:y0}),b0=Dt.extend({elicitationId:x()}),w0=Ot.extend({method:E("notifications/elicitation/complete"),params:b0}),_0=ot.extend({action:rt(["accept","decline","cancel"]),content:io(e=>e===null?void 0:e,be(x(),ge([x(),de(),Ne(),oe(x())])).optional())}),k0=T({type:E("ref/resource"),uri:x()}),S0=T({type:E("ref/prompt"),name:x()}),x0=Ct.extend({ref:ge([S0,k0]),argument:T({name:x(),value:x()}),context:T({arguments:be(x(),x()).optional()}).optional()}),E0=it.extend({method:E("completion/complete"),params:x0}),$0=ot.extend({completion:nt({values:oe(x()).max(100),total:De(de().int()),hasMore:De(Ne())})}),T0=T({uri:x().startsWith("file://"),name:x().optional(),_meta:be(x(),Ae()).optional()}),C0=it.extend({method:E("roots/list"),params:Ct.optional()}),A0=ot.extend({roots:oe(T0)}),I0=Ot.extend({method:E("notifications/roots/list_changed"),params:Dt.optional()});ge([Ia,aE,E0,HE,PE,zE,vE,bE,kE,EE,TE,Fb,Mb,df,hf,pf,gf]);ge([uf,cf,lE,I0,ns]);ge([af,Gb,jb,_0,A0,ff,mf,lf]);ge([Ia,n0,v0,C0,df,hf,pf,gf]);ge([uf,cf,WE,AE,SE,BE,FE,ns,w0]);ge([af,cE,$0,ME,RE,Lb,wE,Pb,Na,jE,ff,mf,lf]);class _e 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===Ce.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new N0(i.elicitations,n)}return new _e(t,n,r)}}class N0 extends _e{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Ce.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function An(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ch(e){const n=wx(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=_x(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Ah(e,t){const n=fb(e,t);if(!n.success)throw n.error;return n.data}const z0=6e4;class R0{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(uf,n=>{this._oncancel(n)}),this.setNotificationHandler(cf,n=>{this._onprogress(n)}),this.setRequestHandler(Ia,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(df,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new _e(Ce.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(hf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new _e(Ce.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 _e(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 _e(Ce.InvalidParams,`Task not found: ${o}`);if(!An(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(An(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[Rn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(pf,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 _e(Ce.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(gf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new _e(Ce.InvalidParams,`Task not found: ${n.params.taskId}`);if(An(i.status))throw new _e(Ce.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 _e(Ce.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof _e?i:new _e(Ce.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),_e.fromError(Ce.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),$o(o)||Yx(o)?this._onresponse(o):Th(o)?this._onrequest(o,s):Jx(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=_e.fromError(Ce.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?.[Rn]?.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 _e(Ce.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:Ce.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(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}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=Kx(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,g)=>{if(l.signal.aborted)throw new _e(Ce.ConnectionClosed,"Request was cancelled");const w={...g,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const y=w.relatedTask?.taskId??o;return y&&f&&await f.updateTaskStatus(y,"input_required"),await this.request(p,m,w)},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 _e(Ce.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:Ce.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),$o(t))r(t);else{const s=new _e(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($o(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),$o(t))i(t);else{const s=_e.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 _e?s:new _e(Ce.InternalError,String(s))}}return}let o;try{const s=await this.request(t,lf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new _e(Ce.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},An(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new _e(Ce.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new _e(Ce.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 _e?s:new _e(Ce.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=y=>{l(y)};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(y){d(y);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||{},[Rn]:u}});const p=y=>{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(y)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=y instanceof _e?y:new _e(Ce.RequestTimeout,String(y));l(b)};this._responseHandlers.set(f,y=>{if(!r?.signal?.aborted){if(y instanceof Error)return l(y);try{const b=fb(n,y.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??z0,g=()=>p(_e.fromError(Ce.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,g,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const y=b=>{const v=this._responseHandlers.get(f);v?v(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,y),this._enqueueTaskMessage(w,{type:"request",message:h,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),l(b)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(y=>{this._cleanupTimeout(f),l(y)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},ff,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},mf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},gE,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||{},[Rn]: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||{},[Rn]: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||{},[Rn]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Ch(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Ah(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=Ch(t);this._notificationHandlers.set(r,i=>{const o=Ah(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"&&Th(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new _e(Ce.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 _e(Ce.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new _e(Ce.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 _e(Ce.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=ns.parse({method:"notifications/tasks/status",params:a});await this.notification(u),An(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 _e(Ce.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(An(a.status))throw new _e(Ce.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=ns.parse({method:"notifications/tasks/status",params:u});await this.notification(c),An(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Ih(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function L0(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];Ih(s)&&Ih(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 P0 extends R0{_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 D0="2026-01-26",O0="ui/notifications/tool-input-partial";class Zb{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=Xx.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!==O0&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var M0=ge([E("light"),E("dark")]).describe("Color theme preference for the host environment."),ii=ge([E("inline"),E("fullscreen"),E("pip")]).describe("Display mode for UI presentation."),F0=ge([E("--color-background-primary"),E("--color-background-secondary"),E("--color-background-tertiary"),E("--color-background-inverse"),E("--color-background-ghost"),E("--color-background-info"),E("--color-background-danger"),E("--color-background-success"),E("--color-background-warning"),E("--color-background-disabled"),E("--color-text-primary"),E("--color-text-secondary"),E("--color-text-tertiary"),E("--color-text-inverse"),E("--color-text-ghost"),E("--color-text-info"),E("--color-text-danger"),E("--color-text-success"),E("--color-text-warning"),E("--color-text-disabled"),E("--color-border-primary"),E("--color-border-secondary"),E("--color-border-tertiary"),E("--color-border-inverse"),E("--color-border-ghost"),E("--color-border-info"),E("--color-border-danger"),E("--color-border-success"),E("--color-border-warning"),E("--color-border-disabled"),E("--color-ring-primary"),E("--color-ring-secondary"),E("--color-ring-inverse"),E("--color-ring-info"),E("--color-ring-danger"),E("--color-ring-success"),E("--color-ring-warning"),E("--font-sans"),E("--font-mono"),E("--font-weight-normal"),E("--font-weight-medium"),E("--font-weight-semibold"),E("--font-weight-bold"),E("--font-text-xs-size"),E("--font-text-sm-size"),E("--font-text-md-size"),E("--font-text-lg-size"),E("--font-heading-xs-size"),E("--font-heading-sm-size"),E("--font-heading-md-size"),E("--font-heading-lg-size"),E("--font-heading-xl-size"),E("--font-heading-2xl-size"),E("--font-heading-3xl-size"),E("--font-text-xs-line-height"),E("--font-text-sm-line-height"),E("--font-text-md-line-height"),E("--font-text-lg-line-height"),E("--font-heading-xs-line-height"),E("--font-heading-sm-line-height"),E("--font-heading-md-line-height"),E("--font-heading-lg-line-height"),E("--font-heading-xl-line-height"),E("--font-heading-2xl-line-height"),E("--font-heading-3xl-line-height"),E("--border-radius-xs"),E("--border-radius-sm"),E("--border-radius-md"),E("--border-radius-lg"),E("--border-radius-xl"),E("--border-radius-full"),E("--border-width-regular"),E("--shadow-hairline"),E("--shadow-sm"),E("--shadow-md"),E("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),U0=be(F0.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 bv(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;bv(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 wv=new Set(["type","properties","required","additionalProperties"]),mh=["oneOf","anyOf"];function gh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function $u(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!wv.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]??gh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:$u(a)??{allOf:a};$t(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=gh(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 hE(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of wv)if(i in e)return;const n=t.filter(i=>mh.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=$u(t);else{const i=n[0],o=mh.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=>$u([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,Kr(e,r))}function nr(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)):Kr(c,p),Kr(c,l),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(p.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}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())bv(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)??[])hE(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)}Kr(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,$t(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:ei(t,"input",e.processors),output:ei(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function pt(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 pt(r.element,n);if(r.type==="set")return pt(r.valueType,n);if(r.type==="lazy")return pt(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 pt(r.innerType,n);if(r.type==="intersection")return pt(r.left,n)||pt(r.right,n);if(r.type==="record"||r.type==="map")return pt(r.keyType,n)||pt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:pt(r.in,n)||pt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(pt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(pt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(pt(i,n))return!0;return!!(r.rest&&pt(r.rest,n))}return!1}const _v=(e,t={})=>n=>{const r=er({...n,processors:t});return ze(e,r),tr(r,e),nr(r,e)},ei=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=er({...i??{},target:o,io:t,processors:n});return ze(e,s),tr(s,e),nr(s,e)},rr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ir=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},yh=(e,t)=>{rr(e,"minimum",t),ir(e,"maximum",t)},kv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Sv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ev=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},xv=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},vh=(e,t)=>rr(e,"minimum",t.minimum),bh=(e,t)=>ir(e,"maximum",t.maximum),wh=e=>(t,n)=>{xv(t,n.format);const[r,i]=e[n.format];rr(t,"minimum",r),ir(t,"maximum",i)},pE={greater_than:(e,t)=>rr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ir(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>kv(e,t.value),number_format:wh(rc),bigint_format:wh(ic),min_length:vh,max_length:bh,length_equals:(e,t)=>yh(e,t.length),min_size:vh,max_size:bh,size_equals:(e,t)=>yh(e,t.size),string_format:(e,t)=>{xv(e,t.format),t.pattern&&Sv(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)=>Ev(e,t.mime)};function Xe(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)pE[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&rr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&rr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&ir(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&ir(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&kv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Ev(t,i.mime);for(const o of i.patterns??[])Sv(t,o);return t}const mE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gE=new Map([[Dc,Am],[xs,Im]]),$v=e=>gE.get(e)??e,Tv=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=Xe(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=mE[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($v);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}))])}},Cv=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=Xe(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 w of a)Number.isFinite(w)&&w!==0?p.add(Math.abs(w)):Qe(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...g]=p;m!==void 0&&(i.multipleOf=m),g.length&&(i.allOf=[...i.allOf??[],...g.map(w=>({multipleOf:w}))])}},Av=(e,t,n,r)=>{n.type="boolean"},Iv=(e,t,n,r)=>{Qe(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Nv=(e,t,n,r)=>{Qe(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Rv=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},zv=(e,t,n,r)=>{Qe(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Lv=(e,t,n,r)=>{Qe(e,t,n,r,"Void cannot be represented in JSON Schema")},Pv=(e,t,n,r)=>{n.not={}},Dv=(e,t,n,r)=>{},Ov=(e,t,n,r)=>{},Mv=(e,t,n,r)=>{Qe(e,t,n,r,"Date cannot be represented in JSON Schema")},Fv=(e,t,n,r)=>{const i=e._zod.def,o=Wo(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},Uv=(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(Qe(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(Qe(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},Gv=(e,t,n,r)=>{Qe(e,t,n,r,"NaN cannot be represented in JSON Schema")},jv=(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},Zv=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=Xe(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})))},Bv=(e,t,n,r)=>{n.type="boolean"},Vv=(e,t,n,r)=>{Qe(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Hv=(e,t,n,r)=>{Qe(e,t,n,r,"Function types cannot be represented in JSON Schema")},qv=(e,t,n,r)=>{Qe(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Wv=(e,t,n,r)=>{Qe(e,t,n,r,"Map cannot be represented in JSON Schema")},Kv=(e,t,n,r)=>{Qe(e,t,n,r,"Set cannot be represented in JSON Schema")},Jv=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=Xe(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ze(o.element,t,{...r,path:[...r.path,"items"]})};function ti(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ti(t.out):t.type==="catch"?ti(t.innerType):e._zod.optin}const Yv=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&Qe(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)$t(i.properties,c,ze(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"?ti(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=ze(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Al=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>ze(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},Xv=(e,t,n,r)=>{const i=e._zod.def,o=ze(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=ze(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)},Qv=(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,g)=>ze(m,t,{...r,path:[...r.path,s,g]})),c=o.rest?ze(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"?ti(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}=Xe(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Tu(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=Tu(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const g=m.map(w=>Tu(e,w,n));g.some((w,y)=>w!==m[y])&&(t={...t,[p]:g})}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")?dr:Sc).source)),h}const Cu=new WeakMap;function yE(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 Cu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Tu(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 eb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=Xe(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=ze(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)$t(i.patternProperties,$v(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=ze(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Cu.get(t);l||(l=[],Cu.set(t,l),t.deferred.push(()=>yE(t))),l.push(e)}i.additionalProperties=ze(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&ti(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))}},tb=(e,t,n,r)=>{const i=e._zod.def,o=ze(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"}]},nb=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Il=Symbol();function rb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(Qe(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Il):JSON.parse(s)}const ib=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=rb(i.defaultValue,e,t,n,r);s!==Il&&(n.default=s)},ob=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=rb(i.defaultValue,e,t,n,r);s!==Il&&(n._prefault=s)},sb=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{Qe(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},ab=(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;ze(s,t,r);const a=t.seen.get(e);a.ref=s},ub=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},cb=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Nl=(e,t,n,r)=>{const i=e._zod.def;ze(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},lb=(e,t,n,r)=>{const i=e._zod.innerType;ze(i,t,r);const o=t.seen.get(e);o.ref=i},Au={string:Tv,number:Cv,boolean:Av,bigint:Iv,symbol:Nv,null:Rv,undefined:zv,void:Lv,never:Pv,any:Dv,unknown:Ov,date:Mv,enum:Fv,literal:Uv,nan:Gv,template_literal:jv,file:Zv,success:Bv,custom:Vv,function:Hv,transform:qv,map:Wv,set:Kv,array:Jv,object:Yv,union:Al,intersection:Xv,tuple:Qv,record:eb,nullable:tb,nonoptional:nb,default:ib,prefault:ob,catch:sb,pipe:ab,readonly:ub,promise:cb,optional:Nl,lazy:lb};function Rl(e,t){if("_idmap"in e){const r=e,i=er({...t,processors:Au}),o={};for(const u of r._idmap.entries()){const[c,l]=u;ze(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;tr(i,l),$t(s,c,nr(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=er({...t,processors:Au});return ze(e,n),tr(n,e),nr(n,e)}class vE{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=er({processors:Au,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 ze(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,tr(this.ctx,t);const r=nr(this.ctx,t),{"~standard":i,...o}=r;return o}}const bE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),db=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Wg,$ZodArray:Qg,$ZodAsyncError:en,$ZodBase64:Dg,$ZodBase64URL:Og,$ZodBigInt:Zc,$ZodBigIntFormat:Bg,$ZodBoolean:jc,$ZodCIDRv4:Lg,$ZodCIDRv6:Pg,$ZodCUID:kg,$ZodCUID2:Sg,$ZodCatch:_y,$ZodCheck:Me,$ZodCheckBigIntFormat:Jm,$ZodCheckEndsWith:ug,$ZodCheckGreaterThan:Tc,$ZodCheckIncludes:sg,$ZodCheckLengthEquals:ng,$ZodCheckLessThan:$c,$ZodCheckLowerCase:ig,$ZodCheckMaxLength:eg,$ZodCheckMaxSize:Ym,$ZodCheckMimeType:dg,$ZodCheckMinLength:tg,$ZodCheckMinSize:Xm,$ZodCheckMultipleOf:Wm,$ZodCheckNumberFormat:Km,$ZodCheckOverwrite:fg,$ZodCheckProperties:lg,$ZodCheckProperty:cg,$ZodCheckRegex:rg,$ZodCheckSizeEquals:Qm,$ZodCheckStartsWith:ag,$ZodCheckStringFormat:yi,$ZodCheckUpperCase:og,$ZodCodec:Wc,$ZodCreditCard:Fg,$ZodCustom:Cy,$ZodCustomStringFormat:jg,$ZodCyclicError:Ay,$ZodDate:Xg,$ZodDefault:yy,$ZodDiscriminatedUnion:sy,$ZodE164:Mg,$ZodEmail:yg,$ZodEmoji:wg,$ZodEncodeError:gs,$ZodEnum:dy,$ZodError:um,$ZodExactOptional:my,$ZodFile:hy,$ZodFunction:$y,$ZodGUID:mg,$ZodIBAN:Ug,$ZodIPv4:Ng,$ZodIPv6:Rg,$ZodISODate:Cg,$ZodISODateTime:Tg,$ZodISODuration:Ig,$ZodISOTime:Ag,$ZodIntersection:ay,$ZodJWT:Gg,$ZodKSUID:$g,$ZodLazy:Kc,$ZodLiteral:fy,$ZodMAC:zg,$ZodMap:cy,$ZodNaN:ky,$ZodNanoID:_g,$ZodNever:Jg,$ZodNonOptional:by,$ZodNull:qg,$ZodNullable:gy,$ZodNumber:Gc,$ZodNumberFormat:Zg,$ZodObject:ny,$ZodObjectJIT:ry,$ZodOptional:Hc,$ZodPipe:qc,$ZodPrefault:vy,$ZodPreprocess:Sy,$ZodPromise:Ty,$ZodReadonly:Ey,$ZodRealError:Tt,$ZodRecord:uy,$ZodRegistry:Ry,$ZodSet:ly,$ZodString:vi,$ZodStringFormat:Pe,$ZodSuccess:wy,$ZodSymbol:Vg,$ZodTemplateLiteral:xy,$ZodTransform:py,$ZodTuple:Vc,$ZodType:le,$ZodULID:Eg,$ZodURL:bg,$ZodUUID:gg,$ZodUndefined:Hg,$ZodUnion:$s,$ZodUnknown:Kg,$ZodVoid:Yg,$ZodXID:xg,$ZodXor:iy,$brand:cc,$constructor:k,$input:el,$output:Qc,Doc:Cc,INVALID:yt,JSONSchema:bE,JSONSchemaGenerator:vE,NEVER:uc,TimePrecision:El,URL_BAD_FORMAT:Ic,URL_UNPARSEABLE:Xr,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,_any:rv,_array:lv,_base64:wl,_base64url:_l,_bigint:Jy,_boolean:Wy,_catch:aE,_check:mv,_cidrv4:vl,_cidrv6:bl,_coercedBigint:Yy,_coercedBoolean:Ky,_coercedDate:uv,_coercedNumber:jy,_coercedString:Oy,_creditCard:Fy,_cuid:dl,_cuid2:fl,_custom:fv,_date:av,_decode:hc,_decodeAsync:mc,_default:iE,_discriminatedUnion:HS,_e164:kl,_email:rl,_emoji:cl,_encode:fc,_encodeAsync:pc,_endsWith:Ei,_enum:XS,_file:dv,_float32:By,_float64:Vy,_gt:cn,_gte:xt,_guid:il,_iban:Uy,_includes:ki,_int:Zy,_int32:Hy,_int64:Xy,_intersection:qS,_ipv4:gl,_ipv6:yl,_isoDate:$l,_isoDateTime:xl,_isoDuration:Cl,_isoTime:Tl,_jwt:Sl,_ksuid:ml,_lazy:dE,_length:pr,_literal:eE,_lowercase:wi,_lt:un,_lte:Et,_mac:My,_map:JS,_max:Et,_maxLength:hr,_maxSize:Zn,_mime:$i,_min:xt,_minLength:kn,_minSize:ln,_multipleOf:Fn,_nan:cv,_nanoid:ll,_nativeEnum:QS,_negative:Ls,_never:ov,_nonnegative:Ds,_nonoptional:oE,_nonpositive:Ps,_normalize:Ti,_null:nv,_nullable:rE,_number:Gy,_optional:nE,_overwrite:Yt,_parse:di,_parseAsync:fi,_pipe:uE,_positive:zs,_promise:fE,_properties:xi,_property:Os,_readonly:cE,_record:KS,_refine:hv,_regex:bi,_safeDecode:yc,_safeDecodeAsync:bc,_safeEncode:gc,_safeEncodeAsync:vc,_safeParse:hi,_safeParseAsync:pi,_set:YS,_size:fr,_slugify:Ni,_startsWith:Si,_string:Dy,_stringFormat:mr,_stringbool:vv,_success:sE,_superRefine:pv,_symbol:ev,_templateLiteral:lE,_toLowerCase:Ai,_toUpperCase:Ii,_transform:tE,_trim:Ci,_tuple:WS,_uint32:qy,_uint64:Qy,_ulid:hl,_undefined:tv,_union:BS,_unknown:iv,_uppercase:_i,_url:Rs,_uuid:ol,_uuidv4:sl,_uuidv6:al,_uuidv7:ul,_void:sv,_xid:pl,_xor:VS,base64Charset:Dc,base64urlCharset:xs,canParseURL:Nc,clone:Oe,compile:tl,compileFn:Is,config:Ye,createStandardJSONSchemaMethod:ei,createToJSONSchemaMethod:_v,decode:nk,decodeAsync:ik,describe:gv,encode:tk,encodeAsync:rk,extractDefs:tr,finalize:nr,flattenError:ys,formatError:vs,getDiscriminatedOption:Bc,globalConfig:gt,globalRegistry:kt,handleUnrepresentable:Qe,initializeContext:er,isBackEdge:Yc,isRecursiveSchema:Jc,isValidBase64:Es,isValidBase64URL:Oc,isValidCIDRv6:Pc,isValidCreditCard:Mc,isValidIBAN:Fc,isValidIPv6:Ss,isValidJWT:Uc,locales:Xc,memoizer:Ts,mergeValues:Qr,meta:yv,parse:bu,parseAsync:wu,parseURLObject:vg,prettifyError:dc,process:ze,processSchema:ze,regexes:ks,registry:Cs,safeDecode:sk,safeDecodeAsync:uk,safeEncode:ok,safeEncodeAsync:ak,safeParse:lm,safeParseAsync:Y_,standardProps:Ac,stripTabAndNewline:Qo,toDotPath:cm,toJSONSchema:Rl,toZod:ls,treeifyError:lc,urlHostnameOk:zc,urlProtocolOk:Lc,util:ac,validate:ws,validateAsync:_s,validateURL:Rc,version:hg,withParser:As},Symbol.toStringTag,{value:"Module"})),_h=Symbol("z.visit/resolving");function zl(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===_h)return new Kc({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,_h);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?Oe(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:Oe(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?Oe(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:Oe(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:Oe(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?Oe(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:Oe(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:Oe(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:Oe(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:Oe(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return Oe(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 Ll(e){return!!e._zod}function fb(e,t){return Ll(e)?lm(e,t):e.safeParse(t)}function wE(e){if(!e)return;let t;if(Ll(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function _E(e){if(Ll(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 kE=()=>{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=nm(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 ${nc(o.values[0])}`:`Invalid option: expected one of ${gu(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":""}: ${gu(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 SE(){return{localeError:kE()}}const EE=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Ei,gt:cn,gte:xt,includes:ki,length:pr,lowercase:wi,lt:un,lte:Et,maxLength:hr,maxSize:Zn,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,negative:Ls,nonnegative:Ds,nonpositive:Ps,normalize:Ti,overwrite:Yt,positive:zs,properties:xi,property:Os,regex:bi,size:fr,slugify:Ni,startsWith:Si,toLowerCase:Ai,toUpperCase:Ii,trim:Ci,uppercase:_i},Symbol.toStringTag,{value:"Module"})),kh=new WeakSet([Object.prototype,Error.prototype]);function xo(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 hb=(e,t)=>{um.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);kh.has(n)||(kh.add(n),xo(n,"format",r=>i=>vs(r,i)),xo(n,"flatten",r=>i=>ys(r,i)),xo(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,Ko,2)}),xo(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,Ko,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},pb=k("ZodError",hb),bt=k("ZodError",hb,void 0,{Parent:Error}),Pl=di(bt),Dl=fi(bt),Ol=hi(bt),Ml=pi(bt),Fl=fc(bt),Ul=hc(bt),Gl=pc(bt),jl=mc(bt),Zl=gc(bt),Bl=yc(bt),Vl=vc(bt),Hl=bc(bt);function xE(){gt.localeError||Ye(SE())}function Bn(){gt.memoizer||Ye({memoizer:Ts()})}const fe=k("ZodType",(e,t)=>(xE(),le.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ct(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 Oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(xa(e,t))},superRefine(e,t){return this.check($a(e,t))},overwrite(e){return this.check(Yt(e))},optional(){return De(this)},exactOptional(){return oa(this)},nullable(){return sr(this)},nullish(){return De(sr(this))},nonoptional(e){return da(this,e)},array(){return oe(this)},or(e){return ge([this,e])},and(e){return Tr(this,e)},transform(e){return ri(this,to(e))},default(e){return ua(this,e)},prefault(e){return la(this,e)},catch(e){return pa(this,e)},pipe(e){return ri(this,e)},readonly(){return va(this)},describe(e){const t=this.clone();return kt.add(t,{description:e}),t},meta(...e){if(e.length===0)return kt.get(this);const t=this.clone();return kt.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",{...Ac(this),jsonSchema:{input:ei(this,"input"),output:ei(this,"output")}})},set"~standard"(e){sn(this,"~standard",e)},parse:function e(t,n){return Pl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Dl(this,t,n,{callee:e})},safeParse(e,t){return Ol(this,e,t)},async safeParseAsync(e,t){return Ml(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){sn(this,"spa",e)},validate(e,t){return ws(this,e,t)},validateAsync(e,t){return _s(this,e,t)},encode:function e(t,n){return Fl(this,t,n,{callee:e})},decode:function e(t,n){return Ul(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await jl(this,t,n,{callee:e})},safeEncode(e,t){return Zl(this,e,t)},safeDecode(e,t){return Bl(this,e,t)},async safeEncodeAsync(e,t){return Vl(this,e,t)},async safeDecodeAsync(e,t){return Hl(this,e,t)},toJSONSchema(e){return _v(this,{})(e)},get description(){return kt.get(this)?.description},get _def(){return this._zod.def}}),Ri=k("_ZodString",(e,t)=>{vi.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tv(e,n,r)},li({format:e=>Xe(e).format??null,minLength:e=>Xe(e).minimum??null,maxLength:e=>Xe(e).maximum??null},{regex(...e){return this.check(bi(...e))},includes(...e){return this.check(ki(...e))},startsWith(...e){return this.check(Si(...e))},endsWith(...e){return this.check(Ei(...e))},min(...e){return this.check(kn(...e))},max(...e){return this.check(hr(...e))},length(...e){return this.check(pr(...e))},nonempty(...e){return this.check(kn(1,...e))},lowercase(e){return this.check(wi(e))},uppercase(e){return this.check(_i(e))},trim(){return this.check(Ci())},normalize(...e){return this.check(Ti(...e))},toLowerCase(){return this.check(Ai())},toUpperCase(){return this.check(Ii())},slugify(){return this.check(Ni())}})),gr=k("ZodString",(e,t)=>{vi.init(e,t),Ri.init(e,t)},{email(e){return this.check(rl(zi,e))},url(e){return this.check(Rs(_r,e))},jwt(e){return this.check(Sl(Ki,e))},emoji(e){return this.check(cl(Pi,e))},guid(e){return this.check(il(Li,e))},uuid(e){return this.check(ol(Bt,e))},uuidv4(e){return this.check(sl(Bt,e))},uuidv6(e){return this.check(al(Bt,e))},uuidv7(e){return this.check(ul(Bt,e))},nanoid(e){return this.check(ll(Di,e))},cuid(e){return this.check(dl(Oi,e))},cuid2(e){return this.check(fl(Mi,e))},ulid(e){return this.check(hl(Fi,e))},base64(e){return this.check(wl(Hi,e))},base64url(e){return this.check(_l(qi,e))},xid(e){return this.check(pl(Ui,e))},ksuid(e){return this.check(ml(Gi,e))},ipv4(e){return this.check(gl(ji,e))},ipv6(e){return this.check(yl(Zi,e))},cidrv4(e){return this.check(vl(Bi,e))},cidrv6(e){return this.check(bl(Vi,e))},e164(e){return this.check(kl(Wi,e))},datetime(e){return this.check(xl(yr,e))},date(e){return this.check($l(vr,e))},time(e){return this.check(Tl(br,e))},duration(e){return this.check(Cl(wr,e))}});function E(e){return Dy(gr,e)}const Re=k("ZodStringFormat",(e,t)=>{Pe.init(e,t),Ri.init(e,t)}),yr=k("ZodISODateTime",(e,t)=>{Tg.init(e,t),Re.init(e,t)}),vr=k("ZodISODate",(e,t)=>{Cg.init(e,t),Re.init(e,t)}),br=k("ZodISOTime",(e,t)=>{Ag.init(e,t),Re.init(e,t)}),wr=k("ZodISODuration",(e,t)=>{Ig.init(e,t),Re.init(e,t)}),zi=k("ZodEmail",(e,t)=>{yg.init(e,t),Re.init(e,t)});function ql(e){return rl(zi,e)}const Li=k("ZodGUID",(e,t)=>{mg.init(e,t),Re.init(e,t)});function Wl(e){return il(Li,e)}const Bt=k("ZodUUID",(e,t)=>{gg.init(e,t),Re.init(e,t)});function Kl(e){return ol(Bt,e)}function Jl(e){return sl(Bt,e)}function Yl(e){return al(Bt,e)}function Xl(e){return ul(Bt,e)}const _r=k("ZodURL",(e,t)=>{bg.init(e,t),Re.init(e,t)});function Ql(e){return Rs(_r,e)}function ed(e){return Rs(_r,{protocol:wc,hostname:Rm,...A(e)})}const Pi=k("ZodEmoji",(e,t)=>{wg.init(e,t),Re.init(e,t)});function td(e){return cl(Pi,e)}const Di=k("ZodNanoID",(e,t)=>{_g.init(e,t),Re.init(e,t)});function nd(e){return ll(Di,e)}const Oi=k("ZodCUID",(e,t)=>{kg.init(e,t),Re.init(e,t)});function rd(e){return dl(Oi,e)}const Mi=k("ZodCUID2",(e,t)=>{Sg.init(e,t),Re.init(e,t)});function id(e){return fl(Mi,e)}const Fi=k("ZodULID",(e,t)=>{Eg.init(e,t),Re.init(e,t)});function od(e){return hl(Fi,e)}const Ui=k("ZodXID",(e,t)=>{xg.init(e,t),Re.init(e,t)});function sd(e){return pl(Ui,e)}const Gi=k("ZodKSUID",(e,t)=>{$g.init(e,t),Re.init(e,t)});function ad(e){return ml(Gi,e)}const ji=k("ZodIPv4",(e,t)=>{Ng.init(e,t),Re.init(e,t)});function ud(e){return gl(ji,e)}const Ms=k("ZodMAC",(e,t)=>{zg.init(e,t),Re.init(e,t)});function cd(e){return My(Ms,e)}const Zi=k("ZodIPv6",(e,t)=>{Rg.init(e,t),Re.init(e,t)});function ld(e){return yl(Zi,e)}const Bi=k("ZodCIDRv4",(e,t)=>{Lg.init(e,t),Re.init(e,t)});function dd(e){return vl(Bi,e)}const Vi=k("ZodCIDRv6",(e,t)=>{Pg.init(e,t),Re.init(e,t)});function fd(e){return bl(Vi,e)}const Hi=k("ZodBase64",(e,t)=>{Dg.init(e,t),Re.init(e,t)});function hd(e){return wl(Hi,e)}const qi=k("ZodBase64URL",(e,t)=>{Og.init(e,t),Re.init(e,t)});function pd(e){return _l(qi,e)}const Wi=k("ZodE164",(e,t)=>{Mg.init(e,t),Re.init(e,t)});function md(e){return kl(Wi,e)}const Fs=k("ZodCreditCard",(e,t)=>{Fg.init(e,t),Re.init(e,t)});function gd(e){return Fy(Fs,e)}const Us=k("ZodIBAN",(e,t)=>{Ug.init(e,t),Re.init(e,t)});function yd(e){return Uy(Us,e)}const Ki=k("ZodJWT",(e,t)=>{Gg.init(e,t),Re.init(e,t)});function vd(e){return Sl(Ki,e)}const Sn=k("ZodCustomStringFormat",(e,t)=>{jg.init(e,t),Re.init(e,t)});function bd(e,t,n={}){return mr(Sn,e,t,n)}function wd(e){return mr(Sn,"hostname",Nm,e)}function _d(e){return mr(Sn,"hex",qm,e)}function kd(e){return mr(Sn,"currency_code",Lm,e)}function Sd(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=ks[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return mr(Sn,r,i,t)}const kr=k("ZodNumber",(e,t)=>{Gc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Cv(e,n,r,i),e.isFinite=!0},li({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=Xe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=Xe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=Xe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Xe(e).format??null},{gt(e,t){return this.check(cn(e,t))},gte(e,t){return this.check(xt(e,t))},min(e,t){return this.check(xt(e,t))},lt(e,t){return this.check(un(e,t))},lte(e,t){return this.check(Et(e,t))},max(e,t){return this.check(Et(e,t))},int(e){return this.check(ni(e))},safe(e){return this.check(ni(e))},positive(e){return this.check(cn(0,e))},nonnegative(e){return this.check(xt(0,e))},negative(e){return this.check(un(0,e))},nonpositive(e){return this.check(Et(0,e))},multipleOf(e,t){return this.check(Fn(e,t))},step(e,t){return this.check(Fn(e,t))},finite(){return this}}));function de(e){return Gy(kr,e)}const En=k("ZodNumberFormat",(e,t)=>{Zg.init(e,t),kr.init(e,t)});function ni(e){return Zy(En,e)}function Ed(e){return By(En,e)}function xd(e){return Vy(En,e)}function $d(e){return Hy(En,e)}function Td(e){return qy(En,e)}const Sr=k("ZodBoolean",(e,t)=>{jc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Av(e,n,r)});function Ne(e){return Wy(Sr,e)}const Er=k("ZodBigInt",(e,t)=>{Zc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Iv(e,n,r,i)},li({minValue:e=>Xe(e).minimum??null,maxValue:e=>Xe(e).maximum??null,format:e=>Xe(e).format??null},{gte(e,t){return this.check(xt(e,t))},min(e,t){return this.check(xt(e,t))},gt(e,t){return this.check(cn(e,t))},lt(e,t){return this.check(un(e,t))},lte(e,t){return this.check(Et(e,t))},max(e,t){return this.check(Et(e,t))},positive(e){return this.check(cn(BigInt(0),e))},negative(e){return this.check(un(BigInt(0),e))},nonpositive(e){return this.check(Et(BigInt(0),e))},nonnegative(e){return this.check(xt(BigInt(0),e))},multipleOf(e,t){return this.check(Fn(e,t))}}));function Cd(e){return Jy(Er,e)}const Ji=k("ZodBigIntFormat",(e,t)=>{Bg.init(e,t),Er.init(e,t)});function Ad(e){return Xy(Ji,e)}function Id(e){return Qy(Ji,e)}const Gs=k("ZodSymbol",(e,t)=>{Vg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nv(e,n,r,i)});function Nd(e){return ev(Gs,e)}const js=k("ZodUndefined",(e,t)=>{Hg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zv(e,n,r,i)});function or(e){return tv(js,e)}const Zs=k("ZodNull",(e,t)=>{qg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rv(e,n,r)});function Yi(e){return nv(Zs,e)}const Bs=k("ZodAny",(e,t)=>{Wg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Dv()});function Xi(){return rv(Bs)}const Vs=k("ZodUnknown",(e,t)=>{Kg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ov()});function Ae(){return iv(Vs)}const Hs=k("ZodNever",(e,t)=>{Jg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pv(e,n,r)});function Un(e){return ov(Hs,e)}const qs=k("ZodVoid",(e,t)=>{Yg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lv(e,n,r,i)});function Rd(e){return sv(qs,e)}const Qi=k("ZodDate",(e,t)=>{Xg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mv(e,n,r,i),e.min=(n,r)=>e.check(xt(n,r)),e.max=(n,r)=>e.check(Et(n,r))},li({minDate:e=>{const{minimum:t}=Xe(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=Xe(e);return t?new Date(t):null}},{}));function zd(e){return av(Qi,e)}const Ws=k("ZodArray",(e,t)=>{Bn(),Qg.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jv(e,n,r,i),e.element=t.element},{min(e,t){return this.check(kn(e,t))},nonempty(e){return this.check(kn(1,e))},max(e,t){return this.check(hr(e,t))},length(e,t){return this.check(pr(e,t))},unwrap(){return this.element}});function oe(e,t){return lv(Ws,e,t)}function Ld(e){const t=e._zod.def.shape;return rt(Object.keys(t))}const xr=k("ZodObject",(e,t)=>{Bn(),ry.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yv(e,n,r,i),sm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return rt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ct(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ct(this._zod.def,{catchall:Ae()}))},loose(){return this.clone(ct(this._zod.def,{catchall:Ae()}))},strict(){return this.clone(ct(this._zod.def,{catchall:Un()}))},strip(){return this.clone(ct(this._zod.def,{catchall:void 0}))},extend(e){return Jp(this,e)},safeExtend(e){return Xp(this,e)},merge(e){return Qp(this,e)},pick(e){return Wp(this,e)},omit(e){return Kp(this,e)},partial(...e){return yu(Cr,this,e[0])},exactPartial(...e){return yu(no,this,e[0],"exactPartial")},required(...e){return em(ro,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...A(t)};return new xr(n)}function Pd(e,t){return new xr({type:"object",shape:e,catchall:Un(),...A(t)})}function nt(e,t){return new xr({type:"object",shape:e,catchall:Ae(),...A(t)})}const $r=k("ZodUnion",(e,t)=>{$s.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Al(e,n,r,i),e.options=t.options});function ge(e,t){return new $r({type:"union",options:e,...A(t)})}const Ks=k("ZodXor",(e,t)=>{$r.init(e,t),iy.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Al(e,n,r,i),e.options=t.options});function Dd(e,t){return new Ks({type:"union",options:e,inclusive:!1,...A(t)})}const Js=k("ZodDiscriminatedUnion",(e,t)=>{$r.init(e,t),sy.init(e,t)});function eo(e,t,n){return new Js({type:"union",options:t,discriminator:e,...A(n)})}const Ys=k("ZodIntersection",(e,t)=>{ay.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xv(e,n,r,i)});function Tr(e,t){return new Ys({type:"intersection",left:e,right:t})}const Xs=k("ZodTuple",(e,t)=>{Bn(),Vc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qv(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 Cr({type:"optional",innerType:t}))})}});function Qs(e,t,n){const r=t instanceof le,i=r?n:t,o=r?t:null;return new Xs({type:"tuple",items:e,rest:o,...A(i)})}const Gn=k("ZodRecord",(e,t)=>{Bn(),uy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function be(e,t,n){return!t||!t._zod?new Gn({type:"record",keyType:E(),valueType:e,...A(t)}):new Gn({type:"record",keyType:e,valueType:t,...A(n)})}function Od(e,t,n){return new Gn({type:"record",keyType:e,valueType:t,...A(n),partial:!0})}function Md(e,t,n){return new Gn({type:"record",keyType:e,valueType:t,mode:"loose",...A(n)})}const ea=k("ZodMap",(e,t)=>{Bn(),cy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wv(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(ln(...n)),e.nonempty=n=>e.check(ln(1,n)),e.max=(...n)=>e.check(Zn(...n)),e.size=(...n)=>e.check(fr(...n))});function Fd(e,t,n){return new ea({type:"map",keyType:e,valueType:t,...A(n)})}const ta=k("ZodSet",(e,t)=>{Bn(),ly.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r,i),e.min=(...n)=>e.check(ln(...n)),e.nonempty=n=>e.check(ln(1,n)),e.max=(...n)=>e.check(Zn(...n)),e.size=(...n)=>e.check(fr(...n))});function Ud(e,t){return new ta({type:"set",valueType:e,...A(t)})}const jn=k("ZodEnum",(e,t)=>{dy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(r,i,o)=>Fv(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 jn({...t,checks:[],...A(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 jn({...t,checks:[],...A(i),entries:o})}});function rt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new jn({type:"enum",entries:n,...A(t)})}function Gd(e,t){return new jn({type:"enum",entries:e,...A(t)})}const na=k("ZodLiteral",(e,t)=>{fy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uv(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 x(e,t){return new na({type:"literal",values:Array.isArray(e)?e:[e],...A(t)})}const ra=k("ZodFile",(e,t)=>{hy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zv(e,n,r),e.min=(n,r)=>e.check(ln(n,r)),e.max=(n,r)=>e.check(Zn(n,r)),e.mime=(n,r)=>e.check($i(Array.isArray(n)?n:[n],r))});function jd(e){return dv(ra,e)}const ia=k("ZodTransform",(e,t)=>{Bn(),py.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qv(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new gs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Xn(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(Xn(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function to(e){return new ia({type:"transform",transform:e})}const Cr=k("ZodOptional",(e,t)=>{Hc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function De(e){return new Cr({type:"optional",innerType:e})}const no=k("ZodExactOptional",(e,t)=>{my.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function oa(e){return new no({type:"optional",innerType:e})}const sa=k("ZodNullable",(e,t)=>{gy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function sr(e){return new sa({type:"nullable",innerType:e})}function Zd(e){return De(sr(e))}const aa=k("ZodDefault",(e,t)=>{yy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ua(e,t){return new aa({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ui(t)}})}const ca=k("ZodPrefault",(e,t)=>{vy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function la(e,t){return new ca({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ui(t)}})}const ro=k("ZodNonOptional",(e,t)=>{by.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function da(e,t){return new ro({type:"nonoptional",innerType:e,...A(t)})}const fa=k("ZodSuccess",(e,t)=>{wy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bv(e,n,r),e.unwrap=()=>e._zod.def.innerType});function Bd(e){return new fa({type:"success",innerType:e})}const ha=k("ZodCatch",(e,t)=>{_y.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pa(e,t){return new ha({type:"catch",innerType:e,catchValue:typeof t=="function"?t:sc(t)})}const ma=k("ZodNaN",(e,t)=>{ky.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gv(e,n,r,i)});function Vd(e){return cv(ma,e)}const Ar=k("ZodPipe",(e,t)=>{qc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r,i),e.in=t.in,e.out=t.out});function ri(e,t){return new Ar({type:"pipe",in:e,out:t})}const Ir=k("ZodCodec",(e,t)=>{Ar.init(e,t),Wc.init(e,t)});function Hd(e,t,n){return new Ir({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function qd(e){const t=e._zod.def;return new Ir({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const ga=k("ZodPreprocess",(e,t)=>{Ar.init(e,t),Sy.init(e,t)}),ya=k("ZodReadonly",(e,t)=>{Ey.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e){return new ya({type:"readonly",innerType:e})}const ba=k("ZodTemplateLiteral",(e,t)=>{xy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jv(e,n,r)});function Wd(e,t){return new ba({type:"template_literal",parts:e,...A(t)})}const wa=k("ZodLazy",(e,t)=>{Kc.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function _a(e){return new wa({type:"lazy",getter:e})}const ka=k("ZodPromise",(e,t)=>{Ty.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Kd(e){return new ka({type:"promise",innerType:e})}const Sa=k("ZodFunction",(e,t)=>{$y.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hv(e,n,r,i)});function ar(e){return new Sa({type:"function",input:Array.isArray(e?.input)?Qs(e?.input):e?.input??oe(Ae()),output:e?.output??Ae()})}const Nr=k("ZodCustom",(e,t)=>{Cy.init(e,t),fe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r,i)});function Jd(e){const t=new Me({check:"custom"});return t._zod.check=e,t}function Ea(e,t){return fv(Nr,e??(()=>!0),t)}function xa(e,t={}){return hv(Nr,e,t)}function $a(e,t){return pv(e,t)}const Yd=gv,Xd=yv,Ta=k("ZodInstanceOf",(e,t)=>{Nr.init(e,t)},{properties(e,t){return this.check(xi(e,t))}});function Qd(e,t={}){const n=new Ta({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...A(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 ef=(...e)=>vv({Codec:Ir,Boolean:Sr,String:gr},...e);function tf(e){const t=_a(()=>ge([E(e),de(),Ne(),Yi(),oe(t),be(E(),t)]));return t}function io(e,t){return new ga({type:"pipe",in:to(e),out:t})}const $E=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:Er,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:zi,ZodEmoji:Pi,ZodEnum:jn,ZodExactOptional:no,ZodFile:ra,ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:En,ZodObject:xr,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:Re,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:Ri,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,codec:Hd,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:Ea,date:zd,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,enum:rt,exactOptional:oa,file:jd,float32:Ed,float64:xd,function:ar,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,literal:x,looseObject:nt,looseRecord:Md,mac:cd,map:Fd,meta:Xd,nan:Vd,nanoid:nd,nativeEnum:Gd,never:Un,nonoptional:da,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,partialRecord:Od,pipe:ri,prefault:la,preprocess:io,promise:Kd,readonly:va,record:be,refine:xa,set:Ud,strictObject:Pd,string:E,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,transform:to,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,url:Ql,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,void:Rd,xid:sd,xor:Dd},Symbol.toStringTag,{value:"Module"})),mb={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 gb(e){Ye({customError:e})}function yb(){return Ye().customError}var ts;ts||(ts={});function vb(e){return xl(yr,e)}function TE(e){return $l(vr,e)}function CE(e){return Tl(br,e)}function AE(e){return Cl(wr,e)}const nf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,date:TE,datetime:vb,duration:AE,time:CE},Symbol.toStringTag,{value:"Module"})),j={...$E,...EE,iso:nf},IE=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 NE(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 Sh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function RE(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function zE(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:RE(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 LE(e,t){return j.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 Iu(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=Iu(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=Iu(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 PE=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),DE=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Jr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Jr):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>PE.has(t)?Jr(n):!DE.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Jr))}function Eh(e){return e===1?"element":"elements"}function OE(e,t){return j.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=Iu(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 ${Eh(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 ${Eh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function xh(e,t){if(e!==!1)return e===void 0||e===!0?j.any():mt(e,t)}const ME=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function bb(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return j.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 j.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=zE(i,t),s=mt(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 j.null();if(i.length===0)return j.never();if(i.length===1)return j.literal(i[0]);if(i.every(s=>typeof s=="string"))return j.enum(i);const o=i.map(s=>j.literal(s));return o.length<2?o[0]:j.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return j.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return bb(s,t)});return i.length===0?j.never():i.length===1?i[0]:j.union(i)}if(!n)return j.any();let r;switch(n){case"string":{let i=j.string();if(e.format){const o=e.format;o==="email"?i=i.check(j.email()):o==="uri"||o==="uri-reference"?i=i.check(j.url()):o==="uuid"||o==="guid"?i=i.check(j.uuid()):o==="date-time"?i=i.check(j.iso.datetime({offset:!0})):o==="date"?i=i.check(j.iso.date()):o==="time"?i=i.check(j.regex(ME)):o==="duration"?i=i.check(j.iso.duration()):o==="hostname"?i=i.check(j.hostname()):o==="ipv4"?i=i.check(j.ipv4()):o==="ipv6"?i=i.check(j.ipv6()):o==="mac"?i=i.check(j.mac()):o==="cidr"?i=i.check(j.cidrv4()):o==="cidr-v6"?i=i.check(j.cidrv6()):o==="base64"?i=i.check(j.base64()):o==="base64url"?i=i.check(j.base64url()):o==="e164"?i=i.check(j.e164()):o==="credit_card"?i=i.check(j.creditCard()):o==="iban"?i=i.check(j.iban()):o==="jwt"?i=i.check(j.jwt()):o==="emoji"?i=i.check(j.emoji()):o==="nanoid"?i=i.check(j.nanoid()):o==="cuid"?i=i.check(j.cuid()):o==="cuid2"?i=i.check(j.cuid2()):o==="ulid"?i=i.check(j.ulid()):o==="xid"?i=i.check(j.xid()):o==="ksuid"&&(i=i.check(j.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"?j.number().int():j.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=j.boolean();break}case"null":{r=j.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?mt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=mt(f,t);$t(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 g=mt(d[m],t),w=j.string().regex(new RegExp(m));h.push(j.looseRecord(w,g))}const p=[];if(Object.keys(i).length>0&&p.push(j.object(i).passthrough()),p.push(...h),p.length===0)r=j.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=j.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)m=j.intersection(m,p[g]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),g=f.map(y=>new RegExp(y)),w=r;r=r.check(y=>{if(!rn(y.value))return;const b=[];for(const v of Object.keys(y.value))m.includes(v)||g.some(S=>S.test(v))||b.push(v);b.length&&y.issues.push({code:"unrecognized_keys",keys:b,input:y.value,inst:w})})}}else{const d=j.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=mt(f,t)}r=LE(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=>mt(d,t)),u=Sh(a,s),c=Array.isArray(o)?void 0:xh(o,t),l=j.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(j.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>mt(d,t)),u=Sh(a,s),c=xh(e.additionalItems,t),l=j.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(j.maxLength(e.maxItems)))}else if(o!==void 0){const s=mt(o,t);let a=j.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=j.array(j.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=OE(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?mt(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 mt(e,t){if(typeof e=="boolean")return e?j.any():j.never();let n=bb(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=>mt(c,t)),u=j.union(a);n=r?j.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>mt(c,t)),u=j.xor(a);n=r?j.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:j.any();else{let a=r?n:mt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=j.intersection(a,mt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=j.nullable(n)),e.readOnly===!0&&(n=j.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&&!Jr(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&&!Jr(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))IE.has(a)||$t(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function wb(e,t){if(typeof e=="boolean")return e?j.any():j.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=NE(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??kt};return mt(n,o)}function _b(e){return zl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:ge(n.options)}})}function FE(e,t){if(!t?.length)return e;const n=e._zod.def;return Oe(e,ct(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function kb(e){return FE(e.out,e.checks)}function UE(e){return e.in._zod.traits.has("$ZodTransform")?kb(e):e.in}function Sb(e){return zl(e,{pipe:t=>UE(t._zod.def),default:(t,n)=>n?De(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Eb(e){return zl(e,{pipe:t=>kb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function GE(e){return Oy(gr,e)}function jE(e){return jy(kr,e)}function ZE(e){return Ky(Sr,e)}function BE(e){return Yy(Er,e)}function VE(e){return uv(Qi,e)}const xb=Object.freeze(Object.defineProperty({__proto__:null,bigint:BE,boolean:ZE,date:VE,number:jE,string:GE},Symbol.toStringTag,{value:"Module"})),$h=Object.freeze(Object.defineProperty({__proto__:null,$brand:cc,$input:el,$output:Qc,INVALID:yt,NEVER:uc,TimePrecision:El,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:Er,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:zi,ZodEmoji:Pi,ZodEnum:jn,ZodError:pb,ZodExactOptional:no,ZodFile:ra,get ZodFirstPartyTypeKind(){return ts},ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodIssueCode:mb,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:En,ZodObject:xr,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRealError:bt,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:Re,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:Ri,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,clone:Oe,codec:Hd,coerce:xb,compile:tl,config:Ye,core:db,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:Ea,date:zd,decode:Ul,decodeAsync:jl,deepPartial:_b,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,encode:Fl,encodeAsync:Gl,endsWith:Ei,enum:rt,exactOptional:oa,file:jd,flattenError:ys,float32:Ed,float64:xd,formatError:vs,fromJSONSchema:wb,function:ar,getDiscriminatedOption:Bc,getErrorMap:yb,globalRegistry:kt,gt:cn,gte:xt,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,includes:ki,input:Sb,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,iso:nf,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,length:pr,literal:x,locales:Xc,looseObject:nt,looseRecord:Md,lowercase:wi,lt:un,lte:Et,mac:cd,map:Fd,maxLength:hr,maxSize:Zn,memoizer:Ts,meta:Xd,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,nan:Vd,nanoid:nd,nativeEnum:Gd,negative:Ls,never:Un,nonnegative:Ds,nonoptional:da,nonpositive:Ps,normalize:Ti,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,output:Eb,overwrite:Yt,parse:Pl,parseAsync:Dl,partialRecord:Od,pipe:ri,positive:zs,prefault:la,preprocess:io,prettifyError:dc,promise:Kd,properties:xi,property:Os,readonly:va,record:be,refine:xa,regex:bi,regexes:ks,registry:Cs,safeDecode:Bl,safeDecodeAsync:Hl,safeEncode:Zl,safeEncodeAsync:Vl,safeParse:Ol,safeParseAsync:Ml,set:Ud,setErrorMap:gb,size:fr,slugify:Ni,startsWith:Si,strictObject:Pd,string:E,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,toJSONSchema:Rl,toLowerCase:Ai,toUpperCase:Ii,toZod:ls,transform:to,treeifyError:lc,trim:Ci,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,uppercase:_i,url:Ql,util:ac,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,validate:ws,validateAsync:_s,void:Rd,withParser:As,xid:sd,xor:Dd},Symbol.toStringTag,{value:"Module"})),HE=Object.freeze(Object.defineProperty({__proto__:null,$brand:cc,$input:el,$output:Qc,INVALID:yt,NEVER:uc,TimePrecision:El,ZodAny:Bs,ZodArray:Ws,ZodBase64:Hi,ZodBase64URL:qi,ZodBigInt:Er,ZodBigIntFormat:Ji,ZodBoolean:Sr,ZodCIDRv4:Bi,ZodCIDRv6:Vi,ZodCUID:Oi,ZodCUID2:Mi,ZodCatch:ha,ZodCodec:Ir,ZodCompileAsyncError:an,ZodCompileUnsupportedError:ke,ZodCreditCard:Fs,ZodCustom:Nr,ZodCustomStringFormat:Sn,ZodDate:Qi,ZodDefault:aa,ZodDiscriminatedUnion:Js,ZodE164:Wi,ZodEmail:zi,ZodEmoji:Pi,ZodEnum:jn,ZodError:pb,ZodExactOptional:no,ZodFile:ra,get ZodFirstPartyTypeKind(){return ts},ZodFunction:Sa,ZodGUID:Li,ZodIBAN:Us,ZodIPv4:ji,ZodIPv6:Zi,ZodISODate:vr,ZodISODateTime:yr,ZodISODuration:wr,ZodISOTime:br,ZodInstanceOf:Ta,ZodIntersection:Ys,ZodIssueCode:mb,ZodJWT:Ki,ZodKSUID:Gi,ZodLazy:wa,ZodLiteral:na,ZodMAC:Ms,ZodMap:ea,ZodNaN:ma,ZodNanoID:Di,ZodNever:Hs,ZodNonOptional:ro,ZodNull:Zs,ZodNullable:sa,ZodNumber:kr,ZodNumberFormat:En,ZodObject:xr,ZodOptional:Cr,ZodPipe:Ar,ZodPrefault:ca,ZodPreprocess:ga,ZodPromise:ka,ZodReadonly:ya,ZodRealError:bt,ZodRecord:Gn,ZodSet:ta,ZodString:gr,ZodStringFormat:Re,ZodSuccess:fa,ZodSymbol:Gs,ZodTemplateLiteral:ba,ZodTransform:ia,ZodTuple:Xs,ZodType:fe,ZodULID:Fi,ZodURL:_r,ZodUUID:Bt,ZodUndefined:js,ZodUnion:$r,ZodUnknown:Vs,ZodVoid:qs,ZodXID:Ui,ZodXor:Ks,_ZodString:Ri,_default:ua,_function:ar,any:Xi,array:oe,base64:hd,base64url:pd,bigint:Cd,boolean:Ne,catch:pa,check:Jd,cidrv4:dd,cidrv6:fd,clone:Oe,codec:Hd,coerce:xb,compile:tl,config:Ye,core:db,creditCard:gd,cuid:rd,cuid2:id,currencyCode:kd,custom:Ea,date:zd,decode:Ul,decodeAsync:jl,deepPartial:_b,default:$h,describe:Yd,discriminatedUnion:eo,e164:md,email:ql,emoji:td,encode:Fl,encodeAsync:Gl,endsWith:Ei,enum:rt,exactOptional:oa,file:jd,flattenError:ys,float32:Ed,float64:xd,formatError:vs,fromJSONSchema:wb,function:ar,getDiscriminatedOption:Bc,getErrorMap:yb,globalRegistry:kt,gt:cn,gte:xt,guid:Wl,hash:Sd,hex:_d,hostname:wd,httpUrl:ed,iban:yd,includes:ki,input:Sb,instanceof:Qd,int:ni,int32:$d,int64:Ad,intersection:Tr,invertCodec:qd,ipv4:ud,ipv6:ld,iso:nf,json:tf,jwt:vd,keyof:Ld,ksuid:ad,lazy:_a,length:pr,literal:x,locales:Xc,looseObject:nt,looseRecord:Md,lowercase:wi,lt:un,lte:Et,mac:cd,map:Fd,maxLength:hr,maxSize:Zn,memoizer:Ts,meta:Xd,mime:$i,minLength:kn,minSize:ln,multipleOf:Fn,nan:Vd,nanoid:nd,nativeEnum:Gd,negative:Ls,never:Un,nonnegative:Ds,nonoptional:da,nonpositive:Ps,normalize:Ti,null:Yi,nullable:sr,nullish:Zd,number:de,object:T,optional:De,output:Eb,overwrite:Yt,parse:Pl,parseAsync:Dl,partialRecord:Od,pipe:ri,positive:zs,prefault:la,preprocess:io,prettifyError:dc,promise:Kd,properties:xi,property:Os,readonly:va,record:be,refine:xa,regex:bi,regexes:ks,registry:Cs,safeDecode:Bl,safeDecodeAsync:Hl,safeEncode:Zl,safeEncodeAsync:Vl,safeParse:Ol,safeParseAsync:Ml,set:Ud,setErrorMap:gb,size:fr,slugify:Ni,startsWith:Si,strictObject:Pd,string:E,stringFormat:bd,stringbool:ef,success:Bd,superRefine:$a,symbol:Nd,templateLiteral:Wd,toJSONSchema:Rl,toLowerCase:Ai,toUpperCase:Ii,toZod:ls,transform:to,treeifyError:lc,trim:Ci,tuple:Qs,uint32:Td,uint64:Id,ulid:od,undefined:or,union:ge,unknown:Ae,uppercase:_i,url:Ql,util:ac,uuid:Kl,uuidv4:Jl,uuidv6:Yl,uuidv7:Xl,validate:ws,validateAsync:_s,void:Rd,withParser:As,xid:sd,xor:Dd,z:$h},Symbol.toStringTag,{value:"Module"})),zn="io.modelcontextprotocol/related-task",Ca="2.0",Je=Ea(e=>e!==null&&(typeof e=="object"||typeof e=="function")),$b=ge([E(),de().int()]),Tb=E();nt({ttl:de().optional(),pollInterval:de().optional()});const qE=T({ttl:de().optional()}),WE=T({taskId:E()}),rf=nt({progressToken:$b.optional(),[zn]:WE.optional()}),Ct=T({_meta:rf.optional()}),oo=Ct.extend({task:qE.optional()}),KE=e=>oo.safeParse(e).success,it=T({method:E(),params:Ct.loose().optional()}),Dt=T({_meta:rf.optional()}),Ot=T({method:E(),params:Dt.loose().optional()}),ot=nt({_meta:rf.optional()}),so=ge([E(),de().int()]),Cb=T({jsonrpc:x(Ca),id:so,...it.shape}).strict(),Th=e=>Cb.safeParse(e).success,Ab=T({jsonrpc:x(Ca),...Ot.shape}).strict(),JE=e=>Ab.safeParse(e).success,of=T({jsonrpc:x(Ca),id:so,result:ot}).strict(),$o=e=>of.safeParse(e).success;var Ce;(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"})(Ce||(Ce={}));const sf=T({jsonrpc:x(Ca),id:so.optional(),error:T({code:de().int(),message:E(),data:Ae().optional()})}).strict(),YE=e=>sf.safeParse(e).success,XE=ge([Cb,Ab,of,sf]);ge([of,sf]);const af=ot.strict(),QE=Dt.extend({requestId:so.optional(),reason:E().optional()}),uf=Ot.extend({method:x("notifications/cancelled"),params:QE}),ex=T({src:E(),mimeType:E().optional(),sizes:oe(E()).optional(),theme:rt(["light","dark"]).optional()}),ao=T({icons:oe(ex).optional()}),ur=T({name:E(),title:E().optional()}),Aa=ur.extend({...ur.shape,...ao.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),tx=Tr(T({applyDefaults:Ne().optional()}),be(E(),Ae())),nx=io(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Tr(T({form:tx.optional(),url:Je.optional()}),be(E(),Ae()).optional())),rx=nt({list:Je.optional(),cancel:Je.optional(),requests:nt({sampling:nt({createMessage:Je.optional()}).optional(),elicitation:nt({create:Je.optional()}).optional()}).optional()}),ix=nt({list:Je.optional(),cancel:Je.optional(),requests:nt({tools:nt({call:Je.optional()}).optional()}).optional()}),ox=T({experimental:be(E(),Je).optional(),sampling:T({context:Je.optional(),tools:Je.optional()}).optional(),elicitation:nx.optional(),roots:T({listChanged:Ne().optional()}).optional(),tasks:rx.optional(),extensions:be(E(),Je).optional()}),sx=Ct.extend({protocolVersion:E(),capabilities:ox,clientInfo:Aa}),ax=it.extend({method:x("initialize"),params:sx}),ux=T({experimental:be(E(),Je).optional(),logging:Je.optional(),completions:Je.optional(),prompts:T({listChanged:Ne().optional()}).optional(),resources:T({subscribe:Ne().optional(),listChanged:Ne().optional()}).optional(),tools:T({listChanged:Ne().optional()}).optional(),tasks:ix.optional(),extensions:be(E(),Je).optional()}),cx=ot.extend({protocolVersion:E(),capabilities:ux,serverInfo:Aa,instructions:E().optional()}),lx=Ot.extend({method:x("notifications/initialized"),params:Dt.optional()}),Ia=it.extend({method:x("ping"),params:Ct.optional()}),dx=T({progress:de(),total:De(de()),message:De(E())}),fx=T({...Dt.shape,...dx.shape,progressToken:$b}),cf=Ot.extend({method:x("notifications/progress"),params:fx}),hx=Ct.extend({cursor:Tb.optional()}),uo=it.extend({params:hx.optional()}),co=ot.extend({nextCursor:Tb.optional()}),px=rt(["working","input_required","completed","failed","cancelled"]),lo=T({taskId:E(),status:px,ttl:ge([de(),Yi()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:De(de()),statusMessage:De(E())}),lf=ot.extend({task:lo}),mx=Dt.merge(lo),ns=Ot.extend({method:x("notifications/tasks/status"),params:mx}),df=it.extend({method:x("tasks/get"),params:Ct.extend({taskId:E()})}),ff=ot.merge(lo),hf=it.extend({method:x("tasks/result"),params:Ct.extend({taskId:E()})});ot.loose();const pf=uo.extend({method:x("tasks/list")}),mf=co.extend({tasks:oe(lo)}),gf=it.extend({method:x("tasks/cancel"),params:Ct.extend({taskId:E()})}),gx=ot.merge(lo),Ib=T({uri:E(),mimeType:De(E()),_meta:be(E(),Ae()).optional()}),Nb=Ib.extend({text:E()}),yf=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Rb=Ib.extend({blob:yf}),fo=rt(["user","assistant"]),Rr=T({audience:oe(fo).optional(),priority:de().min(0).max(1).optional(),lastModified:vb({offset:!0}).optional()}),zb=T({...ur.shape,...ao.shape,uri:E(),description:De(E()),mimeType:De(E()),size:De(de()),annotations:Rr.optional(),_meta:De(nt({}))}),yx=T({...ur.shape,...ao.shape,uriTemplate:E(),description:De(E()),mimeType:De(E()),annotations:Rr.optional(),_meta:De(nt({}))}),vx=uo.extend({method:x("resources/list")}),Lb=co.extend({resources:oe(zb)}),bx=uo.extend({method:x("resources/templates/list")}),wx=co.extend({resourceTemplates:oe(yx)}),vf=Ct.extend({uri:E()}),_x=vf,kx=it.extend({method:x("resources/read"),params:_x}),Pb=ot.extend({contents:oe(ge([Nb,Rb]))}),Sx=Ot.extend({method:x("notifications/resources/list_changed"),params:Dt.optional()}),Ex=vf,xx=it.extend({method:x("resources/subscribe"),params:Ex}),$x=vf,Tx=it.extend({method:x("resources/unsubscribe"),params:$x}),Cx=Dt.extend({uri:E()}),Ax=Ot.extend({method:x("notifications/resources/updated"),params:Cx}),Ix=T({name:E(),description:De(E()),required:De(Ne())}),Nx=T({...ur.shape,...ao.shape,description:De(E()),arguments:De(oe(Ix)),_meta:De(nt({}))}),Rx=uo.extend({method:x("prompts/list")}),zx=co.extend({prompts:oe(Nx)}),Lx=Ct.extend({name:E(),arguments:be(E(),E()).optional()}),Px=it.extend({method:x("prompts/get"),params:Lx}),bf=T({type:x("text"),text:E(),annotations:Rr.optional(),_meta:be(E(),Ae()).optional()}),wf=T({type:x("image"),data:yf,mimeType:E(),annotations:Rr.optional(),_meta:be(E(),Ae()).optional()}),_f=T({type:x("audio"),data:yf,mimeType:E(),annotations:Rr.optional(),_meta:be(E(),Ae()).optional()}),Dx=T({type:x("tool_use"),name:E(),id:E(),input:be(E(),Ae()),_meta:be(E(),Ae()).optional()}),Db=T({type:x("resource"),resource:ge([Nb,Rb]),annotations:Rr.optional(),_meta:be(E(),Ae()).optional()}),Ob=zb.extend({type:x("resource_link")}),ho=ge([bf,wf,_f,Ob,Db]),Ox=T({role:fo,content:ho}),Mx=ot.extend({description:E().optional(),messages:oe(Ox)}),Fx=Ot.extend({method:x("notifications/prompts/list_changed"),params:Dt.optional()}),Ux=T({title:E().optional(),readOnlyHint:Ne().optional(),destructiveHint:Ne().optional(),idempotentHint:Ne().optional(),openWorldHint:Ne().optional()}),Gx=T({taskSupport:rt(["required","optional","forbidden"]).optional()}),kf=T({...ur.shape,...ao.shape,description:E().optional(),inputSchema:T({type:x("object"),properties:be(E(),Je).optional(),required:oe(E()).optional()}).catchall(Ae()),outputSchema:T({type:x("object"),properties:be(E(),Je).optional(),required:oe(E()).optional()}).catchall(Ae()).optional(),annotations:Ux.optional(),execution:Gx.optional(),_meta:be(E(),Ae()).optional()}),Mb=uo.extend({method:x("tools/list")}),jx=co.extend({tools:oe(kf)}),Na=ot.extend({content:oe(ho).default([]),structuredContent:be(E(),Ae()).optional(),isError:Ne().optional()});Na.or(ot.extend({toolResult:Ae()}));const Zx=oo.extend({name:E(),arguments:be(E(),Ae()).optional()}),Fb=it.extend({method:x("tools/call"),params:Zx}),Bx=Ot.extend({method:x("notifications/tools/list_changed"),params:Dt.optional()});T({autoRefresh:Ne().default(!0),debounceMs:de().int().nonnegative().default(300)});const Ub=rt(["debug","info","notice","warning","error","critical","alert","emergency"]),Vx=Ct.extend({level:Ub}),Hx=it.extend({method:x("logging/setLevel"),params:Vx}),qx=Dt.extend({level:Ub,logger:E().optional(),data:Ae()}),Wx=Ot.extend({method:x("notifications/message"),params:qx}),Kx=T({name:E().optional()}),Jx=T({hints:oe(Kx).optional(),costPriority:de().min(0).max(1).optional(),speedPriority:de().min(0).max(1).optional(),intelligencePriority:de().min(0).max(1).optional()}),Yx=T({mode:rt(["auto","required","none"]).optional()}),Xx=T({type:x("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:oe(ho).default([]),structuredContent:T({}).loose().optional(),isError:Ne().optional(),_meta:be(E(),Ae()).optional()}),Qx=eo("type",[bf,wf,_f]),rs=eo("type",[bf,wf,_f,Dx,Xx]),e0=T({role:fo,content:ge([rs,oe(rs)]),_meta:be(E(),Ae()).optional()}),t0=oo.extend({messages:oe(e0),modelPreferences:Jx.optional(),systemPrompt:E().optional(),includeContext:rt(["none","thisServer","allServers"]).optional(),temperature:de().optional(),maxTokens:de().int(),stopSequences:oe(E()).optional(),metadata:Je.optional(),tools:oe(kf).optional(),toolChoice:Yx.optional()}),n0=it.extend({method:x("sampling/createMessage"),params:t0}),Gb=ot.extend({model:E(),stopReason:De(rt(["endTurn","stopSequence","maxTokens"]).or(E())),role:fo,content:Qx}),jb=ot.extend({model:E(),stopReason:De(rt(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:fo,content:ge([rs,oe(rs)])}),r0=T({type:x("boolean"),title:E().optional(),description:E().optional(),default:Ne().optional()}),i0=T({type:x("string"),title:E().optional(),description:E().optional(),minLength:de().optional(),maxLength:de().optional(),format:rt(["email","uri","date","date-time"]).optional(),default:E().optional()}),o0=T({type:rt(["number","integer"]),title:E().optional(),description:E().optional(),minimum:de().optional(),maximum:de().optional(),default:de().optional()}),s0=T({type:x("string"),title:E().optional(),description:E().optional(),enum:oe(E()),default:E().optional()}),a0=T({type:x("string"),title:E().optional(),description:E().optional(),oneOf:oe(T({const:E(),title:E()})),default:E().optional()}),u0=T({type:x("string"),title:E().optional(),description:E().optional(),enum:oe(E()),enumNames:oe(E()).optional(),default:E().optional()}),c0=ge([s0,a0]),l0=T({type:x("array"),title:E().optional(),description:E().optional(),minItems:de().optional(),maxItems:de().optional(),items:T({type:x("string"),enum:oe(E())}),default:oe(E()).optional()}),d0=T({type:x("array"),title:E().optional(),description:E().optional(),minItems:de().optional(),maxItems:de().optional(),items:T({anyOf:oe(T({const:E(),title:E()}))}),default:oe(E()).optional()}),f0=ge([l0,d0]),h0=ge([u0,c0,f0]),p0=ge([h0,r0,i0,o0]),m0=oo.extend({mode:x("form").optional(),message:E(),requestedSchema:T({type:x("object"),properties:be(E(),p0),required:oe(E()).optional()})}),g0=oo.extend({mode:x("url"),message:E(),elicitationId:E(),url:E().url()}),y0=ge([m0,g0]),v0=it.extend({method:x("elicitation/create"),params:y0}),b0=Dt.extend({elicitationId:E()}),w0=Ot.extend({method:x("notifications/elicitation/complete"),params:b0}),_0=ot.extend({action:rt(["accept","decline","cancel"]),content:io(e=>e===null?void 0:e,be(E(),ge([E(),de(),Ne(),oe(E())])).optional())}),k0=T({type:x("ref/resource"),uri:E()}),S0=T({type:x("ref/prompt"),name:E()}),E0=Ct.extend({ref:ge([S0,k0]),argument:T({name:E(),value:E()}),context:T({arguments:be(E(),E()).optional()}).optional()}),x0=it.extend({method:x("completion/complete"),params:E0}),$0=ot.extend({completion:nt({values:oe(E()).max(100),total:De(de().int()),hasMore:De(Ne())})}),T0=T({uri:E().startsWith("file://"),name:E().optional(),_meta:be(E(),Ae()).optional()}),C0=it.extend({method:x("roots/list"),params:Ct.optional()}),A0=ot.extend({roots:oe(T0)}),I0=Ot.extend({method:x("notifications/roots/list_changed"),params:Dt.optional()});ge([Ia,ax,x0,Hx,Px,Rx,vx,bx,kx,xx,Tx,Fb,Mb,df,hf,pf,gf]);ge([uf,cf,lx,I0,ns]);ge([af,Gb,jb,_0,A0,ff,mf,lf]);ge([Ia,n0,v0,C0,df,hf,pf,gf]);ge([uf,cf,Wx,Ax,Sx,Bx,Fx,ns,w0]);ge([af,cx,$0,Mx,zx,Lb,wx,Pb,Na,jx,ff,mf,lf]);class _e 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===Ce.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new N0(i.elicitations,n)}return new _e(t,n,r)}}class N0 extends _e{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Ce.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function An(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ch(e){const n=wE(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=_E(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Ah(e,t){const n=fb(e,t);if(!n.success)throw n.error;return n.data}const R0=6e4;class z0{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(uf,n=>{this._oncancel(n)}),this.setNotificationHandler(cf,n=>{this._onprogress(n)}),this.setRequestHandler(Ia,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(df,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new _e(Ce.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(hf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new _e(Ce.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 _e(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 _e(Ce.InvalidParams,`Task not found: ${o}`);if(!An(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(An(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[zn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(pf,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 _e(Ce.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(gf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new _e(Ce.InvalidParams,`Task not found: ${n.params.taskId}`);if(An(i.status))throw new _e(Ce.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 _e(Ce.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof _e?i:new _e(Ce.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),_e.fromError(Ce.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),$o(o)||YE(o)?this._onresponse(o):Th(o)?this._onrequest(o,s):JE(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=_e.fromError(Ce.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?.[zn]?.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 _e(Ce.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:Ce.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(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}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=KE(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,g)=>{if(l.signal.aborted)throw new _e(Ce.ConnectionClosed,"Request was cancelled");const w={...g,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const y=w.relatedTask?.taskId??o;return y&&f&&await f.updateTaskStatus(y,"input_required"),await this.request(p,m,w)},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 _e(Ce.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:Ce.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),$o(t))r(t);else{const s=new _e(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($o(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),$o(t))i(t);else{const s=_e.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 _e?s:new _e(Ce.InternalError,String(s))}}return}let o;try{const s=await this.request(t,lf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new _e(Ce.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},An(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new _e(Ce.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new _e(Ce.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 _e?s:new _e(Ce.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=y=>{l(y)};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(y){d(y);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||{},[zn]:u}});const p=y=>{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(y)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=y instanceof _e?y:new _e(Ce.RequestTimeout,String(y));l(b)};this._responseHandlers.set(f,y=>{if(!r?.signal?.aborted){if(y instanceof Error)return l(y);try{const b=fb(n,y.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??R0,g=()=>p(_e.fromError(Ce.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,g,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const y=b=>{const v=this._responseHandlers.get(f);v?v(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,y),this._enqueueTaskMessage(w,{type:"request",message:h,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),l(b)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(y=>{this._cleanupTimeout(f),l(y)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},ff,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},mf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},gx,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||{},[zn]: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||{},[zn]: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||{},[zn]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Ch(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Ah(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=Ch(t);this._notificationHandlers.set(r,i=>{const o=Ah(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"&&Th(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new _e(Ce.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 _e(Ce.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new _e(Ce.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 _e(Ce.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=ns.parse({method:"notifications/tasks/status",params:a});await this.notification(u),An(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 _e(Ce.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(An(a.status))throw new _e(Ce.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=ns.parse({method:"notifications/tasks/status",params:u});await this.notification(c),An(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Ih(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function L0(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];Ih(s)&&Ih(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 P0 extends z0{_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 D0="2026-01-26",O0="ui/notifications/tool-input-partial";class Zb{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=XE.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!==O0&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var M0=ge([x("light"),x("dark")]).describe("Color theme preference for the host environment."),ii=ge([x("inline"),x("fullscreen"),x("pip")]).describe("Display mode for UI presentation."),F0=ge([x("--color-background-primary"),x("--color-background-secondary"),x("--color-background-tertiary"),x("--color-background-inverse"),x("--color-background-ghost"),x("--color-background-info"),x("--color-background-danger"),x("--color-background-success"),x("--color-background-warning"),x("--color-background-disabled"),x("--color-text-primary"),x("--color-text-secondary"),x("--color-text-tertiary"),x("--color-text-inverse"),x("--color-text-ghost"),x("--color-text-info"),x("--color-text-danger"),x("--color-text-success"),x("--color-text-warning"),x("--color-text-disabled"),x("--color-border-primary"),x("--color-border-secondary"),x("--color-border-tertiary"),x("--color-border-inverse"),x("--color-border-ghost"),x("--color-border-info"),x("--color-border-danger"),x("--color-border-success"),x("--color-border-warning"),x("--color-border-disabled"),x("--color-ring-primary"),x("--color-ring-secondary"),x("--color-ring-inverse"),x("--color-ring-info"),x("--color-ring-danger"),x("--color-ring-success"),x("--color-ring-warning"),x("--font-sans"),x("--font-mono"),x("--font-weight-normal"),x("--font-weight-medium"),x("--font-weight-semibold"),x("--font-weight-bold"),x("--font-text-xs-size"),x("--font-text-sm-size"),x("--font-text-md-size"),x("--font-text-lg-size"),x("--font-heading-xs-size"),x("--font-heading-sm-size"),x("--font-heading-md-size"),x("--font-heading-lg-size"),x("--font-heading-xl-size"),x("--font-heading-2xl-size"),x("--font-heading-3xl-size"),x("--font-text-xs-line-height"),x("--font-text-sm-line-height"),x("--font-text-md-line-height"),x("--font-text-lg-line-height"),x("--font-heading-xs-line-height"),x("--font-heading-sm-line-height"),x("--font-heading-md-line-height"),x("--font-heading-lg-line-height"),x("--font-heading-xl-line-height"),x("--font-heading-2xl-line-height"),x("--font-heading-3xl-line-height"),x("--border-radius-xs"),x("--border-radius-sm"),x("--border-radius-md"),x("--border-radius-lg"),x("--border-radius-xl"),x("--border-radius-full"),x("--border-width-regular"),x("--shadow-hairline"),x("--shadow-sm"),x("--shadow-md"),x("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),U0=be(F0.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.`),ge([x(),or()]).describe(`Style variables for theming MCP apps.
76
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),ge([E(),or()]).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.`);T({method:E("ui/open-link"),params:T({url:x().describe("URL to open in the host's browser")})});var G0=T({isError:Ne().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),j0=T({isError:Ne().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),Z0=T({isError:Ne().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();T({method:E("ui/notifications/sandbox-proxy-ready"),params:T({})});var Sf=T({connectDomains:oe(x()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
88
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);T({method:x("ui/open-link"),params:T({url:E().describe("URL to open in the host's browser")})});var G0=T({isError:Ne().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),j0=T({isError:Ne().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),Z0=T({isError:Ne().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();T({method:x("ui/notifications/sandbox-proxy-ready"),params:T({})});var Sf=T({connectDomains:oe(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:oe(x()).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:oe(x()).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:oe(x()).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'`)")}),xf=T({camera:T({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:T({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:T({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:T({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});T({method:E("ui/notifications/size-changed"),params:T({width:de().optional().describe("New width in pixels."),height:de().optional().describe("New height in pixels.")})});var B0=T({method:E("ui/notifications/tool-input"),params:T({arguments:be(x(),Ae().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),V0=T({method:E("ui/notifications/tool-input-partial"),params:T({arguments:be(x(),Ae().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),H0=T({method:E("ui/notifications/tool-cancelled"),params:T({reason:x().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),q0=T({fonts:x().optional()}),W0=T({variables:U0.optional().describe("CSS variables for theming the app."),css:q0.optional().describe("CSS blocks that apps can inject.")}),K0=T({method:E("ui/resource-teardown"),params:T({})});be(x(),Ae());var Nh=T({text:T({}).optional().describe("Host supports text content blocks."),image:T({}).optional().describe("Host supports image content blocks."),audio:T({}).optional().describe("Host supports audio content blocks."),resource:T({}).optional().describe("Host supports resource content blocks."),resourceLink:T({}).optional().describe("Host supports resource link content blocks."),structuredContent:T({}).optional().describe("Host supports structured content.")});T({method:E("ui/notifications/request-teardown"),params:T({}).optional()});var J0=T({experimental:be(x(),be(x(),Xi()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:T({}).optional().describe("Host supports opening external URLs."),downloadFile:T({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:T({listChanged:Ne().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:T({listChanged:Ne().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:T({}).optional().describe("Host accepts log messages."),sandbox:T({permissions:xf.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Sf.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Nh.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Nh.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:T({tools:T({}).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.")}),Y0=T({experimental:be(x(),be(x(),Xi()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:T({listChanged:Ne().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:oe(ii).optional().describe("Display modes the app supports.")});T({method:E("ui/notifications/initialized"),params:T({}).optional()});T({csp:Sf.optional().describe("Content Security Policy configuration for UI resources."),permissions:xf.optional().describe("Sandbox permissions requested by the UI resource."),domain:x().optional().describe(`Dedicated origin for view sandbox.
91
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:oe(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:oe(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:oe(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'`)")}),Ef=T({camera:T({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:T({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:T({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:T({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});T({method:x("ui/notifications/size-changed"),params:T({width:de().optional().describe("New width in pixels."),height:de().optional().describe("New height in pixels.")})});var B0=T({method:x("ui/notifications/tool-input"),params:T({arguments:be(E(),Ae().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),V0=T({method:x("ui/notifications/tool-input-partial"),params:T({arguments:be(E(),Ae().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),H0=T({method:x("ui/notifications/tool-cancelled"),params:T({reason:E().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),q0=T({fonts:E().optional()}),W0=T({variables:U0.optional().describe("CSS variables for theming the app."),css:q0.optional().describe("CSS blocks that apps can inject.")}),K0=T({method:x("ui/resource-teardown"),params:T({})});be(E(),Ae());var Nh=T({text:T({}).optional().describe("Host supports text content blocks."),image:T({}).optional().describe("Host supports image content blocks."),audio:T({}).optional().describe("Host supports audio content blocks."),resource:T({}).optional().describe("Host supports resource content blocks."),resourceLink:T({}).optional().describe("Host supports resource link content blocks."),structuredContent:T({}).optional().describe("Host supports structured content.")});T({method:x("ui/notifications/request-teardown"),params:T({}).optional()});var J0=T({experimental:be(E(),be(E(),Xi()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:T({}).optional().describe("Host supports opening external URLs."),downloadFile:T({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:T({listChanged:Ne().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:T({listChanged:Ne().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:T({}).optional().describe("Host accepts log messages."),sandbox:T({permissions:Ef.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Sf.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Nh.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Nh.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:T({tools:T({}).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.")}),Y0=T({experimental:be(E(),be(E(),Xi()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:T({listChanged:Ne().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:oe(ii).optional().describe("Display modes the app supports.")});T({method:x("ui/notifications/initialized"),params:T({}).optional()});T({csp:Sf.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ef.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,16 +102,16 @@ 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`)});T({method:E("ui/request-display-mode"),params:T({mode:ii.describe("The display mode being requested.")})});var X0=T({mode:ii.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Q0=ge([E("model"),E("app")]).describe("Tool visibility scope - who can access the tool.");T({resourceUri:x().optional(),visibility:oe(Q0).optional().describe(`Who can access this tool. Default: ["model", "app"]
105
+ - omitted: host decides border`)});T({method:x("ui/request-display-mode"),params:T({mode:ii.describe("The display mode being requested.")})});var X0=T({mode:ii.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Q0=ge([x("model"),x("app")]).describe("Tool visibility scope - who can access the tool.");T({resourceUri:E().optional(),visibility:oe(Q0).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:Un().optional(),permissions:Un().optional()});T({mimeTypes:oe(x()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});T({method:E("ui/download-file"),params:T({contents:oe(ge([Db,Ob])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});T({method:E("ui/message"),params:T({role:E("user").describe('Message role, currently only "user" is supported.'),content:oe(ho).describe("Message content blocks (text, image, etc.).")})});T({method:E("ui/notifications/sandbox-resource-ready"),params:T({html:x().describe("HTML content to load into the inner iframe."),sandbox:x().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Sf.optional().describe("CSP configuration from resource metadata."),permissions:xf.optional().describe("Sandbox permissions from resource metadata.")})});var e$=T({method:E("ui/notifications/tool-result"),params:Na.describe("Standard MCP tool execution result.")}),Bb=T({toolInfo:T({id:so.optional().describe("JSON-RPC id of the tools/call request."),tool:kf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:M0.optional().describe("Current color theme preference."),styles:W0.optional().describe("Style configuration for theming the app."),displayMode:ii.optional().describe("How the UI is currently displayed."),availableDisplayModes:oe(ii).optional().describe("Display modes the host supports."),containerDimensions:ge([T({height:de().describe("Fixed container height in pixels.")}),T({maxHeight:ge([de(),or()]).optional().describe("Maximum container height in pixels.")})]).and(ge([T({width:de().describe("Fixed container width in pixels.")}),T({maxWidth:ge([de(),or()]).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:x().optional().describe("User's language and region preference in BCP 47 format."),timeZone:x().optional().describe("User's timezone in IANA format."),userAgent:x().optional().describe("Host application identifier."),platform:ge([E("web"),E("desktop"),E("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Ne().optional().describe("Whether the device supports touch input."),hover:Ne().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:T({top:de().describe("Top safe area inset in pixels."),right:de().describe("Right safe area inset in pixels."),bottom:de().describe("Bottom safe area inset in pixels."),left:de().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),t$=T({method:E("ui/notifications/host-context-changed"),params:Bb.describe("Partial context update containing only changed fields.")});T({method:E("ui/update-model-context"),params:T({content:oe(ho).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:be(x(),Ae().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});T({method:E("ui/initialize"),params:T({appInfo:Aa.describe("App identification (name and version)."),appCapabilities:Y0.describe("Features and capabilities this app provides."),protocolVersion:x().describe("Protocol version this app supports.")})});var n$=T({protocolVersion:x().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Aa.describe("Host application identification and version."),hostCapabilities:J0.describe("Features and capabilities provided by the host."),hostContext:Bb.describe("Rich context about the host environment.")}).passthrough(),r$={target:"draft-2020-12"};async function zh(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](r$);if(n.vendor==="zod"){let{z:r}=await w_(()=>Promise.resolve().then(()=>Hx),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 Rh(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 i$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function o$(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 Ef extends P0{_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:B0,toolinputpartial:V0,toolresult:e$,toolcancelled:H0,hostcontextchanged:t$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!Ef.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||Ye({jitless:!0}),this.setRequestHandler(Ia,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=L0(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 Rh(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 Rh(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 zh(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await zh(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(K0,(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(Fb,(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(Mb,(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},Na,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Pb,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Lb,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?jb:Gb;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},Z0,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},af,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},G0,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},j0,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},X0,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 Zb(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:D0}},n$,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 Vb=new Map;function s$(e,t){Vb.set(e,t)}function Lh(e){return Vb.get(e)??null}function a$(e){try{const t=e.createElement("canvas");if(typeof t.getContext!="function")return!1;const n=t.getContext("webgl2")??t.getContext("webgl");return n?(n.getExtension?.("WEBGL_lose_context")?.loseContext(),!0):!1}catch{return!1}}const u$="http://www.w3.org/2000/svg";let c$=0;function To(e){return Math.round(e*10)/10}function l$(e,t,n={}){const r=e.createElementNS(u$,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function Ph(e,t,n,r){const i=`cia-graph-svg-${++c$}`,o=e.ownerDocument,s=(M,G)=>l$(o,M,G),a=(M,G,B)=>{const ee=s("text",{x:0,y:G,"text-anchor":"middle",class:B,"pointer-events":"none"});return ee.textContent=M,ee},{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":""}),g=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(g,w),l.append(d,h,p,m),e.append(l);const y=new Map,b=new Map,v=new Map;let S=null;function _(){if(S)return S;const M=t.model(),G=t.positions(),B=new Map;S=B;const ee=M.nodes.length>Q$,X=new Map(M.nodes.map(q=>[q.address,q])),V=ee?[]:B$(M,G,t.notes());for(const q of M.edges){const W=X.get(q.from),xe=X.get(q.to),Ie=W&&G[W.id],je=xe&&G[xe.id];if(!W||!xe||!Ie||!je){B.set(q.id,null);continue}if(ee){B.set(q.id,Ru(Ie,je,Pn(W,M.checked_address),Pn(xe,M.checked_address)));continue}const st=V.filter(et=>et.id!==W.id&&et.id!==xe.id);B.set(q.id,eT(Ie,je,Pn(W,M.checked_address),Pn(xe,M.checked_address),st))}return B}function $(M){let G=y.get(M);if(G)return G;G=`${i}-arrow-${y.size}`;const B=s("marker",{id:G,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),ee=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return ee.style.fill=M,B.append(ee),d.append(B),y.set(M,G),G}function R(){return[...t.model().nodes??[]].sort((M,G)=>String(M.id).localeCompare(String(G.id)))}function P(){S=null;const M=t.model();g.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const G=new Map(M.nodes.map(B=>[B.address,B]));for(const B of M.edges){const ee=G.get(B.from);if(!ee||!G.get(B.to))continue;const X=t.colorOf(ee),V=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Mu(B,t.now())});V.dataset.edgeId=B.id,V.style.setProperty("--edge-tone",X);const q=nT(),W=s("path",{class:"cia-graph-edge-hit","stroke-width":q.hit.width,"pointer-events":"stroke"}),xe=s("path",{class:"cia-graph-edge-line","stroke-width":q.line.width,"marker-end":`url(#${$(X)})`,"pointer-events":"none"});V.append(W,xe),V.addEventListener("keydown",Ie=>{Zh(Ie.key)&&(Ie.preventDefault(),n.selectEdge(B.id,"keyboard"))}),V.addEventListener("pointerenter",Ie=>n.showTooltip(Ie,Mu(B,t.now()))),V.addEventListener("pointerleave",()=>n.hideTooltip()),g.append(V),v.set(B.id,{group:V,hit:W,line:xe})}for(const B of R())w.append(O(B));he(),$e()}function O(M){const G=t.model(),B=M.address===G.checked_address,ee=t.notes().get(M.id),X=Rr(M,G.checked_address,ee),V=X.radius,q=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":Ou(M),"aria-pressed":"false"});q.dataset.nodeId=M.id,B&&(q.dataset.checked=""),q.style.setProperty("--node-tone",t.colorOf(M)),B&&q.append(s("circle",{class:"cia-graph-node-ring",r:V+6})),q.append(s("circle",{class:"cia-graph-node-body",r:V})),q.append(s("circle",{class:"cia-graph-node-dot",r:X.dot}));for(const W of X.texts)q.append(a(W.text,W.y,`cia-graph-node-${W.kind}`));ee&&(q.dataset.state="refused");for(const W of t.flags().get(M.id)??[])q.setAttribute(`data-flag-${W}`,"");return q.addEventListener("keydown",W=>{Zh(W.key)&&(W.preventDefault(),n.selectNode(M.id,"keyboard"))}),q.addEventListener("pointerenter",W=>n.showTooltip(W,Ou(M))),q.addEventListener("pointerleave",()=>n.hideTooltip()),b.set(M.id,q),q}function Y(){const M=t.transform();m.setAttribute("transform",`translate(${M.x} ${M.y}) scale(${M.scale})`)}function he(){Y();const M=t.positions(),{width:G,height:B}=t.dimensions();for(const[X,V]of b){const q=M[X]??{x:G/2,y:B/2};V.setAttribute("transform",`translate(${To(q.x)} ${To(q.y)})`)}const ee=_();for(const X of t.model().edges){const V=v.get(X.id);if(!V)continue;const q=ee.get(X.id)??null;V.group.style.display=q?"":"none",q&&(V.hit.setAttribute("d",q.d),V.line.setAttribute("d",q.d))}}function Se(M){const G=t.model(),B=t.positions(),ee=B[M],X=b.get(M);if(!ee||!X)return;X.setAttribute("transform",`translate(${To(ee.x)} ${To(ee.y)})`);const V=G.nodes.find(W=>W.id===M);if(!V)return;const q=new Map(G.nodes.map(W=>[W.address,W]));for(const W of G.edges){if(W.from!==V.address&&W.to!==V.address)continue;const xe=v.get(W.id),Ie=q.get(W.from),je=q.get(W.to),st=Ie&&B[Ie.id],et=je&&B[je.id];if(!xe||!Ie||!je||!st||!et)continue;const L=Ru(st,et,Pn(Ie,G.checked_address),Pn(je,G.checked_address));xe.group.style.display=L?"":"none",L&&(xe.hit.setAttribute("d",L.d),xe.line.setAttribute("d",L.d))}}function $e(){const M=t.model(),G=t.selected(),B=t.highlighted(),ee=G?.kind==="node"?M.nodes.find(X=>X.id===G.id)?.address??null:null;for(const X of M.edges){const V=v.get(X.id);if(!V)continue;const q=G?.kind==="edge"&&G.id===X.id,W=G?.kind==="edge"?q?Wt.related:Wt.faded:Jb(X,ee),xe=W===Wt.faded;V.group.setAttribute("opacity",xe?String(W):"1"),V.line.setAttribute("stroke-opacity",xe?"1":String(W)),V.group.dataset.opacity=String(W),V.group.dataset.state=W===Wt.rest?"rest":W===Wt.related?"related":"faded",V.group.setAttribute("aria-pressed",String(q))}for(const[X,V]of b){const q=G?.kind==="node"&&G.id===X;V.classList.toggle("is-selected",q),V.classList.toggle("is-focused",B===X),V.setAttribute("aria-pressed",String(q))}}function Fe(){let M=null;for(const G of _().values())G?.bounds&&(M=M??{...G.bounds},M.x1=Math.min(M.x1,G.bounds.x1),M.y1=Math.min(M.y1,G.bounds.y1),M.x2=Math.max(M.x2,G.bounds.x2),M.y2=Math.max(M.y2,G.bounds.y2));return M}return{kind:"svg",surface:l,build:P,geometry(){S=null,he()},moveNode:Se,endMove(){S=null,he()},camera:Y,selection:$e,flag(M,G,B){b.get(M)?.toggleAttribute(`data-flag-${G}`,B)},theme(){for(const M of t.model().nodes)b.get(M.id)?.style.setProperty("--node-tone",t.colorOf(M))},resize(M,G){l.setAttribute("viewBox",`0 0 ${M} ${G}`)},pick:()=>null,linkBounds:Fe,destroy(){l.remove()}}}const d$=.45,f$=2.5,h$=5,p$="chain-insights.flows.v1",$f="cia-graph-model",m$=90,Wt={rest:.6,related:.95,faded:.07},Dh={checked:24,other:19},oi=16,g$=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],po=["exchange","scam","sanctioned","victim","pool","other"],y$={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},Hb={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Tf(e){return!!e&&e.schema===p$}function v$(e){return!!e&&e.kind===$f}function qe(e){return String(e??"").trim().toLowerCase()}function b$(e){const t=qe(e);return po.includes(t)?t:"other"}function hn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Nu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function w$(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Rt(e){return v$(e)?e:Tf(e)?_$(e):S$(e)}function _$(e){const t=qe(e.center),n=new Map;for(const a of e.nodes??[]){const u=qe(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=qe(a?.from),c=qe(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:hn(a.usd),tx_count:hn(a.tx_count),first_seen_timestamp:hn(a.first_seen_ms),last_seen_timestamp:hn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=k$(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:Nu(u.labels),taxonomy:[],role:b$(u.role),total_in_usd:hn(u.total_in_usd),total_out_usd:hn(u.total_out_usd),degree_in:hn(u.degree_in),degree_out:hn(u.degree_out)}});return{kind:$f,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function k$(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 g of d.get(m)??[])f.has(g)||(f.set(g,(f.get(m)??0)+1),p.push(g));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 S$(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":w$(r.direction),labels:Nu(r.labels),taxonomy:Nu(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:$f,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function x$(e,t,n){const r=Rt(t),i=Ln(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[qe(d.address),d])),a=[];for(const d of r.nodes){if(s.has(qe(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(qe(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${qe(d.from)}->${qe(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${qe(d.from)}->${qe(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(qe(d.from))||!s.has(qe(d.to)))continue;const h=s.get(qe(d.from)).address,p=s.get(qe(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 Ln(e,t){if(t==null)return null;const n=qe(t);return e.nodes.find(i=>i.id===t||qe(i.address)===n)?.id??null}function si(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Cf(e){return String(e??"").trim().replace(/\s+/g," ")}function is(e){return Cf(e).replaceAll(" ","").toLowerCase()}function wn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Cf(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Co(e,t){const n=new Set(wn(e).map(is));return t.some(r=>n.has(is(r)))}function E$(e){if(e.role&&po.includes(e.role))return y$[e.role];if(Co(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Co(e,["Victim","Targeted"]))return"target";if(Co(e,["OnMoneyTrail","Mixer"]))return"trail";if(Co(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 He(e){return`var(--cia-graph-${e})`}const $$={semantic:{danger:{stroke:He("danger"),fill:He("node")},target:{stroke:He("target"),fill:He("node")},trail:{stroke:He("trail"),fill:He("node")},infrastructure:{stroke:He("infrastructure"),fill:He("node")},neutral:{stroke:He("neutral"),fill:He("node")}},risk:{CRITICAL:{stroke:He("critical"),fill:He("node")},HIGH:{stroke:He("high"),fill:He("node")},MEDIUM:{stroke:He("medium"),fill:He("node")},LOW:{stroke:He("low"),fill:He("node")}}};function T$(e,t=$$){const n=E$(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function C$(e){return e.role&&po.includes(e.role)?He(`role-${e.role}`):T$(e).stroke}function mo(e){if(e.role&&e.role!=="other"&&po.includes(e.role))return Hb[e.role];const t=wn(e);for(const[r,i]of g$)if(t.some(o=>is(o)===is(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Cf).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function zu(e){return Math.min(f$,Math.max(d$,e))}function za(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Af(e,t=za(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Oh(e,t){return e.address===t?43:e.hop>=2?25:30}function Pn(e,t){return e.address===t?Dh.checked:Dh.other}function Rr(e,t,n){const r=e.address===t,i=Pn(e,t),o=mo(e),s=[];return o&&s.push({kind:"role",text:gT(o),y:i+17}),s.push({kind:"address",text:si(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 A$={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},Ha=2;function If(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=A$[r.kind],o=[...r.text].length*i.size*i.advance/2+Ha;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-Ha,x2:o,y2:r.y+i.size*.25+Ha}})}return n}function qb(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 Wb(e){return qb(If(e).map(t=>t.box))}const Nf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function I$(e,t,n){const r=Rt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of If(Rr(o,r.checked_address,Nf(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 N$(e,t,n){return qb(I$(e,t,n))}function z$(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function R$(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function L$(e,t,n){const r=Rt(e),i={x:t/2,y:n/2},o={},s=za(r),a=Af(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const c of s){if(c.id===a.id)continue;let l=c.direction==="IN"?-1:1;c.direction==="MIXED"&&(l=R$(c.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(c.hop)||1)),f=`${l}:${d}`;u.has(f)||u.set(f,[]),u.get(f).push(c)}for(const[c,l]of u){const[d,f]=c.split(":"),h=Number(d),p=Number(f),m=i.x+h*(p===1?t*.23:t*.43);Object.assign(o,P$(l,m,i.y,r.checked_address))}return o}function P$(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=>Wb(Rr(u,r)),a=(u,c)=>Math.max(Oh(u,r)+Oh(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 D$(e,t,n){const r=Rt(e),i={x:t/2,y:n/2},o={},s=za(r),a=Af(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),f=c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function O$(e,t,n,r){const i=Rt(e),o=za(i).filter(u=>t[u.id]),s=o.find(u=>u.address===i.checked_address);for(let u=0;u<o.length;u++)for(let c=u+1;c<o.length;c++){const l=o[u],d=o[c],f=l&&t[l.id],h=d&&t[d.id];if(!f||!h)continue;const p=h.x-f.x||.1,m=h.y-f.y||.1,g=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-g)*.012;f.x-=p/g*w,f.y-=m/g*w,h.x+=p/g*w,h.y+=m/g*w}const a=new Map(o.map(u=>[u.address,u]));for(const u of i.edges){const c=a.get(u.from),l=a.get(u.to);if(!c||!l)continue;const d=t[c.id],f=t[l.id];if(!d||!f)continue;const h=f.x-d.x,p=f.y-d.y,m=Math.max(1,Math.hypot(h,p)),g=(m-155)*.003;c!==s&&(d.x+=h/m*g,d.y+=p/m*g),l!==s&&(f.x-=h/m*g,f.y-=p/m*g)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function M$(e,t,n,r=m$){const i=Rt(e),o=D$(i,t,n);for(let s=0;s<r;s++)O$(i,o,t,n);return o}function Ao(e,t,n,r){return t==="tree"?L$(e,n,r):M$(e,n,r)}function F$(e,t,n,r,i={}){const o=Rt(e),s=t[n],a={...t};if(!s)return a;const u=i.spacing??80,c=i.gap??48,l=Math.max(1,i.perColumn??6),d=o.nodes.find(y=>y.id===n),f=new Map(o.nodes.map(y=>[y.id,y])),h=y=>Wb(Rr(y,o.checked_address,Nf(i.notes,y.id))),p=o.nodes.flatMap(y=>{const b=t[y.id];if(!b)return[];const v=h(y);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(y=>y.x1)):s.x,g=p.length?Math.max(...p.map(y=>y.x2)):s.x;const w={left:[],right:[]};for(const y of[...r].sort()){const b=f.get(y);if(!b||a[y])continue;const v=o.edges.some(_=>_.from===b.address&&_.to===d?.address),S=o.edges.some(_=>_.to===b.address&&_.from===d?.address);w[v&&!S?"left":"right"].push(b)}for(const y of["left","right"]){const b=w[y];for(let v=0;v<b.length;v+=l){const S=b.slice(v,v+l),_=S.map(h),$=Math.max(..._.map(O=>Math.max(-O.x1,O.x2))),R=Math.max(u,Math.max(..._.map(O=>O.y2))-Math.min(..._.map(O=>O.y1))+6),P=y==="left"?m-c-$:g+c+$;S.forEach((O,Y)=>{a[O.id]={x:P,y:s.y+(Y-(S.length-1)/2)*R}}),y==="left"?m=P-$:g=P+$}}return a}function U$(e,t,n,r=oi){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=zu(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 Mh(e,t,n,r=oi){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function G$(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 yn(e){return Math.round(e*100)/100}function qa(e,t,n,r,i){const o=s=>`${yn(s.x)},${yn(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function Ru(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 qa("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 qa("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),g=Math.max(m*.45,Math.min(40,m));return qa("vertical",h,{x:h.x,y:h.y+f*g},{x:p.x,y:p.y-f*g},p)}const c=G$(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${yn(l.x)},${yn(l.y)} L${yn(d.x)},${yn(d.y)}`}}const j$=6,Wa=j$+3,qt=14,Fh=10,Z$=3,Uh=6;function B$(e,t,n){const r=Rt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of If(Rr(o,r.checked_address,Nf(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 V$(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 H$(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 q$(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 W$(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 Kb(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 K$(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(Kb(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(q$(r.points,s))}}return n}function Gh(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 K$(e,Z$))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)&&V$(a,l)<r)return!1}return!0}function J$(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(Kb(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(qt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},g={x:(c.x-u.x)/d,y:(c.y-u.y)/d},w={x:u.x-m.x*p,y:u.y-m.y*p},y={x:u.x+g.x*p,y:u.y+g.y*p};i.push({kind:"L",points:[o,w]}),i.push({kind:"C",points:[w,{x:w.x+m.x*p*.55,y:w.y+m.y*p*.55},{x:y.x-g.x*p*.55,y:y.y-g.y*p*.55},y]}),o=y}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 Y$(e){const t=i=>`${yn(i.x)},${yn(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 jh(e,t,n,r,i){const o=Math.min(e.y,n)-qt,s=Math.max(e.y,n)+qt,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 X$(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 Q$=120;function eT(e,t,n,r,i,o=4){const s=Ru(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>H$(f,Wa));if(Gh(W$(s),i,a,Wa))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<Uh?e.y:Math.abs(f-t.y)<Uh?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-qt-1)),u.add(c(Math.round(f.y2)+qt+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},g=[];for(const w of u){const y=Math.abs(w-p.y)<.01?p.x:jh(p,f,w,qt,a);if(y===null)continue;const b=Math.abs(w-m.y)<.01?m.x:jh(m,-h,w,qt+Fh,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-y)*h<qt+Fh||Math.abs(w-p.y)<.01&&(b-p.x)*f<qt)continue;const v=X$([p,{x:y,y:p.y},{x:y,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!tT(v,a))continue;let S=(v.length-2)*qt,_;for(const $ of v)_&&(S+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;g.push({points:v,length:S})}g.sort((w,y)=>{const b=w.points[2]?.y,v=y.points[2]?.y;return w.length-y.length||(b===void 0||v===void 0?0:b-v)});for(const w of g){const y=J$(w.points);if(!Gh(y,i,a,Wa))continue;const b=w.points,v=b[0],S=b[b.length-1];if(!v||!S)continue;const _={x1:Math.min(...b.map($=>$.x)),y1:Math.min(...b.map($=>$.y)),x2:Math.max(...b.map($=>$.x)),y2:Math.max(...b.map($=>$.y))};return{kind:"routed",start:v,end:S,controls:null,d:Y$(y),bounds:_}}}return s}function tT(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(z$(i,o))return!1}n=r}return!0}function Jb(e,t){if(!t)return Wt.rest;const n=qe(t);return qe(e.from)===n||qe(e.to)===n?Wt.related:Wt.faded}function nT(){return{hit:{stroke:"transparent",width:16},line:{stroke:He("edge"),width:1.6},arrow:{fill:He("edge")}}}function rT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function iT(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 oT(e,t,n,r=h$){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 sT(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:"select-checked"}:null}function Zh(e){return e==="Enter"||e===" "}function aT(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function uT(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=aT(r,i),!0)}function cT(e,t){return e?.pointerId===t?null:e}function lT(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 dT(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 g=p?.closest?.("[data-edge-id]");return g?{kind:"edge",id:g.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=iT(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[g,w]=[...r.values()];g&&w&&(s={distance:Math.hypot(w.x-g.x,w.y-g.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,g]=[...r.values()];m&&g&&t.pinch(s,[m,g],h);return}if(i?.pointerId===h.pointerId){if(i=oT(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=sT(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 fT(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 Yb(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Lu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Pu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function vn(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 Xb(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 Du(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Lu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function hT(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Lu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Lu(e.total_out_usd)]];return e.role&&po.includes(e.role)?[["Role",Hb[e.role]||"Other"],...t,["Senders",Pu(e.degree_in)],["Receivers",Pu(e.degree_out)],["Labels",wn(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Yb(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",vn(e.first_activity_timestamp)],["Last activity (UTC)",vn(e.last_activity_timestamp)],["Labels",wn(e).join(", ")||"No labels"]]}function pT(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Du(e)],["Transfers",Pu(e.tx_count)],["First seen (UTC)",vn(e.first_seen_timestamp)],["Last seen (UTC)",vn(e.last_seen_timestamp)],["Since last seen",Xb(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)",Du(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)",vn(e.first_seen_timestamp)],["Last seen (UTC)",vn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function Qb(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function Ou(e){const t=mo(e);if(e.role)return`${e.address}. ${t||"Other"}.${wn(e).length?` Labels: ${wn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Yb(e.risk_level)} risk`,r=wn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Mu(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Du(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Xb(e.last_seen_timestamp,t)}.`:n}function mT(e,t){return Rt(e).nodes.map(n=>{const r={id:n.address,label:wn(n).join(", ")||mo(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function gT(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function yT(e,t,n={}){const r=e.ownerDocument;let i=Rt(t),o=n.layout??(Tf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Ao(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=C=>n.nodeStyle?.(C).stroke??C$(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const g={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,z)=>G(C,z),selectEdge:(C,z)=>B(C,z),showTooltip:(C,z)=>W(C,z),hideTooltip:()=>xe(),lost:()=>ue()};function y(C){const z=C==="webgl"?Lh("webgl"):null;if(z)try{return z(e,g,w,{label:n.label})}catch{}return Ph(e,g,w,{label:n.label})}const b=n.renderer??(Lh("webgl")&&a$(r)?"webgl":"svg");let v=y(b);e.dataset.renderer=v.kind;const S=()=>{const C=N$(i,a,u);if(!C)return null;const z=v.linkBounds();return z&&(C.x1=Math.min(C.x1,z.x1),C.y1=Math.min(C.y1,z.y1),C.x2=Math.max(C.x2,z.x2),C.y2=Math.max(C.y2,z.y2)),C},_=()=>{const C=S();return C?U$(C,s.width,s.height,oi):{x:0,y:0,scale:1}};l=_();const $=r.createElement("div");$.className="graph-tooltip cia-graph-tooltip",$.hidden=!0,$.setAttribute("role","tooltip"),e.append($);let R=0,P=!1,O=!1;function Y(){if(R){P=!0;return}v.build()}function he(){if(R){O=!0;return}l=_(),Se()}function Se(){v.camera()}function $e(C="program"){const z=mT(i,n.href),te=d?.kind==="node"?i.nodes.find(ce=>ce.id===d.id)??null:null,ve=d?.kind==="edge"?i.edges.find(ce=>ce.id===d.id)??null:null;if(te){const ce=i.edges.filter(ut=>ut.from===te.address||ut.to===te.address);return{kind:"node",id:te.id,selectedId:te.address,nodes:z,title:"Selected address",identity:te.address,values:hT(te),related:ce,node:te,edge:null,source:C}}return ve?{kind:"edge",id:ve.id,selectedId:null,nodes:z,title:"Selected aggregate flow",identity:`${ve.from} → ${ve.to}`,values:pT(ve,p()),related:[ve],node:null,edge:ve,source:C}:{kind:null,id:null,selectedId:null,nodes:z,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Fe(C){const z=$e(C);M(z),n.onSelect?.(z)}function M(C){const z=n.selectionRoot,te=z?.querySelector("[data-selection-title]"),ve=z?.querySelector("[data-selection-identity]"),ce=z?.querySelector("[data-selection-meta]");!te||!ve||!ce||(te.textContent=C.title,ve.textContent=C.identity,ce.replaceChildren(...C.values.map(([ut,At])=>{const Ut=r.createElement("div");Ut.className="meta-item",At!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(ut)&&Ut.classList.add("meta-item--identity"),ut==="Incoming amount (USD)"&&Ut.classList.add("meta-item--incoming"),ut==="Outgoing amount (USD)"&&Ut.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(ut)&&Ut.classList.add("meta-item--wide");const Or=r.createElement("span");Or.textContent=ut;const $n=r.createElement("strong"),fn=["First transaction","Last transaction"].includes(ut)?Qb(At):null;if(fn&&n.openLink){const D=n.openLink,ie=r.createElement("button");ie.type="button",ie.className="cia-graph-explorer-link",ie.dataset.explorer=fn,ie.textContent=At,ie.setAttribute("aria-label",`${ut}: ${At} (opens the explorer)`),ie.addEventListener("click",()=>D(fn)),$n.append(ie)}else if(fn){const D=r.createElement("a");D.href=fn,D.target="_blank",D.rel="noopener noreferrer",D.textContent=At,D.setAttribute("aria-label",`${ut}: ${At} (opens in new tab)`),$n.append(D)}else $n.textContent=At;return Ut.append(Or,$n),Ut})))}function G(C,z="program"){d=C?{kind:"node",id:C}:null,v.selection(),Fe(z)}function B(C,z="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Fe(z)}function ee(C){if(C==null)return G(null);const z=Ln(i,C);if(z)return G(z);if(i.edges.some(te=>te.id===C))return B(C)}function X(){l=_(),Se()}function V(C,z={x:s.width/2,y:s.height/2}){const te=zu(l.scale*(1+C)),ve=te/l.scale;l={x:z.x-(z.x-l.x)*ve,y:z.y-(z.y-l.y)*ve,scale:te},Se()}function q(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(z=>{z.classList.toggle("active",z.dataset.layout===C),z.setAttribute("aria-pressed",String(z.dataset.layout===C))}),n.onLayoutChange?.(C),a=Ao(i,o,s.width,s.height),v.geometry(),X()}function W(C,z){$.textContent=z,$.hidden=!1;const te=e.getBoundingClientRect();$.style.left=`${Math.min(te.width-330,Math.max(8,C.clientX-te.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-te.top+12)}px`}function xe(){$.hidden=!0}function Ie(C){return lT({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const je={point:Ie,transform:()=>l,select(C){C.type==="select-node"?G(C.id,"pointer"):C.type==="select-edge"?B(C.id,"pointer"):G(Af(i)?.id??null,"canvas")},drag(C,z,te){!h&&(h=rT(o,C,z),!h)||uT(a,h,z,te,l)&&(st=!0,v.moveNode(h.id))},endDrag(C){const z=h?.pointerId===C&&st;h=cT(h,C),z&&(st=!1,v.endMove())},pan(C,z){l={x:C.transform.x+z.x-C.point.x,y:C.transform.y+z.y-C.point.y,scale:l.scale},Se()},startPinch(){h=null},pinch(C,[z,te]){const ve=Math.hypot(te.x-z.x,te.y-z.y),ce=zu(C.scale*ve/Math.max(1,C.distance));V(ce/l.scale-1,{x:(z.x+te.x)/2,y:(z.y+te.y)/2})}};let st=!1;const et=C=>{C.preventDefault(),V(C.deltaY>0?-.12:.12,Ie(C))},L={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},F=C=>{if(C.target!==v.surface)return;const z=L[C.key];z?(C.preventDefault(),l={...l,x:l.x+z[0],y:l.y+z[1]},Se()):C.key==="+"||C.key==="="?V(.18):C.key==="-"?V(-.18):C.key==="0"&&X()};let H=()=>{};function J(){const C=v.surface,z=te=>v.pick(Ie(te));H=dT(C,je,v.kind==="svg"?void 0:z),C.addEventListener("wheel",et,{passive:!1}),C.addEventListener("keydown",F)}function me(){H(),v.surface.removeEventListener("wheel",et),v.surface.removeEventListener("keydown",F)}J();function ue(){v.kind!=="svg"&&(me(),v.destroy(),v=Ph(e,g,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),J(),Y())}const we=n.controls?.querySelector("[data-expand]")??null,Ee=n.panel&&we?fT(n.panel,we,r.body):null,ae=()=>{Ee?.toggle(),n.onExpansionChange?.(Ee?.isOpen()??!1),requestAnimationFrame(X)},Q=n.panel??e,Ge=C=>{if(C.key==="Tab"&&Ee?.isOpen()&&n.panel){const z=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(ce=>ce.checkVisibility()),te=z[0],ve=z.at(-1);C.shiftKey&&r.activeElement===te?(C.preventDefault(),ve?.focus()):!C.shiftKey&&r.activeElement===ve&&(C.preventDefault(),te?.focus())}if(C.key==="Escape"){if(Ee?.isOpen()){Ee.close(),n.onExpansionChange?.(!1),requestAnimationFrame(X);return}G(null,"keyboard")}};Q.addEventListener("keydown",Ge);const at=[],Ze=(C,z)=>{C&&(C.addEventListener("click",z),at.push([C,z]))};n.controls?.querySelectorAll("[data-layout]").forEach(C=>Ze(C,()=>q(C.dataset.layout==="tree"?"tree":"gravity"))),Ze(n.controls?.querySelector("[data-zoom='in']"),()=>V(.18)),Ze(n.controls?.querySelector("[data-zoom='out']"),()=>V(-.18)),Ze(n.controls?.querySelector("[data-zoom='fit']"),X),Ee&&Ze(we,ae);const Be=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,z=e.clientHeight;!C||!z||C===s.width&&z===s.height||(s.width=C,s.height=z,v.resize(C,z),X())});Be?.observe(e),Y(),n.selected&&ee(n.selected);const ht={update(C){const z=a;i=Rt(C);const te=i.nodes.every(ce=>z[ce.id])?{}:Ao(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(ce=>[ce.id,z[ce.id]??te[ce.id]]).filter(([,ce])=>ce)),d&&!(d.kind==="node"?i.nodes.some(ce=>ce.id===d.id):i.edges.some(ce=>ce.id===d.id))&&(d=null),f&&!i.nodes.some(ce=>ce.id===f)&&(f=null);const ve=new Set(i.nodes.map(ce=>ce.id));for(const ce of[...c.keys()])ve.has(ce)||c.delete(ce);Y(),he()},merge(C,z){const te=x$(i,C,z);i=te.model;const ve=Ln(i,z??Rt(C).checked_address);return a=ve?F$(i,a,ve,te.added,{notes:u}):{...a,...Ao(i,o,s.width,s.height),...a},Y(),te.added.length&&he(),te.added},batch(C){R++;try{C()}finally{R--,!R&&P&&(P=!1,v.build()),!R&&O&&(O=!1,l=_(),Se())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:ee,destroy(){Be?.disconnect(),me(),Q.removeEventListener("keydown",Ge);for(const[C,z]of at)C.removeEventListener("click",z);Ee?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:X,zoom:C=>V(C),setLayout:q,markNode(C,z){const te=Ln(i,C);te&&(z?u.set(te,z):u.delete(te),Y())},flagNode(C,z,te){const ve=Ln(i,C);if(!ve)return;const ce=c.get(ve)??new Set;te?ce.add(z):ce.delete(z),ce.size?c.set(ve,ce):c.delete(ve),R?P=!0:v.flag(ve,z,te)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>S(),transform:()=>({...l}),highlight(C){f=C==null?null:Ln(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const z=Ln(i,C),te=z?a[z]:null;if(!te)return null;const ve=v.surface.getBoundingClientRect(),ce=Math.min(ve.width/s.width,ve.height/s.height)||1,ut=ve.left+(ve.width-s.width*ce)/2,At=ve.top+(ve.height-s.height*ce)/2;return{x:ut+(te.x*l.scale+l.x)*ce,y:At+(te.y*l.scale+l.y)*ce}}};return Object.defineProperty(e,"ciaGraph",{value:ht,configurable:!0}),ht}const ew="chain-insights.flows.v1",tw="chain-insights.result.v1",nw=5e3,Bh=6,vT=3,rw=/^0x[0-9a-fA-F]{40}$/,bT=/^0x[0-9a-fA-F]{64}$/;function wT(e){return typeof e=="string"&&(rw.test(e)||bT.test(e))}function os(e){return typeof e=="string"&&rw.test(e)}function Fu(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function iw(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(Fu):[]}function _T(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Kt(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 zf(e){return e<1e11?e*1e3:e}const Uu=/^\d{4}-\d{2}-\d{2}$/,kT=Date.UTC(2009,0,1),ST=Date.UTC(2100,0,1);function Ka(e){return new Date(zf(e)).toISOString().slice(0,10)}function Vh(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function xT(e){return typeof e=="string"&&Uu.test(e)&&Number.isFinite(Date.parse(`${e}T00:00:00Z`))}const ET=new Set(["day","date"]);function Hh(e){return ET.has(e)||e.endsWith("_timestamp")}function $T(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function TT(e){return Array.isArray(e)?e.some(os):os(e)}function CT(e){return e.some(t=>Object.values(t).some(TT))}function AT(e){return e.length>0&&e.every(t=>os(t.from_address)&&os(t.to_address))}function qh(e){if(typeof e=="string"){const r=e.trim();if(Uu.test(r)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(r)){const i=Date.parse(Uu.test(r)?`${r}T00:00:00Z`:/(?:Z|[+-]\d{2}:?\d{2})$/.test(r)?r.replace(" ","T"):`${r.replace(" ","T")}Z`);return Number.isFinite(i)?i:null}}const t=Kt(e);if(t==null)return null;const n=zf(t);return n>=kT&&n<ST?n:null}function ow(e){if(e.length===0||CT(e))return null;const t=$T(e),r=t.filter(Hh).find(u=>e.some(c=>qh(c[u])!=null));if(!r)return null;const i=t.filter(u=>{if(Hh(u))return!1;const c=e.map(l=>l[u]).filter(l=>l!=null);return c.length>0&&c.every(l=>Kt(l)!=null)});if(i.length===0)return null;const o=e.map((u,c)=>({time:qh(u[r]),row:u,index:c})).filter(u=>u.time!=null).sort((u,c)=>u.time-c.time||u.index-c.index),s=i.slice(0,Bh);return new Set(o.filter(u=>s.some(c=>Kt(u.row[c])!=null)).map(u=>u.time)).size<vT?null:{xColumn:r,times:o.map(u=>u.time),daily:o.every(u=>u.time%864e5===0),series:s.map(u=>({column:u,values:o.map(c=>Kt(c.row[u]))})),omittedColumns:i.slice(Bh),skippedRows:e.length-o.length}}function IT(e){return AT(e)?"graph":ow(e)?"chart":"table"}const NT=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function Wh(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function zT(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of NT)if(n.has(r))return i;return"other"}const Kh=(e,t)=>e==null?t:t==null?e:e+t;function RT(e,t="robinhood"){const n=new Map;for(const d of e)for(const f of new Set([String(d.from_address).toLowerCase(),String(d.to_address).toLowerCase()]))n.set(f,(n.get(f)??0)+1);let r="",i=0;for(const[d,f]of n)f>i&&(r=d,i=f);const o=new Map,s=new Map,a=(d,f,h)=>{const p=o.get(d)??{address:d,labels:[],exchange:!1};for(const m of f)p.labels.some(g=>g.toLowerCase()===m.toLowerCase())||p.labels.push(m);p.exchange=p.exchange||h,o.set(d,p)};r&&o.set(r,{address:r,labels:[],exchange:!1});let u=0;for(const d of e){const f=String(d.from_address).toLowerCase(),h=String(d.to_address).toLowerCase(),p=[f,h].filter((b,v,S)=>!o.has(b)&&S.indexOf(b)===v).length;if(o.size+p>nw||(u++,a(f,Wh(d.from_labels),d.from_is_exchange===!0),a(h,Wh(d.to_labels),d.to_is_exchange===!0),f===h))continue;const m=`${f}->${h}`,g=s.get(m)??{from:f,to:h,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=Kh(g.usd,Kt(d.amount_usd_sum)),g.tx=Kh(g.tx,Kt(d.tx_count));const w=Kt(d.first_seen_timestamp),y=Kt(d.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),y!=null&&(g.last=g.last==null?y:Math.max(g.last,y)),typeof d.link_kind=="string"&&d.link_kind&&!g.kinds.includes(d.link_kind)&&g.kinds.push(d.link_kind),s.set(m,g)}const c=[...o.values()].map(d=>({address:d.address,role:zT(d.labels,d.exchange),labels:d.labels})),l=[...s.values()].map(d=>({from:d.from,to:d.to,usd:d.usd,tx_count:d.tx,first_seen_ms:d.first,last_seen_ms:d.last,...d.kinds.length?{link_kind:d.kinds.join(", ")}:{}}));return{view:{schema:ew,network:t,center:r,nodes:c,edges:l,truncated:!1},rowsTotal:e.length,rowsDrawn:u,rowsLeftOut:e.length-u,addresses:o.size}}function LT(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(Fu).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(Fu):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null})):[]}const Jh=200;function go(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
109
- `).trim()}function Mr(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 sw(e){if(!e)return null;const t=e.structuredContent,n=Mr(t?.error)??Mr(t?.facts?.error)??Mr(t?.facts?.query?.error);if(!e.isError||n)return n;const r=go(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=Mr(i?.error)??Mr(i);if(o)return o}catch{}return r||"The tool answered with an error."}const PT=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function aw(e){if(!e||sw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===ew)return"flows";if(t?.schema===tw){if(t.tool==="graph_query")return IT(iw(t));if(t.tool==="graph_query_batch")return Array.isArray(t.facts?.queries)&&t.facts.queries.length>0?"batch":"text";if(typeof t.tool=="string"&&PT.has(t.tool))return"balance"}return"text"}function I(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 DT(e,t){const n=I(e,"code",{class:"cv-addr",title:t,"data-full":t,text:si(t)}),r=I(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",()=>{OT(e,t,n,r)}),I(e,"span",{class:"cv-addr-cell"},n,r)}async function OT(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 MT(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?vn(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 FT=160,Yh=2e3;function UT(e,t=FT){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 uw(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>Yh?`${n.full.slice(0,Yh-1)}…`:n.full,o=i!=null&&i!==t,s=I(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?I(r,"details",{class:"cv-notice-more"},I(r,"summary",{class:"cv-notice-line",text:t}),I(r,"p",{class:"cv-notice-full",text:i})):I(r,"p",{class:"cv-notice-line",text:t}));return e.replaceChildren(s),s}function GT(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,Jh),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>Jh||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function jT(e,t,n){return t==null?I(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):wT(t)?DT(e,t):typeof t=="number"?e.createTextNode(MT(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))}function Xh(e,t,n={}){const r=e.ownerDocument,i=GT(t.structuredContent),o=i.rows.length;if(i.total===0)return uw(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=I(r,"table",{class:"cv-table"},I(r,"thead",{},I(r,"tr",{},...i.columns.map(u=>I(r,"th",{scope:"col",text:u})))),I(r,"tbody",{},...i.rows.map(u=>I(r,"tr",{},...i.columns.map(c=>I(r,"td",{},jT(r,u[c],c)))))));return e.replaceChildren(I(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},I(r,"header",{class:"cv-card-head"},I(r,"strong",{text:"Graph query result"}),I(r,"span",{class:"cv-muted",text:s}),n.toggle??null),i.truncated?I(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?I(r,"div",{class:"cv-table-wrap"},a):null)),i}const Fr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Io=e=>typeof e=="string"&&e?e:null;function ZT(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Fr(t.allowance_usd),consumedUsd:Fr(t.consumed_usd),windowEnd:Io(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=Io(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Fr(r?n.daily_units_used:n.daily_seconds_used),limit:Fr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Fr(r?n.remaining_units:n.remaining_seconds),resetAt:Io(n.reset_at),identifierKind:Io(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Qh=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),No=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function Ja(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${vn(t)} UTC`:e}function ep(e,t,n,r){const i=n>0?Math.min(1,t/n):0,o=I(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},I(e,"span"));return o.firstElementChild.style.width=`${Math.round(i*100)}%`,o}function Ya(e,t){return I(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[I(e,"dt",{text:n}),I(e,"dd",{text:r})]))}function BT(e,t){const n=e.ownerDocument,r=ZT(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${si(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[ep(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),Ya(n,[["Daily allowance",Qh(r.allowanceUsd)],["Used today",Qh(r.consumedUsd)],["Window ends",Ja(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?[I(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),Ya(n,[["Daily allowance","No daily limit"],["Used today",No(r.used,r.unit)],["Window ends",Ja(r.resetAt)]])]:[ep(n,r.used,r.limit,"Share of today's free allowance used"),Ya(n,[["Daily allowance",No(r.limit,r.unit)],["Used today",No(r.used,r.unit)],["Left today",No(r.remaining,r.unit)],["Window ends",Ja(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[I(n,"p",{class:"cv-muted",text:go(t)||"Nothing to show."})]),e.replaceChildren(I(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":o},I(n,"header",{class:"cv-card-head"},I(n,"strong",{text:o}),I(n,"span",{class:"cv-muted",text:s})),...i)),r}function Ra(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=sw(t);if(i!=null){uw(e,UT(i),{kind:"refused",view:"text",full:i});return}const o=go(t);e.replaceChildren(I(r,"section",{class:"cv-card cv-text-view","data-view":"text"},I(r,"p",{text:n}),o?I(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function cw(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(I(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},I(n,"span",{class:"cv-sr",text:t}),I(n,"div",{class:"cv-skel-line cv-skel-title"}),I(n,"div",{class:"cv-skel-line cv-skel-sub"}),I(n,"div",{class:"cv-skel-block"})))}const VT="http://www.w3.org/2000/svg",HT=720,qT=6,zo={left:66,right:18,top:6},tp=18,WT=16,KT=26,JT=170,YT=82,XT=80;function lw(e,t){const n=new Date(e).toISOString();return t?n.slice(0,10):`${n.slice(0,10)} ${n.slice(11,16)}`}const QT=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),dw=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function np(e){return Math.abs(e)<1e3?dw.format(Math.round(e*100)/100):QT.format(e)}function eC(e,t=HT){const n=zo.left,r=t-zo.right,i=r-n,o=e.times[0]??0,s=e.times[e.times.length-1]??o,a=s-o,u=h=>a>0?n+(h-o)/a*i:n+i/2,c=e.series.length===1?JT:YT,l=e.series.map((h,p)=>{const m=zo.top+p*(tp+c+WT),g=m+tp,w=g+c,y=h.values.filter(P=>P!=null),b=Math.min(0,...y),v=Math.max(...y,b+1e-9),S=P=>w-(P-b)/(v-b||1)*c,_=[],$=[];let R=[];return h.values.forEach((P,O)=>{if(P==null){R.length&&$.push(R),R=[];return}const Y={x:u(e.times[O]??o),y:S(P),time:e.times[O]??o,value:P};_.push(Y),R.push(Y)}),R.length&&$.push(R),{column:h.column,color:`var(--cia-graph-series-${p%qT+1})`,top:m,plotTop:g,plotBottom:w,min:b,max:v,runs:$,points:_}}),d=(l[l.length-1]?.plotBottom??zo.top)+6,f=[];if(e.times.length){const h=a>0?[[o,"start"],[o+a/2,"middle"],[s,"end"]]:[[o,"middle"]];for(const[p,m]of h)f.push({x:u(p),label:lw(p,e.daily),anchor:m})}return{width:t,height:d+KT,plotLeft:n,plotRight:r,lanes:l,ticks:f,axisY:d}}function _t(e,t,n={}){const r=e.createElementNS(VT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const Ur=e=>Math.round(e*10)/10;function tC(e,t,n={}){const r=e.ownerDocument,i=eC(t),o=_t(r,"svg",{class:"cv-chart-svg",viewBox:`0 0 ${i.width} ${i.height}`,role:"img",preserveAspectRatio:"xMidYMid meet","aria-label":`Line chart of ${t.series.map(c=>c.column).join(", ")} by ${t.xColumn}, ${t.times.length} ${t.times.length===1?"point":"points"}`});for(const c of i.lanes){const l=_t(r,"g",{class:"cv-chart-lane","data-series":c.column}),d=_t(r,"rect",{class:"cv-chart-swatch",x:i.plotLeft,y:c.top+4,width:14,height:4,rx:2});d.style.fill=c.color;const f=_t(r,"text",{class:"cv-chart-name",x:i.plotLeft+20,y:c.top+11});f.textContent=c.column,l.append(d,f,_t(r,"line",{class:"cv-chart-grid",x1:i.plotLeft,x2:i.plotRight,y1:c.plotTop,y2:c.plotTop}),_t(r,"line",{class:"cv-chart-base",x1:i.plotLeft,x2:i.plotRight,y1:c.plotBottom,y2:c.plotBottom}));const h=_t(r,"text",{class:"cv-chart-tick",x:i.plotLeft-8,y:c.plotTop+4,"text-anchor":"end"});h.textContent=np(c.max);const p=_t(r,"text",{class:"cv-chart-tick",x:i.plotLeft-8,y:c.plotBottom+4,"text-anchor":"end"});p.textContent=np(c.min),l.append(h,p);for(const m of c.runs){if(m.length<2)continue;const g=_t(r,"polyline",{class:"cv-chart-line",points:m.map(w=>`${Ur(w.x)},${Ur(w.y)}`).join(" "),fill:"none"});g.style.stroke=c.color,l.append(g)}if(c.points.length<=XT)for(const m of c.points){const g=_t(r,"circle",{class:"cv-chart-dot",cx:Ur(m.x),cy:Ur(m.y),r:3});g.style.fill=c.color;const w=_t(r,"title");w.textContent=`${lw(m.time,t.daily)} · ${c.column} ${dw.format(m.value)}`,g.append(w),l.append(g)}o.append(l)}const s=_t(r,"g",{class:"cv-chart-axis"});for(const c of i.ticks){const l=_t(r,"text",{class:"cv-chart-tick",x:Ur(c.x),y:i.axisY+14,"text-anchor":c.anchor});l.textContent=c.label,s.append(l)}o.append(s);const a=[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),u=I(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Chart by ${t.xColumn}`},I(r,"header",{class:"cv-flows-head"},I(r,"div",{class:"cv-title"},I(r,"strong",{text:"Chart"}),I(r,"span",{class:"cv-muted",text:`${t.times.length} ${t.times.length===1?"point":"points"} by ${t.xColumn} (UTC) · ${t.series.length} ${t.series.length===1?"line":"lines"}`})),n.toggle??null),a.length?I(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:a.join(" ")}):null,I(r,"div",{class:"cv-chart-body"},o));return e.replaceChildren(u),{root:u,layout:i}}const nC="chain-insights.transfers.v1",rC="graph_expand",iC="2015-01-01";function oC(e,t,n,r){return{network:e,from:t,to:n,day:r}}function sC(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?Ka(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?Ka(e.last_seen_timestamp):Ka(t);return{first:n,last:n&&r<n?n:r}}function Ro(e,t){return e<=(t??iC)}function aC(e){if(!e)return"no answer";const t=go(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:fw(e.structuredContent)?null:t||"the answer held no transfers"}function fw(e){const t=e;if(!t||t.schema!==nC||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!xT(t.day))return null;const n=[];for(const r of t.transfers){if(!r||typeof r!="object")continue;const i=r;if(typeof i.tx_id!="string")continue;const o=Kt(i.block_timestamp);n.push({tx_id:i.tx_id,block_timestamp:o,amount:typeof i.amount=="string"?i.amount:typeof i.amount=="number"?String(i.amount):null,asset_symbol:typeof i.asset_symbol=="string"&&i.asset_symbol?i.asset_symbol:null,amount_usd:Kt(i.amount_usd)})}return{network:typeof t.network=="string"?t.network:null,from:t.from,to:t.to,day:t.day,transfers:n,truncated:t.truncated===!0}}function uC(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function cC(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 lC(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 dC(e){return e==null?"—":`${new Date(zf(e)).toISOString().slice(11,19)} UTC`}function Xa(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function fC(e,t){const n=t.now??Date.now,r=I(e,"strong",{"data-link-title":"",text:"Transfers"}),i=I(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),o=I(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=I(e,"p",{class:"cv-link-day","data-link-day":""}),a=I(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),u=I(e,"button",{type:"button",class:"cv-button","data-link-earlier":"",text:"Earlier day"}),c=I(e,"section",{class:"cv-linkpanel cv-linkpanel-embedded","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},I(e,"header",{class:"cv-link-head"},r,null),o,s,a,u);let l=null,d=0;function f(){if(!l){c.hidden=!0;return}c.hidden=!1,o.replaceChildren(I(e,"code",{"data-link-from":"",text:l.from})," → ",I(e,"code",{"data-link-to":"",text:l.to})),s.textContent=`${Xa(l.day)} (UTC)`,u.disabled=l.status==="loading"||Ro(l.day,l.firstDay);const w=Ro(l.day,l.firstDay)?null:Vh(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${Xa(w)}`:"Earlier day: this is the first day the link was seen"),l.status==="loading"?a.replaceChildren(I(e,"p",{class:"cv-muted",text:`Loading the transfers of ${Xa(l.day)}…`})):l.status==="error"?a.replaceChildren(I(e,"p",{class:"cv-link-error","data-link-error":"",role:"alert",text:l.error??"The transfers could not be read."})):l.transfers.length===0?a.replaceChildren(I(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses on this day."})):(a.replaceChildren(I(e,"ol",{class:"cv-transfers"},...l.transfers.map(y=>hC(e,y,t.host)))),l.truncated&&a.append(I(e,"p",{class:"cv-muted","data-link-truncated":"",text:`${l.transfers.length} transfers shown. This day holds more.`}))),l.status!=="loading"&&Ro(l.day,l.firstDay)&&l.firstDay&&a.append(I(e,"p",{class:"cv-muted","data-link-first":"",text:"This is the first day the link was seen."}))}async function h(w){const y=++d,b=l;b.day=w,b.status="loading",b.error=null,f(),t.onLayout?.();let v=null;try{v=await t.host.callServerTool({name:rC,arguments:oC(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(y!==d||l!==b)return b;const S=aC(v);if(S)b.status="error",b.transfers=[],b.error=S.length>300?`${S.slice(0,299)}…`:S;else{const _=fw(v.structuredContent);b.status="ready",b.transfers=uC(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>g.close(),m=()=>{g.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const g={element:c,open(w){const y=sC(w,n());return l={from:w.from,to:w.to,day:y.last,firstDay:y.first,status:"loading",transfers:[],truncated:!1,error:null},h(y.last)},async earlier(){return!l||l.status==="loading"||Ro(l.day,l.firstDay)?null:h(Vh(l.day))},close(){d++,l=null,f(),t.onLayout?.()},state:()=>l?{...l,transfers:[...l.transfers]}:null,destroy(){d++,i.removeEventListener("click",p),u.removeEventListener("click",m)}};return g}function hC(e,t,n){const r=Qb(t.tx_id),i=n.openLink,o=r&&i?I(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:si(t.tx_id)}):I(e,"code",{title:t.tx_id,text:si(t.tx_id)});return r&&i&&o.addEventListener("click",()=>{i.call(n,{url:r}).catch(()=>{})}),I(e,"li",{class:"cv-transfer","data-tx":t.tx_id},I(e,"span",{class:"cv-transfer-time",text:dC(t.block_timestamp)}),I(e,"span",{class:"cv-transfer-amount",text:`${cC(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),I(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":lC(t.amount_usd)}),o)}const pC="graph_expand",Lo="too busy to expand",hw=640,mC=300,Qa=.45,gC="Full screen shows the whole graph",rp=400,eu="expanded",pw=5e3,yC="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.",Gu=new Intl.NumberFormat("en-US");function ip(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 vC(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${Gu.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function bC(e,t){return`Not loaded: ${Gu.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${Gu.format(pw)} addresses. Fold another address to make room.`}const op=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let wC=0;const _C=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function kC(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function SC(e){const t=go(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Tf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function xC(e,t,n,r=hw,i=mC){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(Qa,Math.min(1,(t-oi*2)/o)),u=Math.ceil(n+s*a+oi*2),c=Math.min(r,Math.max(i,u));return Mh(e,t,c-n)>=Qa?{height:c,fits:!0}:{height:r,fits:Mh(e,t,r-n)>=Qa}}function EC(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function $C(e){const t=e.split(`
110
- `)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function TC(e,t){return`investigator expanded ${e}: ${t} new addresses`}function CC(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&mo({role:n.role??null,labels:n.labels??[]})||"Other"}function mw(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:ip(t)}]]:[]);let a=s();const u=new Set,c=new Set;let l=[];const d=new Set;let f=null,h=null;const p=n.now??Date.now,m=n.title??"Money flow graph",g=I(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:yC}),w=I(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),y=I(r,"div",{class:"cv-canvas","data-graph":""}),b=I(r,"div",{class:"cv-detail","aria-label":"Selection"},I(r,"strong",{"data-selection-title":""}),I(r,"code",{"data-selection-identity":""}),I(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),v=I(r,"strong",{"data-side-title":"",text:"Details"}),S=I(r,"button",{type:"button",class:"cv-button cv-icon","data-side-close":"","aria-label":"Close the details",text:"×"}),_=I(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),$=I(r,"button",{type:"button",class:"cv-button","data-more":"",hidden:!0,text:"More flows"}),R=I(r,"p",{class:"cv-remaining cv-muted","data-remaining":"",hidden:!0}),P=fC(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Be()}),O=I(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},I(r,"header",{class:"cv-side-head"},v,S),b,R,I(r,"div",{class:"cv-side-actions"},_,$),P.element),Y=I(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),he=I(r,"button",{type:"button",class:"cv-button","data-reset":"","aria-label":"Reset the graph to the first answer",text:"Reset"}),Se=I(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:gC}),$e=I(r,"div",{class:"cv-actions"},I(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),I(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),I(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),he,Se,Y),Fe=I(r,"span",{class:"cv-muted","data-subtitle":""}),M=`cv-addresses-${++wC}`,G=I(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:M,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let B=[],ee=-1;const X=I(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${m} of ${o}`},I(r,"header",{class:"cv-flows-head"},I(r,"div",{class:"cv-title"},I(r,"strong",{text:m}),Fe),n.toggle??null,$e),w,n.note?I(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,I(r,"div",{class:"cv-body"},G,y,O),g);e.replaceChildren(X);function V(){const D=Q.model(),ie=D.truncated?" · more flows than shown":"";Fe.textContent=`${o} · ${CC(t,o)} · ${i} · ${D.nodes.length} addresses${ie}`;const pe=new Set(D.nodes.map(Te=>Te.role??"other"));w.replaceChildren(..._C.filter(([Te])=>pe.has(Te)).map(([Te,We])=>{const It=I(r,"i",{"aria-hidden":"true"});return It.style.background=`var(--cia-graph-role-${Te})`,I(r,"li",{"data-role":Te},It,We)})),q()}function q(){const D=Q.model().nodes,ie=B[ee]??null;B=D.map(Te=>Te.address.toLowerCase()),G.replaceChildren(...D.map((Te,We)=>I(r,"div",{role:"option",id:`${M}-${We}`,"data-list-address":B[We],"aria-selected":"false",text:`${Te.address} ${mo({role:Te.role??null,labels:Te.labels??[]})||"Other"}`})));const pe=ie?B.indexOf(ie):-1;ee=pe>=0?pe:B.length?Math.min(Math.max(ee,-1),B.length-1):-1,W()}function W(){for(const ie of G.children)ie.setAttribute("aria-selected",String(ie.id===`${M}-${ee}`));ee>=0?G.setAttribute("aria-activedescendant",`${M}-${ee}`):G.removeAttribute("aria-activedescendant");const D=r.activeElement===G;Q.highlight(D?B[ee]??null:null)}function xe(D){return D?Q.model().nodes.find(ie=>ie.id===D)?.address.toLowerCase()??null:null}const Ie=D=>{const ie=D.target,pe=D.key==="Enter"||D.key===" ",Te=ie?.closest?.("[data-node-id]");if(pe&&D.shiftKey&&Te){D.preventDefault();const We=xe(Te.dataset.nodeId);We&&te(We)}};y.addEventListener("keydown",Ie,!0);function je(D){B.length&&(ee=Math.max(0,Math.min(B.length-1,D)),W())}const st=()=>{ee<0&&B.length&&(ee=0),W()},et=()=>Q.highlight(null),L=D=>{const ie=B[ee];switch(D.key){case"ArrowDown":D.preventDefault(),je(ee+1);return;case"ArrowUp":D.preventDefault(),je(ee-1);return;case"Home":D.preventDefault(),je(0);return;case"End":D.preventDefault(),je(B.length-1);return;case"Escape":Ut();return;case"Enter":case" ":if(D.preventDefault(),!ie)return;D.shiftKey?te(ie):Q.select(ie);return}};G.addEventListener("focus",st),G.addEventListener("blur",et),G.addEventListener("keydown",L);function F(){const D=h;if(!D){_.hidden=!0,$.hidden=!0,R.hidden=!0;return}const ie=d.has(D),pe=ie?vC(a.get(D)?.remaining??null):null;R.hidden=!pe,R.textContent=pe??"",_.hidden=!1,_.disabled=u.has(D)||c.has(D),_.textContent=u.has(D)?"Too busy to expand":ie?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${D}`),$.hidden=!(ie&&op(a.get(D)))}function H(D){const ie=O.hidden;O.hidden=D.kind==null,D.kind==="node"&&D.node?(h=D.node.address.toLowerCase(),v.textContent="Address details",P.close()):(h=null,D.kind==="edge"?v.textContent="Link details":P.close()),F(),ie!==O.hidden&&Be()}let J=null;function me(){J&&clearTimeout(J),J=null}function ue(D){const ie=D.source==="pointer"&&D.kind==="node"&&D.node,pe=D.source!=="program"&&D.kind==="edge"&&D.edge;if(me(),ie){const Te=D.node.address.toLowerCase(),We=p();f&&f.address===Te&&We-f.at<=rp?(f=null,Ut(),te(Te)):(f={address:Te,at:We},J=setTimeout(()=>{J=null,H(D)},rp));return}D.kind!=="node"&&(f=null),H(D),pe&&P.open(D.edge)}const we=n.height??hw,Ee=`${m} 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 ae(){return yT(y,t,{layout:"tree",width:n.width??720,height:we,now:n.now,controls:$e,selectionRoot:b,onSelect:ue,openLink:D=>{n.host.openLink?.({url:D}).catch(()=>{g.textContent="The host did not open the link."})},label:Ee})}let Q=ae();V();let Ge=n.displayMode??"inline",at=n.availableDisplayModes??[];const Ze=()=>!!n.host.requestDisplayMode&&(at.length===0||at.includes("fullscreen"));function Be(){if(Ge==="fullscreen"){X.style.removeProperty("height"),Se.hidden=!0;return}const D=y.clientWidth||n.width||720,ie=Math.max(0,X.offsetHeight-y.offsetHeight)||140,{height:pe,fits:Te}=xC(Q.contentBounds(),D,ie);X.style.height=`${pe}px`,Se.hidden=Te||!Ze(),X.dataset.fits=String(Te),Q.fit()}async function ht(D){try{await n.host.updateModelContext?.({content:[{type:"text",text:D}]})}catch{}}async function C(D,ie=!1){const pe=D.toLowerCase();if(u.has(pe))return g.textContent=`${pe} is ${Lo}.`,{added:[],refused:Lo};if(c.has(pe))return{added:[],refused:null};const Te=a.get(pe);if(Te&&!op(Te))return g.textContent=`Every recent flow of ${pe} is drawn.`,{added:[],refused:null};c.add(pe),F(),g.textContent=`Loading the flows of ${pe}…`;let We=null;try{We=await n.host.callServerTool({name:pC,arguments:kC(i,pe,ie||Te?Te?.cursor:null)})}catch(wt){We={isError:!0,content:[{type:"text",text:wt instanceof Error?wt.message:String(wt)}]}}finally{c.delete(pe)}const It=SC(We);if(It)return EC(It)?(u.add(pe),Q.markNode(pe,Lo),g.textContent=`${pe} is ${Lo}. The drawing is kept.`):g.textContent=`${pe} could not be expanded: ${$C(It)}. The drawing is kept; try again.`,F(),{added:[],refused:It};const Ve=We.structuredContent,Fa=Q.model(),Tn=new Set(Fa.nodes.map(wt=>wt.address.toLowerCase())),Ua=new Set;for(const wt of Ve.nodes)Tn.has(wt.address.toLowerCase())||Ua.add(wt.address.toLowerCase());for(const wt of Ve.edges)for(const bo of[wt.from,wt.to])Tn.has(bo.toLowerCase())||Ua.add(bo.toLowerCase());if(Tn.size+Ua.size>pw){const wt=new Set(Fa.edges.map(Cn=>`${Cn.from.toLowerCase()}->${Cn.to.toLowerCase()}`)),bo=new Set(Ve.edges.map(Cn=>`${Cn.from.toLowerCase()}->${Cn.to.toLowerCase()}`).filter(Cn=>!wt.has(Cn))).size,Uf=bC(bo,pe);return g.textContent=Uf,F(),{added:[],refused:Uf}}const vo=Q.merge(Ve,pe);return l.push({address:pe,page:Ve}),d.add(pe),Q.flagNode(pe,eu,!0),a.set(pe,{cursor:Ve.cursor??null,truncated:!!Ve.truncated,remaining:ip(Ve)}),V(),Be(),F(),g.textContent=`${vo.length} new ${vo.length===1?"address":"addresses"} linked to ${pe}. Double-click it again to fold them back.`,await ht(TC(pe,vo.length)),{added:vo,refused:null}}function z(D){const ie=D.toLowerCase();if(!d.has(ie))return{removed:0};const pe=Q.model().nodes.length;d.delete(ie),a.delete(ie);const Te=l.filter(Ve=>Ve.address!==ie),We=[];Q.batch(()=>{Q.flagNode(ie,eu,!1),Q.update(t);for(const Ve of Te)Q.model().nodes.some(Tn=>Tn.address.toLowerCase()===Ve.address)?(Q.merge(Ve.page,Ve.address),We.push(Ve)):We.some(Tn=>Tn.address===Ve.address)||(Q.flagNode(Ve.address,eu,!1),d.delete(Ve.address),a.delete(Ve.address))}),l=We;const It=Math.max(0,pe-Q.model().nodes.length);return h&&!Q.model().nodes.some(Ve=>Ve.address.toLowerCase()===h)&&(O.hidden=!0,h=null),V(),Be(),F(),g.textContent=`Folded ${ie} back: ${It} ${It===1?"address":"addresses"} removed.`,ht(`investigator collapsed ${ie}: ${It} addresses removed`),{removed:It}}async function te(D){d.has(D)?z(D):await C(D)}function ve(){me(),Q.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,P.close(),O.hidden=!0,Q=ae(),V(),Be(),F(),g.textContent="Back to the first answer."}function ce(D,ie){D&&(Ge=D),ie&&(at=ie),X.dataset.displayMode=Ge,Y.hidden=!Ze(),Y.textContent=Ge==="fullscreen"?"Exit full screen":"Full screen",Y.setAttribute("aria-label",Ge==="fullscreen"?"Back to the inline view":"Open full screen"),Be()}ce(Ge);const ut=async()=>{const D=Ge==="fullscreen"?"inline":"fullscreen";try{const ie=await n.host.requestDisplayMode?.({mode:D});ce(ie?.mode??D)}catch{g.textContent="The host did not change the display mode."}},At=()=>ve();function Ut(){me();const D=!O.hidden;Q.select(null),P.close(),O.hidden=!0,h=null,F(),D&&Be()}const Or=()=>Ut(),$n=()=>{h&&te(h)},fn=()=>{h&&C(h,!0)};return Y.addEventListener("click",ut),he.addEventListener("click",At),S.addEventListener("click",Or),_.addEventListener("click",$n),$.addEventListener("click",fn),{root:X,get graph(){return Q},expand:D=>C(D),collapse:z,reset:ve,expanded:()=>[...d],linkPanel:P,openLink(D,ie){const pe=Q.model().edges.find(Te=>Te.from===D.toLowerCase()&&Te.to===ie.toLowerCase());return pe?(Q.select(pe.id),P.open(pe)):Promise.resolve(null)},setTheme(D){Q.setTheme(D)},setDisplayMode:ce,refit:Be,destroy(){me(),y.removeEventListener("keydown",Ie,!0),G.removeEventListener("focus",st),G.removeEventListener("blur",et),G.removeEventListener("keydown",L),Y.removeEventListener("click",ut),he.removeEventListener("click",At),S.removeEventListener("click",Or),_.removeEventListener("click",$n),$.removeEventListener("click",fn),P.destroy(),Q.destroy()}}}function ju(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function AC(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 gw=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height});function IC(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(nw)} addresses. The table has the rows.`}function NC(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=I(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=I(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=I(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 yw(e,t,n){const r=e.ownerDocument,i=aw(t);if(i!=="graph"&&i!=="chart")return i==="table"?Xh(e,t):Ra(e,t),ju(i==="table"?"table":"text");const o=t.structuredContent,s=iw(o),a=I(r,"div",{class:"cv-face","data-face":"picture"}),u=I(r,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(a,u);const c=NC(r,i==="graph"?"Graph":"Chart",h=>f(h));let l=null,d=!1;if(i==="graph"){const h=RT(s,_T(o));l=mw(a,h.view,{...gw(n),title:"Money flow graph",toggle:c.make(),note:IC(h.rowsLeftOut,h.rowsTotal)})}else tC(a,ow(s),{toggle:c.make()});function f(h){a.hidden=h!=="picture",u.hidden=h!=="table",h==="table"&&!d&&(d=!0,Xh(u,t,{toggle:c.make()})),c.set(h),h==="picture"&&l?.refit()}return{kind:i,flows:()=>l?[l]:[],setTheme(h){l?.setTheme(h)},setDisplayMode(h,p){l?.setDisplayMode(h,p)},refit(){a.hidden||l?.refit()},destroy(){l?.destroy()}}}function zC(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:tw,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 RC(e,t,n){const r=e.ownerDocument,i=LT(t.structuredContent),o=i.map((p,m)=>I(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)=>I(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=I(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],g=s[p];if(!m||!g)return;d=p,o.forEach((y,b)=>{y.setAttribute("aria-selected",String(b===p)),y.tabIndex=b===p?0:-1}),s.forEach((y,b)=>{y.hidden=b!==p});const w=u[p];if(w)w.refit();else{const y=yw(g,zC(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l});u[p]=y,g.dataset.view=y.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",g=>{const w=o.length-1,y=g.key==="ArrowRight"?m===w?0:m+1:g.key==="ArrowLeft"?m===0?w:m-1:g.key==="Home"?0:g.key==="End"?w:null;y!=null&&(g.preventDefault(),h(y),o[y]?.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 g of u)g?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function LC(e,t,n){const r=aw(t);if(r==="flows"){const i=mw(e,t.structuredContent,gw(n));return AC("flows",()=>i)}return r==="graph"||r==="chart"||r==="table"?yw(e,t,n):r==="batch"?RC(e,t,n):r==="balance"?(BT(e,t),ju("balance")):(Ra(e,t),ju("text"))}function PC(e){return e==="light"||e==="dark"}function DC(e,t=()=>!1){return PC(e?.theme)?e.theme:t()?"dark":"light"}function Rf(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 vw(e,t,n={}){const r=e.documentElement,i=DC(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 OC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Po={exports:{}},sp;function MC(){if(sp)return Po.exports;sp=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(S,_,$){return Function.prototype.apply.call(S,_,$)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:n=function(S){return Object.getOwnPropertyNames(S)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(S){return S!==S};function o(){o.init.call(this)}Po.exports=o,Po.exports.once=w,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(S){if(typeof S!="number"||S<0||i(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(S){for(var _=[],$=1;$<arguments.length;$++)_.push(arguments[$]);var R=S==="error",P=this._events;if(P!==void 0)R=R&&P.error===void 0;else if(!R)return!1;if(R){var O;if(_.length>0&&(O=_[0]),O instanceof Error)throw O;var Y=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw Y.context=O,Y}var he=P[S];if(he===void 0)return!1;if(typeof he=="function")t(he,this,_);else for(var Se=he.length,$e=p(he,Se),$=0;$<Se;++$)t($e[$],this,_);return!0};function c(v,S,_,$){var R,P,O;if(a(_),P=v._events,P===void 0?(P=v._events=Object.create(null),v._eventsCount=0):(P.newListener!==void 0&&(v.emit("newListener",S,_.listener?_.listener:_),P=v._events),O=P[S]),O===void 0)O=P[S]=_,++v._eventsCount;else if(typeof O=="function"?O=P[S]=$?[_,O]:[O,_]:$?O.unshift(_):O.push(_),R=u(v),R>0&&O.length>R&&!O.warned){O.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=v,Y.type=S,Y.count=O.length,r(Y)}return v}o.prototype.addListener=function(S,_){return c(this,S,_,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(S,_){return c(this,S,_,!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,S,_){var $={fired:!1,wrapFn:void 0,target:v,type:S,listener:_},R=l.bind($);return R.listener=_,$.wrapFn=R,R}o.prototype.once=function(S,_){return a(_),this.on(S,d(this,S,_)),this},o.prototype.prependOnceListener=function(S,_){return a(_),this.prependListener(S,d(this,S,_)),this},o.prototype.removeListener=function(S,_){var $,R,P,O,Y;if(a(_),R=this._events,R===void 0)return this;if($=R[S],$===void 0)return this;if($===_||$.listener===_)--this._eventsCount===0?this._events=Object.create(null):(delete R[S],R.removeListener&&this.emit("removeListener",S,$.listener||_));else if(typeof $!="function"){for(P=-1,O=$.length-1;O>=0;O--)if($[O]===_||$[O].listener===_){Y=$[O].listener,P=O;break}if(P<0)return this;P===0?$.shift():m($,P),$.length===1&&(R[S]=$[0]),R.removeListener!==void 0&&this.emit("removeListener",S,Y||_)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(S){var _,$,R;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[S]),this;if(arguments.length===0){var P=Object.keys($),O;for(R=0;R<P.length;++R)O=P[R],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(_=$[S],typeof _=="function")this.removeListener(S,_);else if(_!==void 0)for(R=_.length-1;R>=0;R--)this.removeListener(S,_[R]);return this};function f(v,S,_){var $=v._events;if($===void 0)return[];var R=$[S];return R===void 0?[]:typeof R=="function"?_?[R.listener||R]:[R]:_?g(R):p(R,R.length)}o.prototype.listeners=function(S){return f(this,S,!0)},o.prototype.rawListeners=function(S){return f(this,S,!1)},o.listenerCount=function(v,S){return typeof v.listenerCount=="function"?v.listenerCount(S):h.call(v,S)},o.prototype.listenerCount=h;function h(v){var S=this._events;if(S!==void 0){var _=S[v];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function p(v,S){for(var _=new Array(S),$=0;$<S;++$)_[$]=v[$];return _}function m(v,S){for(;S+1<v.length;S++)v[S]=v[S+1];v.pop()}function g(v){for(var S=new Array(v.length),_=0;_<S.length;++_)S[_]=v[_].listener||v[_];return S}function w(v,S){return new Promise(function(_,$){function R(O){v.removeListener(S,P),$(O)}function P(){typeof v.removeListener=="function"&&v.removeListener("error",R),_([].slice.call(arguments))}b(v,S,P,{once:!0}),S!=="error"&&y(v,R,{once:!0})})}function y(v,S,_){typeof v.on=="function"&&b(v,"error",S,_)}function b(v,S,_,$){if(typeof v.on=="function")$.once?v.once(S,_):v.on(S,_);else if(typeof v.addEventListener=="function")v.addEventListener(S,function R(P){$.once&&v.removeEventListener(S,R),_(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Po.exports}var bw=MC();function FC(){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 Ke=FC;typeof Object.assign=="function"&&(Ke=Object.assign);function Lt(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 tt(e){return typeof e=="object"&&e!==null}function ww(e){let t;for(t in e)return!1;return!0}function Nt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Gt(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 ap(e){return!(!tt(e)||e.attributes&&!Array.isArray(e.attributes))}function UC(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function tn(){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 Lr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Lf extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class Z extends Lf{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Z.prototype.constructor)}}class U extends Lf{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}class re extends Lf{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,re.prototype.constructor)}}function _w(e,t){this.key=e,this.attributes=t,this.clear()}_w.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 kw(e,t){this.key=e,this.attributes=t,this.clear()}kw.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Sw(e,t){this.key=e,this.attributes=t,this.clear()}Sw.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Pr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Pr.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)};Pr.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};Pr.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]};Pr.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 xw=0,Ew=1,GC=2,$w=3;function dn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===xw){if(a=e._nodes.get(r),!a)throw new U(`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 U(`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 U(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Ew?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function jC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);return s.attributes[a]}}function ZC(e,t,n){e.prototype[t]=function(r,i){const[o]=dn(this,t,n,r,i);return o.attributes}}function BC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function VC(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=dn(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 HC(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=dn(this,t,n,r,i,o,s);if(typeof c!="function")throw new Z(`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 qC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(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 WC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(!tt(a))throw new Z(`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 KC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(!tt(a))throw new Z(`Graph.${t}: provided attributes are not a plain object.`);return Ke(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function JC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(typeof a!="function")throw new Z(`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 YC=[{name:e=>`get${e}Attribute`,attacher:jC},{name:e=>`get${e}Attributes`,attacher:ZC},{name:e=>`has${e}Attribute`,attacher:BC},{name:e=>`set${e}Attribute`,attacher:VC},{name:e=>`update${e}Attribute`,attacher:HC},{name:e=>`remove${e}Attribute`,attacher:qC},{name:e=>`replace${e}Attributes`,attacher:WC},{name:e=>`merge${e}Attributes`,attacher:KC},{name:e=>`update${e}Attributes`,attacher:JC}];function XC(e){YC.forEach(function({name:t,attacher:n}){n(e,t("Node"),xw),n(e,t("Source"),Ew),n(e,t("Target"),GC),n(e,t("Opposite"),$w)})}function QC(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function eA(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new re(`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=Lt(this,o,s,n),!i)throw new U(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function tA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function nA(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new re(`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=Lt(this,a,u,n),!s)throw new U(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new re(`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 U(`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 rA(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new re(`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=Lt(this,a,u,n),!s)throw new U(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new Z(`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 iA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`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 oA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!tt(i))throw new Z(`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 sA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!tt(i))throw new Z(`Graph.${t}: provided attributes are not a plain object.`);return Ke(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function aA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new Z(`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 uA=[{name:e=>`get${e}Attribute`,attacher:QC},{name:e=>`get${e}Attributes`,attacher:eA},{name:e=>`has${e}Attribute`,attacher:tA},{name:e=>`set${e}Attribute`,attacher:nA},{name:e=>`update${e}Attribute`,attacher:rA},{name:e=>`remove${e}Attribute`,attacher:iA},{name:e=>`replace${e}Attributes`,attacher:oA},{name:e=>`merge${e}Attributes`,attacher:sA},{name:e=>`update${e}Attributes`,attacher:aA}];function cA(e){uA.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const lA=[{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 dA(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 fA(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 tu(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 hA(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 pA(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 mA(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 Tw(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 gA(e,t){if(e.size===0)return Lr();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 Pf(e,t,n,r,i,o){const s=t?fA:dA;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 yA(e,t,n,r){const i=[];return Pf(!1,e,t,n,r,function(o){i.push(o)}),i}function vA(e,t,n){let r=Lr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=tn(r,tu(n.in))),t!=="in"&&typeof n.out<"u"&&(r=tn(r,tu(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=tn(r,tu(n.undirected))),r}function Df(e,t,n,r,i,o,s){const a=n?pA:hA;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 bA(e,t,n,r,i){const o=[];return Df(!1,e,t,n,r,i,function(s){o.push(s)}),o}function wA(e,t,n,r){let i=Lr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=tn(i,nu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=tn(i,nu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=tn(i,nu(n.undirected,r))),i}function _A(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 mA(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new U(`Graph.${n}: could not find the "${o}" node in the graph.`);return yA(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 U(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new U(`Graph.${n}: could not find the "${s}" target node in the graph.`);return bA(r,this.multi,i,a,s)}throw new Z(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function kA(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,Tw(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new U(`Graph.${o}: could not find the "${c}" node in the graph.`);return Pf(!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 U(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new U(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Df(!1,r,this.multi,i,f,l,d)}throw new Z(`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,g,w,y,b,v)=>{d[h++]=l(p,m,g,w,y,b,v)})}else d=[],c.push((f,h,p,m,g,w,y)=>{d.push(l(f,h,p,m,g,w,y))});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,g,w,y)=>{l(f,h,p,m,g,w,y)&&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 Z(`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 Z(`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,g,w,y,b)=>{f=l(f,h,p,m,g,w,y,b)}),this[o].apply(this,c),f}}function SA(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,Tw(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new U(`Graph.${o}: could not find the "${u}" node in the graph.`);return Pf(!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 U(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new U(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Df(!0,r,this.multi,i,d,c,l)}throw new Z(`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,g,w)=>c(d,f,h,p,m,g,w)),!!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,g,w)=>!c(d,f,h,p,m,g,w)),!this[o].apply(this,u)}}function xA(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 Lr();if(!arguments.length)return gA(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new U(`Graph.${o}: could not find the "${s}" node in the graph.`);return vA(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new U(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new U(`Graph.${o}: could not find the "${a}" target node in the graph.`);return wA(r,i,u,a)}throw new Z(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function EA(e){lA.forEach(t=>{_A(e,t),kA(e,t),SA(e,t),xA(e,t)})}const $A=[{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 La(){this.A=null,this.B=null}La.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};La.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Gr(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 Of(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Gr(e,null,r,r.undirected,i);if(typeof n=="string")return Gr(e,null,r,r[n],i)}const o=new La;let s;if(t!=="undirected"){if(n!=="out"){if(s=Gr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Gr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Gr(e,o,r,r.undirected,i),e&&s))return s}function TA(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 Of(!1,e,t,n,function(i){r.push(i)}),r}function jr(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 CA(e,t,n){if(e!=="mixed"){if(e==="undirected")return jr(null,n,n.undirected);if(typeof t=="string")return jr(null,n,n[t])}let r=Lr();const i=new La;return e!=="undirected"&&(t!=="out"&&(r=tn(r,jr(i,n,n.in))),t!=="in"&&(r=tn(r,jr(i,n,n.out)))),e!=="directed"&&(r=tn(r,jr(i,n,n.undirected))),r}function AA(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 U(`Graph.${n}: could not find the "${o}" node in the graph.`);return TA(r==="mixed"?this.type:r,i,s)}}function IA(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 U(`Graph.${o}: could not find the "${c}" node in the graph.`);Of(!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 Z(`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 NA(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 U(`Graph.${s}: could not find the "${c}" node in the graph.`);return Of(!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 zA(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 Lr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new U(`Graph.${o}: could not find the "${s}" node in the graph.`);return CA(r==="mixed"?this.type:r,i,a)}}function RA(e){$A.forEach(t=>{AA(e,t),IA(e,t),NA(e,t),zA(e,t)})}function Do(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 LA(e,t){const n={key:e};return ww(t.attributes)||(n.attributes=Ke({},t.attributes)),n}function PA(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return ww(n.attributes)||(r.attributes=Ke({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function DA(e){if(!tt(e))throw new Z('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 Z("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!tt(e.attributes)||e.attributes===null))throw new Z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function OA(e){if(!tt(e))throw new Z('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 Z("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new Z("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!tt(e.attributes)||e.attributes===null))throw new Z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new Z("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const MA=UC(),FA=new Set(["directed","undirected","mixed"]),up=new Set(["domain","_events","_eventsCount","_maxListeners"]),UA=[{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"}],GA={allowSelfLoops:!0,multi:!1,type:"mixed"};function jA(e,t,n){if(n&&!tt(n))throw new Z(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new re(`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 cp(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 Cw(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new re(`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 re(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!tt(a))throw new Z(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new re(`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 U(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new U(`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 re(`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 re(`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 Pr(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 ZA(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new re(`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 re(`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 Z(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!tt(a))throw new Z(`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 re(`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 re(`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 y=[h.key,!1,!1,!1];if(u?!c:!a)return y;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Ke(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return y}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 re(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,g=!1;l||(l=cp(e,o,{}),m=!0,o===s&&(d=l,g=!0)),d||(d=cp(e,s,{}),g=!0),f=new Pr(r,i,l,d,a),e._edges.set(i,f);const w=o===s;return r?(l.undirectedDegree++,d.undirectedDegree++,w&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,w&&(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,g]}function Vn(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 Le extends bw.EventEmitter{constructor(t){if(super(),t=Ke({},GA,t),typeof t.multi!="boolean")throw new Z(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!FA.has(t.type))throw new Z(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new Z(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?_w:t.type==="directed"?kw:Sw;Nt(this,"NodeDataClass",n);const r="geid_"+MA()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Nt(this,"_attributes",{}),Nt(this,"_nodes",new Map),Nt(this,"_edges",new Map),Nt(this,"_directedSize",0),Nt(this,"_undirectedSize",0),Nt(this,"_directedSelfLoopCount",0),Nt(this,"_undirectedSelfLoopCount",0),Nt(this,"_edgeKeyGenerator",o),Nt(this,"_options",t),up.forEach(s=>Nt(this,s,this[s])),Gt(this,"order",()=>this._nodes.size),Gt(this,"size",()=>this._edges.size),Gt(this,"directedSize",()=>this._directedSize),Gt(this,"undirectedSize",()=>this._undirectedSize),Gt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Gt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Gt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Gt(this,"multi",this._options.multi),Gt(this,"type",this._options.type),Gt(this,"allowSelfLoops",this._options.allowSelfLoops),Gt(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 Z(`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 Z(`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 Z(`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 re("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 U(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 re("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 U(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 re("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 U(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return jA(this,t,n).key}mergeNode(t,n){if(n&&!tt(n))throw new Z(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ke(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 Z(`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 U(`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 Vn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Vn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Vn(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=Lt(this,r,i,this.type),!n)throw new U(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new U(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Vn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new re("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 re("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=Lt(this,t,n,"directed");if(!r)throw new U(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Vn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new re("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 re("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=Lt(this,t,n,"undirected");if(!r)throw new U(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Vn(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 Z("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(!tt(t))throw new Z("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(!tt(t))throw new Z("Graph.mergeAttributes: provided attributes are not a plain object.");return Ke(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new Z("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 Z("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!ap(n))throw new Z("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 Z("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!ap(n))throw new Z("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 Z("Graph.forEachAdjacencyEntry: expecting a callback.");Do(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Z("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Do(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new Z("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Do(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Z("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Do(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new Z("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 Z("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 Z("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 Z("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 Z("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 Z("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 Z("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Z("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++]=LA(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=PA(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 Le)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(!tt(t))throw new Z("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!tt(t.attributes))throw new Z("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 Z("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],DA(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 Z("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],OA(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 Le(Ke({},this._options,t));return n.replaceAttributes(Ke({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Ke({},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 re(`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 re("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 re("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,Cw(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Ke({},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)&&!up.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Nt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Le.prototype[Symbol.for("nodejs.util.inspect.custom")]=Le.prototype.inspect);UA.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?Cw:ZA;e.generateKey?Le.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Le.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});XC(Le);cA(Le);EA(Le);RA(Le);class Aw extends Le{constructor(t){const n=Ke({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new Z("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new Z('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Iw extends Le{constructor(t){const n=Ke({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new Z("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new Z('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Nw extends Le{constructor(t){const n=Ke({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class zw extends Le{constructor(t){const n=Ke({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new Z('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Rw extends Le{constructor(t){const n=Ke({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new Z('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Dr(e){e.from=function(t,n){const r=Ke({},t.options,n),i=new e(r);return i.import(t),i}}Dr(Le);Dr(Aw);Dr(Iw);Dr(Nw);Dr(zw);Dr(Rw);Le.Graph=Le;Le.DirectedGraph=Aw;Le.UndirectedGraph=Iw;Le.MultiGraph=Nw;Le.MultiDirectedGraph=zw;Le.MultiUndirectedGraph=Rw;Le.InvalidArgumentsGraphError=Z;Le.NotFoundGraphError=U;Le.UsageGraphError=re;function BA(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 Yr(e){var t=BA(e,"string");return typeof t=="symbol"?t:t+""}function dt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lp(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,Yr(r.key),r)}}function ft(e,t,n){return t&&lp(e.prototype,t),n&&lp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function cr(e){return cr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},cr(e)}function Lw(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lw=function(){return!!e})()}function VA(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function HA(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 VA(e)}function Mt(e,t,n){return t=cr(t),HA(e,Lw()?Reflect.construct(t,n||[],cr(e).constructor):t.apply(e,n))}function Zu(e,t){return Zu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Zu(e,t)}function Ft(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&&Zu(e,t)}function qA(e){if(Array.isArray(e))return e}function WA(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 Bu(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 Pw(e,t){if(e){if(typeof e=="string")return Bu(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)?Bu(e,t):void 0}}function KA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
111
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lr(e,t){return qA(e)||WA(e,t)||Pw(e,t)||KA()}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"},Dw=new Int8Array(4),Ho=new Int32Array(Dw.buffer,0,1),Ow=new Float32Array(Dw.buffer,0,1),JA=/^\s*rgba?\s*\(/,YA=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function XA(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(JA.test(e)){var o=e.match(YA);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 Jn={};for(var Oo in ru)Jn[Oo]=En(ru[Oo]),Jn[ru[Oo]]=Jn[Oo];function Mw(e,t,n,r,i){return Ho[0]=r<<24|n<<16|t<<8|e,Ho[0]=Ho[0]&4278190079,Ow[0]}function En(e){if(e=e.toLowerCase(),typeof Jn[e]<"u")return Jn[e];var t=XA(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=Mw(n,r,i,o);return Jn[e]=s,s}function QA(e,t){Ow[0]=En(e);var n=Ho[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var iu={};function Fw(e){if(typeof iu[e]<"u")return iu[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Mw(t,n,r,i);return iu[e]=o,o}function dp(e,t,n,r){return n+(t<<8)+(e<<16)}function fp(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=lr(u,4),l=c[0],d=c[1],f=c[2],h=c[3];return[l,d,f,h]}function N(e,t,n){return(t=Yr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hp(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hp(Object(n),!0).forEach(function(r){N(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function eI(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=cr(e))!==null;);return e}function Vu(){return Vu=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=eI(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Vu.apply(null,arguments)}function Uw(e,t,n,r){var i=Vu(cr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function tI(e){return e.normalized?1:e.size}function ou(e){var t=0;return e.forEach(function(n){return t+=tI(n)}),t}function Gw(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:Un().optional(),permissions:Un().optional()});T({mimeTypes:oe(E()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});T({method:x("ui/download-file"),params:T({contents:oe(ge([Db,Ob])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});T({method:x("ui/message"),params:T({role:x("user").describe('Message role, currently only "user" is supported.'),content:oe(ho).describe("Message content blocks (text, image, etc.).")})});T({method:x("ui/notifications/sandbox-resource-ready"),params:T({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:Sf.optional().describe("CSP configuration from resource metadata."),permissions:Ef.optional().describe("Sandbox permissions from resource metadata.")})});var e$=T({method:x("ui/notifications/tool-result"),params:Na.describe("Standard MCP tool execution result.")}),Bb=T({toolInfo:T({id:so.optional().describe("JSON-RPC id of the tools/call request."),tool:kf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:M0.optional().describe("Current color theme preference."),styles:W0.optional().describe("Style configuration for theming the app."),displayMode:ii.optional().describe("How the UI is currently displayed."),availableDisplayModes:oe(ii).optional().describe("Display modes the host supports."),containerDimensions:ge([T({height:de().describe("Fixed container height in pixels.")}),T({maxHeight:ge([de(),or()]).optional().describe("Maximum container height in pixels.")})]).and(ge([T({width:de().describe("Fixed container width in pixels.")}),T({maxWidth:ge([de(),or()]).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:ge([x("web"),x("desktop"),x("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Ne().optional().describe("Whether the device supports touch input."),hover:Ne().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:T({top:de().describe("Top safe area inset in pixels."),right:de().describe("Right safe area inset in pixels."),bottom:de().describe("Bottom safe area inset in pixels."),left:de().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),t$=T({method:x("ui/notifications/host-context-changed"),params:Bb.describe("Partial context update containing only changed fields.")});T({method:x("ui/update-model-context"),params:T({content:oe(ho).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:be(E(),Ae().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});T({method:x("ui/initialize"),params:T({appInfo:Aa.describe("App identification (name and version)."),appCapabilities:Y0.describe("Features and capabilities this app provides."),protocolVersion:E().describe("Protocol version this app supports.")})});var n$=T({protocolVersion:E().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Aa.describe("Host application identification and version."),hostCapabilities:J0.describe("Features and capabilities provided by the host."),hostContext:Bb.describe("Rich context about the host environment.")}).passthrough(),r$={target:"draft-2020-12"};async function Rh(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](r$);if(n.vendor==="zod"){let{z:r}=await w_(()=>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 zh(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 i$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function o$(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 xf extends P0{_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:B0,toolinputpartial:V0,toolresult:e$,toolcancelled:H0,hostcontextchanged:t$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!xf.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||Ye({jitless:!0}),this.setRequestHandler(Ia,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=L0(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 zh(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 zh(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 Rh(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await Rh(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(K0,(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(Fb,(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(Mb,(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},Na,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Pb,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Lb,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?jb:Gb;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},Z0,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},af,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},G0,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},j0,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},X0,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 Zb(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:D0}},n$,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 Vb=new Map;function s$(e,t){Vb.set(e,t)}function Lh(e){return Vb.get(e)??null}const a$=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function u$(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 a$.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const c$="http://www.w3.org/2000/svg";let l$=0;function To(e){return Math.round(e*10)/10}function d$(e,t,n={}){const r=e.createElementNS(c$,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function Ph(e,t,n,r){const i=`cia-graph-svg-${++l$}`,o=e.ownerDocument,s=(M,G)=>d$(o,M,G),a=(M,G,B)=>{const ee=s("text",{x:0,y:G,"text-anchor":"middle",class:B,"pointer-events":"none"});return ee.textContent=M,ee},{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":""}),g=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(g,w),l.append(d,h,p,m),e.append(l);const y=new Map,b=new Map,v=new Map;let S=null;function _(){if(S)return S;const M=t.model(),G=t.positions(),B=new Map;S=B;const ee=M.nodes.length>eT,X=new Map(M.nodes.map(q=>[q.address,q])),V=ee?[]:V$(M,G,t.notes());for(const q of M.edges){const W=X.get(q.from),Ee=X.get(q.to),Ie=W&&G[W.id],je=Ee&&G[Ee.id];if(!W||!Ee||!Ie||!je){B.set(q.id,null);continue}if(ee){B.set(q.id,zu(Ie,je,Pn(W,M.checked_address),Pn(Ee,M.checked_address)));continue}const st=V.filter(et=>et.id!==W.id&&et.id!==Ee.id);B.set(q.id,tT(Ie,je,Pn(W,M.checked_address),Pn(Ee,M.checked_address),st))}return B}function $(M){let G=y.get(M);if(G)return G;G=`${i}-arrow-${y.size}`;const B=s("marker",{id:G,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),ee=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return ee.style.fill=M,B.append(ee),d.append(B),y.set(M,G),G}function z(){return[...t.model().nodes??[]].sort((M,G)=>String(M.id).localeCompare(String(G.id)))}function P(){S=null;const M=t.model();g.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const G=new Map(M.nodes.map(B=>[B.address,B]));for(const B of M.edges){const ee=G.get(B.from);if(!ee||!G.get(B.to))continue;const X=t.colorOf(ee),V=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Mu(B,t.now())});V.dataset.edgeId=B.id,V.style.setProperty("--edge-tone",X);const q=rT(),W=s("path",{class:"cia-graph-edge-hit","stroke-width":q.hit.width,"pointer-events":"stroke"}),Ee=s("path",{class:"cia-graph-edge-line","stroke-width":q.line.width,"marker-end":`url(#${$(X)})`,"pointer-events":"none"});V.append(W,Ee),V.addEventListener("keydown",Ie=>{Zh(Ie.key)&&(Ie.preventDefault(),n.selectEdge(B.id,"keyboard"))}),V.addEventListener("pointerenter",Ie=>n.showTooltip(Ie,Mu(B,t.now()))),V.addEventListener("pointerleave",()=>n.hideTooltip()),g.append(V),v.set(B.id,{group:V,hit:W,line:Ee})}for(const B of z())w.append(O(B));he(),$e()}function O(M){const G=t.model(),B=M.address===G.checked_address,ee=t.notes().get(M.id),X=zr(M,G.checked_address,ee),V=X.radius,q=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":Ou(M),"aria-pressed":"false"});q.dataset.nodeId=M.id,B&&(q.dataset.checked=""),q.style.setProperty("--node-tone",t.colorOf(M)),B&&q.append(s("circle",{class:"cia-graph-node-ring",r:V+6})),q.append(s("circle",{class:"cia-graph-node-body",r:V})),q.append(s("circle",{class:"cia-graph-node-dot",r:X.dot}));for(const W of X.texts)q.append(a(W.text,W.y,`cia-graph-node-${W.kind}`));ee&&(q.dataset.state="refused");for(const W of t.flags().get(M.id)??[])q.setAttribute(`data-flag-${W}`,"");return q.addEventListener("keydown",W=>{Zh(W.key)&&(W.preventDefault(),n.selectNode(M.id,"keyboard"))}),q.addEventListener("pointerenter",W=>n.showTooltip(W,Ou(M))),q.addEventListener("pointerleave",()=>n.hideTooltip()),b.set(M.id,q),q}function Y(){const M=t.transform();m.setAttribute("transform",`translate(${M.x} ${M.y}) scale(${M.scale})`)}function he(){Y();const M=t.positions(),{width:G,height:B}=t.dimensions();for(const[X,V]of b){const q=M[X]??{x:G/2,y:B/2};V.setAttribute("transform",`translate(${To(q.x)} ${To(q.y)})`)}const ee=_();for(const X of t.model().edges){const V=v.get(X.id);if(!V)continue;const q=ee.get(X.id)??null;V.group.style.display=q?"":"none",q&&(V.hit.setAttribute("d",q.d),V.line.setAttribute("d",q.d))}}function Se(M){const G=t.model(),B=t.positions(),ee=B[M],X=b.get(M);if(!ee||!X)return;X.setAttribute("transform",`translate(${To(ee.x)} ${To(ee.y)})`);const V=G.nodes.find(W=>W.id===M);if(!V)return;const q=new Map(G.nodes.map(W=>[W.address,W]));for(const W of G.edges){if(W.from!==V.address&&W.to!==V.address)continue;const Ee=v.get(W.id),Ie=q.get(W.from),je=q.get(W.to),st=Ie&&B[Ie.id],et=je&&B[je.id];if(!Ee||!Ie||!je||!st||!et)continue;const L=zu(st,et,Pn(Ie,G.checked_address),Pn(je,G.checked_address));Ee.group.style.display=L?"":"none",L&&(Ee.hit.setAttribute("d",L.d),Ee.line.setAttribute("d",L.d))}}function $e(){const M=t.model(),G=t.selected(),B=t.highlighted(),ee=G?.kind==="node"?M.nodes.find(X=>X.id===G.id)?.address??null:null;for(const X of M.edges){const V=v.get(X.id);if(!V)continue;const q=G?.kind==="edge"&&G.id===X.id,W=G?.kind==="edge"?q?Wt.related:Wt.faded:Jb(X,ee),Ee=W===Wt.faded;V.group.setAttribute("opacity",Ee?String(W):"1"),V.line.setAttribute("stroke-opacity",Ee?"1":String(W)),V.group.dataset.opacity=String(W),V.group.dataset.state=W===Wt.rest?"rest":W===Wt.related?"related":"faded",V.group.setAttribute("aria-pressed",String(q))}for(const[X,V]of b){const q=G?.kind==="node"&&G.id===X;V.classList.toggle("is-selected",q),V.classList.toggle("is-focused",B===X),V.setAttribute("aria-pressed",String(q))}}function Fe(){let M=null;for(const G of _().values())G?.bounds&&(M=M??{...G.bounds},M.x1=Math.min(M.x1,G.bounds.x1),M.y1=Math.min(M.y1,G.bounds.y1),M.x2=Math.max(M.x2,G.bounds.x2),M.y2=Math.max(M.y2,G.bounds.y2));return M}return{kind:"svg",surface:l,build:P,geometry(){S=null,he()},moveNode:Se,endMove(){S=null,he()},camera:Y,selection:$e,flag(M,G,B){b.get(M)?.toggleAttribute(`data-flag-${G}`,B)},theme(){for(const M of t.model().nodes)b.get(M.id)?.style.setProperty("--node-tone",t.colorOf(M))},resize(M,G){l.setAttribute("viewBox",`0 0 ${M} ${G}`)},pick:()=>null,linkBounds:Fe,destroy(){l.remove()}}}const f$=.45,h$=2.5,p$=5,m$="chain-insights.flows.v1",$f="cia-graph-model",g$=90,Wt={rest:.6,related:.95,faded:.07},Dh={checked:24,other:19},oi=16,y$=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],po=["exchange","scam","sanctioned","victim","pool","other"],v$={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},Hb={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Tf(e){return!!e&&e.schema===m$}function b$(e){return!!e&&e.kind===$f}function qe(e){return String(e??"").trim().toLowerCase()}function w$(e){const t=qe(e);return po.includes(t)?t:"other"}function hn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Nu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function _$(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function zt(e){return b$(e)?e:Tf(e)?k$(e):E$(e)}function k$(e){const t=qe(e.center),n=new Map;for(const a of e.nodes??[]){const u=qe(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=qe(a?.from),c=qe(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:hn(a.usd),tx_count:hn(a.tx_count),first_seen_timestamp:hn(a.first_seen_ms),last_seen_timestamp:hn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=S$(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:Nu(u.labels),taxonomy:[],role:w$(u.role),total_in_usd:hn(u.total_in_usd),total_out_usd:hn(u.total_out_usd),degree_in:hn(u.degree_in),degree_out:hn(u.degree_out)}});return{kind:$f,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function S$(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 g of d.get(m)??[])f.has(g)||(f.set(g,(f.get(m)??0)+1),p.push(g));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 E$(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":_$(r.direction),labels:Nu(r.labels),taxonomy:Nu(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:$f,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function x$(e,t,n){const r=zt(t),i=Ln(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[qe(d.address),d])),a=[];for(const d of r.nodes){if(s.has(qe(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(qe(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${qe(d.from)}->${qe(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${qe(d.from)}->${qe(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(qe(d.from))||!s.has(qe(d.to)))continue;const h=s.get(qe(d.from)).address,p=s.get(qe(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 Ln(e,t){if(t==null)return null;const n=qe(t);return e.nodes.find(i=>i.id===t||qe(i.address)===n)?.id??null}function si(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Cf(e){return String(e??"").trim().replace(/\s+/g," ")}function is(e){return Cf(e).replaceAll(" ","").toLowerCase()}function wn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Cf(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Co(e,t){const n=new Set(wn(e).map(is));return t.some(r=>n.has(is(r)))}function $$(e){if(e.role&&po.includes(e.role))return v$[e.role];if(Co(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Co(e,["Victim","Targeted"]))return"target";if(Co(e,["OnMoneyTrail","Mixer"]))return"trail";if(Co(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 He(e){return`var(--cia-graph-${e})`}const T$={semantic:{danger:{stroke:He("danger"),fill:He("node")},target:{stroke:He("target"),fill:He("node")},trail:{stroke:He("trail"),fill:He("node")},infrastructure:{stroke:He("infrastructure"),fill:He("node")},neutral:{stroke:He("neutral"),fill:He("node")}},risk:{CRITICAL:{stroke:He("critical"),fill:He("node")},HIGH:{stroke:He("high"),fill:He("node")},MEDIUM:{stroke:He("medium"),fill:He("node")},LOW:{stroke:He("low"),fill:He("node")}}};function C$(e,t=T$){const n=$$(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function A$(e){return e.role&&po.includes(e.role)?He(`role-${e.role}`):C$(e).stroke}function mo(e){if(e.role&&e.role!=="other"&&po.includes(e.role))return Hb[e.role];const t=wn(e);for(const[r,i]of y$)if(t.some(o=>is(o)===is(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Cf).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function Ru(e){return Math.min(h$,Math.max(f$,e))}function Ra(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Af(e,t=Ra(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Oh(e,t){return e.address===t?43:e.hop>=2?25:30}function Pn(e,t){return e.address===t?Dh.checked:Dh.other}function zr(e,t,n){const r=e.address===t,i=Pn(e,t),o=mo(e),s=[];return o&&s.push({kind:"role",text:yT(o),y:i+17}),s.push({kind:"address",text:si(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 I$={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},Ha=2;function If(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=I$[r.kind],o=[...r.text].length*i.size*i.advance/2+Ha;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-Ha,x2:o,y2:r.y+i.size*.25+Ha}})}return n}function qb(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 Wb(e){return qb(If(e).map(t=>t.box))}const Nf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function N$(e,t,n){const r=zt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of If(zr(o,r.checked_address,Nf(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 R$(e,t,n){return qb(N$(e,t,n))}function z$(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function L$(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function P$(e,t,n){const r=zt(e),i={x:t/2,y:n/2},o={},s=Ra(r),a=Af(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const c of s){if(c.id===a.id)continue;let l=c.direction==="IN"?-1:1;c.direction==="MIXED"&&(l=L$(c.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(c.hop)||1)),f=`${l}:${d}`;u.has(f)||u.set(f,[]),u.get(f).push(c)}for(const[c,l]of u){const[d,f]=c.split(":"),h=Number(d),p=Number(f),m=i.x+h*(p===1?t*.23:t*.43);Object.assign(o,D$(l,m,i.y,r.checked_address))}return o}function D$(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=>Wb(zr(u,r)),a=(u,c)=>Math.max(Oh(u,r)+Oh(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 O$(e,t,n){const r=zt(e),i={x:t/2,y:n/2},o={},s=Ra(r),a=Af(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),f=c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function M$(e,t,n,r){const i=zt(e),o=Ra(i).filter(u=>t[u.id]),s=o.find(u=>u.address===i.checked_address);for(let u=0;u<o.length;u++)for(let c=u+1;c<o.length;c++){const l=o[u],d=o[c],f=l&&t[l.id],h=d&&t[d.id];if(!f||!h)continue;const p=h.x-f.x||.1,m=h.y-f.y||.1,g=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-g)*.012;f.x-=p/g*w,f.y-=m/g*w,h.x+=p/g*w,h.y+=m/g*w}const a=new Map(o.map(u=>[u.address,u]));for(const u of i.edges){const c=a.get(u.from),l=a.get(u.to);if(!c||!l)continue;const d=t[c.id],f=t[l.id];if(!d||!f)continue;const h=f.x-d.x,p=f.y-d.y,m=Math.max(1,Math.hypot(h,p)),g=(m-155)*.003;c!==s&&(d.x+=h/m*g,d.y+=p/m*g),l!==s&&(f.x-=h/m*g,f.y-=p/m*g)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function F$(e,t,n,r=g$){const i=zt(e),o=O$(i,t,n);for(let s=0;s<r;s++)M$(i,o,t,n);return o}function Ao(e,t,n,r){return t==="tree"?P$(e,n,r):F$(e,n,r)}function U$(e,t,n,r,i={}){const o=zt(e),s=t[n],a={...t};if(!s)return a;const u=i.spacing??80,c=i.gap??48,l=Math.max(1,i.perColumn??6),d=o.nodes.find(y=>y.id===n),f=new Map(o.nodes.map(y=>[y.id,y])),h=y=>Wb(zr(y,o.checked_address,Nf(i.notes,y.id))),p=o.nodes.flatMap(y=>{const b=t[y.id];if(!b)return[];const v=h(y);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(y=>y.x1)):s.x,g=p.length?Math.max(...p.map(y=>y.x2)):s.x;const w={left:[],right:[]};for(const y of[...r].sort()){const b=f.get(y);if(!b||a[y])continue;const v=o.edges.some(_=>_.from===b.address&&_.to===d?.address),S=o.edges.some(_=>_.to===b.address&&_.from===d?.address);w[v&&!S?"left":"right"].push(b)}for(const y of["left","right"]){const b=w[y];for(let v=0;v<b.length;v+=l){const S=b.slice(v,v+l),_=S.map(h),$=Math.max(..._.map(O=>Math.max(-O.x1,O.x2))),z=Math.max(u,Math.max(..._.map(O=>O.y2))-Math.min(..._.map(O=>O.y1))+6),P=y==="left"?m-c-$:g+c+$;S.forEach((O,Y)=>{a[O.id]={x:P,y:s.y+(Y-(S.length-1)/2)*z}}),y==="left"?m=P-$:g=P+$}}return a}function G$(e,t,n,r=oi){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=Ru(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 Mh(e,t,n,r=oi){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function j$(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 yn(e){return Math.round(e*100)/100}function qa(e,t,n,r,i){const o=s=>`${yn(s.x)},${yn(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function zu(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 qa("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 qa("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),g=Math.max(m*.45,Math.min(40,m));return qa("vertical",h,{x:h.x,y:h.y+f*g},{x:p.x,y:p.y-f*g},p)}const c=j$(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${yn(l.x)},${yn(l.y)} L${yn(d.x)},${yn(d.y)}`}}const Z$=6,Wa=Z$+3,qt=14,Fh=10,B$=3,Uh=6;function V$(e,t,n){const r=zt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of If(zr(o,r.checked_address,Nf(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 H$(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 q$(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 W$(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 K$(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 Kb(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 J$(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(Kb(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(W$(r.points,s))}}return n}function Gh(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 J$(e,B$))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)&&H$(a,l)<r)return!1}return!0}function Y$(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(Kb(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(qt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},g={x:(c.x-u.x)/d,y:(c.y-u.y)/d},w={x:u.x-m.x*p,y:u.y-m.y*p},y={x:u.x+g.x*p,y:u.y+g.y*p};i.push({kind:"L",points:[o,w]}),i.push({kind:"C",points:[w,{x:w.x+m.x*p*.55,y:w.y+m.y*p*.55},{x:y.x-g.x*p*.55,y:y.y-g.y*p*.55},y]}),o=y}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 X$(e){const t=i=>`${yn(i.x)},${yn(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 jh(e,t,n,r,i){const o=Math.min(e.y,n)-qt,s=Math.max(e.y,n)+qt,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 Q$(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 eT=120;function tT(e,t,n,r,i,o=4){const s=zu(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>q$(f,Wa));if(Gh(K$(s),i,a,Wa))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<Uh?e.y:Math.abs(f-t.y)<Uh?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-qt-1)),u.add(c(Math.round(f.y2)+qt+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},g=[];for(const w of u){const y=Math.abs(w-p.y)<.01?p.x:jh(p,f,w,qt,a);if(y===null)continue;const b=Math.abs(w-m.y)<.01?m.x:jh(m,-h,w,qt+Fh,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-y)*h<qt+Fh||Math.abs(w-p.y)<.01&&(b-p.x)*f<qt)continue;const v=Q$([p,{x:y,y:p.y},{x:y,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!nT(v,a))continue;let S=(v.length-2)*qt,_;for(const $ of v)_&&(S+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;g.push({points:v,length:S})}g.sort((w,y)=>{const b=w.points[2]?.y,v=y.points[2]?.y;return w.length-y.length||(b===void 0||v===void 0?0:b-v)});for(const w of g){const y=Y$(w.points);if(!Gh(y,i,a,Wa))continue;const b=w.points,v=b[0],S=b[b.length-1];if(!v||!S)continue;const _={x1:Math.min(...b.map($=>$.x)),y1:Math.min(...b.map($=>$.y)),x2:Math.max(...b.map($=>$.x)),y2:Math.max(...b.map($=>$.y))};return{kind:"routed",start:v,end:S,controls:null,d:X$(y),bounds:_}}}return s}function nT(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(z$(i,o))return!1}n=r}return!0}function Jb(e,t){if(!t)return Wt.rest;const n=qe(t);return qe(e.from)===n||qe(e.to)===n?Wt.related:Wt.faded}function rT(){return{hit:{stroke:"transparent",width:16},line:{stroke:He("edge"),width:1.6},arrow:{fill:He("edge")}}}function iT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function oT(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 sT(e,t,n,r=p$){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 aT(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:"select-checked"}:null}function Zh(e){return e==="Enter"||e===" "}function uT(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function cT(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=uT(r,i),!0)}function lT(e,t){return e?.pointerId===t?null:e}function dT(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 fT(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 g=p?.closest?.("[data-edge-id]");return g?{kind:"edge",id:g.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=oT(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[g,w]=[...r.values()];g&&w&&(s={distance:Math.hypot(w.x-g.x,w.y-g.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,g]=[...r.values()];m&&g&&t.pinch(s,[m,g],h);return}if(i?.pointerId===h.pointerId){if(i=sT(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=aT(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 hT(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 Yb(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Lu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Pu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function vn(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 Xb(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 Du(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Lu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function pT(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Lu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Lu(e.total_out_usd)]];return e.role&&po.includes(e.role)?[["Role",Hb[e.role]||"Other"],...t,["Senders",Pu(e.degree_in)],["Receivers",Pu(e.degree_out)],["Labels",wn(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Yb(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",vn(e.first_activity_timestamp)],["Last activity (UTC)",vn(e.last_activity_timestamp)],["Labels",wn(e).join(", ")||"No labels"]]}function mT(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Du(e)],["Transfers",Pu(e.tx_count)],["First seen (UTC)",vn(e.first_seen_timestamp)],["Last seen (UTC)",vn(e.last_seen_timestamp)],["Since last seen",Xb(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)",Du(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)",vn(e.first_seen_timestamp)],["Last seen (UTC)",vn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function Qb(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function Ou(e){const t=mo(e);if(e.role)return`${e.address}. ${t||"Other"}.${wn(e).length?` Labels: ${wn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Yb(e.risk_level)} risk`,r=wn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Mu(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Du(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Xb(e.last_seen_timestamp,t)}.`:n}function gT(e,t){return zt(e).nodes.map(n=>{const r={id:n.address,label:wn(n).join(", ")||mo(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function yT(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function vT(e,t,n={}){const r=e.ownerDocument;let i=zt(t),o=n.layout??(Tf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Ao(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=C=>n.nodeStyle?.(C).stroke??A$(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const g={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,R)=>G(C,R),selectEdge:(C,R)=>B(C,R),showTooltip:(C,R)=>W(C,R),hideTooltip:()=>Ee(),lost:()=>ue()};function y(C){const R=C==="webgl"?Lh("webgl"):null;if(R)try{return R(e,g,w,{label:n.label})}catch{}return Ph(e,g,w,{label:n.label})}const b=n.renderer??(Lh("webgl")&&u$(r)?"webgl":"svg");let v=y(b);e.dataset.renderer=v.kind;const S=()=>{const C=R$(i,a,u);if(!C)return null;const R=v.linkBounds();return R&&(C.x1=Math.min(C.x1,R.x1),C.y1=Math.min(C.y1,R.y1),C.x2=Math.max(C.x2,R.x2),C.y2=Math.max(C.y2,R.y2)),C},_=()=>{const C=S();return C?G$(C,s.width,s.height,oi):{x:0,y:0,scale:1}};l=_();const $=r.createElement("div");$.className="graph-tooltip cia-graph-tooltip",$.hidden=!0,$.setAttribute("role","tooltip"),e.append($);let z=0,P=!1,O=!1;function Y(){if(z){P=!0;return}v.build()}function he(){if(z){O=!0;return}l=_(),Se()}function Se(){v.camera()}function $e(C="program"){const R=gT(i,n.href),te=d?.kind==="node"?i.nodes.find(ce=>ce.id===d.id)??null:null,ve=d?.kind==="edge"?i.edges.find(ce=>ce.id===d.id)??null:null;if(te){const ce=i.edges.filter(ut=>ut.from===te.address||ut.to===te.address);return{kind:"node",id:te.id,selectedId:te.address,nodes:R,title:"Selected address",identity:te.address,values:pT(te),related:ce,node:te,edge:null,source:C}}return ve?{kind:"edge",id:ve.id,selectedId:null,nodes:R,title:"Selected aggregate flow",identity:`${ve.from} → ${ve.to}`,values:mT(ve,p()),related:[ve],node:null,edge:ve,source:C}:{kind:null,id:null,selectedId:null,nodes:R,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Fe(C){const R=$e(C);M(R),n.onSelect?.(R)}function M(C){const R=n.selectionRoot,te=R?.querySelector("[data-selection-title]"),ve=R?.querySelector("[data-selection-identity]"),ce=R?.querySelector("[data-selection-meta]");!te||!ve||!ce||(te.textContent=C.title,ve.textContent=C.identity,ce.replaceChildren(...C.values.map(([ut,At])=>{const Ut=r.createElement("div");Ut.className="meta-item",At!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(ut)&&Ut.classList.add("meta-item--identity"),ut==="Incoming amount (USD)"&&Ut.classList.add("meta-item--incoming"),ut==="Outgoing amount (USD)"&&Ut.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(ut)&&Ut.classList.add("meta-item--wide");const Or=r.createElement("span");Or.textContent=ut;const $n=r.createElement("strong"),fn=["First transaction","Last transaction"].includes(ut)?Qb(At):null;if(fn&&n.openLink){const D=n.openLink,ie=r.createElement("button");ie.type="button",ie.className="cia-graph-explorer-link",ie.dataset.explorer=fn,ie.textContent=At,ie.setAttribute("aria-label",`${ut}: ${At} (opens the explorer)`),ie.addEventListener("click",()=>D(fn)),$n.append(ie)}else if(fn){const D=r.createElement("a");D.href=fn,D.target="_blank",D.rel="noopener noreferrer",D.textContent=At,D.setAttribute("aria-label",`${ut}: ${At} (opens in new tab)`),$n.append(D)}else $n.textContent=At;return Ut.append(Or,$n),Ut})))}function G(C,R="program"){d=C?{kind:"node",id:C}:null,v.selection(),Fe(R)}function B(C,R="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Fe(R)}function ee(C){if(C==null)return G(null);const R=Ln(i,C);if(R)return G(R);if(i.edges.some(te=>te.id===C))return B(C)}function X(){l=_(),Se()}function V(C,R={x:s.width/2,y:s.height/2}){const te=Ru(l.scale*(1+C)),ve=te/l.scale;l={x:R.x-(R.x-l.x)*ve,y:R.y-(R.y-l.y)*ve,scale:te},Se()}function q(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(R=>{R.classList.toggle("active",R.dataset.layout===C),R.setAttribute("aria-pressed",String(R.dataset.layout===C))}),n.onLayoutChange?.(C),a=Ao(i,o,s.width,s.height),v.geometry(),X()}function W(C,R){$.textContent=R,$.hidden=!1;const te=e.getBoundingClientRect();$.style.left=`${Math.min(te.width-330,Math.max(8,C.clientX-te.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-te.top+12)}px`}function Ee(){$.hidden=!0}function Ie(C){return dT({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const je={point:Ie,transform:()=>l,select(C){C.type==="select-node"?G(C.id,"pointer"):C.type==="select-edge"?B(C.id,"pointer"):G(Af(i)?.id??null,"canvas")},drag(C,R,te){!h&&(h=iT(o,C,R),!h)||cT(a,h,R,te,l)&&(st=!0,v.moveNode(h.id))},endDrag(C){const R=h?.pointerId===C&&st;h=lT(h,C),R&&(st=!1,v.endMove())},pan(C,R){l={x:C.transform.x+R.x-C.point.x,y:C.transform.y+R.y-C.point.y,scale:l.scale},Se()},startPinch(){h=null},pinch(C,[R,te]){const ve=Math.hypot(te.x-R.x,te.y-R.y),ce=Ru(C.scale*ve/Math.max(1,C.distance));V(ce/l.scale-1,{x:(R.x+te.x)/2,y:(R.y+te.y)/2})}};let st=!1;const et=C=>{C.preventDefault(),V(C.deltaY>0?-.12:.12,Ie(C))},L={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},F=C=>{if(C.target!==v.surface)return;const R=L[C.key];R?(C.preventDefault(),l={...l,x:l.x+R[0],y:l.y+R[1]},Se()):C.key==="+"||C.key==="="?V(.18):C.key==="-"?V(-.18):C.key==="0"&&X()};let H=()=>{};function J(){const C=v.surface,R=te=>v.pick(Ie(te));H=fT(C,je,v.kind==="svg"?void 0:R),C.addEventListener("wheel",et,{passive:!1}),C.addEventListener("keydown",F)}function me(){H(),v.surface.removeEventListener("wheel",et),v.surface.removeEventListener("keydown",F)}J();function ue(){v.kind!=="svg"&&(me(),v.destroy(),v=Ph(e,g,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),J(),Y())}const we=n.controls?.querySelector("[data-expand]")??null,xe=n.panel&&we?hT(n.panel,we,r.body):null,ae=()=>{xe?.toggle(),n.onExpansionChange?.(xe?.isOpen()??!1),requestAnimationFrame(X)},Q=n.panel??e,Ge=C=>{if(C.key==="Tab"&&xe?.isOpen()&&n.panel){const R=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(ce=>ce.checkVisibility()),te=R[0],ve=R.at(-1);C.shiftKey&&r.activeElement===te?(C.preventDefault(),ve?.focus()):!C.shiftKey&&r.activeElement===ve&&(C.preventDefault(),te?.focus())}if(C.key==="Escape"){if(xe?.isOpen()){xe.close(),n.onExpansionChange?.(!1),requestAnimationFrame(X);return}G(null,"keyboard")}};Q.addEventListener("keydown",Ge);const at=[],Ze=(C,R)=>{C&&(C.addEventListener("click",R),at.push([C,R]))};n.controls?.querySelectorAll("[data-layout]").forEach(C=>Ze(C,()=>q(C.dataset.layout==="tree"?"tree":"gravity"))),Ze(n.controls?.querySelector("[data-zoom='in']"),()=>V(.18)),Ze(n.controls?.querySelector("[data-zoom='out']"),()=>V(-.18)),Ze(n.controls?.querySelector("[data-zoom='fit']"),X),xe&&Ze(we,ae);const Be=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,R=e.clientHeight;!C||!R||C===s.width&&R===s.height||(s.width=C,s.height=R,v.resize(C,R),X())});Be?.observe(e),Y(),n.selected&&ee(n.selected);const ht={update(C){const R=a;i=zt(C);const te=i.nodes.every(ce=>R[ce.id])?{}:Ao(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(ce=>[ce.id,R[ce.id]??te[ce.id]]).filter(([,ce])=>ce)),d&&!(d.kind==="node"?i.nodes.some(ce=>ce.id===d.id):i.edges.some(ce=>ce.id===d.id))&&(d=null),f&&!i.nodes.some(ce=>ce.id===f)&&(f=null);const ve=new Set(i.nodes.map(ce=>ce.id));for(const ce of[...c.keys()])ve.has(ce)||c.delete(ce);Y(),he()},merge(C,R){const te=x$(i,C,R);i=te.model;const ve=Ln(i,R??zt(C).checked_address);return a=ve?U$(i,a,ve,te.added,{notes:u}):{...a,...Ao(i,o,s.width,s.height),...a},Y(),te.added.length&&he(),te.added},batch(C){z++;try{C()}finally{z--,!z&&P&&(P=!1,v.build()),!z&&O&&(O=!1,l=_(),Se())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:ee,destroy(){Be?.disconnect(),me(),Q.removeEventListener("keydown",Ge);for(const[C,R]of at)C.removeEventListener("click",R);xe?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:X,zoom:C=>V(C),setLayout:q,markNode(C,R){const te=Ln(i,C);te&&(R?u.set(te,R):u.delete(te),Y())},flagNode(C,R,te){const ve=Ln(i,C);if(!ve)return;const ce=c.get(ve)??new Set;te?ce.add(R):ce.delete(R),ce.size?c.set(ve,ce):c.delete(ve),z?P=!0:v.flag(ve,R,te)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>S(),transform:()=>({...l}),highlight(C){f=C==null?null:Ln(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const R=Ln(i,C),te=R?a[R]:null;if(!te)return null;const ve=v.surface.getBoundingClientRect(),ce=Math.min(ve.width/s.width,ve.height/s.height)||1,ut=ve.left+(ve.width-s.width*ce)/2,At=ve.top+(ve.height-s.height*ce)/2;return{x:ut+(te.x*l.scale+l.x)*ce,y:At+(te.y*l.scale+l.y)*ce}}};return Object.defineProperty(e,"ciaGraph",{value:ht,configurable:!0}),ht}const ew="chain-insights.flows.v1",tw="chain-insights.result.v1",nw=5e3,Bh=6,bT=3,rw=/^0x[0-9a-fA-F]{40}$/,wT=/^0x[0-9a-fA-F]{64}$/;function _T(e){return typeof e=="string"&&(rw.test(e)||wT.test(e))}function os(e){return typeof e=="string"&&rw.test(e)}function Fu(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function iw(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(Fu):[]}function kT(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Kt(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 Rf(e){return e<1e11?e*1e3:e}const Uu=/^\d{4}-\d{2}-\d{2}$/,ST=Date.UTC(2009,0,1),ET=Date.UTC(2100,0,1);function Ka(e){return new Date(Rf(e)).toISOString().slice(0,10)}function Vh(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function xT(e){return typeof e=="string"&&Uu.test(e)&&Number.isFinite(Date.parse(`${e}T00:00:00Z`))}const $T=new Set(["day","date"]);function Hh(e){return $T.has(e)||e.endsWith("_timestamp")}function TT(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function CT(e){return Array.isArray(e)?e.some(os):os(e)}function AT(e){return e.some(t=>Object.values(t).some(CT))}function IT(e){return e.length>0&&e.every(t=>os(t.from_address)&&os(t.to_address))}function qh(e){if(typeof e=="string"){const r=e.trim();if(Uu.test(r)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(r)){const i=Date.parse(Uu.test(r)?`${r}T00:00:00Z`:/(?:Z|[+-]\d{2}:?\d{2})$/.test(r)?r.replace(" ","T"):`${r.replace(" ","T")}Z`);return Number.isFinite(i)?i:null}}const t=Kt(e);if(t==null)return null;const n=Rf(t);return n>=ST&&n<ET?n:null}function ow(e){if(e.length===0||AT(e))return null;const t=TT(e),r=t.filter(Hh).find(u=>e.some(c=>qh(c[u])!=null));if(!r)return null;const i=t.filter(u=>{if(Hh(u))return!1;const c=e.map(l=>l[u]).filter(l=>l!=null);return c.length>0&&c.every(l=>Kt(l)!=null)});if(i.length===0)return null;const o=e.map((u,c)=>({time:qh(u[r]),row:u,index:c})).filter(u=>u.time!=null).sort((u,c)=>u.time-c.time||u.index-c.index),s=i.slice(0,Bh);return new Set(o.filter(u=>s.some(c=>Kt(u.row[c])!=null)).map(u=>u.time)).size<bT?null:{xColumn:r,times:o.map(u=>u.time),daily:o.every(u=>u.time%864e5===0),series:s.map(u=>({column:u,values:o.map(c=>Kt(c.row[u]))})),omittedColumns:i.slice(Bh),skippedRows:e.length-o.length}}function NT(e){return IT(e)?"graph":ow(e)?"chart":"table"}const RT=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function Wh(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function zT(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of RT)if(n.has(r))return i;return"other"}const Kh=(e,t)=>e==null?t:t==null?e:e+t;function LT(e,t="robinhood"){const n=new Map;for(const d of e)for(const f of new Set([String(d.from_address).toLowerCase(),String(d.to_address).toLowerCase()]))n.set(f,(n.get(f)??0)+1);let r="",i=0;for(const[d,f]of n)f>i&&(r=d,i=f);const o=new Map,s=new Map,a=(d,f,h)=>{const p=o.get(d)??{address:d,labels:[],exchange:!1};for(const m of f)p.labels.some(g=>g.toLowerCase()===m.toLowerCase())||p.labels.push(m);p.exchange=p.exchange||h,o.set(d,p)};r&&o.set(r,{address:r,labels:[],exchange:!1});let u=0;for(const d of e){const f=String(d.from_address).toLowerCase(),h=String(d.to_address).toLowerCase(),p=[f,h].filter((b,v,S)=>!o.has(b)&&S.indexOf(b)===v).length;if(o.size+p>nw||(u++,a(f,Wh(d.from_labels),d.from_is_exchange===!0),a(h,Wh(d.to_labels),d.to_is_exchange===!0),f===h))continue;const m=`${f}->${h}`,g=s.get(m)??{from:f,to:h,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=Kh(g.usd,Kt(d.amount_usd_sum)),g.tx=Kh(g.tx,Kt(d.tx_count));const w=Kt(d.first_seen_timestamp),y=Kt(d.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),y!=null&&(g.last=g.last==null?y:Math.max(g.last,y)),typeof d.link_kind=="string"&&d.link_kind&&!g.kinds.includes(d.link_kind)&&g.kinds.push(d.link_kind),s.set(m,g)}const c=[...o.values()].map(d=>({address:d.address,role:zT(d.labels,d.exchange),labels:d.labels})),l=[...s.values()].map(d=>({from:d.from,to:d.to,usd:d.usd,tx_count:d.tx,first_seen_ms:d.first,last_seen_ms:d.last,...d.kinds.length?{link_kind:d.kinds.join(", ")}:{}}));return{view:{schema:ew,network:t,center:r,nodes:c,edges:l,truncated:!1},rowsTotal:e.length,rowsDrawn:u,rowsLeftOut:e.length-u,addresses:o.size}}function PT(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(Fu).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(Fu):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null})):[]}const Jh=200;function go(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
109
+ `).trim()}function Mr(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 sw(e){if(!e)return null;const t=e.structuredContent,n=Mr(t?.error)??Mr(t?.facts?.error)??Mr(t?.facts?.query?.error);if(!e.isError||n)return n;const r=go(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=Mr(i?.error)??Mr(i);if(o)return o}catch{}return r||"The tool answered with an error."}const DT=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function aw(e){if(!e||sw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===ew)return"flows";if(t?.schema===tw){if(t.tool==="graph_query")return NT(iw(t));if(t.tool==="graph_query_batch")return Array.isArray(t.facts?.queries)&&t.facts.queries.length>0?"batch":"text";if(typeof t.tool=="string"&&DT.has(t.tool))return"balance"}return"text"}function I(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 OT(e,t){const n=I(e,"code",{class:"cv-addr",title:t,"data-full":t,text:si(t)}),r=I(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",()=>{MT(e,t,n,r)}),I(e,"span",{class:"cv-addr-cell"},n,r)}async function MT(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 FT(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?vn(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 UT=160,Yh=2e3;function GT(e,t=UT){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 uw(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>Yh?`${n.full.slice(0,Yh-1)}…`:n.full,o=i!=null&&i!==t,s=I(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?I(r,"details",{class:"cv-notice-more"},I(r,"summary",{class:"cv-notice-line",text:t}),I(r,"p",{class:"cv-notice-full",text:i})):I(r,"p",{class:"cv-notice-line",text:t}));return e.replaceChildren(s),s}function jT(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,Jh),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>Jh||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function ZT(e,t,n){return t==null?I(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):_T(t)?OT(e,t):typeof t=="number"?e.createTextNode(FT(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))}function Xh(e,t,n={}){const r=e.ownerDocument,i=jT(t.structuredContent),o=i.rows.length;if(i.total===0)return uw(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=I(r,"table",{class:"cv-table"},I(r,"thead",{},I(r,"tr",{},...i.columns.map(u=>I(r,"th",{scope:"col",text:u})))),I(r,"tbody",{},...i.rows.map(u=>I(r,"tr",{},...i.columns.map(c=>I(r,"td",{},ZT(r,u[c],c)))))));return e.replaceChildren(I(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},I(r,"header",{class:"cv-card-head"},I(r,"strong",{text:"Graph query result"}),I(r,"span",{class:"cv-muted",text:s}),n.toggle??null),i.truncated?I(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?I(r,"div",{class:"cv-table-wrap"},a):null)),i}const Fr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Io=e=>typeof e=="string"&&e?e:null;function BT(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Fr(t.allowance_usd),consumedUsd:Fr(t.consumed_usd),windowEnd:Io(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=Io(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Fr(r?n.daily_units_used:n.daily_seconds_used),limit:Fr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Fr(r?n.remaining_units:n.remaining_seconds),resetAt:Io(n.reset_at),identifierKind:Io(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Qh=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),No=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function Ja(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${vn(t)} UTC`:e}function ep(e,t,n,r){const i=n>0?Math.min(1,t/n):0,o=I(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},I(e,"span"));return o.firstElementChild.style.width=`${Math.round(i*100)}%`,o}function Ya(e,t){return I(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[I(e,"dt",{text:n}),I(e,"dd",{text:r})]))}function VT(e,t){const n=e.ownerDocument,r=BT(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${si(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[ep(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),Ya(n,[["Daily allowance",Qh(r.allowanceUsd)],["Used today",Qh(r.consumedUsd)],["Window ends",Ja(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?[I(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),Ya(n,[["Daily allowance","No daily limit"],["Used today",No(r.used,r.unit)],["Window ends",Ja(r.resetAt)]])]:[ep(n,r.used,r.limit,"Share of today's free allowance used"),Ya(n,[["Daily allowance",No(r.limit,r.unit)],["Used today",No(r.used,r.unit)],["Left today",No(r.remaining,r.unit)],["Window ends",Ja(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[I(n,"p",{class:"cv-muted",text:go(t)||"Nothing to show."})]),e.replaceChildren(I(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":o},I(n,"header",{class:"cv-card-head"},I(n,"strong",{text:o}),I(n,"span",{class:"cv-muted",text:s})),...i)),r}function za(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=sw(t);if(i!=null){uw(e,GT(i),{kind:"refused",view:"text",full:i});return}const o=go(t);e.replaceChildren(I(r,"section",{class:"cv-card cv-text-view","data-view":"text"},I(r,"p",{text:n}),o?I(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function cw(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(I(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},I(n,"span",{class:"cv-sr",text:t}),I(n,"div",{class:"cv-skel-line cv-skel-title"}),I(n,"div",{class:"cv-skel-line cv-skel-sub"}),I(n,"div",{class:"cv-skel-block"})))}const HT="http://www.w3.org/2000/svg",qT=720,WT=6,Ro={left:66,right:18,top:6},tp=18,KT=16,JT=26,YT=170,XT=82,QT=80;function lw(e,t){const n=new Date(e).toISOString();return t?n.slice(0,10):`${n.slice(0,10)} ${n.slice(11,16)}`}const eC=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),dw=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function np(e){return Math.abs(e)<1e3?dw.format(Math.round(e*100)/100):eC.format(e)}function tC(e,t=qT){const n=Ro.left,r=t-Ro.right,i=r-n,o=e.times[0]??0,s=e.times[e.times.length-1]??o,a=s-o,u=h=>a>0?n+(h-o)/a*i:n+i/2,c=e.series.length===1?YT:XT,l=e.series.map((h,p)=>{const m=Ro.top+p*(tp+c+KT),g=m+tp,w=g+c,y=h.values.filter(P=>P!=null),b=Math.min(0,...y),v=Math.max(...y,b+1e-9),S=P=>w-(P-b)/(v-b||1)*c,_=[],$=[];let z=[];return h.values.forEach((P,O)=>{if(P==null){z.length&&$.push(z),z=[];return}const Y={x:u(e.times[O]??o),y:S(P),time:e.times[O]??o,value:P};_.push(Y),z.push(Y)}),z.length&&$.push(z),{column:h.column,color:`var(--cia-graph-series-${p%WT+1})`,top:m,plotTop:g,plotBottom:w,min:b,max:v,runs:$,points:_}}),d=(l[l.length-1]?.plotBottom??Ro.top)+6,f=[];if(e.times.length){const h=a>0?[[o,"start"],[o+a/2,"middle"],[s,"end"]]:[[o,"middle"]];for(const[p,m]of h)f.push({x:u(p),label:lw(p,e.daily),anchor:m})}return{width:t,height:d+JT,plotLeft:n,plotRight:r,lanes:l,ticks:f,axisY:d}}function _t(e,t,n={}){const r=e.createElementNS(HT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const Ur=e=>Math.round(e*10)/10;function nC(e,t,n={}){const r=e.ownerDocument,i=tC(t),o=_t(r,"svg",{class:"cv-chart-svg",viewBox:`0 0 ${i.width} ${i.height}`,role:"img",preserveAspectRatio:"xMidYMid meet","aria-label":`Line chart of ${t.series.map(c=>c.column).join(", ")} by ${t.xColumn}, ${t.times.length} ${t.times.length===1?"point":"points"}`});for(const c of i.lanes){const l=_t(r,"g",{class:"cv-chart-lane","data-series":c.column}),d=_t(r,"rect",{class:"cv-chart-swatch",x:i.plotLeft,y:c.top+4,width:14,height:4,rx:2});d.style.fill=c.color;const f=_t(r,"text",{class:"cv-chart-name",x:i.plotLeft+20,y:c.top+11});f.textContent=c.column,l.append(d,f,_t(r,"line",{class:"cv-chart-grid",x1:i.plotLeft,x2:i.plotRight,y1:c.plotTop,y2:c.plotTop}),_t(r,"line",{class:"cv-chart-base",x1:i.plotLeft,x2:i.plotRight,y1:c.plotBottom,y2:c.plotBottom}));const h=_t(r,"text",{class:"cv-chart-tick",x:i.plotLeft-8,y:c.plotTop+4,"text-anchor":"end"});h.textContent=np(c.max);const p=_t(r,"text",{class:"cv-chart-tick",x:i.plotLeft-8,y:c.plotBottom+4,"text-anchor":"end"});p.textContent=np(c.min),l.append(h,p);for(const m of c.runs){if(m.length<2)continue;const g=_t(r,"polyline",{class:"cv-chart-line",points:m.map(w=>`${Ur(w.x)},${Ur(w.y)}`).join(" "),fill:"none"});g.style.stroke=c.color,l.append(g)}if(c.points.length<=QT)for(const m of c.points){const g=_t(r,"circle",{class:"cv-chart-dot",cx:Ur(m.x),cy:Ur(m.y),r:3});g.style.fill=c.color;const w=_t(r,"title");w.textContent=`${lw(m.time,t.daily)} · ${c.column} ${dw.format(m.value)}`,g.append(w),l.append(g)}o.append(l)}const s=_t(r,"g",{class:"cv-chart-axis"});for(const c of i.ticks){const l=_t(r,"text",{class:"cv-chart-tick",x:Ur(c.x),y:i.axisY+14,"text-anchor":c.anchor});l.textContent=c.label,s.append(l)}o.append(s);const a=[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),u=I(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Chart by ${t.xColumn}`},I(r,"header",{class:"cv-flows-head"},I(r,"div",{class:"cv-title"},I(r,"strong",{text:"Chart"}),I(r,"span",{class:"cv-muted",text:`${t.times.length} ${t.times.length===1?"point":"points"} by ${t.xColumn} (UTC) · ${t.series.length} ${t.series.length===1?"line":"lines"}`})),n.toggle??null),a.length?I(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:a.join(" ")}):null,I(r,"div",{class:"cv-chart-body"},o));return e.replaceChildren(u),{root:u,layout:i}}const rC="chain-insights.transfers.v1",iC="graph_expand",oC="2015-01-01";function sC(e,t,n,r){return{network:e,from:t,to:n,day:r}}function aC(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?Ka(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?Ka(e.last_seen_timestamp):Ka(t);return{first:n,last:n&&r<n?n:r}}function zo(e,t){return e<=(t??oC)}function uC(e){if(!e)return"no answer";const t=go(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:fw(e.structuredContent)?null:t||"the answer held no transfers"}function fw(e){const t=e;if(!t||t.schema!==rC||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!xT(t.day))return null;const n=[];for(const r of t.transfers){if(!r||typeof r!="object")continue;const i=r;if(typeof i.tx_id!="string")continue;const o=Kt(i.block_timestamp);n.push({tx_id:i.tx_id,block_timestamp:o,amount:typeof i.amount=="string"?i.amount:typeof i.amount=="number"?String(i.amount):null,asset_symbol:typeof i.asset_symbol=="string"&&i.asset_symbol?i.asset_symbol:null,amount_usd:Kt(i.amount_usd)})}return{network:typeof t.network=="string"?t.network:null,from:t.from,to:t.to,day:t.day,transfers:n,truncated:t.truncated===!0}}function cC(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function lC(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 dC(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 fC(e){return e==null?"—":`${new Date(Rf(e)).toISOString().slice(11,19)} UTC`}function Xa(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function hC(e,t){const n=t.now??Date.now,r=I(e,"strong",{"data-link-title":"",text:"Transfers"}),i=I(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),o=I(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=I(e,"p",{class:"cv-link-day","data-link-day":""}),a=I(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),u=I(e,"button",{type:"button",class:"cv-button","data-link-earlier":"",text:"Earlier day"}),c=I(e,"section",{class:"cv-linkpanel cv-linkpanel-embedded","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},I(e,"header",{class:"cv-link-head"},r,null),o,s,a,u);let l=null,d=0;function f(){if(!l){c.hidden=!0;return}c.hidden=!1,o.replaceChildren(I(e,"code",{"data-link-from":"",text:l.from})," → ",I(e,"code",{"data-link-to":"",text:l.to})),s.textContent=`${Xa(l.day)} (UTC)`,u.disabled=l.status==="loading"||zo(l.day,l.firstDay);const w=zo(l.day,l.firstDay)?null:Vh(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${Xa(w)}`:"Earlier day: this is the first day the link was seen"),l.status==="loading"?a.replaceChildren(I(e,"p",{class:"cv-muted",text:`Loading the transfers of ${Xa(l.day)}…`})):l.status==="error"?a.replaceChildren(I(e,"p",{class:"cv-link-error","data-link-error":"",role:"alert",text:l.error??"The transfers could not be read."})):l.transfers.length===0?a.replaceChildren(I(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses on this day."})):(a.replaceChildren(I(e,"ol",{class:"cv-transfers"},...l.transfers.map(y=>pC(e,y,t.host)))),l.truncated&&a.append(I(e,"p",{class:"cv-muted","data-link-truncated":"",text:`${l.transfers.length} transfers shown. This day holds more.`}))),l.status!=="loading"&&zo(l.day,l.firstDay)&&l.firstDay&&a.append(I(e,"p",{class:"cv-muted","data-link-first":"",text:"This is the first day the link was seen."}))}async function h(w){const y=++d,b=l;b.day=w,b.status="loading",b.error=null,f(),t.onLayout?.();let v=null;try{v=await t.host.callServerTool({name:iC,arguments:sC(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(y!==d||l!==b)return b;const S=uC(v);if(S)b.status="error",b.transfers=[],b.error=S.length>300?`${S.slice(0,299)}…`:S;else{const _=fw(v.structuredContent);b.status="ready",b.transfers=cC(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>g.close(),m=()=>{g.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const g={element:c,open(w){const y=aC(w,n());return l={from:w.from,to:w.to,day:y.last,firstDay:y.first,status:"loading",transfers:[],truncated:!1,error:null},h(y.last)},async earlier(){return!l||l.status==="loading"||zo(l.day,l.firstDay)?null:h(Vh(l.day))},close(){d++,l=null,f(),t.onLayout?.()},state:()=>l?{...l,transfers:[...l.transfers]}:null,destroy(){d++,i.removeEventListener("click",p),u.removeEventListener("click",m)}};return g}function pC(e,t,n){const r=Qb(t.tx_id),i=n.openLink,o=r&&i?I(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:si(t.tx_id)}):I(e,"code",{title:t.tx_id,text:si(t.tx_id)});return r&&i&&o.addEventListener("click",()=>{i.call(n,{url:r}).catch(()=>{})}),I(e,"li",{class:"cv-transfer","data-tx":t.tx_id},I(e,"span",{class:"cv-transfer-time",text:fC(t.block_timestamp)}),I(e,"span",{class:"cv-transfer-amount",text:`${lC(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),I(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":dC(t.amount_usd)}),o)}const mC="graph_expand",Lo="too busy to expand",hw=640,gC=300,Qa=.45,yC="Full screen shows the whole graph",rp=400,eu="expanded",pw=5e3,vC="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.",Gu=new Intl.NumberFormat("en-US");function ip(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 bC(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${Gu.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function wC(e,t){return`Not loaded: ${Gu.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${Gu.format(pw)} addresses. Fold another address to make room.`}const op=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let _C=0;const kC=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function SC(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function EC(e){const t=go(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Tf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function xC(e,t,n,r=hw,i=gC){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(Qa,Math.min(1,(t-oi*2)/o)),u=Math.ceil(n+s*a+oi*2),c=Math.min(r,Math.max(i,u));return Mh(e,t,c-n)>=Qa?{height:c,fits:!0}:{height:r,fits:Mh(e,t,r-n)>=Qa}}function $C(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function TC(e){const t=e.split(`
110
+ `)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function CC(e,t){return`investigator expanded ${e}: ${t} new addresses`}function AC(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&mo({role:n.role??null,labels:n.labels??[]})||"Other"}function mw(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:ip(t)}]]:[]);let a=s();const u=new Set,c=new Set;let l=[];const d=new Set;let f=null,h=null;const p=n.now??Date.now,m=n.title??"Money flow graph",g=I(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:vC}),w=I(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),y=I(r,"div",{class:"cv-canvas","data-graph":""}),b=I(r,"div",{class:"cv-detail","aria-label":"Selection"},I(r,"strong",{"data-selection-title":""}),I(r,"code",{"data-selection-identity":""}),I(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),v=I(r,"strong",{"data-side-title":"",text:"Details"}),S=I(r,"button",{type:"button",class:"cv-button cv-icon","data-side-close":"","aria-label":"Close the details",text:"×"}),_=I(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),$=I(r,"button",{type:"button",class:"cv-button","data-more":"",hidden:!0,text:"More flows"}),z=I(r,"p",{class:"cv-remaining cv-muted","data-remaining":"",hidden:!0}),P=hC(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Be()}),O=I(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},I(r,"header",{class:"cv-side-head"},v,S),b,z,I(r,"div",{class:"cv-side-actions"},_,$),P.element),Y=I(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),he=I(r,"button",{type:"button",class:"cv-button","data-reset":"","aria-label":"Reset the graph to the first answer",text:"Reset"}),Se=I(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:yC}),$e=I(r,"div",{class:"cv-actions"},I(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),I(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),I(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),he,Se,Y),Fe=I(r,"span",{class:"cv-muted","data-subtitle":""}),M=`cv-addresses-${++_C}`,G=I(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:M,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let B=[],ee=-1;const X=I(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${m} of ${o}`},I(r,"header",{class:"cv-flows-head"},I(r,"div",{class:"cv-title"},I(r,"strong",{text:m}),Fe),n.toggle??null,$e),w,n.note?I(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,I(r,"div",{class:"cv-body"},G,y,O),g);e.replaceChildren(X);function V(){const D=Q.model(),ie=D.truncated?" · more flows than shown":"";Fe.textContent=`${o} · ${AC(t,o)} · ${i} · ${D.nodes.length} addresses${ie}`;const pe=new Set(D.nodes.map(Te=>Te.role??"other"));w.replaceChildren(...kC.filter(([Te])=>pe.has(Te)).map(([Te,We])=>{const It=I(r,"i",{"aria-hidden":"true"});return It.style.background=`var(--cia-graph-role-${Te})`,I(r,"li",{"data-role":Te},It,We)})),q()}function q(){const D=Q.model().nodes,ie=B[ee]??null;B=D.map(Te=>Te.address.toLowerCase()),G.replaceChildren(...D.map((Te,We)=>I(r,"div",{role:"option",id:`${M}-${We}`,"data-list-address":B[We],"aria-selected":"false",text:`${Te.address} ${mo({role:Te.role??null,labels:Te.labels??[]})||"Other"}`})));const pe=ie?B.indexOf(ie):-1;ee=pe>=0?pe:B.length?Math.min(Math.max(ee,-1),B.length-1):-1,W()}function W(){for(const ie of G.children)ie.setAttribute("aria-selected",String(ie.id===`${M}-${ee}`));ee>=0?G.setAttribute("aria-activedescendant",`${M}-${ee}`):G.removeAttribute("aria-activedescendant");const D=r.activeElement===G;Q.highlight(D?B[ee]??null:null)}function Ee(D){return D?Q.model().nodes.find(ie=>ie.id===D)?.address.toLowerCase()??null:null}const Ie=D=>{const ie=D.target,pe=D.key==="Enter"||D.key===" ",Te=ie?.closest?.("[data-node-id]");if(pe&&D.shiftKey&&Te){D.preventDefault();const We=Ee(Te.dataset.nodeId);We&&te(We)}};y.addEventListener("keydown",Ie,!0);function je(D){B.length&&(ee=Math.max(0,Math.min(B.length-1,D)),W())}const st=()=>{ee<0&&B.length&&(ee=0),W()},et=()=>Q.highlight(null),L=D=>{const ie=B[ee];switch(D.key){case"ArrowDown":D.preventDefault(),je(ee+1);return;case"ArrowUp":D.preventDefault(),je(ee-1);return;case"Home":D.preventDefault(),je(0);return;case"End":D.preventDefault(),je(B.length-1);return;case"Escape":Ut();return;case"Enter":case" ":if(D.preventDefault(),!ie)return;D.shiftKey?te(ie):Q.select(ie);return}};G.addEventListener("focus",st),G.addEventListener("blur",et),G.addEventListener("keydown",L);function F(){const D=h;if(!D){_.hidden=!0,$.hidden=!0,z.hidden=!0;return}const ie=d.has(D),pe=ie?bC(a.get(D)?.remaining??null):null;z.hidden=!pe,z.textContent=pe??"",_.hidden=!1,_.disabled=u.has(D)||c.has(D),_.textContent=u.has(D)?"Too busy to expand":ie?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${D}`),$.hidden=!(ie&&op(a.get(D)))}function H(D){const ie=O.hidden;O.hidden=D.kind==null,D.kind==="node"&&D.node?(h=D.node.address.toLowerCase(),v.textContent="Address details",P.close()):(h=null,D.kind==="edge"?v.textContent="Link details":P.close()),F(),ie!==O.hidden&&Be()}let J=null;function me(){J&&clearTimeout(J),J=null}function ue(D){const ie=D.source==="pointer"&&D.kind==="node"&&D.node,pe=D.source!=="program"&&D.kind==="edge"&&D.edge;if(me(),ie){const Te=D.node.address.toLowerCase(),We=p();f&&f.address===Te&&We-f.at<=rp?(f=null,Ut(),te(Te)):(f={address:Te,at:We},J=setTimeout(()=>{J=null,H(D)},rp));return}D.kind!=="node"&&(f=null),H(D),pe&&P.open(D.edge)}const we=n.height??hw,xe=`${m} 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 ae(){return vT(y,t,{layout:"tree",width:n.width??720,height:we,now:n.now,controls:$e,selectionRoot:b,onSelect:ue,openLink:D=>{n.host.openLink?.({url:D}).catch(()=>{g.textContent="The host did not open the link."})},label:xe})}let Q=ae();V();let Ge=n.displayMode??"inline",at=n.availableDisplayModes??[];const Ze=()=>!!n.host.requestDisplayMode&&(at.length===0||at.includes("fullscreen"));function Be(){if(Ge==="fullscreen"){X.style.removeProperty("height"),Se.hidden=!0;return}const D=y.clientWidth||n.width||720,ie=Math.max(0,X.offsetHeight-y.offsetHeight)||140,{height:pe,fits:Te}=xC(Q.contentBounds(),D,ie);X.style.height=`${pe}px`,Se.hidden=Te||!Ze(),X.dataset.fits=String(Te),Q.fit()}async function ht(D){try{await n.host.updateModelContext?.({content:[{type:"text",text:D}]})}catch{}}async function C(D,ie=!1){const pe=D.toLowerCase();if(u.has(pe))return g.textContent=`${pe} is ${Lo}.`,{added:[],refused:Lo};if(c.has(pe))return{added:[],refused:null};const Te=a.get(pe);if(Te&&!op(Te))return g.textContent=`Every recent flow of ${pe} is drawn.`,{added:[],refused:null};c.add(pe),F(),g.textContent=`Loading the flows of ${pe}…`;let We=null;try{We=await n.host.callServerTool({name:mC,arguments:SC(i,pe,ie||Te?Te?.cursor:null)})}catch(wt){We={isError:!0,content:[{type:"text",text:wt instanceof Error?wt.message:String(wt)}]}}finally{c.delete(pe)}const It=EC(We);if(It)return $C(It)?(u.add(pe),Q.markNode(pe,Lo),g.textContent=`${pe} is ${Lo}. The drawing is kept.`):g.textContent=`${pe} could not be expanded: ${TC(It)}. The drawing is kept; try again.`,F(),{added:[],refused:It};const Ve=We.structuredContent,Fa=Q.model(),Tn=new Set(Fa.nodes.map(wt=>wt.address.toLowerCase())),Ua=new Set;for(const wt of Ve.nodes)Tn.has(wt.address.toLowerCase())||Ua.add(wt.address.toLowerCase());for(const wt of Ve.edges)for(const bo of[wt.from,wt.to])Tn.has(bo.toLowerCase())||Ua.add(bo.toLowerCase());if(Tn.size+Ua.size>pw){const wt=new Set(Fa.edges.map(Cn=>`${Cn.from.toLowerCase()}->${Cn.to.toLowerCase()}`)),bo=new Set(Ve.edges.map(Cn=>`${Cn.from.toLowerCase()}->${Cn.to.toLowerCase()}`).filter(Cn=>!wt.has(Cn))).size,Uf=wC(bo,pe);return g.textContent=Uf,F(),{added:[],refused:Uf}}const vo=Q.merge(Ve,pe);return l.push({address:pe,page:Ve}),d.add(pe),Q.flagNode(pe,eu,!0),a.set(pe,{cursor:Ve.cursor??null,truncated:!!Ve.truncated,remaining:ip(Ve)}),V(),Be(),F(),g.textContent=`${vo.length} new ${vo.length===1?"address":"addresses"} linked to ${pe}. Double-click it again to fold them back.`,await ht(CC(pe,vo.length)),{added:vo,refused:null}}function R(D){const ie=D.toLowerCase();if(!d.has(ie))return{removed:0};const pe=Q.model().nodes.length;d.delete(ie),a.delete(ie);const Te=l.filter(Ve=>Ve.address!==ie),We=[];Q.batch(()=>{Q.flagNode(ie,eu,!1),Q.update(t);for(const Ve of Te)Q.model().nodes.some(Tn=>Tn.address.toLowerCase()===Ve.address)?(Q.merge(Ve.page,Ve.address),We.push(Ve)):We.some(Tn=>Tn.address===Ve.address)||(Q.flagNode(Ve.address,eu,!1),d.delete(Ve.address),a.delete(Ve.address))}),l=We;const It=Math.max(0,pe-Q.model().nodes.length);return h&&!Q.model().nodes.some(Ve=>Ve.address.toLowerCase()===h)&&(O.hidden=!0,h=null),V(),Be(),F(),g.textContent=`Folded ${ie} back: ${It} ${It===1?"address":"addresses"} removed.`,ht(`investigator collapsed ${ie}: ${It} addresses removed`),{removed:It}}async function te(D){d.has(D)?R(D):await C(D)}function ve(){me(),Q.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,P.close(),O.hidden=!0,Q=ae(),V(),Be(),F(),g.textContent="Back to the first answer."}function ce(D,ie){D&&(Ge=D),ie&&(at=ie),X.dataset.displayMode=Ge,Y.hidden=!Ze(),Y.textContent=Ge==="fullscreen"?"Exit full screen":"Full screen",Y.setAttribute("aria-label",Ge==="fullscreen"?"Back to the inline view":"Open full screen"),Be()}ce(Ge);const ut=async()=>{const D=Ge==="fullscreen"?"inline":"fullscreen";try{const ie=await n.host.requestDisplayMode?.({mode:D});ce(ie?.mode??D)}catch{g.textContent="The host did not change the display mode."}},At=()=>ve();function Ut(){me();const D=!O.hidden;Q.select(null),P.close(),O.hidden=!0,h=null,F(),D&&Be()}const Or=()=>Ut(),$n=()=>{h&&te(h)},fn=()=>{h&&C(h,!0)};return Y.addEventListener("click",ut),he.addEventListener("click",At),S.addEventListener("click",Or),_.addEventListener("click",$n),$.addEventListener("click",fn),{root:X,get graph(){return Q},expand:D=>C(D),collapse:R,reset:ve,expanded:()=>[...d],linkPanel:P,openLink(D,ie){const pe=Q.model().edges.find(Te=>Te.from===D.toLowerCase()&&Te.to===ie.toLowerCase());return pe?(Q.select(pe.id),P.open(pe)):Promise.resolve(null)},setTheme(D){Q.setTheme(D)},setDisplayMode:ce,refit:Be,destroy(){me(),y.removeEventListener("keydown",Ie,!0),G.removeEventListener("focus",st),G.removeEventListener("blur",et),G.removeEventListener("keydown",L),Y.removeEventListener("click",ut),he.removeEventListener("click",At),S.removeEventListener("click",Or),_.removeEventListener("click",$n),$.removeEventListener("click",fn),P.destroy(),Q.destroy()}}}function ju(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function IC(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 gw=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height});function NC(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(nw)} addresses. The table has the rows.`}function RC(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=I(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=I(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=I(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 yw(e,t,n){const r=e.ownerDocument,i=aw(t);if(i!=="graph"&&i!=="chart")return i==="table"?Xh(e,t):za(e,t),ju(i==="table"?"table":"text");const o=t.structuredContent,s=iw(o),a=I(r,"div",{class:"cv-face","data-face":"picture"}),u=I(r,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(a,u);const c=RC(r,i==="graph"?"Graph":"Chart",h=>f(h));let l=null,d=!1;if(i==="graph"){const h=LT(s,kT(o));l=mw(a,h.view,{...gw(n),title:"Money flow graph",toggle:c.make(),note:NC(h.rowsLeftOut,h.rowsTotal)})}else nC(a,ow(s),{toggle:c.make()});function f(h){a.hidden=h!=="picture",u.hidden=h!=="table",h==="table"&&!d&&(d=!0,Xh(u,t,{toggle:c.make()})),c.set(h),h==="picture"&&l?.refit()}return{kind:i,flows:()=>l?[l]:[],setTheme(h){l?.setTheme(h)},setDisplayMode(h,p){l?.setDisplayMode(h,p)},refit(){a.hidden||l?.refit()},destroy(){l?.destroy()}}}function zC(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:tw,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 LC(e,t,n){const r=e.ownerDocument,i=PT(t.structuredContent),o=i.map((p,m)=>I(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)=>I(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=I(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],g=s[p];if(!m||!g)return;d=p,o.forEach((y,b)=>{y.setAttribute("aria-selected",String(b===p)),y.tabIndex=b===p?0:-1}),s.forEach((y,b)=>{y.hidden=b!==p});const w=u[p];if(w)w.refit();else{const y=yw(g,zC(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l});u[p]=y,g.dataset.view=y.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",g=>{const w=o.length-1,y=g.key==="ArrowRight"?m===w?0:m+1:g.key==="ArrowLeft"?m===0?w:m-1:g.key==="Home"?0:g.key==="End"?w:null;y!=null&&(g.preventDefault(),h(y),o[y]?.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 g of u)g?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function PC(e,t,n){const r=aw(t);if(r==="flows"){const i=mw(e,t.structuredContent,gw(n));return IC("flows",()=>i)}return r==="graph"||r==="chart"||r==="table"?yw(e,t,n):r==="batch"?LC(e,t,n):r==="balance"?(VT(e,t),ju("balance")):(za(e,t),ju("text"))}function DC(e){return e==="light"||e==="dark"}function OC(e,t=()=>!1){return DC(e?.theme)?e.theme:t()?"dark":"light"}function zf(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 vw(e,t,n={}){const r=e.documentElement,i=OC(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 MC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Po={exports:{}},sp;function FC(){if(sp)return Po.exports;sp=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(S,_,$){return Function.prototype.apply.call(S,_,$)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:n=function(S){return Object.getOwnPropertyNames(S)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(S){return S!==S};function o(){o.init.call(this)}Po.exports=o,Po.exports.once=w,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(S){if(typeof S!="number"||S<0||i(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(S){for(var _=[],$=1;$<arguments.length;$++)_.push(arguments[$]);var z=S==="error",P=this._events;if(P!==void 0)z=z&&P.error===void 0;else if(!z)return!1;if(z){var O;if(_.length>0&&(O=_[0]),O instanceof Error)throw O;var Y=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw Y.context=O,Y}var he=P[S];if(he===void 0)return!1;if(typeof he=="function")t(he,this,_);else for(var Se=he.length,$e=p(he,Se),$=0;$<Se;++$)t($e[$],this,_);return!0};function c(v,S,_,$){var z,P,O;if(a(_),P=v._events,P===void 0?(P=v._events=Object.create(null),v._eventsCount=0):(P.newListener!==void 0&&(v.emit("newListener",S,_.listener?_.listener:_),P=v._events),O=P[S]),O===void 0)O=P[S]=_,++v._eventsCount;else if(typeof O=="function"?O=P[S]=$?[_,O]:[O,_]:$?O.unshift(_):O.push(_),z=u(v),z>0&&O.length>z&&!O.warned){O.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=v,Y.type=S,Y.count=O.length,r(Y)}return v}o.prototype.addListener=function(S,_){return c(this,S,_,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(S,_){return c(this,S,_,!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,S,_){var $={fired:!1,wrapFn:void 0,target:v,type:S,listener:_},z=l.bind($);return z.listener=_,$.wrapFn=z,z}o.prototype.once=function(S,_){return a(_),this.on(S,d(this,S,_)),this},o.prototype.prependOnceListener=function(S,_){return a(_),this.prependListener(S,d(this,S,_)),this},o.prototype.removeListener=function(S,_){var $,z,P,O,Y;if(a(_),z=this._events,z===void 0)return this;if($=z[S],$===void 0)return this;if($===_||$.listener===_)--this._eventsCount===0?this._events=Object.create(null):(delete z[S],z.removeListener&&this.emit("removeListener",S,$.listener||_));else if(typeof $!="function"){for(P=-1,O=$.length-1;O>=0;O--)if($[O]===_||$[O].listener===_){Y=$[O].listener,P=O;break}if(P<0)return this;P===0?$.shift():m($,P),$.length===1&&(z[S]=$[0]),z.removeListener!==void 0&&this.emit("removeListener",S,Y||_)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(S){var _,$,z;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[S]),this;if(arguments.length===0){var P=Object.keys($),O;for(z=0;z<P.length;++z)O=P[z],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(_=$[S],typeof _=="function")this.removeListener(S,_);else if(_!==void 0)for(z=_.length-1;z>=0;z--)this.removeListener(S,_[z]);return this};function f(v,S,_){var $=v._events;if($===void 0)return[];var z=$[S];return z===void 0?[]:typeof z=="function"?_?[z.listener||z]:[z]:_?g(z):p(z,z.length)}o.prototype.listeners=function(S){return f(this,S,!0)},o.prototype.rawListeners=function(S){return f(this,S,!1)},o.listenerCount=function(v,S){return typeof v.listenerCount=="function"?v.listenerCount(S):h.call(v,S)},o.prototype.listenerCount=h;function h(v){var S=this._events;if(S!==void 0){var _=S[v];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function p(v,S){for(var _=new Array(S),$=0;$<S;++$)_[$]=v[$];return _}function m(v,S){for(;S+1<v.length;S++)v[S]=v[S+1];v.pop()}function g(v){for(var S=new Array(v.length),_=0;_<S.length;++_)S[_]=v[_].listener||v[_];return S}function w(v,S){return new Promise(function(_,$){function z(O){v.removeListener(S,P),$(O)}function P(){typeof v.removeListener=="function"&&v.removeListener("error",z),_([].slice.call(arguments))}b(v,S,P,{once:!0}),S!=="error"&&y(v,z,{once:!0})})}function y(v,S,_){typeof v.on=="function"&&b(v,"error",S,_)}function b(v,S,_,$){if(typeof v.on=="function")$.once?v.once(S,_):v.on(S,_);else if(typeof v.addEventListener=="function")v.addEventListener(S,function z(P){$.once&&v.removeEventListener(S,z),_(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Po.exports}var bw=FC();function UC(){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 Ke=UC;typeof Object.assign=="function"&&(Ke=Object.assign);function Lt(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 tt(e){return typeof e=="object"&&e!==null}function ww(e){let t;for(t in e)return!1;return!0}function Nt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Gt(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 ap(e){return!(!tt(e)||e.attributes&&!Array.isArray(e.attributes))}function GC(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function tn(){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 Lr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Lf extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class Z extends Lf{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Z.prototype.constructor)}}class U extends Lf{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}class re extends Lf{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,re.prototype.constructor)}}function _w(e,t){this.key=e,this.attributes=t,this.clear()}_w.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 kw(e,t){this.key=e,this.attributes=t,this.clear()}kw.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Sw(e,t){this.key=e,this.attributes=t,this.clear()}Sw.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Pr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Pr.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)};Pr.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};Pr.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]};Pr.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 Ew=0,xw=1,jC=2,$w=3;function dn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===Ew){if(a=e._nodes.get(r),!a)throw new U(`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 U(`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 U(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===xw?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function ZC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);return s.attributes[a]}}function BC(e,t,n){e.prototype[t]=function(r,i){const[o]=dn(this,t,n,r,i);return o.attributes}}function VC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function HC(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=dn(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 qC(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=dn(this,t,n,r,i,o,s);if(typeof c!="function")throw new Z(`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 WC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(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 KC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(!tt(a))throw new Z(`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 JC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(!tt(a))throw new Z(`Graph.${t}: provided attributes are not a plain object.`);return Ke(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function YC(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=dn(this,t,n,r,i,o);if(typeof a!="function")throw new Z(`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 XC=[{name:e=>`get${e}Attribute`,attacher:ZC},{name:e=>`get${e}Attributes`,attacher:BC},{name:e=>`has${e}Attribute`,attacher:VC},{name:e=>`set${e}Attribute`,attacher:HC},{name:e=>`update${e}Attribute`,attacher:qC},{name:e=>`remove${e}Attribute`,attacher:WC},{name:e=>`replace${e}Attributes`,attacher:KC},{name:e=>`merge${e}Attributes`,attacher:JC},{name:e=>`update${e}Attributes`,attacher:YC}];function QC(e){XC.forEach(function({name:t,attacher:n}){n(e,t("Node"),Ew),n(e,t("Source"),xw),n(e,t("Target"),jC),n(e,t("Opposite"),$w)})}function eA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function tA(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new re(`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=Lt(this,o,s,n),!i)throw new U(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function nA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function rA(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new re(`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=Lt(this,a,u,n),!s)throw new U(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new re(`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 U(`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 iA(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new re(`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=Lt(this,a,u,n),!s)throw new U(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new Z(`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 oA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`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 sA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!tt(i))throw new Z(`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 aA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!tt(i))throw new Z(`Graph.${t}: provided attributes are not a plain object.`);return Ke(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function uA(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new re(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new re(`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=Lt(this,s,a,n),!o)throw new U(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new re(`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 U(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new Z(`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 cA=[{name:e=>`get${e}Attribute`,attacher:eA},{name:e=>`get${e}Attributes`,attacher:tA},{name:e=>`has${e}Attribute`,attacher:nA},{name:e=>`set${e}Attribute`,attacher:rA},{name:e=>`update${e}Attribute`,attacher:iA},{name:e=>`remove${e}Attribute`,attacher:oA},{name:e=>`replace${e}Attributes`,attacher:sA},{name:e=>`merge${e}Attributes`,attacher:aA},{name:e=>`update${e}Attributes`,attacher:uA}];function lA(e){cA.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const dA=[{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 fA(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 hA(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 tu(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 pA(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 mA(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 gA(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 Tw(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 yA(e,t){if(e.size===0)return Lr();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 Pf(e,t,n,r,i,o){const s=t?hA:fA;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 vA(e,t,n,r){const i=[];return Pf(!1,e,t,n,r,function(o){i.push(o)}),i}function bA(e,t,n){let r=Lr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=tn(r,tu(n.in))),t!=="in"&&typeof n.out<"u"&&(r=tn(r,tu(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=tn(r,tu(n.undirected))),r}function Df(e,t,n,r,i,o,s){const a=n?mA:pA;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 wA(e,t,n,r,i){const o=[];return Df(!1,e,t,n,r,i,function(s){o.push(s)}),o}function _A(e,t,n,r){let i=Lr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=tn(i,nu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=tn(i,nu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=tn(i,nu(n.undirected,r))),i}function kA(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 gA(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new U(`Graph.${n}: could not find the "${o}" node in the graph.`);return vA(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 U(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new U(`Graph.${n}: could not find the "${s}" target node in the graph.`);return wA(r,this.multi,i,a,s)}throw new Z(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function SA(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,Tw(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new U(`Graph.${o}: could not find the "${c}" node in the graph.`);return Pf(!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 U(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new U(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Df(!1,r,this.multi,i,f,l,d)}throw new Z(`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,g,w,y,b,v)=>{d[h++]=l(p,m,g,w,y,b,v)})}else d=[],c.push((f,h,p,m,g,w,y)=>{d.push(l(f,h,p,m,g,w,y))});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,g,w,y)=>{l(f,h,p,m,g,w,y)&&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 Z(`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 Z(`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,g,w,y,b)=>{f=l(f,h,p,m,g,w,y,b)}),this[o].apply(this,c),f}}function EA(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,Tw(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new U(`Graph.${o}: could not find the "${u}" node in the graph.`);return Pf(!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 U(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new U(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Df(!0,r,this.multi,i,d,c,l)}throw new Z(`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,g,w)=>c(d,f,h,p,m,g,w)),!!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,g,w)=>!c(d,f,h,p,m,g,w)),!this[o].apply(this,u)}}function xA(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 Lr();if(!arguments.length)return yA(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new U(`Graph.${o}: could not find the "${s}" node in the graph.`);return bA(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new U(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new U(`Graph.${o}: could not find the "${a}" target node in the graph.`);return _A(r,i,u,a)}throw new Z(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function $A(e){dA.forEach(t=>{kA(e,t),SA(e,t),EA(e,t),xA(e,t)})}const TA=[{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 La(){this.A=null,this.B=null}La.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};La.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Gr(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 Of(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Gr(e,null,r,r.undirected,i);if(typeof n=="string")return Gr(e,null,r,r[n],i)}const o=new La;let s;if(t!=="undirected"){if(n!=="out"){if(s=Gr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Gr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Gr(e,o,r,r.undirected,i),e&&s))return s}function CA(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 Of(!1,e,t,n,function(i){r.push(i)}),r}function jr(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 AA(e,t,n){if(e!=="mixed"){if(e==="undirected")return jr(null,n,n.undirected);if(typeof t=="string")return jr(null,n,n[t])}let r=Lr();const i=new La;return e!=="undirected"&&(t!=="out"&&(r=tn(r,jr(i,n,n.in))),t!=="in"&&(r=tn(r,jr(i,n,n.out)))),e!=="directed"&&(r=tn(r,jr(i,n,n.undirected))),r}function IA(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 U(`Graph.${n}: could not find the "${o}" node in the graph.`);return CA(r==="mixed"?this.type:r,i,s)}}function NA(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 U(`Graph.${o}: could not find the "${c}" node in the graph.`);Of(!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 Z(`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 RA(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 U(`Graph.${s}: could not find the "${c}" node in the graph.`);return Of(!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 zA(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 Lr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new U(`Graph.${o}: could not find the "${s}" node in the graph.`);return AA(r==="mixed"?this.type:r,i,a)}}function LA(e){TA.forEach(t=>{IA(e,t),NA(e,t),RA(e,t),zA(e,t)})}function Do(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 PA(e,t){const n={key:e};return ww(t.attributes)||(n.attributes=Ke({},t.attributes)),n}function DA(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return ww(n.attributes)||(r.attributes=Ke({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function OA(e){if(!tt(e))throw new Z('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 Z("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!tt(e.attributes)||e.attributes===null))throw new Z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function MA(e){if(!tt(e))throw new Z('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 Z("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new Z("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!tt(e.attributes)||e.attributes===null))throw new Z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new Z("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const FA=GC(),UA=new Set(["directed","undirected","mixed"]),up=new Set(["domain","_events","_eventsCount","_maxListeners"]),GA=[{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"}],jA={allowSelfLoops:!0,multi:!1,type:"mixed"};function ZA(e,t,n){if(n&&!tt(n))throw new Z(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new re(`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 cp(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 Cw(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new re(`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 re(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!tt(a))throw new Z(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new re(`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 U(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new U(`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 re(`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 re(`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 Pr(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 BA(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new re(`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 re(`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 Z(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!tt(a))throw new Z(`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 re(`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 re(`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 y=[h.key,!1,!1,!1];if(u?!c:!a)return y;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Ke(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return y}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 re(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,g=!1;l||(l=cp(e,o,{}),m=!0,o===s&&(d=l,g=!0)),d||(d=cp(e,s,{}),g=!0),f=new Pr(r,i,l,d,a),e._edges.set(i,f);const w=o===s;return r?(l.undirectedDegree++,d.undirectedDegree++,w&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,w&&(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,g]}function Vn(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 Le extends bw.EventEmitter{constructor(t){if(super(),t=Ke({},jA,t),typeof t.multi!="boolean")throw new Z(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!UA.has(t.type))throw new Z(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new Z(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?_w:t.type==="directed"?kw:Sw;Nt(this,"NodeDataClass",n);const r="geid_"+FA()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Nt(this,"_attributes",{}),Nt(this,"_nodes",new Map),Nt(this,"_edges",new Map),Nt(this,"_directedSize",0),Nt(this,"_undirectedSize",0),Nt(this,"_directedSelfLoopCount",0),Nt(this,"_undirectedSelfLoopCount",0),Nt(this,"_edgeKeyGenerator",o),Nt(this,"_options",t),up.forEach(s=>Nt(this,s,this[s])),Gt(this,"order",()=>this._nodes.size),Gt(this,"size",()=>this._edges.size),Gt(this,"directedSize",()=>this._directedSize),Gt(this,"undirectedSize",()=>this._undirectedSize),Gt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Gt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Gt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Gt(this,"multi",this._options.multi),Gt(this,"type",this._options.type),Gt(this,"allowSelfLoops",this._options.allowSelfLoops),Gt(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 Z(`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 Z(`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 Z(`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 re("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 U(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 re("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 U(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 re("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 U(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`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 U(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return ZA(this,t,n).key}mergeNode(t,n){if(n&&!tt(n))throw new Z(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ke(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 Z(`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 U(`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 Vn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Vn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Vn(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=Lt(this,r,i,this.type),!n)throw new U(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new U(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Vn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new re("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 re("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=Lt(this,t,n,"directed");if(!r)throw new U(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Vn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new re("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 re("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=Lt(this,t,n,"undirected");if(!r)throw new U(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Vn(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 Z("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(!tt(t))throw new Z("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(!tt(t))throw new Z("Graph.mergeAttributes: provided attributes are not a plain object.");return Ke(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new Z("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 Z("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!ap(n))throw new Z("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 Z("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!ap(n))throw new Z("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 Z("Graph.forEachAdjacencyEntry: expecting a callback.");Do(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Z("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Do(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new Z("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Do(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Z("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Do(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new Z("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 Z("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 Z("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 Z("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 Z("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 Z("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 Z("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Z("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++]=PA(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=DA(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 Le)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(!tt(t))throw new Z("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!tt(t.attributes))throw new Z("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 Z("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],OA(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 Z("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],MA(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 Le(Ke({},this._options,t));return n.replaceAttributes(Ke({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Ke({},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 re(`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 re("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 re("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,Cw(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Ke({},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)&&!up.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Nt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Le.prototype[Symbol.for("nodejs.util.inspect.custom")]=Le.prototype.inspect);GA.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?Cw:BA;e.generateKey?Le.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Le.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});QC(Le);lA(Le);$A(Le);LA(Le);class Aw extends Le{constructor(t){const n=Ke({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new Z("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new Z('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Iw extends Le{constructor(t){const n=Ke({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new Z("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new Z('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Nw extends Le{constructor(t){const n=Ke({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class Rw extends Le{constructor(t){const n=Ke({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new Z('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class zw extends Le{constructor(t){const n=Ke({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Z("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new Z('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Dr(e){e.from=function(t,n){const r=Ke({},t.options,n),i=new e(r);return i.import(t),i}}Dr(Le);Dr(Aw);Dr(Iw);Dr(Nw);Dr(Rw);Dr(zw);Le.Graph=Le;Le.DirectedGraph=Aw;Le.UndirectedGraph=Iw;Le.MultiGraph=Nw;Le.MultiDirectedGraph=Rw;Le.MultiUndirectedGraph=zw;Le.InvalidArgumentsGraphError=Z;Le.NotFoundGraphError=U;Le.UsageGraphError=re;function VA(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 Yr(e){var t=VA(e,"string");return typeof t=="symbol"?t:t+""}function dt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lp(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,Yr(r.key),r)}}function ft(e,t,n){return t&&lp(e.prototype,t),n&&lp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function cr(e){return cr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},cr(e)}function Lw(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lw=function(){return!!e})()}function HA(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function qA(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 HA(e)}function Mt(e,t,n){return t=cr(t),qA(e,Lw()?Reflect.construct(t,n||[],cr(e).constructor):t.apply(e,n))}function Zu(e,t){return Zu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Zu(e,t)}function Ft(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&&Zu(e,t)}function WA(e){if(Array.isArray(e))return e}function KA(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 Bu(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 Pw(e,t){if(e){if(typeof e=="string")return Bu(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)?Bu(e,t):void 0}}function JA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
111
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lr(e,t){return WA(e)||KA(e,t)||Pw(e,t)||JA()}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"},Dw=new Int8Array(4),Ho=new Int32Array(Dw.buffer,0,1),Ow=new Float32Array(Dw.buffer,0,1),YA=/^\s*rgba?\s*\(/,XA=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function QA(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(YA.test(e)){var o=e.match(XA);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 Jn={};for(var Oo in ru)Jn[Oo]=xn(ru[Oo]),Jn[ru[Oo]]=Jn[Oo];function Mw(e,t,n,r,i){return Ho[0]=r<<24|n<<16|t<<8|e,Ho[0]=Ho[0]&4278190079,Ow[0]}function xn(e){if(e=e.toLowerCase(),typeof Jn[e]<"u")return Jn[e];var t=QA(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=Mw(n,r,i,o);return Jn[e]=s,s}function eI(e,t){Ow[0]=xn(e);var n=Ho[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var iu={};function Fw(e){if(typeof iu[e]<"u")return iu[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Mw(t,n,r,i);return iu[e]=o,o}function dp(e,t,n,r){return n+(t<<8)+(e<<16)}function fp(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=lr(u,4),l=c[0],d=c[1],f=c[2],h=c[3];return[l,d,f,h]}function N(e,t,n){return(t=Yr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hp(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hp(Object(n),!0).forEach(function(r){N(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function tI(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=cr(e))!==null;);return e}function Vu(){return Vu=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=tI(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Vu.apply(null,arguments)}function Uw(e,t,n,r){var i=Vu(cr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function nI(e){return e.normalized?1:e.size}function ou(e){var t=0;return e.forEach(function(n){return t+=nI(n)}),t}function Gw(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:
112
112
  `.concat(s,`
113
- `).concat(n))}return i}function nI(e,t){return Gw("VERTEX",e,t)}function rI(e,t){return Gw("FRAGMENT",e,t)}function iI(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 pp(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 mp(e){return e%1===0?e.toFixed(1):e.toString()}var gp=`#define PICKING_MODE
114
- `,oI=N(N(N(N(N(N(N(N({},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),jw=(function(){function e(t,n,r){dt(this,e),N(this,"array",new Float32Array),N(this,"constantArray",new Float32Array),N(this,"capacity",0),N(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=ou(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,gp+i.VERTEX_SHADER_SOURCE,gp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=ou(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 ft(e,[{key:"kill",value:function(){pp(this.normalProgram),this.pickProgram&&(pp(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=nI(r,i),l=rI(r,o),d=iI(r,[c,l]),f={};a.UNIFORMS.forEach(function(m){var g=r.getUniformLocation(d,m);g&&(f[m]=g)});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=oI[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:ou(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(K(K({},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)}}}])})(),Zw=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"kill",value:function(){Uw(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(Fw(r),s,o)}}])})(jw),Pa=(function(e){function t(){var n;dt(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Mt(this,t,[].concat(i)),N(n,"drawLabel",void 0),n}return Ft(t,e),ft(t,[{key:"kill",value:function(){Uw(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(Fw(r),u,o,s,a)}}])})(jw);function sI(e,t){return(function(){function n(r,i,o){dt(this,n),N(this,"drawLabel",t),this.programs=e.map(function(s){return new s(r,i,o)})}return ft(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 aI(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,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+b*b);if(!(v<l+d)){f+=y*l/v,h+=b*l/v,p-=y*d/v,m-=b*d/v,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+b*b);var S=e.measureText(c).width;if(S>v){var _="…";for(c=c+_,S=e.measureText(c).width;S>v&&c.length>1;)c=c.slice(0,-2)+_,S=e.measureText(c).width;if(c.length<4)return}var $;y>0?b>0?$=Math.acos(y/v):$=Math.asin(b/v):b>0?$=Math.acos(y/v)+Math.PI:$=Math.asin(y/v)+Math.PI/2,e.save(),e.translate(g,w),e.rotate($),e.fillText(c,-S/2,t.size/2+o),e.restore()}}}function Bw(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 uI(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,Bw(e,t,n)}var cI=`
113
+ `).concat(n))}return i}function rI(e,t){return Gw("VERTEX",e,t)}function iI(e,t){return Gw("FRAGMENT",e,t)}function oI(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 pp(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 mp(e){return e%1===0?e.toFixed(1):e.toString()}var gp=`#define PICKING_MODE
114
+ `,sI=N(N(N(N(N(N(N(N({},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),jw=(function(){function e(t,n,r){dt(this,e),N(this,"array",new Float32Array),N(this,"constantArray",new Float32Array),N(this,"capacity",0),N(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=ou(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,gp+i.VERTEX_SHADER_SOURCE,gp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=ou(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 ft(e,[{key:"kill",value:function(){pp(this.normalProgram),this.pickProgram&&(pp(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=rI(r,i),l=iI(r,o),d=oI(r,[c,l]),f={};a.UNIFORMS.forEach(function(m){var g=r.getUniformLocation(d,m);g&&(f[m]=g)});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=sI[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:ou(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(K(K({},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)}}}])})(),Zw=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"kill",value:function(){Uw(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(Fw(r),s,o)}}])})(jw),Pa=(function(e){function t(){var n;dt(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Mt(this,t,[].concat(i)),N(n,"drawLabel",void 0),n}return Ft(t,e),ft(t,[{key:"kill",value:function(){Uw(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(Fw(r),u,o,s,a)}}])})(jw);function aI(e,t){return(function(){function n(r,i,o){dt(this,n),N(this,"drawLabel",t),this.programs=e.map(function(s){return new s(r,i,o)})}return ft(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 uI(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,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+b*b);if(!(v<l+d)){f+=y*l/v,h+=b*l/v,p-=y*d/v,m-=b*d/v,g=(f+p)/2,w=(h+m)/2,y=p-f,b=m-h,v=Math.sqrt(y*y+b*b);var S=e.measureText(c).width;if(S>v){var _="…";for(c=c+_,S=e.measureText(c).width;S>v&&c.length>1;)c=c.slice(0,-2)+_,S=e.measureText(c).width;if(c.length<4)return}var $;y>0?b>0?$=Math.acos(y/v):$=Math.asin(b/v):b>0?$=Math.acos(y/v)+Math.PI:$=Math.asin(y/v)+Math.PI/2,e.save(),e.translate(g,w),e.rotate($),e.fillText(c,-S/2,t.size/2+o),e.restore()}}}function Bw(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 cI(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,Bw(e,t,n)}var lI=`
115
115
  precision highp float;
116
116
 
117
117
  varying vec4 v_color;
@@ -143,7 +143,7 @@ void main(void) {
143
143
  gl_FragColor = mix(v_color, transparent, t);
144
144
  #endif
145
145
  }
146
- `,lI=cI,dI=`
146
+ `,dI=lI,fI=`
147
147
  attribute vec4 a_id;
148
148
  attribute vec4 a_color;
149
149
  attribute vec2 a_position;
@@ -184,7 +184,7 @@ void main() {
184
184
 
185
185
  v_color.a *= bias;
186
186
  }
187
- `,fI=dI,Vw=WebGLRenderingContext,yp=Vw.UNSIGNED_BYTE,su=Vw.FLOAT,hI=["u_sizeRatio","u_correctionRatio","u_matrix"],Da=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:fI,FRAGMENT_SHADER_SOURCE:lI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:hI,ATTRIBUTES:[{name:"a_position",size:2,type:su},{name:"a_size",size:1,type:su},{name:"a_color",size:4,type:yp,normalized:!0},{name:"a_id",size:4,type:yp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:su}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=En(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)}}])})(Zw);N(Da,"ANGLE_1",0);N(Da,"ANGLE_2",2*Math.PI/3);N(Da,"ANGLE_3",4*Math.PI/3);var pI=`
187
+ `,hI=fI,Vw=WebGLRenderingContext,yp=Vw.UNSIGNED_BYTE,su=Vw.FLOAT,pI=["u_sizeRatio","u_correctionRatio","u_matrix"],Da=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:hI,FRAGMENT_SHADER_SOURCE:dI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:pI,ATTRIBUTES:[{name:"a_position",size:2,type:su},{name:"a_size",size:1,type:su},{name:"a_color",size:4,type:yp,normalized:!0},{name:"a_id",size:4,type:yp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:su}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=xn(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)}}])})(Zw);N(Da,"ANGLE_1",0);N(Da,"ANGLE_2",2*Math.PI/3);N(Da,"ANGLE_3",4*Math.PI/3);var mI=`
188
188
  precision mediump float;
189
189
 
190
190
  varying vec4 v_color;
@@ -192,7 +192,7 @@ varying vec4 v_color;
192
192
  void main(void) {
193
193
  gl_FragColor = v_color;
194
194
  }
195
- `,mI=pI,gI=`
195
+ `,gI=mI,yI=`
196
196
  attribute vec2 a_position;
197
197
  attribute vec2 a_normal;
198
198
  attribute float a_radius;
@@ -258,7 +258,7 @@ void main() {
258
258
 
259
259
  v_color.a *= bias;
260
260
  }
261
- `,yI=gI,Hw=WebGLRenderingContext,vp=Hw.UNSIGNED_BYTE,Mo=Hw.FLOAT,vI=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Oa={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function qw(e){var t=K(K({},Oa),e||{});return(function(n){function r(){return dt(this,r),Mt(this,r,arguments)}return Ft(r,n),ft(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:yI,FRAGMENT_SHADER_SOURCE:mI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vI,ATTRIBUTES:[{name:"a_position",size:2,type:Mo},{name:"a_normal",size:2,type:Mo},{name:"a_radius",size:1,type:Mo},{name:"a_color",size:4,type:vp,normalized:!0},{name:"a_id",size:4,type:vp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Mo}],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,g=u.y,w=En(c.color),y=m-h,b=g-p,v=y*y+b*b,S=0,_=0;v&&(v=1/Math.sqrt(v),S=-b*v*d,_=y*v*d);var $=this.array;$[s++]=m,$[s++]=g,$[s++]=-S,$[s++]=-_,$[s++]=f,$[s++]=w,$[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)}}])})(Pa)}qw();var bI=`
261
+ `,vI=yI,Hw=WebGLRenderingContext,vp=Hw.UNSIGNED_BYTE,Mo=Hw.FLOAT,bI=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Oa={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function qw(e){var t=K(K({},Oa),e||{});return(function(n){function r(){return dt(this,r),Mt(this,r,arguments)}return Ft(r,n),ft(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:vI,FRAGMENT_SHADER_SOURCE:gI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:bI,ATTRIBUTES:[{name:"a_position",size:2,type:Mo},{name:"a_normal",size:2,type:Mo},{name:"a_radius",size:1,type:Mo},{name:"a_color",size:4,type:vp,normalized:!0},{name:"a_id",size:4,type:vp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Mo}],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,g=u.y,w=xn(c.color),y=m-h,b=g-p,v=y*y+b*b,S=0,_=0;v&&(v=1/Math.sqrt(v),S=-b*v*d,_=y*v*d);var $=this.array;$[s++]=m,$[s++]=g,$[s++]=-S,$[s++]=-_,$[s++]=f,$[s++]=w,$[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)}}])})(Pa)}qw();var wI=`
262
262
  precision mediump float;
263
263
 
264
264
  varying vec4 v_color;
@@ -284,7 +284,7 @@ void main(void) {
284
284
  gl_FragColor = mix(v_color, transparent, t);
285
285
  #endif
286
286
  }
287
- `,Ww=bI,wI=`
287
+ `,Ww=wI,_I=`
288
288
  attribute vec4 a_id;
289
289
  attribute vec4 a_color;
290
290
  attribute vec2 a_normal;
@@ -352,7 +352,7 @@ void main() {
352
352
 
353
353
  v_color.a *= bias;
354
354
  }
355
- `,_I=wI,Kw=WebGLRenderingContext,bp=Kw.UNSIGNED_BYTE,In=Kw.FLOAT,kI=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],SI={lengthToThicknessRatio:Oa.lengthToThicknessRatio};function Jw(e){var t=K(K({},SI),e||{});return(function(n){function r(){return dt(this,r),Mt(this,r,arguments)}return Ft(r,n),ft(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:_I,FRAGMENT_SHADER_SOURCE:Ww,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:kI,ATTRIBUTES:[{name:"a_positionStart",size:2,type:In},{name:"a_positionEnd",size:2,type:In},{name:"a_normal",size:2,type:In},{name:"a_color",size:4,type:bp,normalized:!0},{name:"a_id",size:4,type:bp,normalized:!0},{name:"a_radius",size:1,type:In}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:In},{name:"a_normalCoef",size:1,type:In},{name:"a_radiusCoef",size:1,type:In}],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=En(c.color),g=h-d,w=p-f,y=u.size||1,b=g*g+w*w,v=0,S=0;b&&(b=1/Math.sqrt(b),v=-w*b*l,S=g*b*l);var _=this.array;_[s++]=d,_[s++]=f,_[s++]=h,_[s++]=p,_[s++]=v,_[s++]=S,_[s++]=m,_[s++]=o,_[s++]=y}},{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,g=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(g,t.lengthToThicknessRatio)}}])})(Pa)}Jw();function Yw(e){return sI([Jw(e),qw(e)])}var xI=Yw(),EI=xI,$I=`
355
+ `,kI=_I,Kw=WebGLRenderingContext,bp=Kw.UNSIGNED_BYTE,In=Kw.FLOAT,SI=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],EI={lengthToThicknessRatio:Oa.lengthToThicknessRatio};function Jw(e){var t=K(K({},EI),e||{});return(function(n){function r(){return dt(this,r),Mt(this,r,arguments)}return Ft(r,n),ft(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:kI,FRAGMENT_SHADER_SOURCE:Ww,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:SI,ATTRIBUTES:[{name:"a_positionStart",size:2,type:In},{name:"a_positionEnd",size:2,type:In},{name:"a_normal",size:2,type:In},{name:"a_color",size:4,type:bp,normalized:!0},{name:"a_id",size:4,type:bp,normalized:!0},{name:"a_radius",size:1,type:In}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:In},{name:"a_normalCoef",size:1,type:In},{name:"a_radiusCoef",size:1,type:In}],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=xn(c.color),g=h-d,w=p-f,y=u.size||1,b=g*g+w*w,v=0,S=0;b&&(b=1/Math.sqrt(b),v=-w*b*l,S=g*b*l);var _=this.array;_[s++]=d,_[s++]=f,_[s++]=h,_[s++]=p,_[s++]=v,_[s++]=S,_[s++]=m,_[s++]=o,_[s++]=y}},{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,g=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(g,t.lengthToThicknessRatio)}}])})(Pa)}Jw();function Yw(e){return aI([Jw(e),qw(e)])}var xI=Yw(),$I=xI,TI=`
356
356
  attribute vec4 a_id;
357
357
  attribute vec4 a_color;
358
358
  attribute vec2 a_normal;
@@ -417,9 +417,9 @@ void main() {
417
417
 
418
418
  v_color.a *= bias;
419
419
  }
420
- `,TI=$I,Xw=WebGLRenderingContext,wp=Xw.UNSIGNED_BYTE,Zr=Xw.FLOAT,CI=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],AI=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:TI,FRAGMENT_SHADER_SOURCE:Ww,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:CI,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Zr},{name:"a_positionEnd",size:2,type:Zr},{name:"a_normal",size:2,type:Zr},{name:"a_color",size:4,type:wp,normalized:!0},{name:"a_id",size:4,type:wp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Zr},{name:"a_normalCoef",size:1,type:Zr}],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=En(a.color),p=d-c,m=f-l,g=p*p+m*m,w=0,y=0;g&&(g=1/Math.sqrt(g),w=-m*g*u,y=p*g*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=y,b[i++]=h,b[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)}}])})(Pa),Mf=(function(e){function t(){var n;return dt(this,t),n=Mt(this,t),n.rawEmitter=n,n}return Ft(t,e),ft(t)})(bw.EventEmitter),au,_p;function II(){return _p||(_p=1,au=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),au}var NI=II();const zI=OC(NI);var RI=function(t){return t},LI=function(t){return t*t},PI=function(t){return t*(2-t)},DI=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},OI=function(t){return t*t*t},MI=function(t){return--t*t*t+1},FI=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},UI={linear:RI,quadraticIn:LI,quadraticOut:PI,quadraticInOut:DI,cubicIn:OI,cubicOut:MI,cubicInOut:FI},GI={easing:"quadraticInOut",duration:150};function jt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Fo(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function kp(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 Sp(e,t,n){return e[6]=t,e[7]=n,e}function pn(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],g=t[5],w=t[6],y=t[7],b=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+g*u,e[4]=p*r+m*s+g*c,e[5]=p*i+m*a+g*l,e[6]=w*n+y*o+b*u,e[7]=w*r+y*s+b*c,e[8]=w*i+y*a+b*l,e}function Hu(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 jI(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 Br(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=jt(),f=Math.min(c,l)-2*r,h=jI(t,n);return i?(pn(d,Sp(jt(),a,u)),pn(d,Fo(jt(),s)),pn(d,kp(jt(),o)),pn(d,Fo(jt(),c/f/2/h,l/f/2/h))):(pn(d,Fo(jt(),2*(f/c)*h,2*(f/l)*h)),pn(d,kp(jt(),-o)),pn(d,Fo(jt(),1/s)),pn(d,Sp(jt(),-a,-u))),d}function ZI(e,t,n){var r=Hu(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 BI(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 VI(e){if(!zI(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 HI(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 xp(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ep(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 $p(e){var t=lr(e.x,2),n=t[0],r=t[1],i=lr(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 qu(e){"@babel/helpers - typeof";return qu=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},qu(e)}function Tp(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 uu(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 Ff={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:aI,defaultDrawNodeLabel:Bw,defaultDrawNodeHover:uI,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:{}},qI={circle:Da},WI={arrow:EI,line:AI};function cu(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 KI(e){var t=uu({},Ff,e);return t.nodeProgramClasses=uu({},qI,t.nodeProgramClasses),t.edgeProgramClasses=uu({},WI,t.edgeProgramClasses),t}var Uo=1.5,Cp=(function(e){function t(){var n;return dt(this,t),n=Mt(this,t),N(n,"x",.5),N(n,"y",.5),N(n,"angle",0),N(n,"ratio",1),N(n,"minRatio",null),N(n,"maxRatio",null),N(n,"enabledZooming",!0),N(n,"enabledPanning",!0),N(n,"enabledRotation",!0),N(n,"clean",null),N(n,"nextFrame",null),N(n,"previousState",null),N(n,"enabled",!0),n.previousState=n.getState(),n}return Ft(t,e),ft(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(K(K({},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=K(K({},GI),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:UI[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),g={};typeof u.x=="number"&&(g.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(g.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(g.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(g.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(g),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||Uo)},r):this.animate({ratio:this.ratio/Uo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Uo)},r):this.animate({ratio:this.ratio*Uo})}},{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)}}])})(Mf);function Zt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Xt(e,t){var n=K(K({},Zt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Vr(e){var t="x"in e?e:K(K({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function JI(e,t){return K(K({},Xt(e,t)),{},{delta:Qw(e)})}var YI=2;function qo(e){for(var t=[],n=0,r=Math.min(e.length,YI);n<r;n++)t.push(e[n]);return t}function Hr(e,t,n){var r={touches:qo(e.touches).map(function(i){return Zt(i,n)}),previousTouches:t.map(function(i){return Zt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Qw(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 e_=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t),i.container=n,i.renderer=r,i}return Ft(t,e),ft(t)})(Mf),XI=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],QI=XI.reduce(function(e,t){return K(K({},e),{},N({},t,Ff[t]))},{}),eN=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t,[n,r]),N(i,"enabled",!0),N(i,"draggedEvents",0),N(i,"downStartTime",null),N(i,"lastMouseX",null),N(i,"lastMouseY",null),N(i,"isMouseDown",!1),N(i,"isMoving",!1),N(i,"movingTimeout",null),N(i,"startCameraState",null),N(i,"clicks",0),N(i,"doubleClickTimeout",null),N(i,"currentWheelDirection",0),N(i,"settings",QI),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 Ft(t,e),ft(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",Xt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Xt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Xt(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(Zt(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=Zt(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",Xt(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=Zt(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",Xt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Xt(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=Zt(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,g=p.y+h;s.setState({x:m,y:g}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Xt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Xt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=Qw(r);if(s){var a=JI(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(Zt(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}}])})(e_),tN=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],nN=tN.reduce(function(e,t){return K(K({},e),{},N({},t,Ff[t]))},{}),rN=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t,[n,r]),N(i,"enabled",!0),N(i,"isMoving",!1),N(i,"hasMoved",!1),N(i,"touchMode",0),N(i,"startTouchesPositions",[]),N(i,"lastTouches",[]),N(i,"lastTap",null),N(i,"settings",nN),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 Ft(t,e),ft(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=qo(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Zt(h,i.container)}),this.touchMode===2){var s=lr(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",Hr(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",Hr(r,this.lastTouches,this.container)),!r.touches.length){var a=Zt(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=Hr(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=Hr(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=qo(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=qo(r.touches),s=o.map(function(V){return Zt(V,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=Hr(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(V,q){var W=i.startTouchesPositions[q];return W&&(V.x!==W.x||V.y!==W.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]),g=m.x,w=m.y;c.setState({x:l.x+h-g,y:l.y+p-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,S=b.y,_=s[1],$=_.x,R=_.y,P=Math.atan2(R-S,$-v)-this.startTouchesAngle,O=Math.hypot(R-S,$-v)/this.startTouchesDistance,Y=c.getBoundedRatio(l.ratio/O);y.ratio=Y,y.angle=l.angle+P;var he=this.getDimensions(),Se=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),$e=Math.min(he.width,he.height)-2*d,Fe=$e/he.width,M=$e/he.height,G=Y/$e,B=v-$e/2/Fe,ee=S-$e/2/M,X=[B*Math.cos(-y.angle)-ee*Math.sin(-y.angle),ee*Math.cos(-y.angle)+B*Math.sin(-y.angle)];B=X[0],ee=X[1],y.x=Se.x-B*G,y.y=Se.y+ee*G,c.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(e_);function iN(e){if(Array.isArray(e))return Bu(e)}function oN(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function sN(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
421
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ap(e){return iN(e)||oN(e)||Pw(e)||sN()}function aN(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 lu(e,t){if(e==null)return{};var n,r,i=aN(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 Ip=(function(){function e(t,n){dt(this,e),this.key=t,this.size=n}return ft(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Np=(function(){function e(){dt(this,e),N(this,"width",0),N(this,"height",0),N(this,"cellSize",0),N(this,"columns",0),N(this,"rows",0),N(this,"cells",{})}return ft(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 Ip(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(Ip.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 uN(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 zp=150,Rp=50,Qt=Object.prototype.hasOwnProperty;function cN(e,t,n){if(!Qt.call(n,"x")||!Qt.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),Qt.call(n,"hidden")||(n.hidden=!1),Qt.call(n,"highlighted")||(n.highlighted=!1),Qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function lN(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Qt.call(n,"hidden")||(n.hidden=!1),Qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var dN=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(dt(this,t),i=Mt(this,t),N(i,"elements",{}),N(i,"canvasContexts",{}),N(i,"webGLContexts",{}),N(i,"pickingLayers",new Set),N(i,"textures",{}),N(i,"frameBuffers",{}),N(i,"activeListeners",{}),N(i,"labelGrid",new Np),N(i,"nodeDataCache",{}),N(i,"edgeDataCache",{}),N(i,"nodeProgramIndex",{}),N(i,"edgeProgramIndex",{}),N(i,"nodesWithForcedLabels",new Set),N(i,"edgesWithForcedLabels",new Set),N(i,"nodeExtent",{x:[0,1],y:[0,1]}),N(i,"nodeZExtent",[1/0,-1/0]),N(i,"edgeZExtent",[1/0,-1/0]),N(i,"matrix",jt()),N(i,"invMatrix",jt()),N(i,"correctionRatio",1),N(i,"customBBox",null),N(i,"normalizationFunction",$p({x:[0,1],y:[0,1]})),N(i,"graphToViewportRatio",1),N(i,"itemIDsIndex",{}),N(i,"nodeIndices",{}),N(i,"edgeIndices",{}),N(i,"width",0),N(i,"height",0),N(i,"pixelRatio",xp()),N(i,"pickingDownSizingRatio",2*i.pixelRatio),N(i,"displayedNodeLabels",new Set),N(i,"displayedEdgeLabels",new Set),N(i,"highlightedNodes",new Set),N(i,"hoveredNode",null),N(i,"hoveredEdge",null),N(i,"renderFrame",null),N(i,"renderHighlightedNodesFrame",null),N(i,"needToProcess",!1),N(i,"checkEdgesEventsFrame",null),N(i,"nodePrograms",{}),N(i,"nodeHoverPrograms",{}),N(i,"edgePrograms",{}),i.settings=KI(o),cu(i.settings),VI(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 Cp,i.bindCameraHandlers(),i.mouseCaptor=new eN(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new rN(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ft(t,e),ft(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=lu(i,[r].map(Yr));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=lu(a,[r].map(Yr));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=lu(i,[r].map(Yr));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=fp(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=dp.apply(void 0,Ap(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=Vr(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",K(K({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",K(K({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",K(K({},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",K(K({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",K(K({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=Vr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Vr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",K(K({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",K(K({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",K({},a))},this.activeListeners.handleEnter=function(o){var s=Vr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",K({},a))};var i=function(s){return function(a){var u=Vr(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),K(K({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),K(K({},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=fp(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=dp.apply(void 0,Ap(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=BI(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=$p(this.customBBox||this.nodeExtent);var f=new Cp,h=Br(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},g={},w={},y=1,b=i.nodes(),v=0,S=b.length;v<S;v++){var _=b[v],$=this.nodeDataCache[_],R=i.getNodeAttributes(_);$.x=R.x,$.y=R.y,this.normalizationFunction.applyTo($),typeof $.label=="string"&&!$.hidden&&this.labelGrid.add(_,$.size,this.framedGraphToViewport($,{matrix:h})),p[$.type]=(p[$.type]||0)+1}this.labelGrid.organize();for(var P in this.nodePrograms){if(!Qt.call(this.nodePrograms,P))throw new Error('Sigma: could not find a suitable program for node type "'.concat(P,'"!'));this.nodePrograms[P].reallocate(p[P]||0),p[P]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=Ep(this.nodeZExtent,function(Ie){return r.nodeDataCache[Ie].zIndex},b));for(var O=0,Y=b.length;O<Y;O++){var he=b[O];m[he]=y,w[m[he]]={type:"node",id:he},y++;var Se=this.nodeDataCache[he];this.addNodeToProgram(he,m[he],p[Se.type]++)}for(var $e={},Fe=i.edges(),M=0,G=Fe.length;M<G;M++){var B=Fe[M],ee=this.edgeDataCache[B];$e[ee.type]=($e[ee.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Fe=Ep(this.edgeZExtent,function(Ie){return r.edgeDataCache[Ie].zIndex},Fe));for(var X in this.edgePrograms){if(!Qt.call(this.edgePrograms,X))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(X,'"!'));this.edgePrograms[X].reallocate($e[X]||0),$e[X]=0}for(var V=0,q=Fe.length;V<q;V++){var W=Fe[V];g[W]=y,w[g[W]]={type:"edge",id:W},y++;var xe=this.edgeDataCache[W];this.addEdgeToProgram(W,g[W],$e[xe.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=g,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&&qu(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=K({},r),c=a||this.nodeExtent,l=lr(c.x,2),d=l[0],f=l[1],h=lr(c.y,2),p=h[0],m=h[1],g=[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})],w=1/0,y=-1/0,b=1/0,v=-1/0;g.forEach(function($e){var Fe=$e.x,M=$e.y;w=Math.min(w,Fe),y=Math.max(y,Fe),b=Math.min(b,M),v=Math.max(v,M)});var S=y-w,_=v-b,$=this.getDimensions(),R=$.width,P=$.height,O=0,Y=0;if(S>=R?y<R-s?O=y-(R-s):w>s&&(O=w-s):y>R+s?O=y-(R+s):w<-s&&(O=w+s),_>=P?v<P-s?Y=v-(P-s):b>s&&(Y=b-s):v>P+s?Y=v-(P+s):b<-s&&(Y=b+s),O||Y){var he=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Se=this.viewportToFramedGraph({x:O,y:Y},{cameraState:r});O=Se.x-he.x,Y=Se.y-he.y,u.x+=O,u.y+=Y}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);Tp(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<-zp||d>this.width+zp||f<-Rp||f>this.height+Rp)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],g=m?.drawLabel||p;g(o,K(K({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=uN({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Tp(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,K(K({key:u},f),{},{size:this.scaleSize(f.size)}),K(K(K({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),K(K(K({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),g=m.x,w=m.y,y=r.scaleSize(p.size),b=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],S=v?.drawHover||b;S(i,K(K({key:h},p),{},{size:y,x:g,y:w}),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(g){return r.resetWebGLTexture(g)}),!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=Br(a,u,c,l),this.invMatrix=Br(a,u,c,l,!0),this.correctionRatio=ZI(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=cN(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=lN(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 Np,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=HI(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=K({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 K({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=K({},this.settings);return this.settings[r]=i,cu(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=K({},this.settings);return this.settings=K(K({},this.settings),r),cu(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=xp(),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)||[],g=0,w=m.length;g<w;g++){var y=m[g];if(this.updateEdge(y),o){var b=this.edgeProgramIndex[y];if(b===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],b)}}}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(K(K({},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),g=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-g.x)*(1-h)+u,y:(m.y-g.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?Br(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=Hu(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?Br(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=Hu(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}}])})(Mf),fN=dN;function hN(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 t_(e){var t=hN(e,"string");return typeof t=="symbol"?t:t+""}function n_(e,t,n){return(t=t_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lp(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 ss(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Lp(Object(n),!0).forEach(function(r){n_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pN(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mN(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,t_(r.key),r)}}function gN(e,t,n){return t&&mN(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 r_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(r_=function(){return!!e})()}function i_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yN(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 i_(e)}function vN(e,t,n){return t=as(t),yN(e,r_()?Reflect.construct(t,n||[],as(e).constructor):t.apply(e,n))}function Wu(e,t){return Wu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Wu(e,t)}function bN(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&&Wu(e,t)}function Ku(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 wN(e){if(Array.isArray(e))return Ku(e)}function _N(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function kN(e,t){if(e){if(typeof e=="string")return Ku(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)?Ku(e,t):void 0}}function SN(){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 du(e){return wN(e)||_N(e)||kN(e)||SN()}function o_(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 xN(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=o_((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 EN(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 g=!i||a.x<u.x,w=g?a.x:u.x,y=g?a.y:u.y,b=g?u.x:a.x,v=g?u.y:a.y,S=(w+b)/2,_=(y+v)/2,$=b-w,R=v-y,P=Math.sqrt(Math.pow($,2)+Math.pow(R,2)),O=g?1:-1,Y=S+R*d*O,he=_-$*d*O,Se=s.size*.7+5,$e={x:he-y,y:-(Y-w)},Fe=Math.sqrt(Math.pow($e.x,2)+Math.pow($e.y,2)),M={x:v-he,y:-(b-Y)},G=Math.sqrt(Math.pow(M.x,2)+Math.pow(M.y,2));w+=Se*$e.x/Fe,y+=Se*$e.y/Fe,b+=Se*M.x/G,v+=Se*M.y/G,Y+=Se*R/P,he-=Se*$/P;var B={x:Y,y:he},ee={x:w,y},X={x:b,y:v},V=xN(ee,B,X);if(!(V<a.size+u.size)){var q=o.measureText(m).width,W=V-a.size-u.size;if(q>W){var xe="…";for(m=m+xe,q=o.measureText(m).width;q>W&&m.length>1;)m=m.slice(0,-2)+xe,q=o.measureText(m).width;if(m.length<4)return}for(var Ie={},je=0,st=m.length;je<st;je++){var et=m[je];Ie[et]||(Ie[et]=o.measureText(et).width*(1+d*.35))}for(var L=.5-q/V/2,F=0,H=m.length;F<H;F++){var J=m[F],me=o_(L,ee,B,X),ue=2*(1-L)*(Y-w)+2*L*(b-Y),we=2*(1-L)*(he-y)+2*L*(v-he),Ee=Math.atan2(we,ue);o.save(),o.translate(me.x,me.y),o.rotate(Ee),o.fillText(J,0,0),o.restore(),L+=Ie[J]/V}}}}}function $N(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
420
+ `,CI=TI,Xw=WebGLRenderingContext,wp=Xw.UNSIGNED_BYTE,Zr=Xw.FLOAT,AI=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],II=(function(e){function t(){return dt(this,t),Mt(this,t,arguments)}return Ft(t,e),ft(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:CI,FRAGMENT_SHADER_SOURCE:Ww,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:AI,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Zr},{name:"a_positionEnd",size:2,type:Zr},{name:"a_normal",size:2,type:Zr},{name:"a_color",size:4,type:wp,normalized:!0},{name:"a_id",size:4,type:wp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Zr},{name:"a_normalCoef",size:1,type:Zr}],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=xn(a.color),p=d-c,m=f-l,g=p*p+m*m,w=0,y=0;g&&(g=1/Math.sqrt(g),w=-m*g*u,y=p*g*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=y,b[i++]=h,b[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)}}])})(Pa),Mf=(function(e){function t(){var n;return dt(this,t),n=Mt(this,t),n.rawEmitter=n,n}return Ft(t,e),ft(t)})(bw.EventEmitter),au,_p;function NI(){return _p||(_p=1,au=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),au}var RI=NI();const zI=MC(RI);var LI=function(t){return t},PI=function(t){return t*t},DI=function(t){return t*(2-t)},OI=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},MI=function(t){return t*t*t},FI=function(t){return--t*t*t+1},UI=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},GI={linear:LI,quadraticIn:PI,quadraticOut:DI,quadraticInOut:OI,cubicIn:MI,cubicOut:FI,cubicInOut:UI},jI={easing:"quadraticInOut",duration:150};function jt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Fo(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function kp(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 Sp(e,t,n){return e[6]=t,e[7]=n,e}function pn(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],g=t[5],w=t[6],y=t[7],b=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+g*u,e[4]=p*r+m*s+g*c,e[5]=p*i+m*a+g*l,e[6]=w*n+y*o+b*u,e[7]=w*r+y*s+b*c,e[8]=w*i+y*a+b*l,e}function Hu(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 ZI(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 Br(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=jt(),f=Math.min(c,l)-2*r,h=ZI(t,n);return i?(pn(d,Sp(jt(),a,u)),pn(d,Fo(jt(),s)),pn(d,kp(jt(),o)),pn(d,Fo(jt(),c/f/2/h,l/f/2/h))):(pn(d,Fo(jt(),2*(f/c)*h,2*(f/l)*h)),pn(d,kp(jt(),-o)),pn(d,Fo(jt(),1/s)),pn(d,Sp(jt(),-a,-u))),d}function BI(e,t,n){var r=Hu(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 VI(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 HI(e){if(!zI(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 qI(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 Ep(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function xp(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 $p(e){var t=lr(e.x,2),n=t[0],r=t[1],i=lr(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 qu(e){"@babel/helpers - typeof";return qu=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},qu(e)}function Tp(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 uu(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 Ff={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:uI,defaultDrawNodeLabel:Bw,defaultDrawNodeHover:cI,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:{}},WI={circle:Da},KI={arrow:$I,line:II};function cu(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 JI(e){var t=uu({},Ff,e);return t.nodeProgramClasses=uu({},WI,t.nodeProgramClasses),t.edgeProgramClasses=uu({},KI,t.edgeProgramClasses),t}var Uo=1.5,Cp=(function(e){function t(){var n;return dt(this,t),n=Mt(this,t),N(n,"x",.5),N(n,"y",.5),N(n,"angle",0),N(n,"ratio",1),N(n,"minRatio",null),N(n,"maxRatio",null),N(n,"enabledZooming",!0),N(n,"enabledPanning",!0),N(n,"enabledRotation",!0),N(n,"clean",null),N(n,"nextFrame",null),N(n,"previousState",null),N(n,"enabled",!0),n.previousState=n.getState(),n}return Ft(t,e),ft(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(K(K({},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=K(K({},jI),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:GI[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),g={};typeof u.x=="number"&&(g.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(g.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(g.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(g.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(g),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||Uo)},r):this.animate({ratio:this.ratio/Uo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Uo)},r):this.animate({ratio:this.ratio*Uo})}},{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)}}])})(Mf);function Zt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Xt(e,t){var n=K(K({},Zt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Vr(e){var t="x"in e?e:K(K({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function YI(e,t){return K(K({},Xt(e,t)),{},{delta:Qw(e)})}var XI=2;function qo(e){for(var t=[],n=0,r=Math.min(e.length,XI);n<r;n++)t.push(e[n]);return t}function Hr(e,t,n){var r={touches:qo(e.touches).map(function(i){return Zt(i,n)}),previousTouches:t.map(function(i){return Zt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Qw(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 e_=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t),i.container=n,i.renderer=r,i}return Ft(t,e),ft(t)})(Mf),QI=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],eN=QI.reduce(function(e,t){return K(K({},e),{},N({},t,Ff[t]))},{}),tN=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t,[n,r]),N(i,"enabled",!0),N(i,"draggedEvents",0),N(i,"downStartTime",null),N(i,"lastMouseX",null),N(i,"lastMouseY",null),N(i,"isMouseDown",!1),N(i,"isMoving",!1),N(i,"movingTimeout",null),N(i,"startCameraState",null),N(i,"clicks",0),N(i,"doubleClickTimeout",null),N(i,"currentWheelDirection",0),N(i,"settings",eN),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 Ft(t,e),ft(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",Xt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Xt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Xt(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(Zt(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=Zt(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",Xt(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=Zt(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",Xt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Xt(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=Zt(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,g=p.y+h;s.setState({x:m,y:g}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Xt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Xt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=Qw(r);if(s){var a=YI(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(Zt(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}}])})(e_),nN=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],rN=nN.reduce(function(e,t){return K(K({},e),{},N({},t,Ff[t]))},{}),iN=(function(e){function t(n,r){var i;return dt(this,t),i=Mt(this,t,[n,r]),N(i,"enabled",!0),N(i,"isMoving",!1),N(i,"hasMoved",!1),N(i,"touchMode",0),N(i,"startTouchesPositions",[]),N(i,"lastTouches",[]),N(i,"lastTap",null),N(i,"settings",rN),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 Ft(t,e),ft(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=qo(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Zt(h,i.container)}),this.touchMode===2){var s=lr(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",Hr(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",Hr(r,this.lastTouches,this.container)),!r.touches.length){var a=Zt(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=Hr(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=Hr(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=qo(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=qo(r.touches),s=o.map(function(V){return Zt(V,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=Hr(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(V,q){var W=i.startTouchesPositions[q];return W&&(V.x!==W.x||V.y!==W.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]),g=m.x,w=m.y;c.setState({x:l.x+h-g,y:l.y+p-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,S=b.y,_=s[1],$=_.x,z=_.y,P=Math.atan2(z-S,$-v)-this.startTouchesAngle,O=Math.hypot(z-S,$-v)/this.startTouchesDistance,Y=c.getBoundedRatio(l.ratio/O);y.ratio=Y,y.angle=l.angle+P;var he=this.getDimensions(),Se=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),$e=Math.min(he.width,he.height)-2*d,Fe=$e/he.width,M=$e/he.height,G=Y/$e,B=v-$e/2/Fe,ee=S-$e/2/M,X=[B*Math.cos(-y.angle)-ee*Math.sin(-y.angle),ee*Math.cos(-y.angle)+B*Math.sin(-y.angle)];B=X[0],ee=X[1],y.x=Se.x-B*G,y.y=Se.y+ee*G,c.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(e_);function oN(e){if(Array.isArray(e))return Bu(e)}function sN(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function aN(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
421
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ap(e){return oN(e)||sN(e)||Pw(e)||aN()}function uN(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 lu(e,t){if(e==null)return{};var n,r,i=uN(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 Ip=(function(){function e(t,n){dt(this,e),this.key=t,this.size=n}return ft(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Np=(function(){function e(){dt(this,e),N(this,"width",0),N(this,"height",0),N(this,"cellSize",0),N(this,"columns",0),N(this,"rows",0),N(this,"cells",{})}return ft(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 Ip(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(Ip.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 cN(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 Rp=150,zp=50,Qt=Object.prototype.hasOwnProperty;function lN(e,t,n){if(!Qt.call(n,"x")||!Qt.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),Qt.call(n,"hidden")||(n.hidden=!1),Qt.call(n,"highlighted")||(n.highlighted=!1),Qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function dN(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Qt.call(n,"hidden")||(n.hidden=!1),Qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var fN=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(dt(this,t),i=Mt(this,t),N(i,"elements",{}),N(i,"canvasContexts",{}),N(i,"webGLContexts",{}),N(i,"pickingLayers",new Set),N(i,"textures",{}),N(i,"frameBuffers",{}),N(i,"activeListeners",{}),N(i,"labelGrid",new Np),N(i,"nodeDataCache",{}),N(i,"edgeDataCache",{}),N(i,"nodeProgramIndex",{}),N(i,"edgeProgramIndex",{}),N(i,"nodesWithForcedLabels",new Set),N(i,"edgesWithForcedLabels",new Set),N(i,"nodeExtent",{x:[0,1],y:[0,1]}),N(i,"nodeZExtent",[1/0,-1/0]),N(i,"edgeZExtent",[1/0,-1/0]),N(i,"matrix",jt()),N(i,"invMatrix",jt()),N(i,"correctionRatio",1),N(i,"customBBox",null),N(i,"normalizationFunction",$p({x:[0,1],y:[0,1]})),N(i,"graphToViewportRatio",1),N(i,"itemIDsIndex",{}),N(i,"nodeIndices",{}),N(i,"edgeIndices",{}),N(i,"width",0),N(i,"height",0),N(i,"pixelRatio",Ep()),N(i,"pickingDownSizingRatio",2*i.pixelRatio),N(i,"displayedNodeLabels",new Set),N(i,"displayedEdgeLabels",new Set),N(i,"highlightedNodes",new Set),N(i,"hoveredNode",null),N(i,"hoveredEdge",null),N(i,"renderFrame",null),N(i,"renderHighlightedNodesFrame",null),N(i,"needToProcess",!1),N(i,"checkEdgesEventsFrame",null),N(i,"nodePrograms",{}),N(i,"nodeHoverPrograms",{}),N(i,"edgePrograms",{}),i.settings=JI(o),cu(i.settings),HI(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 Cp,i.bindCameraHandlers(),i.mouseCaptor=new tN(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new iN(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ft(t,e),ft(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=lu(i,[r].map(Yr));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=lu(a,[r].map(Yr));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=lu(i,[r].map(Yr));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=fp(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=dp.apply(void 0,Ap(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=Vr(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",K(K({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",K(K({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",K(K({},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",K(K({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",K(K({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=Vr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Vr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",K(K({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",K(K({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",K({},a))},this.activeListeners.handleEnter=function(o){var s=Vr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",K({},a))};var i=function(s){return function(a){var u=Vr(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),K(K({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),K(K({},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=fp(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=dp.apply(void 0,Ap(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=VI(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=$p(this.customBBox||this.nodeExtent);var f=new Cp,h=Br(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},g={},w={},y=1,b=i.nodes(),v=0,S=b.length;v<S;v++){var _=b[v],$=this.nodeDataCache[_],z=i.getNodeAttributes(_);$.x=z.x,$.y=z.y,this.normalizationFunction.applyTo($),typeof $.label=="string"&&!$.hidden&&this.labelGrid.add(_,$.size,this.framedGraphToViewport($,{matrix:h})),p[$.type]=(p[$.type]||0)+1}this.labelGrid.organize();for(var P in this.nodePrograms){if(!Qt.call(this.nodePrograms,P))throw new Error('Sigma: could not find a suitable program for node type "'.concat(P,'"!'));this.nodePrograms[P].reallocate(p[P]||0),p[P]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=xp(this.nodeZExtent,function(Ie){return r.nodeDataCache[Ie].zIndex},b));for(var O=0,Y=b.length;O<Y;O++){var he=b[O];m[he]=y,w[m[he]]={type:"node",id:he},y++;var Se=this.nodeDataCache[he];this.addNodeToProgram(he,m[he],p[Se.type]++)}for(var $e={},Fe=i.edges(),M=0,G=Fe.length;M<G;M++){var B=Fe[M],ee=this.edgeDataCache[B];$e[ee.type]=($e[ee.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Fe=xp(this.edgeZExtent,function(Ie){return r.edgeDataCache[Ie].zIndex},Fe));for(var X in this.edgePrograms){if(!Qt.call(this.edgePrograms,X))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(X,'"!'));this.edgePrograms[X].reallocate($e[X]||0),$e[X]=0}for(var V=0,q=Fe.length;V<q;V++){var W=Fe[V];g[W]=y,w[g[W]]={type:"edge",id:W},y++;var Ee=this.edgeDataCache[W];this.addEdgeToProgram(W,g[W],$e[Ee.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=g,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&&qu(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=K({},r),c=a||this.nodeExtent,l=lr(c.x,2),d=l[0],f=l[1],h=lr(c.y,2),p=h[0],m=h[1],g=[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})],w=1/0,y=-1/0,b=1/0,v=-1/0;g.forEach(function($e){var Fe=$e.x,M=$e.y;w=Math.min(w,Fe),y=Math.max(y,Fe),b=Math.min(b,M),v=Math.max(v,M)});var S=y-w,_=v-b,$=this.getDimensions(),z=$.width,P=$.height,O=0,Y=0;if(S>=z?y<z-s?O=y-(z-s):w>s&&(O=w-s):y>z+s?O=y-(z+s):w<-s&&(O=w+s),_>=P?v<P-s?Y=v-(P-s):b>s&&(Y=b-s):v>P+s?Y=v-(P+s):b<-s&&(Y=b+s),O||Y){var he=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Se=this.viewportToFramedGraph({x:O,y:Y},{cameraState:r});O=Se.x-he.x,Y=Se.y-he.y,u.x+=O,u.y+=Y}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);Tp(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<-Rp||d>this.width+Rp||f<-zp||f>this.height+zp)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],g=m?.drawLabel||p;g(o,K(K({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=cN({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Tp(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,K(K({key:u},f),{},{size:this.scaleSize(f.size)}),K(K(K({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),K(K(K({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),g=m.x,w=m.y,y=r.scaleSize(p.size),b=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],S=v?.drawHover||b;S(i,K(K({key:h},p),{},{size:y,x:g,y:w}),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(g){return r.resetWebGLTexture(g)}),!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=Br(a,u,c,l),this.invMatrix=Br(a,u,c,l,!0),this.correctionRatio=BI(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=lN(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=dN(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 Np,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=qI(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=K({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 K({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=K({},this.settings);return this.settings[r]=i,cu(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=K({},this.settings);return this.settings=K(K({},this.settings),r),cu(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=Ep(),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)||[],g=0,w=m.length;g<w;g++){var y=m[g];if(this.updateEdge(y),o){var b=this.edgeProgramIndex[y];if(b===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],b)}}}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(K(K({},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),g=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-g.x)*(1-h)+u,y:(m.y-g.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?Br(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=Hu(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?Br(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=Hu(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}}])})(Mf),hN=fN;function pN(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 t_(e){var t=pN(e,"string");return typeof t=="symbol"?t:t+""}function n_(e,t,n){return(t=t_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lp(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 ss(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Lp(Object(n),!0).forEach(function(r){n_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function mN(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gN(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,t_(r.key),r)}}function yN(e,t,n){return t&&gN(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 r_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(r_=function(){return!!e})()}function i_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vN(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 i_(e)}function bN(e,t,n){return t=as(t),vN(e,r_()?Reflect.construct(t,n||[],as(e).constructor):t.apply(e,n))}function Wu(e,t){return Wu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Wu(e,t)}function wN(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&&Wu(e,t)}function Ku(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 _N(e){if(Array.isArray(e))return Ku(e)}function kN(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function SN(e,t){if(e){if(typeof e=="string")return Ku(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)?Ku(e,t):void 0}}function EN(){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 du(e){return _N(e)||kN(e)||SN(e)||EN()}function o_(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 xN(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=o_((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 $N(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 g=!i||a.x<u.x,w=g?a.x:u.x,y=g?a.y:u.y,b=g?u.x:a.x,v=g?u.y:a.y,S=(w+b)/2,_=(y+v)/2,$=b-w,z=v-y,P=Math.sqrt(Math.pow($,2)+Math.pow(z,2)),O=g?1:-1,Y=S+z*d*O,he=_-$*d*O,Se=s.size*.7+5,$e={x:he-y,y:-(Y-w)},Fe=Math.sqrt(Math.pow($e.x,2)+Math.pow($e.y,2)),M={x:v-he,y:-(b-Y)},G=Math.sqrt(Math.pow(M.x,2)+Math.pow(M.y,2));w+=Se*$e.x/Fe,y+=Se*$e.y/Fe,b+=Se*M.x/G,v+=Se*M.y/G,Y+=Se*z/P,he-=Se*$/P;var B={x:Y,y:he},ee={x:w,y},X={x:b,y:v},V=xN(ee,B,X);if(!(V<a.size+u.size)){var q=o.measureText(m).width,W=V-a.size-u.size;if(q>W){var Ee="…";for(m=m+Ee,q=o.measureText(m).width;q>W&&m.length>1;)m=m.slice(0,-2)+Ee,q=o.measureText(m).width;if(m.length<4)return}for(var Ie={},je=0,st=m.length;je<st;je++){var et=m[je];Ie[et]||(Ie[et]=o.measureText(et).width*(1+d*.35))}for(var L=.5-q/V/2,F=0,H=m.length;F<H;F++){var J=m[F],me=o_(L,ee,B,X),ue=2*(1-L)*(Y-w)+2*L*(b-Y),we=2*(1-L)*(he-y)+2*L*(v-he),xe=Math.atan2(we,ue);o.save(),o.translate(me.x,me.y),o.rotate(xe),o.fillText(J,0,0),o.restore(),L+=Ie[J]/V}}}}}function TN(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
423
423
  precision highp float;
424
424
 
425
425
  varying vec4 v_color;
@@ -494,7 +494,7 @@ void main(void) {
494
494
  gl_FragColor = transparent;
495
495
  }
496
496
  }
497
- `);return i}function TN(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
497
+ `);return i}function CN(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
498
498
  attribute vec4 a_id;
499
499
  attribute vec4 a_color;
500
500
  attribute float a_direction;
@@ -604,9 +604,9 @@ void main() {
604
604
 
605
605
  v_color.a *= bias;
606
606
  }
607
- `);return i}var s_=.25,CN={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:s_},a_=WebGLRenderingContext,Pp=a_.UNSIGNED_BYTE,mn=a_.FLOAT;function Ma(e){var t=ss(ss({},CN),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(du(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){bN(l,c);function l(){var d;pN(this,l);for(var f=arguments.length,h=new Array(f),p=0;p<f;p++)h[p]=arguments[p];return d=vN(this,l,[].concat(h)),n_(i_(d),"drawLabel",o||EN(t)),d}return gN(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:TN(t),FRAGMENT_SHADER_SOURCE:$N(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:mn},{name:"a_target",size:2,type:mn}].concat(du(s?[{name:"a_targetSize",size:1,type:mn}]:[]),du(a?[{name:"a_sourceSize",size:1,type:mn}]:[]),[{name:"a_thickness",size:1,type:mn},{name:"a_curvature",size:1,type:mn},{name:"a_color",size:4,type:Pp,normalized:!0},{name:"a_id",size:4,type:Pp,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:mn},{name:"a_direction",size:1,type:mn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(f,h,p,m,g){var w,y=g.size||1,b=p.x,v=p.y,S=m.x,_=m.y,$=En(g.color),R=(w=g[i])!==null&&w!==void 0?w:s_,P=this.array;P[h++]=b,P[h++]=v,P[h++]=S,P[h++]=_,s&&(P[h++]=m.size),a&&(P[h++]=p.size),P[h++]=y,P[h++]=R,P[h++]=$,P[h++]=f}},{key:"setUniforms",value:function(f,h){var p=h.gl,m=h.uniformLocations,g=m.u_matrix,w=m.u_pixelRatio,y=m.u_feather,b=m.u_sizeRatio,v=m.u_dimensions,S=m.u_minEdgeThickness;if(p.uniformMatrix3fv(g,!1,f.matrix),p.uniform1f(w,f.pixelRatio),p.uniform1f(b,f.sizeRatio),p.uniform1f(y,f.antiAliasingFeather),p.uniform2f(v,f.width*f.pixelRatio,f.height*f.pixelRatio),p.uniform1f(S,f.minEdgeThickness),r){var _=m.u_lengthToThicknessRatio,$=m.u_widenessToThicknessRatio;p.uniform1f(_,r.lengthToThicknessRatio),p.uniform1f($,r.widenessToThicknessRatio)}}}]),l})(Pa)}Ma();Ma({arrowHead:Oa});Ma({arrowHead:ss(ss({},Oa),{},{extremity:"both"})});function AN(e){if(Array.isArray(e))return e}function IN(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 Ju(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 u_(e,t){if(e){if(typeof e=="string")return Ju(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)?Ju(e,t):void 0}}function NN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
608
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zN(e,t){return AN(e)||IN(e,t)||u_(e,t)||NN()}function RN(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function LN(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 c_(e){var t=LN(e,"string");return typeof t=="symbol"?t:t+""}function PN(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,c_(r.key),r)}}function DN(e,t,n){return t&&PN(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function us(e){return us=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},us(e)}function l_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l_=function(){return!!e})()}function Yu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ON(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 Yu(e)}function MN(e,t,n){return t=us(t),ON(e,l_()?Reflect.construct(t,n||[],us(e).constructor):t.apply(e,n))}function Xu(e,t){return Xu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Xu(e,t)}function FN(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&&Xu(e,t)}function Wn(e,t,n){return(t=c_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UN(e){if(Array.isArray(e))return Ju(e)}function GN(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function jN(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
609
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fu(e){return UN(e)||GN(e)||u_(e)||jN()}function Dp(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 Op(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dp(Object(n),!0).forEach(function(r){Wn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ZN="relative",BN={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},VN="#000000";function HN(e){var t=e.borders,n=mp(t.filter(function(i){var o=i.size;return"fill"in o}).length),r=`
607
+ `);return i}var s_=.25,AN={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:s_},a_=WebGLRenderingContext,Pp=a_.UNSIGNED_BYTE,mn=a_.FLOAT;function Ma(e){var t=ss(ss({},AN),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(du(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){wN(l,c);function l(){var d;mN(this,l);for(var f=arguments.length,h=new Array(f),p=0;p<f;p++)h[p]=arguments[p];return d=bN(this,l,[].concat(h)),n_(i_(d),"drawLabel",o||$N(t)),d}return yN(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:CN(t),FRAGMENT_SHADER_SOURCE:TN(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:mn},{name:"a_target",size:2,type:mn}].concat(du(s?[{name:"a_targetSize",size:1,type:mn}]:[]),du(a?[{name:"a_sourceSize",size:1,type:mn}]:[]),[{name:"a_thickness",size:1,type:mn},{name:"a_curvature",size:1,type:mn},{name:"a_color",size:4,type:Pp,normalized:!0},{name:"a_id",size:4,type:Pp,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:mn},{name:"a_direction",size:1,type:mn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(f,h,p,m,g){var w,y=g.size||1,b=p.x,v=p.y,S=m.x,_=m.y,$=xn(g.color),z=(w=g[i])!==null&&w!==void 0?w:s_,P=this.array;P[h++]=b,P[h++]=v,P[h++]=S,P[h++]=_,s&&(P[h++]=m.size),a&&(P[h++]=p.size),P[h++]=y,P[h++]=z,P[h++]=$,P[h++]=f}},{key:"setUniforms",value:function(f,h){var p=h.gl,m=h.uniformLocations,g=m.u_matrix,w=m.u_pixelRatio,y=m.u_feather,b=m.u_sizeRatio,v=m.u_dimensions,S=m.u_minEdgeThickness;if(p.uniformMatrix3fv(g,!1,f.matrix),p.uniform1f(w,f.pixelRatio),p.uniform1f(b,f.sizeRatio),p.uniform1f(y,f.antiAliasingFeather),p.uniform2f(v,f.width*f.pixelRatio,f.height*f.pixelRatio),p.uniform1f(S,f.minEdgeThickness),r){var _=m.u_lengthToThicknessRatio,$=m.u_widenessToThicknessRatio;p.uniform1f(_,r.lengthToThicknessRatio),p.uniform1f($,r.widenessToThicknessRatio)}}}]),l})(Pa)}Ma();Ma({arrowHead:Oa});Ma({arrowHead:ss(ss({},Oa),{},{extremity:"both"})});function IN(e){if(Array.isArray(e))return e}function NN(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 Ju(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 u_(e,t){if(e){if(typeof e=="string")return Ju(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)?Ju(e,t):void 0}}function RN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
608
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zN(e,t){return IN(e)||NN(e,t)||u_(e,t)||RN()}function LN(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function PN(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 c_(e){var t=PN(e,"string");return typeof t=="symbol"?t:t+""}function DN(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,c_(r.key),r)}}function ON(e,t,n){return t&&DN(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function us(e){return us=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},us(e)}function l_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l_=function(){return!!e})()}function Yu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function MN(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 Yu(e)}function FN(e,t,n){return t=us(t),MN(e,l_()?Reflect.construct(t,n||[],us(e).constructor):t.apply(e,n))}function Xu(e,t){return Xu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Xu(e,t)}function UN(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&&Xu(e,t)}function Wn(e,t,n){return(t=c_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function GN(e){if(Array.isArray(e))return Ju(e)}function jN(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ZN(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
609
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fu(e){return GN(e)||jN(e)||u_(e)||ZN()}function Dp(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 Op(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dp(Object(n),!0).forEach(function(r){Wn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var BN="relative",VN={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},HN="#000000";function qN(e){var t=e.borders,n=mp(t.filter(function(i){var o=i.size;return"fill"in o}).length),r=`
610
610
  precision highp float;
611
611
 
612
612
  varying vec2 v_diffVector;
@@ -643,7 +643,7 @@ void main(void) {
643
643
  }
644
644
  #else
645
645
  // Sizes:
646
- `).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):mp(s.value),u=(s.mode||ZN)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(u," * ").concat(a,";")]}).join(`
646
+ `).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):mp(s.value),u=(s.mode||BN)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(u," * ").concat(a,";")]}).join(`
647
647
  `),`
648
648
  // Now, let's split the remaining space between "fill" borders:
649
649
  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,`;
@@ -669,7 +669,7 @@ void main(void) {
669
669
  } else `)}).join(""),` { /* Nothing to add here */ }
670
670
  #endif
671
671
  }
672
- `);return r}function qN(e){var t=e.borders,n=`
672
+ `);return r}function WN(e){var t=e.borders,n=`
673
673
  attribute vec2 a_position;
674
674
  attribute float a_size;
675
675
  attribute float a_angle;
@@ -716,7 +716,7 @@ void main() {
716
716
  `),`
717
717
  #endif
718
718
  }
719
- `);return n}var d_=WebGLRenderingContext,Mp=d_.UNSIGNED_BYTE,Go=d_.FLOAT;function f_(e){var t,n=Op(Op({},BN),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(fu(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){FN(u,a);function u(){var c;RN(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=MN(this,u,[].concat(d)),Wn(Yu(c),"drawLabel",i),Wn(Yu(c),"drawHover",o),c}return DN(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:qN(n),FRAGMENT_SHADER_SOURCE:HN(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:Go},{name:"a_id",size:4,type:Mp,normalized:!0},{name:"a_size",size:1,type:Go}].concat(fu(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:Mp,normalized:!0}]:[]})),fu(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:Go}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Go}],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++]=En(f[m.attribute]||m.defaultValue||VN))}),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,g=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(g,!1,l.matrix),r.forEach(function(w,y){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(y+1)],S=QA(b.value),_=zN(S,4),$=_[0],R=_[1],P=_[2],O=_[3];f.uniform4f(v,$/255,R/255,P/255,O/255)}})}}]),u})(Zw),Wn(t,"ANGLE_1",0),Wn(t,"ANGLE_2",2*Math.PI/3),Wn(t,"ANGLE_3",4*Math.PI/3),t}f_();const cs=.18,WN=500,KN=2,JN=3,jo={rest:2,selected:4,expanded:5},YN=6,hu=2,XN=8,Fp=6,pu=400,QN=2e3,ez={x:[0,1e3],y:[0,1e3]},mu=1e3,Up=500,tz={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 Zo(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Ht(e,t=1){return`#${Zo(e.r)}${Zo(e.g)}${Zo(e.b)}${Zo(e.a*t*255)}`}function h_(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 p_(e,t,n=cs){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 m_(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 nz(e,t,n,r=cs){const i=p_(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=h_(t,i,n,a/12);o=Math.min(o,m_(e,s,u)),s=u}return o}function rz(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(L){const F=u.get(L);if(F)return F;a.style.color="",a.style.color=L;const H=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],J={r:H[0]??0,g:H[1]??0,b:H[2]??0,a:H[3]??1};return u.set(L,J),J}const l=L=>c(`var(--cia-graph-${L})`);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")}}f();function h(L,F){if(!F.texts?.length||!F.outer)return;const H=F.size/F.outer;L.textAlign="center",L.textBaseline="alphabetic",L.lineJoin="round";for(const J of F.texts){const me=tz[J.kind],ue=me.size*H;if(ue<Fp)continue;L.font=me.font(ue);const we=F.y+J.y*H;L.lineWidth=4*H,L.strokeStyle=F.haloColor??"#000",L.strokeText(J.text,F.x,we),L.fillStyle=J.kind==="role"?F.toneColor??"#fff":J.kind==="address"?F.mutedColor??"#aaa":F.textColor??"#fff",L.fillText(J.text,F.x,we)}}const p=()=>{},m=f_({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}),g=Ma({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=Yw({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let y=new Le({type:"directed",multi:!1,allowSelfLoops:!1});const b=new fN(y,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:L=>L,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:Fp,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:g,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(ez);const v=b.getMouseCaptor(),S=b.getTouchCaptor();v.removeAllListeners(),S.removeAllListeners(),v.enabled=!1,S.enabled=!1;const _=new Map;let $=cs;function R(L){const F=t.flags().get(L),H=t.selected();return F?.has("expanded")?{width:jo.expanded,color:d.expanded}:H?.kind==="node"&&H.id===L||t.highlighted()===L?{width:jo.selected,color:d.selected}:{width:jo.rest,color:c(t.colorOf(_.get(L)))}}function P(L,F,H){const J=t.model(),me=t.notes().get(L.id)??null,ue=Rr(L,J.checked_address,me),we=c(t.colorOf(L)),Ee=R(L.id),ae=ue.radius+Ee.width/2,Q=ue.ring?ue.radius+YN+hu/2:ae,Ge=ue.ring?hu/Q:0,at=ue.ring?Math.max(0,Q-hu-ae)/Q:0,Ze=t.selected(),Be=ue.ring||Ee.width!==jo.rest||Ze?.kind==="node"&&Ze.id===L.id;return{x:F.x,y:-F.y,size:Q,label:ue.texts.find(ht=>ht.kind==="address")?.text??L.address,color:Ht(we),forceLabel:!H||Be,ringColor:Ht(d.edge),ringSize:Ge,gapSize:at,strokeColor:Ht(Ee.color,me?.5:1),strokeSize:Ee.width/Q,bodyColor:Ht(d.node),dotColor:Ht(we),dotSize:ue.dot/Q,outer:Q,texts:ue.texts,toneColor:Ht(we),mutedColor:Ht(d.muted),textColor:Ht(d.text),haloColor:Ht(d.halo)}}function O(L,F){const H=t.selected(),J=H?.kind==="node"?_.get(H.id)?.address??null:null,me=H?.kind==="edge"&&H.id===L.id,ue=H?.kind==="edge"?me?Wt.related:Wt.faded:Jb(L,J);return{size:me?JN:KN,color:Ht(c(t.colorOf(F)),ue),curvature:$,type:$?"link":"straight"}}function Y(){const L=t.model(),F=t.positions(),{width:H,height:J}=t.dimensions();_.clear();for(const ae of L.nodes)_.set(ae.id,ae);const me=L.nodes.length>pu;$=L.edges.length>WN?0:cs;const ue=new Le({type:"directed",multi:!1,allowSelfLoops:!1}),we=new Map(L.nodes.map(ae=>[ae.address,ae]));for(const ae of L.nodes)ue.addNode(ae.id,P(ae,F[ae.id]??{x:H/2,y:J/2},me));for(const ae of L.edges){const Q=we.get(ae.from),Ge=we.get(ae.to);!Q||!Ge||Q.id===Ge.id||ue.hasEdge(ae.id)||ue.hasDirectedEdge(Q.id,Ge.id)||ue.addDirectedEdgeWithKey(ae.id,Q.id,Ge.id,O(ae,Q))}y=ue;const Ee=t.selected();$e=[Ee?.kind==="node"?Ee.id:null,t.highlighted()].filter(ae=>!!ae),b.setGraph(y),G()}function he(){const F=t.model().nodes.length>pu,H=t.positions();y.updateEachNodeAttributes((J,me)=>{const ue=_.get(J);return ue?P(ue,H[J]??{x:me.x,y:-me.y},F):me}),M()}function Se(L){const F=L?_.get(L):null;if(!F||!y.hasNode(F.id))return;const H=t.positions()[F.id],J=y.getNodeAttributes(F.id);y.replaceNodeAttributes(F.id,P(F,H??{x:J.x,y:-J.y},t.model().nodes.length>pu))}let $e=[];function Fe(){const L=t.selected(),F=[L?.kind==="node"?L.id:null,t.highlighted()].filter(H=>!!H);for(const H of new Set([...$e,...F]))Se(H);$e=F,M()}function M(){const L=t.model(),F=new Map(L.nodes.map(J=>[J.address,J])),H=new Map(L.edges.map(J=>[J.id,J]));y.updateEachEdgeAttributes((J,me)=>{const ue=H.get(J),we=ue&&F.get(ue.from);return ue&&we?O(ue,we):me})}function G(){const{width:L,height:F}=t.dimensions(),H=b.getDimensions();if(!H.width||!H.height)return;const J=Math.min(H.width/L,H.height/F),me=t.transform(),ue=me.scale*J,we=(H.width-L*J)/2+me.x*J,Ee=(H.height-F*J)/2+me.y*J,ae={x:.5,y:.5,ratio:1,angle:0},Q=b.framedGraphToViewport({x:.5,y:.5},{cameraState:ae}),Ge=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:ae}).x-Q.x)/.1,at=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:ae}).y-Q.y)/.1,Ze=Ge/(mu*ue);b.getCamera().setState({ratio:Ze,angle:0,x:.5-Up/mu-(we-Q.x)*Ze/Ge,y:.5-Up/mu-(Ee-Q.y)*Ze/at})}function B(L){const F=t.transform(),H={x:(L.x-F.x)/F.scale,y:(L.y-F.y)/F.scale},J=t.positions();let me=null,ue=1/0;if(y.forEachNode((Q,Ge)=>{const at=J[Q];if(!at)return;const Ze=Math.hypot(H.x-at.x,H.y-at.y);Ze<=Ge.size+1/F.scale&&Ze<ue&&(me=Q,ue=Ze)}),me)return{kind:"node",id:me};const we=XN/F.scale;let Ee=null,ae=1/0;return y.forEachEdge((Q,Ge,at,Ze)=>{const Be=J[at],ht=J[Ze];if(!Be||!ht)return;const C=Math.hypot(ht.x-Be.x,ht.y-Be.y)*(.5+$)+we;if(Math.hypot(H.x-(Be.x+ht.x)/2,H.y-(Be.y+ht.y)/2)>C)return;const z=$?nz(H,Be,ht,$):m_(H,Be,ht);z<=we&&z<ae&&(Ee=Q,ae=z)}),Ee?{kind:"edge",id:Ee}:{kind:"canvas",id:null}}let ee=0,X=null,V=null;const q=L=>{L.buttons||(V=L,!ee&&(ee=o.requestAnimationFrame(()=>{ee=0;const F=V;if(!F)return;const H=s.getBoundingClientRect(),{width:J,height:me}=t.dimensions(),ue=Math.min(H.width/J,H.height/me)||1,we=B({x:(F.clientX-H.left-(H.width-J*ue)/2)/ue,y:(F.clientY-H.top-(H.height-me*ue)/2)/ue}),Ee=we.kind==="canvas"?null:`${we.kind}:${we.id}`;if(s.style.cursor=Ee?"pointer":"",Ee!==X){if(X=Ee,!Ee){n.hideTooltip();return}if(we.kind==="node"){const ae=_.get(we.id);ae&&n.showTooltip(F,Ou(ae))}else{const ae=t.model().edges.find(Q=>Q.id===we.id);ae&&n.showTooltip(F,Mu(ae,t.now()))}}})))},W=()=>{X=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",q),s.addEventListener("pointerleave",W);let xe=null;const Ie=L=>{L.preventDefault(),!xe&&(xe=setTimeout(()=>{xe=null,n.lost()},QN))},je=()=>{xe&&clearTimeout(xe),xe=null,n.lost()},st=Object.values(b.getCanvases());for(const L of st)L.addEventListener("webglcontextlost",Ie),L.addEventListener("webglcontextrestored",je);function et(){const L=t.positions();let F=null;return y.forEachEdge((H,J,me,ue)=>{const we=L[me],Ee=L[ue];if(!we||!Ee||!$)return;const ae=h_(we,p_(we,Ee,$),Ee,.5);F=F??{x1:ae.x,y1:ae.y,x2:ae.x,y2:ae.y},F.x1=Math.min(F.x1,ae.x),F.y1=Math.min(F.y1,ae.y),F.x2=Math.max(F.x2,ae.x),F.y2=Math.max(F.y2,ae.y)}),F}return{kind:"webgl",surface:s,build:Y,geometry(){const L=t.positions();y.updateEachNodeAttributes((F,H)=>{const J=L[F];return J?{...H,x:J.x,y:-J.y}:H},{attributes:["x","y"]}),G()},moveNode(L){const F=t.positions()[L];F&&y.hasNode(L)&&y.mergeNodeAttributes(L,{x:F.x,y:-F.y})},endMove(){},camera:G,selection:Fe,flag:L=>Se(L),theme(){f(),he()},resize(){b.resize(!0),G()},pick:B,linkBounds:et,destroy(){xe&&clearTimeout(xe),ee&&o.cancelAnimationFrame(ee),s.removeEventListener("pointermove",q),s.removeEventListener("pointerleave",W);for(const L of st)L.removeEventListener("webglcontextlost",Ie),L.removeEventListener("webglcontextrestored",je);b.kill(),s.remove()}}}s$("webgl",rz);const yo=document.getElementById("view"),g_=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let _n={},Bo=vw(document,_n,{prefersDark:g_}),Vt=null;cw(yo);const Jt=new Ef({name:"chain-insights-view",version:"1.0.0"},{});function y_(e){const t=Bo;Bo=vw(document,e,{prefersDark:g_,applyVariables:(n,r)=>i$(n,r),applyFonts:o$}),Vt&&Bo!==t&&Vt.setTheme(Bo),Vt?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function iz(e){Vt?.destroy(),Vt=null;const t=Rf(Jt.getHostContext(),_n);Vt=LC(yo,e,{host:Jt,availableDisplayModes:t.availableDisplayModes,displayMode:t.displayMode}),document.documentElement.dataset.view=Vt.kind}Jt.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;Vt||cw(yo,t?`Loading the graph of ${t}`:"Loading the Chain Insights view")};Jt.ontoolresult=e=>{iz(e)};Jt.ontoolcancelled=()=>{Vt||Ra(yo,null,"The tool call was cancelled. Nothing to draw.")};Jt.onhostcontextchanged=e=>{_n=Rf(_n,e),y_(_n)};Jt.onteardown=async()=>(Vt?.destroy(),Vt=null,{});Jt.onerror=e=>{console.warn("chain-insights-view:",e)};Jt.connect(new Zb(window.parent,window.parent)).then(()=>{_n=Rf(_n,Jt.getHostContext()),y_(_n)},e=>{console.warn("chain-insights-view: no host answered",e),Ra(yo,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
719
+ `);return n}var d_=WebGLRenderingContext,Mp=d_.UNSIGNED_BYTE,Go=d_.FLOAT;function f_(e){var t,n=Op(Op({},VN),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(fu(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){UN(u,a);function u(){var c;LN(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=FN(this,u,[].concat(d)),Wn(Yu(c),"drawLabel",i),Wn(Yu(c),"drawHover",o),c}return ON(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:WN(n),FRAGMENT_SHADER_SOURCE:qN(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:Go},{name:"a_id",size:4,type:Mp,normalized:!0},{name:"a_size",size:1,type:Go}].concat(fu(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:Mp,normalized:!0}]:[]})),fu(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:Go}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Go}],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++]=xn(f[m.attribute]||m.defaultValue||HN))}),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,g=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(g,!1,l.matrix),r.forEach(function(w,y){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(y+1)],S=eI(b.value),_=zN(S,4),$=_[0],z=_[1],P=_[2],O=_[3];f.uniform4f(v,$/255,z/255,P/255,O/255)}})}}]),u})(Zw),Wn(t,"ANGLE_1",0),Wn(t,"ANGLE_2",2*Math.PI/3),Wn(t,"ANGLE_3",4*Math.PI/3),t}f_();const cs=.18,KN=500,JN=2,YN=3,jo={rest:2,selected:4,expanded:5},XN=6,hu=2,QN=8,Fp=6,pu=400,eR=2e3,tR={x:[0,1e3],y:[0,1e3]},mu=1e3,Up=500,nR={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 Zo(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Ht(e,t=1){return`#${Zo(e.r)}${Zo(e.g)}${Zo(e.b)}${Zo(e.a*t*255)}`}function h_(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 p_(e,t,n=cs){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 m_(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 rR(e,t,n,r=cs){const i=p_(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=h_(t,i,n,a/12);o=Math.min(o,m_(e,s,u)),s=u}return o}function iR(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(L){const F=u.get(L);if(F)return F;a.style.color="",a.style.color=L;const H=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],J={r:H[0]??0,g:H[1]??0,b:H[2]??0,a:H[3]??1};return u.set(L,J),J}const l=L=>c(`var(--cia-graph-${L})`);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")}}f();function h(L,F){if(!F.texts?.length||!F.outer)return;const H=F.size/F.outer;L.textAlign="center",L.textBaseline="alphabetic",L.lineJoin="round";for(const J of F.texts){const me=nR[J.kind],ue=me.size*H;if(ue<Fp)continue;L.font=me.font(ue);const we=F.y+J.y*H;L.lineWidth=4*H,L.strokeStyle=F.haloColor??"#000",L.strokeText(J.text,F.x,we),L.fillStyle=J.kind==="role"?F.toneColor??"#fff":J.kind==="address"?F.mutedColor??"#aaa":F.textColor??"#fff",L.fillText(J.text,F.x,we)}}const p=()=>{},m=f_({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}),g=Ma({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=Yw({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let y=new Le({type:"directed",multi:!1,allowSelfLoops:!1});const b=new hN(y,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:L=>L,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:Fp,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:g,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(tR);const v=b.getMouseCaptor(),S=b.getTouchCaptor();v.removeAllListeners(),S.removeAllListeners(),v.enabled=!1,S.enabled=!1;const _=new Map;let $=cs;function z(L){const F=t.flags().get(L),H=t.selected();return F?.has("expanded")?{width:jo.expanded,color:d.expanded}:H?.kind==="node"&&H.id===L||t.highlighted()===L?{width:jo.selected,color:d.selected}:{width:jo.rest,color:c(t.colorOf(_.get(L)))}}function P(L,F,H){const J=t.model(),me=t.notes().get(L.id)??null,ue=zr(L,J.checked_address,me),we=c(t.colorOf(L)),xe=z(L.id),ae=ue.radius+xe.width/2,Q=ue.ring?ue.radius+XN+hu/2:ae,Ge=ue.ring?hu/Q:0,at=ue.ring?Math.max(0,Q-hu-ae)/Q:0,Ze=t.selected(),Be=ue.ring||xe.width!==jo.rest||Ze?.kind==="node"&&Ze.id===L.id;return{x:F.x,y:-F.y,size:Q,label:ue.texts.find(ht=>ht.kind==="address")?.text??L.address,color:Ht(we),forceLabel:!H||Be,ringColor:Ht(d.edge),ringSize:Ge,gapSize:at,strokeColor:Ht(xe.color,me?.5:1),strokeSize:xe.width/Q,bodyColor:Ht(d.node),dotColor:Ht(we),dotSize:ue.dot/Q,outer:Q,texts:ue.texts,toneColor:Ht(we),mutedColor:Ht(d.muted),textColor:Ht(d.text),haloColor:Ht(d.halo)}}function O(L,F){const H=t.selected(),J=H?.kind==="node"?_.get(H.id)?.address??null:null,me=H?.kind==="edge"&&H.id===L.id,ue=H?.kind==="edge"?me?Wt.related:Wt.faded:Jb(L,J);return{size:me?YN:JN,color:Ht(c(t.colorOf(F)),ue),curvature:$,type:$?"link":"straight"}}function Y(){const L=t.model(),F=t.positions(),{width:H,height:J}=t.dimensions();_.clear();for(const ae of L.nodes)_.set(ae.id,ae);const me=L.nodes.length>pu;$=L.edges.length>KN?0:cs;const ue=new Le({type:"directed",multi:!1,allowSelfLoops:!1}),we=new Map(L.nodes.map(ae=>[ae.address,ae]));for(const ae of L.nodes)ue.addNode(ae.id,P(ae,F[ae.id]??{x:H/2,y:J/2},me));for(const ae of L.edges){const Q=we.get(ae.from),Ge=we.get(ae.to);!Q||!Ge||Q.id===Ge.id||ue.hasEdge(ae.id)||ue.hasDirectedEdge(Q.id,Ge.id)||ue.addDirectedEdgeWithKey(ae.id,Q.id,Ge.id,O(ae,Q))}y=ue;const xe=t.selected();$e=[xe?.kind==="node"?xe.id:null,t.highlighted()].filter(ae=>!!ae),b.setGraph(y),G()}function he(){const F=t.model().nodes.length>pu,H=t.positions();y.updateEachNodeAttributes((J,me)=>{const ue=_.get(J);return ue?P(ue,H[J]??{x:me.x,y:-me.y},F):me}),M()}function Se(L){const F=L?_.get(L):null;if(!F||!y.hasNode(F.id))return;const H=t.positions()[F.id],J=y.getNodeAttributes(F.id);y.replaceNodeAttributes(F.id,P(F,H??{x:J.x,y:-J.y},t.model().nodes.length>pu))}let $e=[];function Fe(){const L=t.selected(),F=[L?.kind==="node"?L.id:null,t.highlighted()].filter(H=>!!H);for(const H of new Set([...$e,...F]))Se(H);$e=F,M()}function M(){const L=t.model(),F=new Map(L.nodes.map(J=>[J.address,J])),H=new Map(L.edges.map(J=>[J.id,J]));y.updateEachEdgeAttributes((J,me)=>{const ue=H.get(J),we=ue&&F.get(ue.from);return ue&&we?O(ue,we):me})}function G(){const{width:L,height:F}=t.dimensions(),H=b.getDimensions();if(!H.width||!H.height)return;const J=Math.min(H.width/L,H.height/F),me=t.transform(),ue=me.scale*J,we=(H.width-L*J)/2+me.x*J,xe=(H.height-F*J)/2+me.y*J,ae={x:.5,y:.5,ratio:1,angle:0},Q=b.framedGraphToViewport({x:.5,y:.5},{cameraState:ae}),Ge=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:ae}).x-Q.x)/.1,at=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:ae}).y-Q.y)/.1,Ze=Ge/(mu*ue);b.getCamera().setState({ratio:Ze,angle:0,x:.5-Up/mu-(we-Q.x)*Ze/Ge,y:.5-Up/mu-(xe-Q.y)*Ze/at})}function B(L){const F=t.transform(),H={x:(L.x-F.x)/F.scale,y:(L.y-F.y)/F.scale},J=t.positions();let me=null,ue=1/0;if(y.forEachNode((Q,Ge)=>{const at=J[Q];if(!at)return;const Ze=Math.hypot(H.x-at.x,H.y-at.y);Ze<=Ge.size+1/F.scale&&Ze<ue&&(me=Q,ue=Ze)}),me)return{kind:"node",id:me};const we=QN/F.scale;let xe=null,ae=1/0;return y.forEachEdge((Q,Ge,at,Ze)=>{const Be=J[at],ht=J[Ze];if(!Be||!ht)return;const C=Math.hypot(ht.x-Be.x,ht.y-Be.y)*(.5+$)+we;if(Math.hypot(H.x-(Be.x+ht.x)/2,H.y-(Be.y+ht.y)/2)>C)return;const R=$?rR(H,Be,ht,$):m_(H,Be,ht);R<=we&&R<ae&&(xe=Q,ae=R)}),xe?{kind:"edge",id:xe}:{kind:"canvas",id:null}}let ee=0,X=null,V=null;const q=L=>{L.buttons||(V=L,!ee&&(ee=o.requestAnimationFrame(()=>{ee=0;const F=V;if(!F)return;const H=s.getBoundingClientRect(),{width:J,height:me}=t.dimensions(),ue=Math.min(H.width/J,H.height/me)||1,we=B({x:(F.clientX-H.left-(H.width-J*ue)/2)/ue,y:(F.clientY-H.top-(H.height-me*ue)/2)/ue}),xe=we.kind==="canvas"?null:`${we.kind}:${we.id}`;if(s.style.cursor=xe?"pointer":"",xe!==X){if(X=xe,!xe){n.hideTooltip();return}if(we.kind==="node"){const ae=_.get(we.id);ae&&n.showTooltip(F,Ou(ae))}else{const ae=t.model().edges.find(Q=>Q.id===we.id);ae&&n.showTooltip(F,Mu(ae,t.now()))}}})))},W=()=>{X=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",q),s.addEventListener("pointerleave",W);let Ee=null;const Ie=L=>{L.preventDefault(),!Ee&&(Ee=setTimeout(()=>{Ee=null,n.lost()},eR))},je=()=>{Ee&&clearTimeout(Ee),Ee=null,n.lost()},st=Object.values(b.getCanvases());for(const L of st)L.addEventListener("webglcontextlost",Ie),L.addEventListener("webglcontextrestored",je);function et(){const L=t.positions();let F=null;return y.forEachEdge((H,J,me,ue)=>{const we=L[me],xe=L[ue];if(!we||!xe||!$)return;const ae=h_(we,p_(we,xe,$),xe,.5);F=F??{x1:ae.x,y1:ae.y,x2:ae.x,y2:ae.y},F.x1=Math.min(F.x1,ae.x),F.y1=Math.min(F.y1,ae.y),F.x2=Math.max(F.x2,ae.x),F.y2=Math.max(F.y2,ae.y)}),F}return{kind:"webgl",surface:s,build:Y,geometry(){const L=t.positions();y.updateEachNodeAttributes((F,H)=>{const J=L[F];return J?{...H,x:J.x,y:-J.y}:H},{attributes:["x","y"]}),G()},moveNode(L){const F=t.positions()[L];F&&y.hasNode(L)&&y.mergeNodeAttributes(L,{x:F.x,y:-F.y})},endMove(){},camera:G,selection:Fe,flag:L=>Se(L),theme(){f(),he()},resize(){b.resize(!0),G()},pick:B,linkBounds:et,destroy(){Ee&&clearTimeout(Ee),ee&&o.cancelAnimationFrame(ee),s.removeEventListener("pointermove",q),s.removeEventListener("pointerleave",W);for(const L of st)L.removeEventListener("webglcontextlost",Ie),L.removeEventListener("webglcontextrestored",je);b.kill(),s.remove()}}}s$("webgl",iR);const yo=document.getElementById("view"),g_=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let _n={},Bo=vw(document,_n,{prefersDark:g_}),Vt=null;cw(yo);const Jt=new xf({name:"chain-insights-view",version:"1.0.0"},{});function y_(e){const t=Bo;Bo=vw(document,e,{prefersDark:g_,applyVariables:(n,r)=>i$(n,r),applyFonts:o$}),Vt&&Bo!==t&&Vt.setTheme(Bo),Vt?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function oR(e){Vt?.destroy(),Vt=null;const t=zf(Jt.getHostContext(),_n);Vt=PC(yo,e,{host:Jt,availableDisplayModes:t.availableDisplayModes,displayMode:t.displayMode}),document.documentElement.dataset.view=Vt.kind}Jt.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;Vt||cw(yo,t?`Loading the graph of ${t}`:"Loading the Chain Insights view")};Jt.ontoolresult=e=>{oR(e)};Jt.ontoolcancelled=()=>{Vt||za(yo,null,"The tool call was cancelled. Nothing to draw.")};Jt.onhostcontextchanged=e=>{_n=zf(_n,e),y_(_n)};Jt.onteardown=async()=>(Vt?.destroy(),Vt=null,{});Jt.onerror=e=>{console.warn("chain-insights-view:",e)};Jt.connect(new Zb(window.parent,window.parent)).then(()=>{_n=zf(_n,Jt.getHostContext()),y_(_n)},e=>{console.warn("chain-insights-view: no host answered",e),za(yo,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
720
720
  </script>
721
721
  <style>.cia-graph-surface{--cia-graph-surface:linear-gradient(140deg,#171a20,#0d0f13);--cia-graph-canvas:#101318;--cia-graph-dot:#f2dda621;--cia-graph-text:#e2e8f0;--cia-graph-muted:#adb1ba;--cia-graph-border:#f2dda640;--cia-graph-divider:#ffffff10;--cia-graph-control:#14161a;--cia-graph-hover:#f2dda626;--cia-graph-active:#f2dda6;--cia-graph-active-text:#0b0e13;--cia-graph-node:#14161a;--cia-graph-edge:#f2dda6;--cia-graph-halo:#07090d;--cia-graph-selected:#ffffff;--cia-graph-expanded:#4da3ff;--cia-graph-danger:#d89087;--cia-graph-target:#8bb6b0;--cia-graph-trail:#b49bc4;--cia-graph-infrastructure:#94b58b;--cia-graph-neutral:#f2dda6;--cia-graph-critical:#d89087;--cia-graph-high:#d6a07d;--cia-graph-medium:#b49bc4;--cia-graph-low:#94b58b;--cia-graph-role-exchange:var(--cia-graph-infrastructure);--cia-graph-role-scam:var(--cia-graph-danger);--cia-graph-role-sanctioned:var(--cia-graph-danger);--cia-graph-role-victim:var(--cia-graph-target);--cia-graph-role-pool:var(--cia-graph-trail);--cia-graph-role-other:var(--cia-graph-neutral);--cia-graph-series-1:var(--cia-graph-edge);--cia-graph-series-2:var(--cia-graph-target);--cia-graph-series-3:var(--cia-graph-trail);--cia-graph-series-4:var(--cia-graph-infrastructure);--cia-graph-series-5:var(--cia-graph-danger);--cia-graph-series-6:var(--cia-graph-high);color:var(--cia-graph-text);background:var(--cia-graph-surface);border:1px solid var(--cia-graph-border);border-radius:14px;overflow:hidden}html[data-theme=light] .cia-graph-surface{--cia-graph-surface:#f9f9f9;--cia-graph-canvas:#fff;--cia-graph-dot:#dedede;--cia-graph-text:#242424;--cia-graph-muted:#686868;--cia-graph-border:#dedede;--cia-graph-divider:#e6e6e6;--cia-graph-control:#fff;--cia-graph-hover:#ececec;--cia-graph-active:#4e708a;--cia-graph-active-text:#fff;--cia-graph-node:#fff;--cia-graph-edge:#4e708a;--cia-graph-halo:#fff;--cia-graph-selected:#242424;--cia-graph-expanded:#0057d9;--cia-graph-danger:#a64d4b;--cia-graph-target:#356e68;--cia-graph-trail:#78538f;--cia-graph-infrastructure:#416c4a;--cia-graph-neutral:#4e708a;--cia-graph-critical:#a64d4b;--cia-graph-high:#a15432;--cia-graph-medium:#78538f;--cia-graph-low:#416c4a}.cia-graph-canvas{background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.graph-detail{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem;color:var(--cia-graph-muted,#adb1ba);line-height:1.6}.graph-detail strong{color:var(--cia-graph-text,#f2dda6)}.graph-detail p{margin:0}.graph-detail ul{padding-left:1.25rem;margin-bottom:0}.graph-detail strong,.graph-detail li{overflow-wrap:anywhere}.graph-legend{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem}.graph-legend summary{cursor:pointer}.graph-legend ul{list-style:none;padding:0}.graph-legend li{display:flex;flex-wrap:wrap;gap:.4rem 1rem;padding:.6rem 0;border-bottom:1px solid var(--cia-graph-divider,#ffffff0a)}.graph-legend button{color:var(--cia-graph-edge,#f2dda6);background:none;border:0;padding:0;text-align:left;cursor:pointer;font:inherit;font-family:ui-monospace,monospace;overflow-wrap:anywhere;max-width:100%}.graph-legend span{color:var(--cia-graph-muted,#adb1ba)}.graph-detail a,.graph-legend a{color:var(--cia-graph-edge,#f2dda6);text-decoration:none;border-bottom:1px solid var(--cia-graph-border,#f2dda659)}.graph-detail a:hover,.graph-legend a:hover{border-bottom-color:var(--cia-graph-edge,#f2dda6)}.graph-legend .graph-legend-link{overflow-wrap:normal;flex:none}.cia-graph-node-body{fill:var(--cia-graph-node,#14161a)}.cia-graph-node-ring{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-node-address{fill:var(--cia-graph-muted,#adb1ba)}.cia-graph-edge-underlay{stroke:var(--cia-graph-halo,#07090d)}.cia-graph-edge-direction{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-edge-arrow{fill:var(--cia-graph-edge,#f2dda6);stroke:var(--cia-graph-halo,#07090d)}.cia-graph-surface .graph-tooltip{background:var(--cia-graph-control);color:var(--cia-graph-text);border-color:var(--cia-graph-border)}.cia-graph-engine{position:relative;min-height:240px}.cia-graph-svg{display:block;width:100%;height:100%;touch-action:none;font-family:Inter,system-ui,sans-serif;outline:none}.cia-graph-svg:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-backdrop{fill:var(--cia-graph-canvas)}.cia-graph-dot{fill:var(--cia-graph-dot)}.cia-graph-edge{cursor:pointer;outline:none;transition:opacity .15s}.cia-graph-edge-hit{fill:none;stroke:transparent}.cia-graph-edge-line{fill:none;stroke:var(--edge-tone,var(--cia-graph-edge));stroke-linecap:round}.cia-graph-edge:focus-visible .cia-graph-edge-line,.cia-graph-edge[aria-pressed=true] .cia-graph-edge-line{stroke-width:3}.cia-graph-node{cursor:pointer;outline:none}.cia-graph-engine .cia-graph-node-body{fill:var(--cia-graph-node);stroke:var(--node-tone,var(--cia-graph-neutral));stroke-width:2}.cia-graph-engine .cia-graph-node-ring{fill:none;stroke:var(--cia-graph-edge);stroke-width:2}.cia-graph-node-dot{fill:var(--node-tone,var(--cia-graph-neutral))}.cia-graph-node.is-selected .cia-graph-node-body,.cia-graph-node.is-focused .cia-graph-node-body,.cia-graph-node:focus-visible .cia-graph-node-body{stroke:var(--cia-graph-selected);stroke-width:4}.cia-graph-node text{paint-order:stroke;stroke:var(--cia-graph-halo);stroke-width:4px;stroke-linejoin:round}.cia-graph-node-role{fill:var(--node-tone,var(--cia-graph-neutral));font-size:13px;font-weight:600}.cia-graph-engine .cia-graph-node-address{fill:var(--cia-graph-muted);font:400 11px ui-monospace,monospace}.cia-graph-node-note{fill:var(--cia-graph-text);font-size:11px;font-style:italic}.cia-graph-node[data-state=refused] .cia-graph-node-body{stroke-dasharray:4 3}.cia-graph-engine .cia-graph-node[data-flag-expanded] .cia-graph-node-body{stroke:var(--cia-graph-expanded);stroke-width:5}.cia-graph-engine>.graph-tooltip{position:absolute;z-index:2;max-width:320px;padding:.5rem .65rem;border:1px solid;border-radius:6px;font:12px/1.45 Inter,system-ui,sans-serif;overflow-wrap:anywhere;pointer-events:none}.cia-graph-webgl{position:relative;display:block;width:100%;height:100%;min-height:inherit;touch-action:none;outline:none;overflow:hidden;background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.cia-graph-webgl:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}: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;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-body{padding:4px 14px 12px}.cv-chart-svg{display:block;width:100%;height:auto}.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-earlier]{flex:none;align-self:flex-start;margin-top:8px}.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:4px 0 8px;font-weight:600}.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}}
722
722
  </style>