xmcp
Version:
The TypeScript MCP framework
72 lines • 511 kB
JavaScript
(()=>{var t,r,o={6507(t,r,o){"use strict";let a=o(5317),i=o(8388),n=o(442);function s(t,r,o){let s=i(t,r,o),l=a.spawn(s.command,s.args,s.options);return n.hookChildProcess(l,s),l}t.exports=s,t.exports.spawn=s,t.exports.sync=function(t,r,o){let s=i(t,r,o),l=a.spawnSync(s.command,s.args,s.options);return l.error=l.error||n.verifyENOENTSync(l.status,s),l},t.exports._parse=i,t.exports._enoent=n},442(t){"use strict";let r="win32"===process.platform;function o(t,r){return Object.assign(Error(`${r} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${r} ${t.command}`,path:t.command,spawnargs:t.args})}function a(t,a){return r&&1===t&&!a.file?o(a.original,"spawn"):null}t.exports={hookChildProcess:function(t,o){if(!r)return;let i=t.emit;t.emit=function(r,n){if("exit"===r){let r=a(n,o);if(r)return i.call(t,"error",r)}return i.apply(t,arguments)}},verifyENOENT:a,verifyENOENTSync:function(t,a){return r&&1===t&&!a.file?o(a.original,"spawnSync"):null},notFoundError:o}},8388(t,r,o){"use strict";let a=o(6928),i=o(3803),n=o(2077),s=o(1880),l="win32"===process.platform,c=/\.(?:com|exe)$/i,u=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;t.exports=function(t,r,o){r&&!Array.isArray(r)&&(o=r,r=null);let d={command:t,args:r=r?r.slice(0):[],options:o=Object.assign({},o),file:void 0,original:{command:t,args:r}};return o.shell?d:function(t){let r;if(!l)return t;let o=(t.file=i(t),(r=t.file&&s(t.file))?(t.args.unshift(t.file),t.command=r,i(t)):t.file),d=!c.test(o);if(t.options.forceShell||d){let r=u.test(o);t.command=a.normalize(t.command),t.command=n.command(t.command),t.args=t.args.map(t=>n.argument(t,r));let i=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${i}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}(d)}},2077(t){"use strict";let r=/([()\][%!^"`<>&|;, *?])/g;t.exports.command=function(t){return t.replace(r,"^$1")},t.exports.argument=function(t,o){return t=(t=(t=`${t}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1"),t=(t=`"${t}"`).replace(r,"^$1"),o&&(t=t.replace(r,"^$1")),t}},1880(t,r,o){"use strict";let a=o(9896),i=o(600);t.exports=function(t){let r,o=Buffer.alloc(150);try{r=a.openSync(t,"r"),a.readSync(r,o,0,150,0),a.closeSync(r)}catch(t){}return i(o.toString())}},3803(t,r,o){"use strict";let a=o(6928),i=o(1905),n=o(9695);function s(t,r){let o,s=t.options.env||process.env,l=process.cwd(),c=null!=t.options.cwd,u=c&&void 0!==process.chdir&&!process.chdir.disabled;if(u)try{process.chdir(t.options.cwd)}catch(t){}try{o=i.sync(t.command,{path:s[n({env:s})],pathExt:r?a.delimiter:void 0})}catch(t){}finally{u&&process.chdir(l)}return o&&(o=a.resolve(c?t.options.cwd:"",o)),o}t.exports=function(t){return s(t)||s(t,!0)}},9344(t,r,o){var a;function i(t,r,o){if("function"==typeof r&&(o=r,r={}),!o){if("function"!=typeof Promise)throw TypeError("callback not provided");return new Promise(function(o,a){i(t,r||{},function(t,r){t?a(t):o(r)})})}a(t,r||{},function(t,a){t&&("EACCES"===t.code||r&&r.ignoreErrors)&&(t=null,a=!1),o(t,a)})}o(9896),a="win32"===process.platform||global.TESTING_WINDOWS?o(8541):o(709),t.exports=i,i.sync=function(t,r){try{return a.sync(t,r||{})}catch(t){if(r&&r.ignoreErrors||"EACCES"===t.code)return!1;throw t}}},709(t,r,o){t.exports=i,i.sync=function(t,r){return n(a.statSync(t),r)};var a=o(9896);function i(t,r,o){a.stat(t,function(t,a){o(t,!t&&n(a,r))})}function n(t,r){var o,a,i,n,s,l,c,u,d;return t.isFile()&&(o=t,a=r,i=o.mode,n=o.uid,s=o.gid,l=void 0!==a.uid?a.uid:process.getuid&&process.getuid(),c=void 0!==a.gid?a.gid:process.getgid&&process.getgid(),u=parseInt("100",8),d=parseInt("010",8),i&parseInt("001",8)||i&d&&s===c||i&u&&n===l||i&(u|d)&&0===l)}},8541(t,r,o){t.exports=n,n.sync=function(t,r){return i(a.statSync(t),t,r)};var a=o(9896);function i(t,r,o){if(!t.isSymbolicLink()&&!t.isFile())return!1;var a=void 0!==o.pathExt?o.pathExt:process.env.PATHEXT;if(!a||-1!==(a=a.split(";")).indexOf(""))return!0;for(var i=0;i<a.length;i++){var n=a[i].toLowerCase();if(n&&r.substr(-n.length).toLowerCase()===n)return!0}return!1}function n(t,r,o){a.stat(t,function(a,n){o(a,!a&&i(n,t,r))})}},9695(t){"use strict";let r=(t={})=>{let r=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(r).reverse().find(t=>"PATH"===t.toUpperCase())||"Path"};t.exports=r,t.exports.default=r},600(t,r,o){"use strict";let a=o(9638);t.exports=(t="")=>{let r=t.match(a);if(!r)return null;let[o,i]=r[0].replace(/#! ?/,"").split(" "),n=o.split("/").pop();return"env"===n?i:i?`${n} ${i}`:n}},9638(t){"use strict";t.exports=/^#!(.*)/},1905(t,r,o){let a="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,i=o(6928),n=a?";":":",s=o(9344),l=t=>Object.assign(Error(`not found: ${t}`),{code:"ENOENT"}),c=(t,r)=>{let o=r.colon||n,i=t.match(/\//)||a&&t.match(/\\/)?[""]:[...a?[process.cwd()]:[],...(r.path||process.env.PATH||"").split(o)],s=a?r.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",l=a?s.split(o):[""];return a&&-1!==t.indexOf(".")&&""!==l[0]&&l.unshift(""),{pathEnv:i,pathExt:l,pathExtExe:s}},u=(t,r,o)=>{"function"==typeof r&&(o=r,r={}),r||(r={});let{pathEnv:a,pathExt:n,pathExtExe:u}=c(t,r),d=[],p=o=>new Promise((n,s)=>{if(o===a.length)return r.all&&d.length?n(d):s(l(t));let c=a[o],u=/^".*"$/.test(c)?c.slice(1,-1):c,p=i.join(u,t);n(h(!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p,o,0))}),h=(t,o,a)=>new Promise((i,l)=>{if(a===n.length)return i(p(o+1));let c=n[a];s(t+c,{pathExt:u},(n,s)=>{if(!n&&s)if(!r.all)return i(t+c);else d.push(t+c);return i(h(t,o,a+1))})});return o?p(0).then(t=>o(null,t),o):p(0)};t.exports=u,u.sync=(t,r)=>{let{pathEnv:o,pathExt:a,pathExtExe:n}=c(t,r=r||{}),u=[];for(let l=0;l<o.length;l++){let c=o[l],d=/^".*"$/.test(c)?c.slice(1,-1):c,p=i.join(d,t),h=!d&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p;for(let t=0;t<a.length;t++){let o=h+a[t];try{if(s.sync(o,{pathExt:n}))if(!r.all)return o;else u.push(o)}catch(t){}}}if(r.all&&u.length)return u;if(r.nothrow)return null;throw l(t)}},5317(t){"use strict";t.exports=require("child_process")},9896(t){"use strict";t.exports=require("fs")},7598(t){"use strict";t.exports=require("node:crypto")},6928(t){"use strict";t.exports=require("path")},8775(t,r,o){"use strict";let a,i;o.r(r),o.d(r,{jwksCache:()=>tL,FlattenedEncrypt:()=>tu,decodeProtectedHeader:()=>tW,generateSecret:()=>tG,flattenedDecrypt:()=>ts,exportSPKI:()=>e0,flattenedVerify:()=>th,jwtDecrypt:()=>tE,customFetch:()=>tU,importSPKI:()=>eZ,CompactEncrypt:()=>tP,importPKCS8:()=>eX,decodeJwt:()=>tF,errors:()=>s,generalVerify:()=>tm,compactDecrypt:()=>tl,compactVerify:()=>tf,EmbeddedJWK:()=>tN,exportPKCS8:()=>e1,CompactSign:()=>tR,cryptoRuntime:()=>tX,generalDecrypt:()=>tc,createLocalJWKSet:()=>tH,FlattenedSign:()=>tk,jwtVerify:()=>t$,GeneralEncrypt:()=>tp,EncryptJWT:()=>tT,calculateJwkThumbprintUri:()=>tI,SignJWT:()=>tA,exportJWK:()=>e2,importX509:()=>eG,importJWK:()=>eY,GeneralSign:()=>tC,createRemoteJWKSet:()=>tJ,generateKeyPair:()=>tZ,calculateJwkThumbprint:()=>tj,base64url:()=>n,UnsecuredJWT:()=>tV});var n={};o.r(n),o.d(n,{decode:()=>g,encode:()=>v});var s={};o.r(s),o.d(s,{JOSEAlgNotAllowed:()=>C,JOSEError:()=>k,JOSENotSupported:()=>A,JWEDecryptionFailed:()=>T,JWEInvalid:()=>O,JWKInvalid:()=>N,JWKSInvalid:()=>M,JWKSMultipleMatchingKeys:()=>q,JWKSNoMatchingKey:()=>z,JWKSTimeout:()=>H,JWSInvalid:()=>j,JWSSignatureVerificationFailed:()=>U,JWTClaimValidationFailed:()=>R,JWTExpired:()=>x,JWTInvalid:()=>I});let l=new TextEncoder,c=new TextDecoder;function u(...t){let r=new Uint8Array(t.reduce((t,{length:r})=>t+r,0)),o=0;for(let a of t)r.set(a,o),o+=a.length;return r}function d(t,r,o){if(r<0||r>=0x100000000)throw RangeError(`value must be >= 0 and <= ${0x100000000-1}. Received ${r}`);t.set([r>>>24,r>>>16,r>>>8,255&r],o)}function p(t){let r=Math.floor(t/0x100000000),o=new Uint8Array(8);return d(o,r,0),d(o,t%0x100000000,4),o}function h(t){let r=new Uint8Array(4);return d(r,t),r}function f(t){let r=new Uint8Array(t.length);for(let o=0;o<t.length;o++){let a=t.charCodeAt(o);if(a>127)throw TypeError("non-ASCII string encountered in encode()");r[o]=a}return r}function m(t){if(Uint8Array.prototype.toBase64)return t.toBase64();let r=[];for(let o=0;o<t.length;o+=32768)r.push(String.fromCharCode.apply(null,t.subarray(o,o+32768)));return btoa(r.join(""))}function y(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t);let r=atob(t),o=new Uint8Array(r.length);for(let t=0;t<r.length;t++)o[t]=r.charCodeAt(t);return o}function g(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof t?t:c.decode(t),{alphabet:"base64url"});let r=t;r instanceof Uint8Array&&(r=c.decode(r)),r=r.replace(/-/g,"+").replace(/_/g,"/");try{return y(r)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function v(t){let r=t;return("string"==typeof r&&(r=l.encode(r)),Uint8Array.prototype.toBase64)?r.toBase64({alphabet:"base64url",omitPadding:!0}):m(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}let _=(t,r="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${r} must be ${t}`);function b(t,r){if(parseInt(t.hash.name.slice(4),10)!==r)throw _(`SHA-${r}`,"algorithm.hash")}function S(t,r){if(r&&!t.usages.includes(r))throw TypeError(`CryptoKey does not support this operation, its usages must include ${r}.`)}function w(t,r,o){switch(r){case"A128GCM":case"A192GCM":case"A256GCM":{if("AES-GCM"!==t.algorithm.name)throw _("AES-GCM");let o=parseInt(r.slice(1,4),10);if(t.algorithm.length!==o)throw _(o,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if("AES-KW"!==t.algorithm.name)throw _("AES-KW");let o=parseInt(r.slice(1,4),10);if(t.algorithm.length!==o)throw _(o,"algorithm.length");break}case"ECDH":switch(t.algorithm.name){case"ECDH":case"X25519":break;default:throw _("ECDH or X25519")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if("PBKDF2"!==t.algorithm.name)throw _("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if("RSA-OAEP"!==t.algorithm.name)throw _("RSA-OAEP");b(t.algorithm,parseInt(r.slice(9),10)||1);break;default:throw TypeError("CryptoKey does not support this operation")}S(t,o)}function $(t,r,...o){if((o=o.filter(Boolean)).length>2){let r=o.pop();t+=`one of type ${o.join(", ")}, or ${r}.`}else 2===o.length?t+=`one of type ${o[0]} or ${o[1]}.`:t+=`of type ${o[0]}.`;return null==r?t+=` Received ${r}`:"function"==typeof r&&r.name?t+=` Received function ${r.name}`:"object"==typeof r&&null!=r&&r.constructor?.name&&(t+=` Received an instance of ${r.constructor.name}`),t}let E=(t,...r)=>$("Key must be ",t,...r),P=(t,r,...o)=>$(`Key for the ${t} algorithm must be `,r,...o);class k extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(t,r){super(t,r),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class R extends k{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(t,r,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:r}}),this.claim=o,this.reason=a,this.payload=r}}class x extends k{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(t,r,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:r}}),this.claim=o,this.reason=a,this.payload=r}}class C extends k{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class A extends k{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class T extends k{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(t="decryption operation failed",r){super(t,r)}}class O extends k{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class j extends k{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class I extends k{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class N extends k{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class M extends k{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class z extends k{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(t="no applicable key found in the JSON Web Key Set",r){super(t,r)}}class q extends k{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(t="multiple matching keys found in the JSON Web Key Set",r){super(t,r)}}class H extends k{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(t="request timed out",r){super(t,r)}}class U extends k{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(t="signature verification failed",r){super(t,r)}}function D(t){if(!L(t))throw Error("CryptoKey instance expected")}let L=t=>{if(t?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return t instanceof CryptoKey}catch{return!1}},K=t=>t?.[Symbol.toStringTag]==="KeyObject",J=t=>L(t)||K(t);function V(t){switch(t){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new A(`Unsupported JWE Algorithm: ${t}`)}}let W=t=>crypto.getRandomValues(new Uint8Array(V(t)>>3));function F(t,r){let o=t.byteLength<<3;if(o!==r)throw new O(`Invalid Content Encryption Key length. Expected ${r} bits, got ${o} bits`)}function B(t){switch(t){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new A(`Unsupported JWE Algorithm: ${t}`)}}function Z(t,r){if(r.length<<3!==B(t))throw new O("Invalid Initialization Vector length")}async function G(t,r,o){if(!(r instanceof Uint8Array))throw TypeError(E(r,"Uint8Array"));let a=parseInt(t.slice(1,4),10);return{encKey:await crypto.subtle.importKey("raw",r.subarray(a>>3),"AES-CBC",!1,[o]),macKey:await crypto.subtle.importKey("raw",r.subarray(0,a>>3),{hash:`SHA-${a<<1}`,name:"HMAC"},!1,["sign"]),keySize:a}}async function X(t,r,o){return new Uint8Array((await crypto.subtle.sign("HMAC",t,r)).slice(0,o>>3))}async function Y(t,r,o,a,i){let{encKey:n,macKey:s,keySize:l}=await G(t,o,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:a,name:"AES-CBC"},n,r)),d=u(i,a,c,p(i.length<<3));return{ciphertext:c,tag:await X(s,d,l),iv:a}}async function Q(t,r){if(!(t instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(r instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let o={name:"HMAC",hash:"SHA-256"},a=await crypto.subtle.generateKey(o,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(o,a,t)),n=new Uint8Array(await crypto.subtle.sign(o,a,r)),s=0,l=-1;for(;++l<32;)s|=i[l]^n[l];return 0===s}async function ee(t,r,o,a,i,n){let s,l,{encKey:c,macKey:d,keySize:h}=await G(t,r,"decrypt"),f=u(n,a,o,p(n.length<<3)),m=await X(d,f,h);try{s=await Q(i,m)}catch{}if(!s)throw new T;try{l=new Uint8Array(await crypto.subtle.decrypt({iv:a,name:"AES-CBC"},c,o))}catch{}if(!l)throw new T;return l}async function et(t,r,o,a,i){let n;o instanceof Uint8Array?n=await crypto.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt"]):(w(o,t,"encrypt"),n=o);let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:a,name:"AES-GCM",tagLength:128},n,r)),l=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:l,iv:a}}async function er(t,r,o,a,i,n){let s;r instanceof Uint8Array?s=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["decrypt"]):(w(r,t,"decrypt"),s=r);try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:n,iv:a,name:"AES-GCM",tagLength:128},s,u(o,i)))}catch{throw new T}}let eo="Unsupported JWE Content Encryption Algorithm";async function ea(t,r,o,a,i){if(!L(o)&&!(o instanceof Uint8Array))throw TypeError(E(o,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(a)Z(t,a);else a=crypto.getRandomValues(new Uint8Array(B(t)>>3));switch(t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return o instanceof Uint8Array&&F(o,parseInt(t.slice(-3),10)),Y(t,r,o,a,i);case"A128GCM":case"A192GCM":case"A256GCM":return o instanceof Uint8Array&&F(o,parseInt(t.slice(1,4),10)),et(t,r,o,a,i);default:throw new A(eo)}}async function ei(t,r,o,a,i,n){if(!L(r)&&!(r instanceof Uint8Array))throw TypeError(E(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!a)throw new O("JWE Initialization Vector missing");if(!i)throw new O("JWE Authentication Tag missing");switch(Z(t,a),t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&F(r,parseInt(t.slice(-3),10)),ee(t,r,o,a,i,n);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&F(r,parseInt(t.slice(1,4),10)),er(t,r,o,a,i,n);default:throw new A(eo)}}let en=Symbol();function es(t,r){if(t)throw TypeError(`${r} can only be called once`)}function el(t,r,o){try{return g(t)}catch{throw new o(`Failed to base64url decode the ${r}`)}}async function ec(t,r){let o=`SHA-${t.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(o,r))}function eu(t){if("object"!=typeof t||null===t||"[object Object]"!==Object.prototype.toString.call(t))return!1;if(null===Object.getPrototypeOf(t))return!0;let r=t;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(t)===r}function ed(...t){let r,o=t.filter(Boolean);if(0===o.length||1===o.length)return!0;for(let t of o){let o=Object.keys(t);if(!r||0===r.size){r=new Set(o);continue}for(let t of o){if(r.has(t))return!1;r.add(t)}}return!0}let ep=t=>eu(t)&&"string"==typeof t.kty;function eh(t,r){if(t.algorithm.length!==parseInt(r.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${r}`)}function ef(t,r,o){return t instanceof Uint8Array?crypto.subtle.importKey("raw",t,"AES-KW",!0,[o]):(w(t,r,o),t)}async function em(t,r,o){let a=await ef(r,t,"wrapKey");eh(a,t);let i=await crypto.subtle.importKey("raw",o,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,a,"AES-KW"))}async function ey(t,r,o){let a=await ef(r,t,"unwrapKey");eh(a,t);let i=await crypto.subtle.unwrapKey("raw",o,a,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function eg(t){return u(h(t.length),t)}async function ev(t,r,o){let a=r>>3,i=Math.ceil(a/32),n=new Uint8Array(32*i);for(let r=1;r<=i;r++){let a=new Uint8Array(4+t.length+o.length);a.set(h(r),0),a.set(t,4),a.set(o,4+t.length);let i=await ec("sha256",a);n.set(i,(r-1)*32)}return n.slice(0,a)}async function e_(t,r,o,a,i=new Uint8Array,n=new Uint8Array){var s;w(t,"ECDH"),w(r,"ECDH","deriveBits");let l=u(eg(f(o)),eg(i),eg(n),h(a),new Uint8Array);return ev(new Uint8Array(await crypto.subtle.deriveBits({name:t.algorithm.name,public:t},r,"X25519"===(s=t).algorithm.name?256:Math.ceil(parseInt(s.algorithm.namedCurve.slice(-3),10)/8)<<3)),a,l)}function eb(t){switch(t.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return"X25519"===t.algorithm.name}}async function eS(t,r,o,a){if(!(t instanceof Uint8Array)||t.length<8)throw new O("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(o)||1!==Math.sign(o))throw new O("PBES2 Count Input must be a positive integer");let i=u(f(r),Uint8Array.of(0),t),n=parseInt(r.slice(13,16),10),s={hash:`SHA-${r.slice(8,11)}`,iterations:o,name:"PBKDF2",salt:i},l=await (a instanceof Uint8Array?crypto.subtle.importKey("raw",a,"PBKDF2",!1,["deriveBits"]):(w(a,r,"deriveBits"),a));return new Uint8Array(await crypto.subtle.deriveBits(s,l,n))}async function ew(t,r,o,a=2048,i=crypto.getRandomValues(new Uint8Array(16))){let n=await eS(i,t,a,r);return{encryptedKey:await em(t.slice(-6),n,o),p2c:a,p2s:v(i)}}async function e$(t,r,o,a,i){let n=await eS(i,t,a,r);return ey(t.slice(-6),n,o)}function eE(t,r){if(t.startsWith("RS")||t.startsWith("PS")){let{modulusLength:o}=r.algorithm;if("number"!=typeof o||o<2048)throw TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}function eP(t,r){let o=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:o,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:o,name:"RSA-PSS",saltLength:parseInt(t.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:o,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:o,name:"ECDSA",namedCurve:r.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:t};default:throw new A(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function ek(t,r,o){if(r instanceof Uint8Array){if(!t.startsWith("HS"))throw TypeError(E(r,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",r,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[o])}switch(t){case"HS256":case"HS384":case"HS512":if("HMAC"!==r.algorithm.name)throw _("HMAC");b(r.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if("RSASSA-PKCS1-v1_5"!==r.algorithm.name)throw _("RSASSA-PKCS1-v1_5");b(r.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if("RSA-PSS"!==r.algorithm.name)throw _("RSA-PSS");b(r.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if("Ed25519"!==r.algorithm.name)throw _("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":let a;if(a=r.algorithm,a.name!==t)throw _(t);break;case"ES256":case"ES384":case"ES512":{if("ECDSA"!==r.algorithm.name)throw _("ECDSA");let o=function(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(t);if(r.algorithm.namedCurve!==o)throw _(o,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}return S(r,o),r}async function eR(t,r,o){let a=await ek(t,r,"sign");return eE(t,a),new Uint8Array(await crypto.subtle.sign(eP(t,a.algorithm),a,o))}async function ex(t,r,o,a){let i=await ek(t,r,"verify");eE(t,i);let n=eP(t,i.algorithm);try{return await crypto.subtle.verify(n,i,o,a)}catch{return!1}}let eC=t=>{switch(t){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new A(`alg ${t} is not supported either by JOSE or your javascript runtime`)}};async function eA(t,r,o){return w(r,t,"encrypt"),eE(t,r),new Uint8Array(await crypto.subtle.encrypt(eC(t),r,o))}async function eT(t,r,o){return w(r,t,"decrypt"),eE(t,r),new Uint8Array(await crypto.subtle.decrypt(eC(t),r,o))}let eO='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function ej(t){if(!t.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:r,keyUsages:o}=function(t){let r,o;switch(t.kty){case"AKP":switch(t.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":r={name:t.alg},o=t.priv?["sign"]:["verify"];break;default:throw new A(eO)}break;case"RSA":switch(t.alg){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},o=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},o=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},o=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new A(eO)}break;case"EC":switch(t.alg){case"ES256":case"ES384":case"ES512":r={name:"ECDSA",namedCurve:({ES256:"P-256",ES384:"P-384",ES512:"P-521"})[t.alg]},o=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":r={name:"ECDH",namedCurve:t.crv},o=t.d?["deriveBits"]:[];break;default:throw new A(eO)}break;case"OKP":switch(t.alg){case"Ed25519":case"EdDSA":r={name:"Ed25519"},o=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":r={name:t.crv},o=t.d?["deriveBits"]:[];break;default:throw new A(eO)}break;default:throw new A('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:r,keyUsages:o}}(t),a={...t};return"AKP"!==a.kty&&delete a.alg,delete a.use,crypto.subtle.importKey("jwk",a,r,t.ext??(!t.d&&!t.priv),t.key_ops??o)}let eI="given KeyObject instance cannot be used for this algorithm",eN=async(t,r,o,i=!1)=>{let n=(a||=new WeakMap).get(t);if(n?.[o])return n[o];let s=await ej({...r,alg:o});return i&&Object.freeze(t),n?n[o]=s:a.set(t,{[o]:s}),s};async function eM(t,r){if(t instanceof Uint8Array||L(t))return t;if(K(t)){if("secret"===t.type)return t.export();if("toCryptoKey"in t&&"function"==typeof t.toCryptoKey)try{return((t,r)=>{let o,i=(a||=new WeakMap).get(t);if(i?.[r])return i[r];let n="public"===t.type,s=!!n;if("x25519"===t.asymmetricKeyType){switch(r){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(eI)}o=t.toCryptoKey(t.asymmetricKeyType,s,n?[]:["deriveBits"])}if("ed25519"===t.asymmetricKeyType){if("EdDSA"!==r&&"Ed25519"!==r)throw TypeError(eI);o=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}switch(t.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(r!==t.asymmetricKeyType.toUpperCase())throw TypeError(eI);o=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}if("rsa"===t.asymmetricKeyType){let a;switch(r){case"RSA-OAEP":a="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":a="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":a="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":a="SHA-512";break;default:throw TypeError(eI)}if(r.startsWith("RSA-OAEP"))return t.toCryptoKey({name:"RSA-OAEP",hash:a},s,n?["encrypt"]:["decrypt"]);o=t.toCryptoKey({name:r.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:a},s,[n?"verify":"sign"])}if("ec"===t.asymmetricKeyType){let a=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(t.asymmetricKeyDetails?.namedCurve);if(!a)throw TypeError(eI);let i={ES256:"P-256",ES384:"P-384",ES512:"P-521"};i[r]&&a===i[r]&&(o=t.toCryptoKey({name:"ECDSA",namedCurve:a},s,[n?"verify":"sign"])),r.startsWith("ECDH-ES")&&(o=t.toCryptoKey({name:"ECDH",namedCurve:a},s,n?[]:["deriveBits"]))}if(!o)throw TypeError(eI);return i?i[r]=o:a.set(t,{[r]:o}),o})(t,r)}catch(t){if(t instanceof TypeError)throw t}let o=t.export({format:"jwk"});return eN(t,o,r)}if(ep(t))return t.k?g(t.k):eN(t,t,r,!0);throw Error("unreachable")}let ez=(t,r)=>{let o=(t.match(/.{1,64}/g)||[]).join("\n");return`-----BEGIN ${r}-----
${o}
-----END ${r}-----`},eq=async(t,r,o)=>{if(K(o)){if(o.type!==t)throw TypeError(`key is not a ${t} key`);return o.export({format:"pem",type:r})}if(!L(o))throw TypeError(E(o,"CryptoKey","KeyObject"));if(!o.extractable)throw TypeError("CryptoKey is not extractable");if(o.type!==t)throw TypeError(`key is not a ${t} key`);return ez(m(new Uint8Array(await crypto.subtle.exportKey(r,o))),`${t.toUpperCase()} KEY`)},eH=(t,r)=>{if(t.byteLength!==r.length)return!1;for(let o=0;o<t.byteLength;o++)if(t[o]!==r[o])return!1;return!0},eU=t=>({data:t,pos:0}),eD=t=>{let r=t.data[t.pos++];if(128&r){let o=127&r,a=0;for(let r=0;r<o;r++)a=a<<8|t.data[t.pos++];return a}return r},eL=(t,r=1)=>{if(r<=0)return;t.pos++;let o=eD(t);t.pos+=o,r>1&&eL(t,r-1)},eK=(t,r,o)=>{if(t.data[t.pos++]!==r)throw Error(o)},eJ=(t,r)=>{let o=t.data.subarray(t.pos,t.pos+r);return t.pos+=r,o},eV=t=>{let r,o=(eK(t,6,"Expected algorithm OID"),r=eD(t),eJ(t,r));if(eH(o,[43,101,110]))return"X25519";if(!eH(o,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");eK(t,6,"Expected curve OID");let a=eD(t),i=eJ(t,a);for(let{name:t,oid:r}of[{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}])if(eH(i,r))return t;throw Error("Unsupported named curve")},eW=async(t,r,o,a)=>{let i,n,s="spki"===t,l=()=>s?["verify"]:["sign"];switch(o){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${o.slice(-3)}`},n=l();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${o.slice(-3)}`},n=l();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(o.slice(-3),10)||1}`},n=s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":case"ES384":case"ES512":i={name:"ECDSA",namedCurve:({ES256:"P-256",ES384:"P-384",ES512:"P-521"})[o]},n=l();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{let t=a.getNamedCurve(r);i="X25519"===t?{name:"X25519"}:{name:"ECDH",namedCurve:t}}catch(t){throw new A("Invalid or unsupported key format")}n=s?[]:["deriveBits"];break;case"Ed25519":case"EdDSA":i={name:"Ed25519"},n=l();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:o},n=l();break;default:throw new A('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(t,r,i,a?.extractable??!!s,n)},eF=(t,r)=>y(t.replace(r,"")),eB=(t,r,o)=>{let a=eF(t,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g),i=o;return r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r=eU(t);return eK(r,48,"Invalid SPKI structure"),eD(r),eK(r,48,"Expected algorithm identifier"),eD(r),r.pos,eV(r)}),eW("spki",a,r,i)};async function eZ(t,r,o){if("string"!=typeof t||0!==t.indexOf("-----BEGIN PUBLIC KEY-----"))throw TypeError('"spki" must be SPKI formatted string');return eB(t,r,o)}async function eG(t,r,o){if("string"!=typeof t||0!==t.indexOf("-----BEGIN CERTIFICATE-----"))throw TypeError('"x509" must be X.509 formatted string');return((t,r,o)=>{let a;try{var i;let r,o,n;r=eU(i=eF(t,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g)),eK(r,48,"Invalid certificate structure"),eD(r),eK(r,48,"Invalid tbsCertificate structure"),eD(r),160===i[r.pos]?eL(r,6):eL(r,5),o=r.pos,eK(r,48,"Invalid SPKI structure"),n=eD(r),a=i.subarray(o,o+n+(r.pos-o))}catch(t){throw TypeError("Failed to parse the X.509 certificate",{cause:t})}return eB(ez(m(a),"PUBLIC KEY"),r,o)})(t,r,o)}async function eX(t,r,o){let a,i;if("string"!=typeof t||0!==t.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return a=eF(t,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),i=o,r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r,o=eU(t);return eK(o,48,"Invalid PKCS#8 structure"),eD(o),eK(o,2,"Expected version field"),r=eD(o),o.pos+=r,eK(o,48,"Expected algorithm identifier"),eD(o),o.pos,eV(o)}),eW("pkcs8",a,r,i)}async function eY(t,r,o){let a;if(!eu(t))throw TypeError("JWK must be an object");switch(r??=t.alg,a??=o?.extractable??t.ext,t.kty){case"oct":if("string"!=typeof t.k||!t.k)throw TypeError('missing "k" (Key Value) Parameter value');return g(t.k);case"RSA":if("oth"in t&&void 0!==t.oth)throw new A('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return ej({...t,alg:r,ext:a});case"AKP":if("string"!=typeof t.alg||!t.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==r&&r!==t.alg)throw TypeError("JWK alg and alg option value mismatch");return ej({...t,ext:a});case"EC":case"OKP":return ej({...t,alg:r,ext:a});default:throw new A('Unsupported "kty" (Key Type) Parameter value')}}async function eQ(t){if(K(t))if("secret"!==t.type)return t.export({format:"jwk"});else t=t.export();if(t instanceof Uint8Array)return{kty:"oct",k:v(t)};if(!L(t))throw TypeError(E(t,"CryptoKey","KeyObject","Uint8Array"));if(!t.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:r,key_ops:o,alg:a,use:i,...n}=await crypto.subtle.exportKey("jwk",t);return"AKP"===n.kty&&(n.alg=a),n}async function e0(t){return eq("public","spki",t)}async function e1(t){return eq("private","pkcs8",t)}async function e2(t){return eQ(t)}async function e9(t,r,o,a){let i=t.slice(0,7),n=await ea(i,o,r,a,new Uint8Array);return{encryptedKey:n.ciphertext,iv:v(n.iv),tag:v(n.tag)}}async function e4(t,r,o,a,i){return ei(t.slice(0,7),r,o,a,i,new Uint8Array)}let e5='Invalid or unsupported "alg" (JWE Algorithm) header value';function e3(t){if(void 0===t)throw new O("JWE Encrypted Key missing")}async function e6(t,r,o,a,i){switch(t){case"dir":if(void 0!==o)throw new O("Encountered unexpected JWE Encrypted Key");return r;case"ECDH-ES":if(void 0!==o)throw new O("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let i,n;if(!eu(a.epk))throw new O('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(D(r),!eb(r))throw new A("ECDH with the provided key is not allowed or not supported by your javascript runtime");let s=await eY(a.epk,t);if(D(s),void 0!==a.apu){if("string"!=typeof a.apu)throw new O('JOSE Header "apu" (Agreement PartyUInfo) invalid');i=el(a.apu,"apu",O)}if(void 0!==a.apv){if("string"!=typeof a.apv)throw new O('JOSE Header "apv" (Agreement PartyVInfo) invalid');n=el(a.apv,"apv",O)}let l=await e_(s,r,"ECDH-ES"===t?a.enc:t,"ECDH-ES"===t?V(a.enc):parseInt(t.slice(-5,-2),10),i,n);if("ECDH-ES"===t)return l;return e3(o),ey(t.slice(-6),l,o)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return e3(o),D(r),eT(t,r,o);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let n;if(e3(o),"number"!=typeof a.p2c)throw new O('JOSE Header "p2c" (PBES2 Count) missing or invalid');let s=i?.maxPBES2Count||1e4;if(a.p2c>s)throw new O('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof a.p2s)throw new O('JOSE Header "p2s" (PBES2 Salt) missing or invalid');return n=el(a.p2s,"p2s",O),e$(t,r,o,a.p2c,n)}case"A128KW":case"A192KW":case"A256KW":return e3(o),ey(t,r,o);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":if(e3(o),"string"!=typeof a.iv)throw new O('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof a.tag)throw new O('JOSE Header "tag" (Authentication Tag) missing or invalid');return e4(t,r,o,el(a.iv,"iv",O),el(a.tag,"tag",O));default:throw new A(e5)}}async function e8(t,r,o,a,i={}){let n,s,l;switch(t){case"dir":l=o;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let c;if(D(o),!eb(o))throw new A("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:u,apv:d}=i;c=i.epk?await eM(i.epk,t):(await crypto.subtle.generateKey(o.algorithm,!0,["deriveBits"])).privateKey;let{x:p,y:h,crv:f,kty:m}=await e2(c),y=await e_(o,c,"ECDH-ES"===t?r:t,"ECDH-ES"===t?V(r):parseInt(t.slice(-5,-2),10),u,d);if(s={epk:{x:p,crv:f,kty:m}},"EC"===m&&(s.epk.y=h),u&&(s.apu=v(u)),d&&(s.apv=v(d)),"ECDH-ES"===t){l=y;break}l=a||W(r);let g=t.slice(-6);n=await em(g,y,l);break}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":l=a||W(r),D(o),n=await eA(t,o,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=a||W(r);let{p2c:c,p2s:u}=i;({encryptedKey:n,...s}=await ew(t,o,l,c,u));break}case"A128KW":case"A192KW":case"A256KW":l=a||W(r),n=await em(t,o,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=a||W(r);let{iv:c}=i;({encryptedKey:n,...s}=await e9(t,o,l,c));break}default:throw new A(e5)}return{cek:l,encryptedKey:n,parameters:s}}function e7(t,r,o,a,i){let n;if(void 0!==i.crit&&a?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!a||void 0===a.crit)return new Set;if(!Array.isArray(a.crit)||0===a.crit.length||a.crit.some(t=>"string"!=typeof t||0===t.length))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let s of(n=void 0!==o?new Map([...Object.entries(o),...r.entries()]):r,a.crit)){if(!n.has(s))throw new A(`Extension Header Parameter "${s}" is not recognized`);if(void 0===i[s])throw new t(`Extension Header Parameter "${s}" is missing`);if(n.get(s)&&void 0===a[s])throw new t(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(a.crit)}function te(t,r){if(void 0!==r&&(!Array.isArray(r)||r.some(t=>"string"!=typeof t)))throw TypeError(`"${t}" option must be an array of strings`);if(r)return new Set(r)}let tt=t=>t?.[Symbol.toStringTag],tr=(t,r,o)=>{if(void 0!==r.use){let t;switch(o){case"sign":case"verify":t="sig";break;case"encrypt":case"decrypt":t="enc"}if(r.use!==t)throw TypeError(`Invalid key for this operation, its "use" must be "${t}" when present`)}if(void 0!==r.alg&&r.alg!==t)throw TypeError(`Invalid key for this operation, its "alg" must be "${t}" when present`);if(Array.isArray(r.key_ops)){let a;switch(!0){case"sign"===o||"verify"===o:case"dir"===t:case t.includes("CBC-HS"):a=o;break;case t.startsWith("PBES2"):a="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(t):a=!t.includes("GCM")&&t.endsWith("KW")?"encrypt"===o?"wrapKey":"unwrapKey":o;break;case"encrypt"===o&&t.startsWith("RSA"):a="wrapKey";break;case"decrypt"===o:a=t.startsWith("RSA")?"unwrapKey":"deriveBits"}if(a&&r.key_ops?.includes?.(a)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function to(t,r,o){switch(t.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((t,r,o)=>{if(!(r instanceof Uint8Array)){if(ep(r)){if("oct"===r.kty&&"string"==typeof r.k&&tr(t,r,o))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!J(r))throw TypeError(P(t,r,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==r.type)throw TypeError(`${tt(r)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,o);break;default:((t,r,o)=>{if(ep(r))switch(o){case"decrypt":case"sign":if("oct"!==r.kty&&("AKP"===r.kty&&"string"==typeof r.priv||"string"==typeof r.d)&&tr(t,r,o))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if("oct"!==r.kty&&void 0===r.d&&void 0===r.priv&&tr(t,r,o))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!J(r))throw TypeError(P(t,r,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===r.type)throw TypeError(`${tt(r)} instances for asymmetric algorithms must not be of type "secret"`);if("public"===r.type)switch(o){case"sign":throw TypeError(`${tt(r)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw TypeError(`${tt(r)} instances for asymmetric algorithm decryption must be of type "private"`)}if("private"===r.type)switch(o){case"verify":throw TypeError(`${tt(r)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw TypeError(`${tt(r)} instances for asymmetric algorithm encryption must be of type "public"`)}})(t,r,o)}}function ta(t){if(void 0===globalThis[t])throw new A(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${t} API.`)}async function ti(t){ta("CompressionStream");let r=new CompressionStream("deflate-raw"),o=r.writable.getWriter();o.write(t).catch(()=>{}),o.close().catch(()=>{});let a=[],i=r.readable.getReader();for(;;){let{value:t,done:r}=await i.read();if(r)break;a.push(t)}return u(...a)}async function tn(t,r){ta("DecompressionStream");let o=new DecompressionStream("deflate-raw"),a=o.writable.getWriter();a.write(t).catch(()=>{}),a.close().catch(()=>{});let i=[],n=0,s=o.readable.getReader();for(;;){let{value:t,done:o}=await s.read();if(o)break;if(i.push(t),n+=t.byteLength,r!==1/0&&n>r)throw new O("Decompressed plaintext exceeded the configured limit")}return u(...i)}async function ts(t,r,o){let a,i,n,s,l,d;if(!eu(t))throw new O("Flattened JWE must be an object");if(void 0===t.protected&&void 0===t.header&&void 0===t.unprotected)throw new O("JOSE Header missing");if(void 0!==t.iv&&"string"!=typeof t.iv)throw new O("JWE Initialization Vector incorrect type");if("string"!=typeof t.ciphertext)throw new O("JWE Ciphertext missing or incorrect type");if(void 0!==t.tag&&"string"!=typeof t.tag)throw new O("JWE Authentication Tag incorrect type");if(void 0!==t.protected&&"string"!=typeof t.protected)throw new O("JWE Protected Header incorrect type");if(void 0!==t.encrypted_key&&"string"!=typeof t.encrypted_key)throw new O("JWE Encrypted Key incorrect type");if(void 0!==t.aad&&"string"!=typeof t.aad)throw new O("JWE AAD incorrect type");if(void 0!==t.header&&!eu(t.header))throw new O("JWE Shared Unprotected Header incorrect type");if(void 0!==t.unprotected&&!eu(t.unprotected))throw new O("JWE Per-Recipient Unprotected Header incorrect type");if(t.protected)try{let r=g(t.protected);a=JSON.parse(c.decode(r))}catch{throw new O("JWE Protected Header is invalid")}if(!ed(a,t.header,t.unprotected))throw new O("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let p={...a,...t.header,...t.unprotected};if(e7(O,new Map,o?.crit,a,p),void 0!==p.zip&&"DEF"!==p.zip)throw new A('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==p.zip&&!a?.zip)throw new O('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:h,enc:m}=p;if("string"!=typeof h||!h)throw new O("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof m||!m)throw new O("missing JWE Encryption Algorithm (enc) in JWE Header");let y=o&&te("keyManagementAlgorithms",o.keyManagementAlgorithms),v=o&&te("contentEncryptionAlgorithms",o.contentEncryptionAlgorithms);if(y&&!y.has(h)||!y&&h.startsWith("PBES2"))throw new C('"alg" (Algorithm) Header Parameter value not allowed');if(v&&!v.has(m))throw new C('"enc" (Encryption Algorithm) Header Parameter value not allowed');void 0!==t.encrypted_key&&(i=el(t.encrypted_key,"encrypted_key",O));let _=!1;"function"==typeof r&&(r=await r(a,t),_=!0),to("dir"===h?m:h,r,"decrypt");let b=await eM(r,h);try{n=await e6(h,b,i,p,o)}catch(t){if(t instanceof TypeError||t instanceof O||t instanceof A)throw t;n=W(m)}void 0!==t.iv&&(s=el(t.iv,"iv",O)),void 0!==t.tag&&(l=el(t.tag,"tag",O));let S=void 0!==t.protected?f(t.protected):new Uint8Array;d=void 0!==t.aad?u(S,f("."),f(t.aad)):S;let w=el(t.ciphertext,"ciphertext",O),$=await ei(m,n,w,s,l,d),E={plaintext:$};if("DEF"===p.zip){let t=o?.maxDecompressedLength??25e4;if(0===t)throw new A('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(t!==1/0&&(!Number.isSafeInteger(t)||t<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");E.plaintext=await tn($,t).catch(t=>{if(t instanceof O)throw t;throw new O("Failed to decompress plaintext",{cause:t})})}return(void 0!==t.protected&&(E.protectedHeader=a),void 0!==t.aad&&(E.additionalAuthenticatedData=el(t.aad,"aad",O)),void 0!==t.unprotected&&(E.sharedUnprotectedHeader=t.unprotected),void 0!==t.header&&(E.unprotectedHeader=t.header),_)?{...E,key:b}:E}async function tl(t,r,o){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new O("Compact JWE must be a string or Uint8Array");let{0:a,1:i,2:n,3:s,4:l,length:u}=t.split(".");if(5!==u)throw new O("Invalid Compact JWE");let d=await ts({ciphertext:s,iv:n||void 0,protected:a,tag:l||void 0,encrypted_key:i||void 0},r,o),p={plaintext:d.plaintext,protectedHeader:d.protectedHeader};return"function"==typeof r?{...p,key:d.key}:p}async function tc(t,r,o){if(!eu(t))throw new O("General JWE must be an object");if(!Array.isArray(t.recipients)||!t.recipients.every(eu))throw new O("JWE Recipients missing or incorrect type");if(!t.recipients.length)throw new O("JWE Recipients has no members");for(let a of t.recipients)try{return await ts({aad:t.aad,ciphertext:t.ciphertext,encrypted_key:a.encrypted_key,header:a.header,iv:t.iv,protected:t.protected,tag:t.tag,unprotected:t.unprotected},r,o)}catch{}throw new T}class tu{#e;#t;#r;#o;#a;#i;#n;#s;constructor(t){if(!(t instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this.#e=t}setKeyManagementParameters(t){return es(this.#s,"setKeyManagementParameters"),this.#s=t,this}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setSharedUnprotectedHeader(t){return es(this.#r,"setSharedUnprotectedHeader"),this.#r=t,this}setUnprotectedHeader(t){return es(this.#o,"setUnprotectedHeader"),this.#o=t,this}setAdditionalAuthenticatedData(t){return this.#a=t,this}setContentEncryptionKey(t){return es(this.#i,"setContentEncryptionKey"),this.#i=t,this}setInitializationVector(t){return es(this.#n,"setInitializationVector"),this.#n=t,this}async encrypt(t,r){let o,a,i,n,s,l;if(!this.#t&&!this.#o&&!this.#r)throw new O("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ed(this.#t,this.#o,this.#r))throw new O("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let c={...this.#t,...this.#o,...this.#r};if(e7(O,new Map,r?.crit,this.#t,c),void 0!==c.zip&&"DEF"!==c.zip)throw new A('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==c.zip&&!this.#t?.zip)throw new O('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:d,enc:p}=c;if("string"!=typeof d||!d)throw new O('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof p||!p)throw new O('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(this.#i&&("dir"===d||"ECDH-ES"===d))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${d}`);to("dir"===d?p:d,t,"encrypt");{let i,n=await eM(t,d);({cek:a,encryptedKey:o,parameters:i}=await e8(d,p,n,this.#i,this.#s)),i&&(r&&en in r?this.#o?this.#o={...this.#o,...i}:this.setUnprotectedHeader(i):this.#t?this.#t={...this.#t,...i}:this.setProtectedHeader(i))}if(this.#t?s=f(n=v(JSON.stringify(this.#t))):(n="",s=new Uint8Array),this.#a){let t=f(l=v(this.#a));i=u(s,f("."),t)}else i=s;let h=this.#e;"DEF"===c.zip&&(h=await ti(h).catch(t=>{throw new O("Failed to compress plaintext",{cause:t})}));let{ciphertext:m,tag:y,iv:g}=await ea(p,h,a,this.#n,i),_={ciphertext:v(m)};return g&&(_.iv=v(g)),y&&(_.tag=v(y)),o&&(_.encrypted_key=v(o)),l&&(_.aad=l),this.#t&&(_.protected=n),this.#r&&(_.unprotected=this.#r),this.#o&&(_.header=this.#o),_}}class td{#l;unprotectedHeader;keyManagementParameters;key;options;constructor(t,r,o){this.#l=t,this.key=r,this.options=o}setUnprotectedHeader(t){return es(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=t,this}setKeyManagementParameters(t){return es(this.keyManagementParameters,"setKeyManagementParameters"),this.keyManagementParameters=t,this}addRecipient(...t){return this.#l.addRecipient(...t)}encrypt(...t){return this.#l.encrypt(...t)}done(){return this.#l}}class tp{#e;#c=[];#t;#o;#a;constructor(t){this.#e=t}addRecipient(t,r){let o=new td(this,t,{crit:r?.crit});return this.#c.push(o),o}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setSharedUnprotectedHeader(t){return es(this.#o,"setSharedUnprotectedHeader"),this.#o=t,this}setAdditionalAuthenticatedData(t){return this.#a=t,this}async encrypt(){let t;if(!this.#c.length)throw new O("at least one recipient must be added");if(1===this.#c.length){let[t]=this.#c,r=await new tu(this.#e).setAdditionalAuthenticatedData(this.#a).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#o).setUnprotectedHeader(t.unprotectedHeader).encrypt(t.key,{...t.options}),o={ciphertext:r.ciphertext,iv:r.iv,recipients:[{}],tag:r.tag};return r.aad&&(o.aad=r.aad),r.protected&&(o.protected=r.protected),r.unprotected&&(o.unprotected=r.unprotected),r.encrypted_key&&(o.recipients[0].encrypted_key=r.encrypted_key),r.header&&(o.recipients[0].header=r.header),o}for(let r=0;r<this.#c.length;r++){let o=this.#c[r];if(!ed(this.#t,this.#o,o.unprotectedHeader))throw new O("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let a={...this.#t,...this.#o,...o.unprotectedHeader},{alg:i}=a;if("string"!=typeof i||!i)throw new O('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===i||"ECDH-ES"===i)throw new O('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof a.enc||!a.enc)throw new O('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(t){if(t!==a.enc)throw new O('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else t=a.enc;if(e7(O,new Map,o.options.crit,this.#t,a),void 0!==a.zip&&"DEF"!==a.zip)throw new A('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==a.zip&&!this.#t?.zip)throw new O('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}let r=W(t),o={ciphertext:"",recipients:[]};for(let a=0;a<this.#c.length;a++){let i=this.#c[a],n={};if(o.recipients.push(n),0===a){let t=await new tu(this.#e).setAdditionalAuthenticatedData(this.#a).setContentEncryptionKey(r).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#o).setUnprotectedHeader(i.unprotectedHeader).setKeyManagementParameters(i.keyManagementParameters).encrypt(i.key,{...i.options,[en]:!0});o.ciphertext=t.ciphertext,o.iv=t.iv,o.tag=t.tag,t.aad&&(o.aad=t.aad),t.protected&&(o.protected=t.protected),t.unprotected&&(o.unprotected=t.unprotected),n.encrypted_key=t.encrypted_key,t.header&&(n.header=t.header);continue}let s=i.unprotectedHeader?.alg||this.#t?.alg||this.#o?.alg;to("dir"===s?t:s,i.key,"encrypt");let l=await eM(i.key,s),{encryptedKey:c,parameters:u}=await e8(s,t,l,r,i.keyManagementParameters);n.encrypted_key=v(c),(i.unprotectedHeader||u)&&(n.header={...i.unprotectedHeader,...u})}return o}}async function th(t,r,o){if(!eu(t))throw new j("Flattened JWS must be an object");if(void 0===t.protected&&void 0===t.header)throw new j('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==t.protected&&"string"!=typeof t.protected)throw new j("JWS Protected Header incorrect type");if(void 0===t.payload)throw new j("JWS Payload missing");if("string"!=typeof t.signature)throw new j("JWS Signature missing or incorrect type");if(void 0!==t.header&&!eu(t.header))throw new j("JWS Unprotected Header incorrect type");let a={};if(t.protected)try{let r=g(t.protected);a=JSON.parse(c.decode(r))}catch{throw new j("JWS Protected Header is invalid")}if(!ed(a,t.header))throw new j("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...a,...t.header},n=e7(j,new Map([["b64",!0]]),o?.crit,a,i),s=!0;if(n.has("b64")&&"boolean"!=typeof(s=a.b64))throw new j('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=i;if("string"!=typeof d||!d)throw new j('JWS "alg" (Algorithm) Header Parameter missing or invalid');let p=o&&te("algorithms",o.algorithms);if(p&&!p.has(d))throw new C('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof t.payload)throw new j("JWS Payload must be a string")}else if("string"!=typeof t.payload&&!(t.payload instanceof Uint8Array))throw new j("JWS Payload must be a string or an Uint8Array instance");let h=!1;"function"==typeof r&&(r=await r(a,t),h=!0),to(d,r,"verify");let m=u(void 0!==t.protected?f(t.protected):new Uint8Array,f("."),"string"==typeof t.payload?s?f(t.payload):l.encode(t.payload):t.payload),y=el(t.signature,"signature",j),v=await eM(r,d);if(!await ex(d,v,y,m))throw new U;let _={payload:s?el(t.payload,"payload",j):"string"==typeof t.payload?l.encode(t.payload):t.payload};return(void 0!==t.protected&&(_.protectedHeader=a),void 0!==t.header&&(_.unprotectedHeader=t.header),h)?{..._,key:v}:_}async function tf(t,r,o){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new j("Compact JWS must be a string or Uint8Array");let{0:a,1:i,2:n,length:s}=t.split(".");if(3!==s)throw new j("Invalid Compact JWS");let l=await th({payload:i,protected:a,signature:n},r,o),u={payload:l.payload,protectedHeader:l.protectedHeader};return"function"==typeof r?{...u,key:l.key}:u}async function tm(t,r,o){if(!eu(t))throw new j("General JWS must be an object");if(!Array.isArray(t.signatures)||!t.signatures.every(eu))throw new j("JWS Signatures missing or incorrect type");for(let a of t.signatures)try{return await th({header:a.header,payload:t.payload,protected:a.protected,signature:a.signature},r,o)}catch{}throw new U}let ty=t=>Math.floor(t.getTime()/1e3),tg=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function tv(t){let r,o=tg.exec(t);if(!o||o[4]&&o[1])throw TypeError("Invalid time period format");let a=parseFloat(o[2]);switch(o[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":r=Math.round(a);break;case"minute":case"minutes":case"min":case"mins":case"m":r=Math.round(60*a);break;case"hour":case"hours":case"hr":case"hrs":case"h":r=Math.round(3600*a);break;case"day":case"days":case"d":r=Math.round(86400*a);break;case"week":case"weeks":case"w":r=Math.round(604800*a);break;default:r=Math.round(0x1e187e0*a)}return"-"===o[1]||"ago"===o[4]?-r:r}function t_(t,r){if(!Number.isFinite(r))throw TypeError(`Invalid ${t} input`);return r}let tb=t=>t.includes("/")?t.toLowerCase():`application/${t.toLowerCase()}`;function tS(t,r,o={}){var a,i;let n,s;try{n=JSON.parse(c.decode(r))}catch{}if(!eu(n))throw new I("JWT Claims Set must be a top-level JSON object");let{typ:l}=o;if(l&&("string"!=typeof t.typ||tb(t.typ)!==tb(l)))throw new R('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:u=[],issuer:d,subject:p,audience:h,maxTokenAge:f}=o,m=[...u];for(let t of(void 0!==f&&m.push("iat"),void 0!==h&&m.push("aud"),void 0!==p&&m.push("sub"),void 0!==d&&m.push("iss"),new Set(m.reverse())))if(!(t in n))throw new R(`missing required "${t}" claim`,n,t,"missing");if(d&&!(Array.isArray(d)?d:[d]).includes(n.iss))throw new R('unexpected "iss" claim value',n,"iss","check_failed");if(p&&n.sub!==p)throw new R('unexpected "sub" claim value',n,"sub","check_failed");if(h&&(a=n.aud,i="string"==typeof h?[h]:h,"string"==typeof a?!i.includes(a):!(Array.isArray(a)&&i.some(Set.prototype.has.bind(new Set(a))))))throw new R('unexpected "aud" claim value',n,"aud","check_failed");switch(typeof o.clockTolerance){case"string":s=tv(o.clockTolerance);break;case"number":s=o.clockTolerance;break;case"undefined":s=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:y}=o,g=ty(y||new Date);if((void 0!==n.iat||f)&&"number"!=typeof n.iat)throw new R('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new R('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>g+s)throw new R('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new R('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=g-s)throw new x('"exp" claim timestamp check failed',n,"exp","check_failed")}if(f){let t=g-n.iat;if(t-s>("number"==typeof f?f:tv(f)))throw new x('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(t<0-s)throw new R('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}class tw{#u;constructor(t){if(!eu(t))throw TypeError("JWT Claims Set MUST be an object");this.#u=structuredClone(t)}data(){return l.encode(JSON.stringify(this.#u))}get iss(){return this.#u.iss}set iss(t){this.#u.iss=t}get sub(){return this.#u.sub}set sub(t){this.#u.sub=t}get aud(){return this.#u.aud}set aud(t){this.#u.aud=t}set jti(t){this.#u.jti=t}set nbf(t){"number"==typeof t?this.#u.nbf=t_("setNotBefore",t):t instanceof Date?this.#u.nbf=t_("setNotBefore",ty(t)):this.#u.nbf=ty(new Date)+tv(t)}set exp(t){"number"==typeof t?this.#u.exp=t_("setExpirationTime",t):t instanceof Date?this.#u.exp=t_("setExpirationTime",ty(t)):this.#u.exp=ty(new Date)+tv(t)}set iat(t){void 0===t?this.#u.iat=ty(new Date):t instanceof Date?this.#u.iat=t_("setIssuedAt",ty(t)):"string"==typeof t?this.#u.iat=t_("setIssuedAt",ty(new Date)+tv(t)):this.#u.iat=t_("setIssuedAt",t)}}async function t$(t,r,o){let a=await tf(t,r,o);if(a.protectedHeader.crit?.includes("b64")&&!1===a.protectedHeader.b64)throw new I("JWTs MUST NOT use unencoded payload");let i={payload:tS(a.protectedHeader,a.payload,o),protectedHeader:a.protectedHeader};return"function"==typeof r?{...i,key:a.key}:i}async function tE(t,r,o){let a=await tl(t,r,o),i=tS(a.protectedHeader,a.plaintext,o),{protectedHeader:n}=a;if(void 0!==n.iss&&n.iss!==i.iss)throw new R('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==n.sub&&n.sub!==i.sub)throw new R('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==n.aud&&JSON.stringify(n.aud)!==JSON.stringify(i.aud))throw new R('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let s={payload:i,protectedHeader:n};return"function"==typeof r?{...s,key:a.key}:s}class tP{#d;constructor(t){this.#d=new tu(t)}setContentEncryptionKey(t){return this.#d.setContentEncryptionKey(t),this}setInitializationVector(t){return this.#d.setInitializationVector(t),this}setProtectedHeader(t){return this.#d.setProtectedHeader(t),this}setKeyManagementParameters(t){return this.#d.setKeyManagementParameters(t),this}async encrypt(t,r){let o=await this.#d.encrypt(t,r);return[o.protected,o.encrypted_key,o.iv,o.ciphertext,o.tag].join(".")}}class tk{#u;#t;#o;constructor(t){if(!(t instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this.#u=t}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setUnprotectedHeader(t){return es(this.#o,"setUnprotectedHeader"),this.#o=t,this}async sign(t,r){let o,a,i,n;if(!this.#t&&!this.#o)throw new j("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ed(this.#t,this.#o))throw new j("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let s={...this.#t,...this.#o},l=e7(j,new Map([["b64",!0]]),r?.crit,this.#t,s),c=!0;if(l.has("b64")&&"boolean"!=typeof(c=this.#t.b64))throw new j('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=s;if("string"!=typeof d||!d)throw new j('JWS "alg" (Algorithm) Header Parameter missing or invalid');to(d,t,"sign"),c?a=f(o=v(this.#u)):(a=this.#u,o=""),this.#t?n=f(i=v(JSON.stringify(this.#t))):(i="",n=new Uint8Array);let p=u(n,f("."),a),h=await eM(t,d),m={signature:v(await eR(d,h,p)),payload:o};return this.#o&&(m.header=this.#o),this.#t&&(m.protected=i),m}}class tR{#d;constructor(t){this.#d=new tk(t)}setProtectedHeader(t){return this.#d.setProtectedHeader(t),this}async sign(t,r){let o=await this.#d.sign(t,r);if(void 0===o.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${o.protected}.${o.payload}.${o.signature}`}}class tx{#l;protectedHeader;unprotectedHeader;options;key;constructor(t,r,o){this.#l=t,this.key=r,this.options=o}setProtectedHeader(t){return es(this.protectedHeader,"setProtectedHeader"),this.protectedHeader=t,this}setUnprotectedHeader(t){return es(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=t,this}addSignature(...t){return this.#l.addSignature(...t)}sign(...t){return this.#l.sign(...t)}done(){return this.#l}}class tC{#u;#p=[];constructor(t){this.#u=t}addSignature(t,r){let o=new tx(this,t,r);return this.#p.push(o),o}async sign(){if(!this.#p.length)throw new j("at least one signature must be added");let t={signatures:[],payload:""};for(let r=0;r<this.#p.length;r++){let o=this.#p[r],a=new tk(this.#u);a.setProtectedHeader(o.protectedHeader),a.setUnprotectedHeader(o.unprotectedHeader);let{payload:i,...n}=await a.sign(o.key,o.options);if(0===r)t.payload=i;else if(t.payload!==i)throw new j("inconsistent use of JWS Unencoded Payload (RFC7797)");t.signatures.push(n)}return t}}class tA{#t;#h;constructor(t={}){this.#h=new tw(t)}setIssuer(t){return this.#h.iss=t,this}setSubject(t){return this.#h.sub=t,this}setAudience(t){return this.#h.aud=t,this}setJti(t){return this.#h.jti=t,this}setNotBefore(t){return this.#h.nbf=t,this}setExpirationTime(t){return this.#h.exp=t,this}setIssuedAt(t){return this.#h.iat=t,this}setProtectedHeader(t){return this.#t=t,this}async sign(t,r){let o=new tR(this.#h.data());if(o.setProtectedHeader(this.#t),Array.isArray(this.#t?.crit)&&this.#t.crit.includes("b64")&&!1===this.#t.b64)throw new I("JWTs MUST NOT use unencoded payload");return o.sign(t,r)}}class tT{#i;#n;#s;#t;#f;#m;#y;#h;constructor(t={}){this.#h=new tw(t)}setIssuer(t){return this.#h.iss=t,this}setSubject(t){return this.#h.sub=t,this}setAudience(t){return this.#h.aud=t,this}setJti(t){return this.#h.jti=t,this}setNotBefore(t){return this.#h.nbf=t,this}setExpirationTime(t){return this.#h.exp=t,this}setIssuedAt(t){return this.#h.iat=t,this}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setKeyManagementParameters(t){return es(this.#s,"setKeyManagementParameters"),this.#s=t,this}setContentEncryptionKey(t){return es(this.#i,"setContentEncryptionKey"),this.#i=t,this}setInitializationVector(t){return es(this.#n,"setInitializationVector"),this.#n=t,this}replicateIssuerAsHeader(){return this.#f=!0,this}replicateSubjectAsHeader(){return this.#m=!0,this}replicateAudienceAsHeader(){return this.#y=!0,this}async encrypt(t,r){let o=new tP(this.#h.data());return this.#t&&(this.#f||this.#m||this.#y)&&(this.#t={...this.#t,iss:this.#f?this.#h.iss:void 0,sub:this.#m?this.#h.sub:void 0,aud:this.#y?this.#h.aud:void 0}),o.setProtectedHeader(this.#t),this.#n&&o.setInitializationVector(this.#n),this.#i&&o.setContentEncryptionKey(this.#i),this.#s&&o.setKeyManagementParameters(this.#s),o.encrypt(t,r)}}let tO=(t,r)=>{if("string"!=typeof t||!t)throw new N(`${r} missing or invalid`)};async function tj(t,r){let o,a;if(ep(t))o=t;else if(J(t))o=await e2(t);else throw TypeError(E(t,"CryptoKey","KeyObject","JSON Web Key"));if("sha256"!==(r??="sha256")&&"sha384"!==r&&"sha512"!==r)throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');switch(o.kty){case"AKP":tO(o.alg,'"alg" (Algorithm) Parameter'),tO(o.pub,'"pub" (Public key) Parameter'),a={alg:o.alg,kty:o.kty,pub:o.pub};break;case"EC":tO(o.crv,'"crv" (Curve) Parameter'),tO(o.x,'"x" (X Coordinate) Parameter'),tO(o.y,'"y" (Y Coordinate) Parameter'),a={crv:o.crv,kty:o.kty,x:o.x,y:o.y};break;case"OKP":tO(o.crv,'"crv" (Subtype of Key Pair) Parameter'),tO(o.x,'"x" (Public Key) Parameter'),a={crv:o.crv,kty:o.kty,x:o.x};break;case"RSA":tO(o.e,'"e" (Exponent) Parameter'),tO(o.n,'"n" (Modulus) Parameter'),a={e:o.e,kty:o.kty,n:o.n};break;case"oct":tO(o.k,'"k" (Key Value) Parameter'),a={k:o.k,kty:o.kty};break;default:throw new A('"kty" (Key Type) Parameter missing or unsupported')}let i=f(JSON.stringify(a));return v(await ec(r,i))}async function tI(t,r){r??="sha256";let o=await tj(t,r);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${r.slice(-3)}:${o}`}async function tN(t,r){let o={...t,...r?.header};if(!eu(o.jwk))throw new j('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let a=await eY({...o.jwk,ext:!0},o.alg);if(a instanceof Uint8Array||"public"!==a.type)throw new j('"jwk" (JSON Web Key) Header Parameter must be a public key');return a}function tM(t){return eu(t)}class tz{#g;#v=new WeakMap;constructor(t){if(!function(t){return t&&"object"==typeof t&&Array.isArray(t.keys)&&t.keys.every(tM)}(t))throw new M("JSON Web Key Set malformed");this.#g=structuredClone(t)}jwks(){return this.#g}async getKey(t,r){let{alg:o,kid:a}={...t,...r?.header},i=function(t){switch("string"==typeof t&&t.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";case"ML":return"AKP";default:throw new A('Unsupported "alg" value for a JSON Web Key Set')}}(o),n=this.#g.keys.filter(t=>{let r=i===t.kty;if(r&&"string"==typeof a&&(r=a===t.kid),r&&("string"==typeof t.alg||"AKP"===i)&&(r=o===t.alg),r&&"string"==typeof t.use&&(r="sig"===t.use),r&&Array.isArray(t.key_ops)&&(r=t.key_ops.includes("verify")),r)switch(o){case"ES256":r="P-256"===t.crv;break;case"ES384":r="P-384"===t.crv;break;case"ES512":r="P-521"===t.crv;break;case"Ed25519":case"EdDSA":r="Ed25519"===t.crv}return r}),{0:s,length:l}=n;if(0===l)throw new z;if(1!==l){let t=new q,r=this.#v;throw t[Symbol.asyncIterator]=async function*(){for(let t of n)try{yield await tq(r,t,o)}catch{}},t}return tq(this.#v,s,o)}}async function tq(t,r,o){let a=t.get(r)||t.set(r,{}).get(r);if(void 0===a[o]){let t=await eY({...r,ext:!0},o);if(t instanceof Uint8Array||"public"!==t.type)throw new M("JSON Web Key Set members must be public keys");a[o]=t}return a[o]}function tH(t){let r=new tz(t),o=async(t,o)=>r.getKey(t,o);return Object.defineProperties(o,{jwks:{value:()=>structuredClone(r.jwks()),enumerable:!1,configurable:!1,writable:!1}}),o}"undefined"!=typeof navigator&&navigator.userAgent?.startsWith?.("Mozilla/5.0 ")||(i="jose/v6.2.3");let tU=Symbol();async function tD(t,r,o,a=fetch){let i=await a(t,{method:"GET",signal:o,redirect:"manual",headers:r}).catch(t=>{if("TimeoutError"===t.name)throw new H;throw t});if(200!==i.status)throw new k("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new k("Failed to parse the JSON Web Key Set HTTP response as JSON")}}let tL=Symbol();class tK{#_;#b;#S;#w;#$;#E;#P;#k;#R;#x;constructor(t,r){if(!(t instanceof URL))throw TypeError("url must be an instance of URL");this.#_=new URL(t.href),this.#b="number"==typeof r?.timeoutDuration?r?.timeoutDuration:5e3,this.#S="number"==typeof r?.cooldownDuration?r?.cooldownDuration:3e4,this.#w="number"==typeof r?.cacheMaxAge?r?.cacheMaxAge:6e5,this.#P=new Headers(r?.headers),i&&!this.#P.has("User-Agent")&&this.#P.set("User-Agent",i),this.#P.has("accept")||(this.#P.set("accept","application/json"),this.#P.append("accept","application/jwk-set+json")),this.#k=r?.[tU],r?.[tL]!==void 0&&(this.#x=r?.[tL],function(t,r){return!("object"!=typeof t||null===t||!("uat"in t)||"number"!=typeof t.uat||Date.now()-t.uat>=r)&&"jwks"in t&&!!eu(t.jwks)&&!!Array.isArray(t.jwks.keys)&&!!Array.prototype.every.call(t.jwks.keys,eu)}(r?.[tL],this.#w)&&(this.#$=this.#x.uat,this.#R=tH(this.#x.jwks)))}pendingFetch(){return!!this.#E}coolingDown(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#S}fresh(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#w}jwks(){return this.#R?.jwks()}async getKey(t,r){this.#R&&this.fresh()||await this.reload();try{return await this.#R(t,r)}catch(o){if(o instanceof z&&!1===this.coolingDown())return await this.reload(),this.#R(t,r);throw o}}async reload(){this.#E&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this.#E=void 0),this.#E||=tD(this.#_.href,this.#P,AbortSignal.timeout(this.#b),this.#k).then(t=>{this.#R=tH(t),this.#x&&(this.#x.uat=Date.now(),this.#x.jwks=t),this.#$=Date.now(),this.#E=void 0}).catch(t=>{throw this.#E=void 0,t}),await this.#E}}function tJ(t,r){let o=new tK(t,r),a=async(t,r)=>o.getKey(t,r);return Object.defineProperties(a,{coolingDown:{get:()=>o.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>o.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>o.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>o.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>o.jwks(),enumerable:!0,configurable:!1,writable:!1}}),a}class tV{#h;constructor(t={}){this.#h=new tw(t)}encode(){let t=v(JSON.stringify({alg:"none"})),r=v(this.#h.data());return`${t}.${r}.`}setIssuer(t){return this.#h.iss=t,this}setSubject(t){return this.#h.sub=t,this}setAudience(t){return this.#h.aud=t,this}setJti(t){return this.#h.jti=t,this}setNotBefore(t){return this.#h.nbf=t,this}setExpirationTime(t){return this.#h.exp=t,this}setIssuedAt(t){return this.#h.iat=t,this}static decode(t,r){let o;if("string"!=typeof t)throw new I("Unsecured JWT must be a string");let{0:a,1:i,2:n,length:s}=t.split(".");if(3!==s||""!==n)throw new I("Invalid Unsecured JWT");try{if(o=JSON.parse(c.decode(g(a))),"none"!==o.alg)throw Error()}catch{throw new I("Invalid Unsecured JWT")}return{payload:tS(o,g(i),r),header:o}}}function tW(t){let r;if("string"==typeof t){let o=t.split(".");(3===o.length||5===o.length)&&([r]=o)}else if("object"==typeof t&&t)if("protected"in t)r=t.protected;else throw TypeError("Token does not contain a Protected Header");try{if("string"!=typeof r||!r)throw Error();let t=JSON.parse(c.decode(g(r)));if(!eu(t))throw Error();return t}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function tF(t){let r,o;if("string"!=typeof t)throw new I("JWTs must use Compact JWS serialization, JWT must be a string");let{1:a,length:i}=t.split(".");if(5===i)throw new I("Only JWTs using Compact JWS serialization can be decoded");if(3!==i)throw new I("Invalid JWT");if(!a)throw new I("JWTs must contain a payload");try{r=g(a)}catch{throw new I("Failed to base64url decode the payload")}try{o=JSON.parse(c.decode(r))}catch{throw new I("Failed to parse the decoded payload as JSON")}if(!eu(o))throw new I("Invalid JWT Claims Set");return o}function tB(t){let r=t?.modulusLength??2048;if("number"!=typeof r||r<2048)throw new A("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return r}async function tZ(t,r){let o,a;switch(t){case"PS256":case"PS384":case"PS512":o={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},a=["sign","verify"];break;case"RS256":case"RS384":case"RS512":o={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},a=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":o={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},a=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"},a=["sign","verify"];break;case"ES384":o={name:"ECDSA",namedCurve:"P-384"},a=["sign","verify"];break;case"ES512":o={name:"ECDSA",namedCurve:"P-521"},a=["sign","verify"];break;case"Ed25519":case"EdDSA":a=["sign","verify"],o={name:"Ed25519"};break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":a=["sign","verify"],o={name:t};break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{a=["deriveBits"];let t=r?.crv??"P-256";switch(t){case"P-256":case"P-384":case"P-521":o={name:"ECDH",namedCurve:t};break;case"X25519":o={name:"X25519"};break;default:throw new A("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}break}default:throw new A('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(o,r?.extractable??!1,a)}async function tG(t,r){let o,a,i;switch(t){case"HS256":case"HS384":case"HS512":o=parseInt(t.slice(-3),10),a={name:"HMAC",hash:`SHA-${o}`,length:o},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return o=parseInt(t.slice(-3),10),crypto.getRandomValues(new Uint8Array(o>>3));case"A128KW":case"A192KW":case"A256KW":a={name:"AES-KW",length:o=parseInt(t.slice(1,4),10)},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":a={name:"AES-GCM",length:o=parseInt(t.slice(1,4),10)},i=["encrypt","decrypt"];break;default:throw new A('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(a,r?.extractable??!1,i)}let tX="WebCryptoAPI"},8330(t){"use strict";t.exports=JSON.parse('{"name":"xmcp","description":"The TypeScript MCP framework","version":"1.9.0","author":{"name":"xmcp","email":"support@xmcp.dev","url":"https://xmcp.dev"},"contributors":[{"name":"Valentina Bearzotti","email":"valebearzotti1@gmail.com","url":"https://github.com/valebearzotti"},{"name":"Jose Rago","email":"jose@basement.studio","url":"https://github.com/ragojose"}],"license":"MIT","keywords":["mcp","modelcontextprotocol","http","stdio"],"repository":{"type":"git","url":"https://github.com/basementstudio/xmcp"},"homepage":"https://xmcp.dev","type":"commonjs","main":"./dist/index.js","types":"./dist/index.d.ts","bin":{"xmcp":"dist/cli.js"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js","default":"./dist/index.js"},"./node":{"types":"./dist/node.d.ts","node":"./dist/node.js"},"./host-bridge":{"types":"./dist/host-bridge.d.ts","import":"./dist/host-bridge.js","require":"./dist/host-bridge.js","default":"./dist/host-bridge.js"},"./headers":{"types":"./dist/runtime/headers.d.ts","require":"./dist/runtime/headers.js","default":"./dist/runtime/headers.js"},"./cloudflare":{"types":"./dist/cloudflare.d.ts","import":"./dist/cloudflare.js","require":"./dist/cloudflare.js","default":"./dist/cloudflare.js"},"./config":{"types":"./dist/config/index.d.ts","import":"./dist/config.js","require":"./dist/config.js","default":"./dist/config.js"},"./package.json":"./package.json","./client":{"types":"./dist/client.d.ts","node":"./dist/client.js"}},"typesVersions":{"*":{"node":["dist/node.d.ts"],"host-bridge":["dist/host-bridge.d.ts"],"headers":["dist/runtime/headers.d.ts"],"cloudflare":["dist/cloudflare.d.ts"],"config":["dist/config/index.d.ts"],"client":["dist/client.d.ts"]}},"files":["dist"],"scripts":{"dev":"cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts","build":"cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts","analyze":"cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts","bench":"tsx bench/run.mts","test:config":"pnpm --dir ../compiler test:config","test:adapters":"node --import tsx --test src/runtime/adapters/*/__tests__/*.test.ts","test:runtime":"node --import tsx --test src/runtime/utils/__tests__/*.test.ts src/runtime/utils/ui/__tests__/*.test.ts","test:client":"node --import tsx --test src/client/__tests__/*.test.ts"},"dependencies":{},"devDependencies":{"@modelcontextprotocol/client":"^2.2.0","@modelcontextprotocol/node":"^2.0.0","@modelcontextprotocol/server":"^2.3.0","@nestjs/common":"^11.1.12","@rspack/core":"^1.6.7","@types/async-retry":"^1.4.9","@types/content-type":"^1.1.9","@types/express":"^5.0.6","@types/fs-extra":"^11.0.4","@types/jsonwebtoken":"^9.0.10","@types/node":"^22.19.2","@types/react":"^19.2.7","@types/react-dom":"^19.2.3","async-retry":"^1.3.3","chalk":"^5.6.2","chokidar":"^3.6.0","ci-info":"^4.3.1","commander":"^11.1.0","content-type":"^1.0.5","cross-env":"^7.0.3","del":"^7.1.0","dotenv":"^16.6.1","express":"^4.22.1","fastify":"^5.12.6","fs-extra":"^11.3.2","glob":"^11.1.0","is-docker":"^4.0.0","is-wsl":"^3.1.0","jose":"^6.1.3","json5":"^2.2.3","jsonwebtoken":"^9.0.3","memfs":"^4.51.1","postcss-loader":"^8.2.0","raw-body":"^3.0.2","reflect-metadata":"^0.2.2","rxjs":"^7.8.2","ts-checker-rspack-plugin":"^1.2.1","tsx":"^4.21.0","typescript":"^5.9.3","zod-to-json-schema":"^3.25.0"},"peerDependencies":{"@modelcontextprotocol/client":"^2.2.0","@modelcontextprotocol/server":"^2.3.0","jose":"^6.1.3","react":">=19.0.0","react-dom":">=19.0.0","zod":"^3.25.76 || ^4.0.0"},"peerDependenciesMeta":{"@modelcontextprotocol/client":{"optional":true},"@modelcontextprotocol/server":{"optional":true},"jose":{"optional":true},"react":{"optional":true},"react-dom":{"optional":true}}}')}},a={};function i(t){var r=a[t];if(void 0!==r)return r.exports;var n=a[t]={exports:{}};return o[t](n,n.exports,i),n.exports}r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(o,a){if(1&a&&(o=this(o)),8&a||"object"==typeof o&&o&&(4&a&&o.__esModule||16&a&&"function"==typeof o.then))return o;var n=Object.create(null);i.r(n);var s={};t=t||[null,r({}),r([]),r(r)];for(var l=2&a&&o;("object"==typeof l||"function"==typeof l)&&!~t.indexOf(l);l=r(l))Object.getOwnPropertyNames(l).forEach(t=>{s[t]=()=>o[t]});return s.default=()=>o,i.d(n,s),n},i.d=(t,r)=>{for(var o in r)i.o(r,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},i.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};for(var s in(()=>{"use strict";let t,r,o,a,s,l,c,u,d,p,h,f,m,y,g,v,_,b,S,w;i.r(n),i.d(n,{createClient:()=>h$,withClient:()=>hE});var $,E,P,k,R,x,C,A,T=Object.create,O=Object.defineProperty,j=Object.getOwnPropertyDescriptor,I=Object.getOwnPropertyNames,N=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty,z=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),q=(t,r,o)=>(o=null!=t?T(N(t)):{},((t,r,o,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(var i,n=I(r),s=0,l=n.length;s<l;s++)i=n[s],M.call(t,i)||i===o||O(t,i,{get:(t=>r[t]).bind(null,i),enumerable:!(a=j(r,i))||a.enumerable});return t})(!r&&t&&t.__esModule?o:O(o,"default",{value:t,enumerable:!0}),t));let H=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),U=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),D=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),L=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function K(t){let r=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,o])=>-1===r.indexOf(+t)).map(([t,r])=>r)}function J(t,r="|"){return t.map(t=>ep(t)).join(r)}function V(t,r){return"bigint"==typeof r?r.toString():r}class W{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return void 0!==t&&(this._value=t(),this._getter=void 0),this._value}}function F(t){return new W(t)}function B(t){let r=+!!t.startsWith("^"),o=t.endsWith("$")?t.length-1:t.length;return t.slice(r,o)}let Z=Symbol("evaluating");function G(t,r,o){Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0})}function X(t){let r=Object.getOwnPropertyDescriptor(t,"shape");return r?.get?r.get.raw:r?.value}function Y(t){return X(t._zod.def)??t._zod.def.shape}function Q(t,r,o){Object.defineProperty(t,r,{get(){let t=o();return G(this,r,t),t},enumerable:!0,configurable:!0})}function ee(t,r,o){r in t?G(t,r,o):t[r]=o}function et(t,r,o,a){let i=Y(r);for(let n of o){let o=Object.getOwnPropertyDescriptor(i,n);o.enumerable&&(o.get?Q(t,n,()=>{let t=r._zod.def.shape[n];return a?a(t,n):t}):ee(t,n,a?a(o.value,n):o.value))}}function er(...t){let r={};for(let o of t)Object.assign(r,Object.getOwnPropertyDescriptors(o));return Object.defineProperties({},r)}let eo="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ea(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let ei=F(()=>{if(eq.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(t){return!1}});function en(t){if(!1===ea(t))return!1;let r=t.constructor;if(void 0===r||"function"!=typeof r)return!0;let o=r.prototype;return!1!==ea(o)&&!1!==Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")}function es(t){return en(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}let el=new Set(["string","number","symbol"]);function ec(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eu(t,r,o){let a=new t._zod.constr(r??t._zod.def);return(!r||o?.parent)&&(a._zod.parent=t),a}function ed(t){if(!t)return{};if("string"==typeof t)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return(delete t.message,"string"==typeof t.error)?{...t,error:()=>t.error}:t}function ep(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}let eh={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ef={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function em(t,r){let o=Y(t),a=[];for(let t of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(o,t)?.enumerable)throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&a.push(t)}return a}function ey(t,r){let o={};et(o,t,Reflect.ownKeys(Y(t)));var a=o,i=r;for(let t of Reflect.ownKeys(i)){let r=Object.getOwnPropertyDescriptor(i,t);r.enumerable&&(r.get?Q(a,t,()=>i[t]):ee(a,t,r.value))}return o}function eg(t,r,o,a="partial"){let i=r._zod.def.checks;if(i&&i.length>0)throw Error(`.${a}() cannot be used on object schemas containing refinements`);let n=o?new Set(em(r,o)):void 0,s={};return et(s,r,Reflect.ownKeys(Y(r)),t&&((r,o)=>n&&!n.has(o)?r:new t({type:"optional",innerType:r}))),eu(r,er(r._zod.def,{shape:s,checks:[]}))}function ev(t,r=0){if(!0===t.aborted)return!0;for(let o=r;o<t.issues.length;o++)if(t.issues[o]?.continue!==!0)return!0;return!1}function e_(t,r){return r.map(r=>(r.path??(r.path=[]),r.path.unshift(t),r))}function eb(t){return"string"==typeof t?t:t?.message}function eS(t,r,o){var a;for(let i=r;i<t.length;i++)(a=t[i]).schema??(a.schema=o)}function ew(t,r,o){let a=t.inst?._zod?.traits;a?.has("$ZodType")&&(a.has("$ZodCheck")?t.schema??(t.schema=t.inst):t.schema=t.inst);let i=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,n=t.message?t.message:eb(t.inst?._zod.def?.error?.(t))??eb(i?.(t))??eb(r?.error?.(t))??eb(o.customError?.(t))??eb(o.localeError?.(t))??"Invalid input",s={};for(let r of Object.keys(t))"inst"!==r&&"schema"!==r&&"continue"!==r&&"input"!==r&&"__proto__"!==r&&(s[r]=t[r]);return s.path??(s.path=[]),s.message=n,r?.reportInput&&(s.input=t.input),s}let e$=/[\uD800-\uDBFF]/;function eE(t){let r=t.length;if(!e$.test(t))return r;let o=r;for(let a=0;a<r-1;a++)(64512&t.charCodeAt(a))==55296&&(64512&t.charCodeAt(a+1))==56320&&(o--,a++);return o}function eP(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function ek(...t){let[r,o,a]=t;return"string"==typeof r?{message:r,code:"custom",input:o,inst:a}:{...r}}function eR(t,r,o,a=!0){return Object.defineProperty(t,r,{configurable:!0,writable:!0,enumerable:a,value:o}),o}function ex(t,r){for(let o in t){let a=t[o];Object.defineProperty(r,o,{configurable:!0,enumerable:!0,get(){return eR(this,o,a(this))},set(t){eR(this,o,t)}})}return r}let eC=!1,eA={configurable:!0,get(){eC=!0}};function eT(r,o,a){let i=Object.getPrototypeOf(r._zod);if(o in i&&t!==r._zod){t=void 0;return}t=r._zod,Object.defineProperty(i,o,{configurable:!0,get(){Object.defineProperty(this,o,eA);let t=eC;eC=!1;try{let r=a(this);return eC?delete this[o]:Object.defineProperty(this,o,{configurable:!0,writable:!0,value:r}),eC=eC||t,r}catch(r){throw delete this[o],eC=eC||t,r}},set(t){Object.defineProperty(this,o,{configurable:!0,writable:!0,value:t})}})}let eO=Object.freeze({status:"aborted"}),ej={value:void 0,enumerable:!1},eI="captureStackTrace"in Error?Error:null;function eN(t,r,o,a){function i(t){this.def=t,this.constr=u,this.traits=new Set}i.prototype={};let n=o&&new WeakSet;function s(a,s){if(a._zod){if(a._zod.traits.has(t))return}else{ej.value=new i(s);try{Object.defineProperty(a,"_zod",ej)}finally{ej.value=void 0}}if(a._zod.traits.add(t),r(a,s),n){let t=Object.getPrototypeOf(a),r=a._zod.constr.prototype,i=t;for(;i&&i!==r;)i=Object.getPrototypeOf(i);let s=i??t;if(!n.has(s)){n.add(s);var l=s,c=o;for(let t in c){let r=Object.getOwnPropertyDescriptor(c,t);r.get?Object.defineProperty(l,t,{...r,enumerable:!1}):function(t,r,o){Object.defineProperty(t,r,{configurable:!0,get(){return this==null?o:eR(this,r,o.bind(this))},set(t){eR(this,r,t)}})}(l,t,r.value)}}}let d=u.prototype;for(let t in d)Object.prototype.hasOwnProperty.call(d,t)&&(t in a||(a[t]=d[t].bind(a)))}let l=a?.Parent??Object;class c extends l{}function u(t){let r=a?.Parent?function(t){let r=eI;if(r){let o=r.stackTraceLimit;if("number"==typeof o){try{r.stackTraceLimit=0}catch{return eI=null,new t}try{return new t}finally{r.stackTraceLimit=o}}}return new t}(c):this;s(r,t);let o=r._zod.deferred;if(o){for(let t of o)t();r._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(r),r}return Object.defineProperty(c,"name",{value:t}),Object.defineProperty(u,"init",{value:s}),Object.defineProperty(u,Symbol.hasInstance,{value:r=>!!a?.Parent&&r instanceof a.Parent||r?._zod?.traits?.has(t)}),Object.defineProperty(u,"name",{value:t}),u}class eM extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ez extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(x=globalThis).__zod_globalConfig??(x.__zod_globalConfig={});let eq=globalThis.__zod_globalConfig;function eH(t){return t&&Object.assign(eq,t),eq}class eU extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eD="~memo",eL=[];function eK(t){return null!==t&&"object"==typeof t}function eJ(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}let eV=new WeakMap,eW=[],eF={alloc(t,o,a){let i=r;if(!i)return a;r=void 0;let n={value:a,issues:null};return i.set(o.value,n),eW.push(n),a},guard(t){var r;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,o=(t,o)=>{var a,i;let n;if("backward"!==o.direction&&(a=o,i=t.value,void 0!==(n=a[eD]?.backEdges)&&eK(i)&&n.has(i)))throw new eU;return r(t,o)};t._zod.parse=o,t._zod.run===r&&(t._zod.run=o)})},attach(t){var o;let a,i,n,s=!1;(o=t._zod).deferred??(o.deferred=[]),t._zod.deferred.push(()=>{let o=t._zod.parse,l=(c,u)=>{let d;if(void 0===a){let r=function t(r,o,a){var i,n;let s=eV.get(r);if(void 0!==s)return 2*!!s;if(o.has(r))return 2;o.add(r);let l=0,c=r=>{if(2!==l&&r?._zod){let i=t(r,o,a);i>l&&(l=i)}},u=t=>{t>l&&(l=t)},d=r._zod.def;switch(d.type){case"object":{let r=X(d);u(r?((r,i)=>{let n=0;for(let s of Reflect.ownKeys(r)){let l=Object.getOwnPropertyDescriptor(r,s);if(i&&!l.enumerable)continue;let c=l.get?1:l.value?._zod?t(l.value,o,a):0;c>n&&(n=c)}return n})(r,!0):1),c(d.catchall);break}case"array":c(d.element);break;case"tuple":for(let t of d.items)c(t);c(d.rest);break;case"record":case"map":c(d.keyType),c(d.valueType);break;case"set":c(d.valueType);break;case"union":for(let t of d.options)c(t);break;case"intersection":c(d.left),c(d.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":c(d.innerType);break;case"pipe":c(d.in),c(d.out);break;case"function":c(d.input),c(d.output);break;case"lazy":{let i=d._cachedInner??(a?r._zod.innerType:void 0);u(i?t(i,o,!1):1);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(let t in d){let r=Object.getOwnPropertyDescriptor(d,t);if(!r||r.get)continue;let o=r.value;if(o&&"object"==typeof o){if(o._zod)c(o);else if(Array.isArray(o))for(let t of o)c(t)}}}return o.delete(r),i=r,1!==(n=l)&&eV.set(i,2===n),n}(t,new Set,!1);if(0===r)return t._zod.parse=o,t._zod.run===l&&(t._zod.run=o),o(c,u);2===r||s?a=!0:s=!0}let p=c.value;if(!eK(p))return o(c,u);let h=u[eD];if(h||(h={buckets:new WeakMap,backEdges:void 0},u[eD]=h),i===u)d=n;else{var f,m;let r;f=h,m=t,(r=f.buckets.get(m))||(r=new WeakMap,f.buckets.set(m,r)),d=r,i=u,n=d}let y=d.get(p);if(y)return c.value=y.value,y.issues?y.issues.length&&c.issues.push(...eJ(y.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(y.value)),c;r=d;let g=eW.length,v=o(c,u);r=void 0;let _=eW.length>g?eW.pop():void 0;return v instanceof Promise?v.then(t=>(_&&(_.issues=t.issues.length?eJ(t.issues):eL),t)):(_&&(_.issues=v.issues.length?eJ(v.issues):eL),v)};t._zod.parse=l,t._zod.run===o&&(t._zod.run=l)})}},eB=/^[cC][0-9a-z]{6,}$/,eZ=/^[0-9a-z]+$/,eG=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,eX=/^[0-9a-vA-V]{20}$/,eY=/^[A-Za-z0-9]{27}$/,eQ=/^[a-zA-Z0-9_-]{21}$/,e0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,e1=/^([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})$/,e2=t=>t?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,e9=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,e4=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,e5=/^(?:(?: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])$/,e3=/^(([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}|:))$/,e6=/^((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])$/,e8=/^(([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])$/,e7=/^https?$/,te=/^\+[1-9]\d{6,14}$/,tt="(?:(?:\\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])))",tr=($=tt,RegExp(`^${$}$`));function to(t){let r="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof t.precision?-1===t.precision?`${r}`:0===t.precision?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${r}:[0-5]\\d(?:\\.\\d+)?`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ta=/^[\s\S]{0,}$/,ti=/^-?\d+$/,tn=/^-?\d+(?:\.\d+)?$/,ts=/^(?:true|false)$/i,tl=/^null$/i,tc=/^[^A-Z]*$/,tu=/^[^a-z]*$/,td=eN("$ZodCheck",(t,r)=>{var o;t._zod??(t._zod={}),t._zod.def=r,(o=t._zod).onattach??(o.onattach=[])}),tp=t=>{let r=t.value;return null!=r&&void 0!==r.length},th={number:"number",bigint:"bigint",object:"date"},tf=eN("$ZodCheckLessThan",(t,r)=>{td.init(t,r);let o=th[typeof r.value];t._zod.check=a=>{(r.inclusive?a.value<=r.value:a.value<r.value)||a.issues.push({origin:th[typeof a.value]??o,code:"too_big",maximum:"object"==typeof r.value?r.value.getTime():r.value,input:a.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tm=eN("$ZodCheckGreaterThan",(t,r)=>{td.init(t,r);let o=th[typeof r.value];t._zod.check=a=>{(r.inclusive?a.value>=r.value:a.value>r.value)||a.issues.push({origin:th[typeof a.value]??o,code:"too_small",minimum:"object"==typeof r.value?r.value.getTime():r.value,input:a.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),ty=eN("$ZodCheckMultipleOf",(t,r)=>{td.init(t,r),t._zod.check=o=>{var a;let i,n,s;if(typeof o.value!=typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof o.value?r.value!==BigInt(0)&&o.value%r.value===BigInt(0):0==(n=Math.round(i=(a=o.value)/r.value),s=4*Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<s?0:i-n))||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:r.value,input:o.value,inst:t,continue:!r.abort})}}),tg=eN("$ZodCheckNumberFormat",(t,r)=>{td.init(t,r),r.format=r.format||"float64";let o=r.format?.includes("int"),a=o?"int":"number",[i,n]=eh[r.format];t._zod.check=s=>{let l=s.value;if(o){if(!Number.isInteger(l))return void s.issues.push({expected:a,format:r.format,code:"invalid_type",continue:!1,input:l,inst:t});if(!Number.isSafeInteger(l))return void(l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:a,inclusive:!0,continue:!r.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:a,inclusive:!0,continue:!r.abort}))}l<i&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!r.abort}),l>n&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:n,inclusive:!0,inst:t,continue:!r.abort})}}),tv=eN("$ZodCheckMaxLength",(t,r)=>{var o;td.init(t,r),(o=t._zod.def).when??(o.when=tp),t._zod.check=o=>{let a=o.value,i=a.length;if(("string"==typeof a&&i>r.maximum?eE(a):i)<=r.maximum)return;let n=eP(a);o.issues.push({origin:n,code:"too_big",maximum:r.maximum,inclusive:!0,input:a,inst:t,continue:!r.abort})}}),t_=eN("$ZodCheckMinLength",(t,r)=>{var o;td.init(t,r),(o=t._zod.def).when??(o.when=tp),t._zod.check=o=>{let a=o.value,i=a.length;if(("string"==typeof a&&i>=r.minimum&&i<2*r.minimum?eE(a):i)>=r.minimum)return;let n=eP(a);o.issues.push({origin:n,code:"too_small",minimum:r.minimum,inclusive:!0,input:a,inst:t,continue:!r.abort})}}),tb=eN("$ZodCheckLengthEquals",(t,r)=>{var o;td.init(t,r),(o=t._zod.def).when??(o.when=tp),t._zod.check=o=>{let a=o.value,i=a.length,n="string"==typeof a&&i>=r.length&&i<=2*r.length?eE(a):i;if(n===r.length)return;let s=eP(a),l=n>r.length;o.issues.push({origin:s,...l?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:o.value,inst:t,continue:!r.abort})}}),tS=eN("$ZodCheckStringFormat",(t,r)=>{var o,a;td.init(t,r),r.pattern?(o=t._zod).check??(o.check=o=>{r.pattern.lastIndex=0,r.pattern.test(o.value)||o.issues.push({origin:"string",code:"invalid_format",format:r.format,input:o.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(a=t._zod).check??(a.check=()=>{})}),tw=eN("$ZodCheckRegex",(t,r)=>{tS.init(t,r),t._zod.check=o=>{r.pattern.lastIndex=0,r.pattern.test(o.value)||o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),t$=eN("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=tc),tS.init(t,r)}),tE=eN("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=tu),tS.init(t,r)}),tP=eN("$ZodCheckIncludes",(t,r)=>{td.init(t,r);let o=ec(r.includes),a=new RegExp("number"==typeof r.position?`^.{${r.position},}${o}`:o);r.pattern=a,t._zod.check=o=>{o.value.includes(r.includes,r.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:o.value,inst:t,continue:!r.abort})}}),tk=eN("$ZodCheckStartsWith",(t,r)=>{td.init(t,r);let o=RegExp(`^${ec(r.prefix)}.*`);r.pattern??(r.pattern=o),t._zod.check=o=>{o.value.startsWith(r.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:o.value,inst:t,continue:!r.abort})}}),tR=eN("$ZodCheckEndsWith",(t,r)=>{td.init(t,r);let o=RegExp(`.*${ec(r.suffix)}$`);r.pattern??(r.pattern=o),t._zod.check=o=>{o.value.endsWith(r.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:o.value,inst:t,continue:!r.abort})}}),tx=eN("$ZodCheckOverwrite",(t,r)=>{td.init(t,r),t._zod.check=t=>{t.value=r.tx(t.value)}});class tC{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if("function"==typeof t){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split("\n").filter(t=>t),o=Math.min(...r.map(t=>t.length-t.trimStart().length));for(let t of r.map(t=>t.slice(o)).map(t=>" ".repeat(2*this.indent)+t))this.content.push(t)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
${r.join("\n")}
};`)(...Object.values(this.closed))}}let tA={major:4,minor:6,patch:5},tT=eN("$ZodType",(t,r)=>{var o;t??(t={}),t._zod.def=r,t._zod.bag=t._zod.bag||{},t._zod.version=tA;let a=t._zod.def.checks,i=t._zod.traits.has("$ZodCheck")?[t,...a??[]]:a?.length?[...a]:[];for(let r of i)for(let o of r._zod.onattach)o(t);if(0===i.length)(o=t._zod).deferred??(o.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(r,o,a)=>{let i;if(r.memo)return r;let n=ev(r);for(let s of o){if(s._zod.def.when){if(function(t,r=0){if(!0===t.aborted)return!0;for(let o=r;o<t.issues.length;o++)if(t.issues[o]?.continue===!1)return!0;return!1}(r)||!s._zod.def.when(r))continue}else if(n)continue;let o=r.issues.length,l=s._zod.check(r);if(l instanceof Promise&&a?.async===!1)throw new eM;if(i||l instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await l,r.issues.length!==o&&(eS(r.issues,o,t),n||(n=ev(r,o)))});else{if(r.issues.length===o)continue;eS(r.issues,o,t),n||(n=ev(r,o))}}return i?i.then(()=>r):r},o=(o,a,n)=>{if(ev(o))return o.aborted=!0,o;let s=r(a,i,n);if(s instanceof Promise){if(!1===n.async)throw new eM;return s.then(r=>t._zod.parse(r,n))}return t._zod.parse(s,n)};t._zod.run=(a,n)=>{if(n.skipChecks)return t._zod.parse(a,n);if("backward"===n.direction){let r=t._zod.parse({value:a.value,issues:[]},{...n,skipChecks:!0});return r instanceof Promise?r.then(t=>o(t,a,n)):o(r,a,n)}let s=t._zod.parse(a,n);if(s instanceof Promise){if(!1===n.async)throw new eM;return s.then(t=>r(t,i,n))}return r(s,i,n)}}},{get"~standard"(){var tO;return tO=this,eR(tO,"~standard",tN(this),!1)},set"~standard"(value){eR(this,"~standard",value)}}),tj=(t,r)=>t.issues.length?{issues:t.issues.map(t=>ew(t,r,eH()))}:{value:t.value};async function tI(t,r){let o={async:!0};return tj(await t._zod.run({value:r,issues:[]},o),o)}function tN(t){return{validate:r=>{let o={async:!1};try{let a=t._zod.run({value:r,issues:[]},o);if(!(a instanceof Promise))return tj(a,o)}catch(t){}return tI(t,r)},vendor:"zod",version:1}}let tM=eN("$ZodString",(t,r)=>{tT.init(t,r),t._zod.pattern=r.pattern??ta,t._zod.parse=(o,a)=>{if(r.coerce)try{o.value=String(o.value)}catch(t){}return"string"==typeof o.value||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:t}),o}}),tz=eN("$ZodStringFormat",(t,r)=>{tS.init(t,r),tM.init(t,r)}),tq=eN("$ZodGUID",(t,r)=>{r.pattern??(r.pattern=e1),tz.init(t,r)}),tH=eN("$ZodUUID",(t,r)=>{if(r.version){let t={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(void 0===t)throw Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=e2(t))}else r.pattern??(r.pattern=e2());tz.init(t,r)}),tU=eN("$ZodEmail",(t,r)=>{r.pattern??(r.pattern=e9),tz.init(t,r)});function tD(t){try{if("undefined"!=typeof URL&&"function"==typeof URL.canParse)return URL.canParse(t);return new URL(t),!0}catch{return!1}}let tL=/[\t\n\r]/g;function tK(t){return t.replace(tL,"")}let tJ=eN("$ZodURL",(t,r)=>{tz.init(t,r),t._zod.check=o=>{try{var a,i,n,s,l,c;let u=o.value.trim(),d=(a=u,i=r,"normalize"in i||"hostname"in i||"protocol"in i?function(t,r){if(!r.normalize&&r.protocol?.source===e7.source&&!/^https?:\/\//i.test(t))return 1;try{if("undefined"!=typeof URL){let r=URL;if("function"==typeof r.parse)return r.parse(t)??2}return new URL(t)}catch{return 2}}(a,i):tD(a)||2);if(1===d)return void o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:t,continue:!r.abort});if(2===d)return void o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:t,continue:!r.abort});if(!0===d){o.value=tK(u);return}r.hostname&&(n=d,(s=r.hostname).lastIndex=0,!s.test(n.hostname))&&o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:o.value,inst:t,continue:!r.abort}),r.protocol&&(l=d,(c=r.protocol).lastIndex=0,!c.test(l.protocol.endsWith(":")?l.protocol.slice(0,-1):l.protocol))&&o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:o.value,inst:t,continue:!r.abort}),o.value=r.normalize?d.href:tK(u);return}catch(a){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:t,continue:!r.abort})}}}),tV=eN("$ZodEmoji",(t,r)=>{r.pattern??(r.pattern=RegExp(e4,"u")),tz.init(t,r)}),tW=eN("$ZodNanoID",(t,r)=>{var o;if(void 0!==r.length&&(!Number.isInteger(r.length)||r.length<1))throw Error(`Invalid nanoid length: ${r.length}`);r.pattern??(r.pattern=void 0===r.length?eQ:(o=r.length,RegExp(`^[a-zA-Z0-9_-]{${o}}$`))),tz.init(t,r)}),tF=eN("$ZodCUID",(t,r)=>{r.pattern??(r.pattern=eB),tz.init(t,r)}),tB=eN("$ZodCUID2",(t,r)=>{r.pattern??(r.pattern=eZ),tz.init(t,r)}),tZ=eN("$ZodULID",(t,r)=>{r.pattern??(r.pattern=eG),tz.init(t,r)}),tG=eN("$ZodXID",(t,r)=>{r.pattern??(r.pattern=eX),tz.init(t,r)}),tX=eN("$ZodKSUID",(t,r)=>{r.pattern??(r.pattern=eY),tz.init(t,r)}),tY=eN("$ZodISODateTime",(t,r)=>{var o;let a,i,n;r.pattern??(a=["Z"],(o=r).offset&&a.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),i=`${to({precision:o.precision,seconds:!0})}(?:${a.join("|")})`,n=o.local?`${i}|${to({precision:o.precision})}`:i,r.pattern=RegExp(`^${tt}T(?:${n})$`)),tz.init(t,r)}),tQ=eN("$ZodISODate",(t,r)=>{r.pattern??(r.pattern=tr),tz.init(t,r)}),t0=eN("$ZodISOTime",(t,r)=>{var o;r.pattern??(o=r,r.pattern=RegExp(`^${to(o)}$`)),tz.init(t,r)}),t1=eN("$ZodISODuration",(t,r)=>{r.pattern??(r.pattern=e0),tz.init(t,r)}),t2=eN("$ZodIPv4",(t,r)=>{r.pattern??(r.pattern=e5),tz.init(t,r)}),t9=/^[0-9a-fA-F:.]+$/;function t4(t){return!!t9.test(t)&&tD(`http://[${t}]`)}let t5=eN("$ZodIPv6",(t,r)=>{r.pattern??(r.pattern=e3),tz.init(t,r),t._zod.check=o=>{t4(o.value)||o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:t,continue:!r.abort})}}),t3=eN("$ZodCIDRv4",(t,r)=>{r.pattern??(r.pattern=e6),tz.init(t,r)}),t6=eN("$ZodCIDRv6",(t,r)=>{r.pattern??(r.pattern=e8),tz.init(t,r),t._zod.check=o=>{!function(t){let r=t.split("/");if(2!==r.length)return!1;let[o,a]=r;if(!a)return!1;let i=Number(a);return`${i}`===a&&!(i<0)&&!(i>128)&&t4(o)}(o.value)&&o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:t,continue:!r.abort})}});function t8(t){if(""===t)return!0;if(/\s/.test(t)||t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}let t7=/^[0-9a-zA-Z+/]*={0,2}$/,re=eN("$ZodBase64",(t,r)=>{r.pattern??(r.pattern=t7),tz.init(t,r),t._zod.check=o=>{t8(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:t,continue:!r.abort})}}),rt=/^[A-Za-z0-9_-]*$/,rr=eN("$ZodBase64URL",(t,r)=>{r.pattern??(r.pattern=rt),tz.init(t,r),t._zod.check=o=>{!function(t){if(!rt.test(t))return!1;let r=t.replace(/[-_]/g,t=>"-"===t?"+":"/");return t8(r.padEnd(4*Math.ceil(r.length/4),"="))}(o.value)&&o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:t,continue:!r.abort})}}),ro=eN("$ZodE164",(t,r)=>{r.pattern??(r.pattern=te),tz.init(t,r)}),ra=eN("$ZodJWT",(t,r)=>{tz.init(t,r),t._zod.check=o=>{!function(t,r=null){try{let o=t.split(".");if(3!==o.length)return!1;let[a]=o;if(!a)return!1;let i=JSON.parse(atob(a));if("typ"in i&&i?.typ!=="JWT"||!i.alg||r&&(!("alg"in i)||i.alg!==r))return!1;return!0}catch{return!1}}(o.value,r.alg)&&o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:t,continue:!r.abort})}}),ri=eN("$ZodNumber",(t,r)=>{tT.init(t,r),t._zod.pattern=tn,t._zod.parse=(o,a)=>{if(r.coerce)try{o.value=Number(o.value)}catch(t){}let i=o.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return o;let n="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return o.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...n?{received:n}:{}}),o}}),rn=eN("$ZodNumberFormat",(t,r)=>{tg.init(t,r),ri.init(t,r)}),rs=eN("$ZodBoolean",(t,r)=>{tT.init(t,r),t._zod.pattern=ts,t._zod.parse=(o,a)=>{if(r.coerce)try{o.value=!!o.value}catch(t){}let i=o.value;return"boolean"==typeof i||o.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),o}}),rl=eN("$ZodNull",(t,r)=>{tT.init(t,r),t._zod.pattern=tl,t._zod.values=new Set([null]),t._zod.parse=(r,o)=>{let a=r.value;return null===a||r.issues.push({expected:"null",code:"invalid_type",input:a,inst:t}),r}}),rc=eN("$ZodAny",(t,r)=>{tT.init(t,r),t._zod.parse=t=>t}),ru=eN("$ZodUnknown",(t,r)=>{tT.init(t,r),t._zod.parse=t=>t}),rd=eN("$ZodNever",(t,r)=>{tT.init(t,r),t._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function rp(t,r,o){t.issues.length&&r.issues.push(...e_(o,t.issues)),r.value[o]=t.value}let rh=eN("$ZodArray",(t,r)=>{tT.init(t,r);let o=eq.memoizer;o?.attach(t),t._zod.parse=(a,i)=>{let n=a.value;if(!Array.isArray(n))return a.issues.push({expected:"array",code:"invalid_type",input:n,inst:t}),a;a.value=o?o.alloc(t,a,Array(n.length),i):Array(n.length);let s=[],l=i?.abortEarly;for(let t=0;t<n.length;t++){let o=n[t],c=r.element._zod.run({value:o,issues:[]},i);if(c instanceof Promise)s.push(c.then(r=>rp(r,a,t)));else if(rp(c,a,t),l&&0!==c.issues.length&&ev(c))break}return s.length?Promise.all(s).then(()=>a):a}});function rf(t,r,o,a,i,n){let s=o in a,l="optional"===n;if(s||!l||"optional"!==i){if(t.issues.length){if(void 0!==i&&l&&!s)return;r.issues.push(...e_(o,t.issues))}if(!s&&void 0===i){t.issues.length||r.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}void 0===t.value?(s||"defaulted"===i&&!l)&&(r.value[o]=void 0):r.value[o]=t.value}}let rm=[];function ry(t){var r;let o=Object.keys(t.shape),a=Object.getOwnPropertySymbols(t.shape),i=a.length?a:rm,n=i.length?[...o,...i]:o;for(let r of n)if(!t.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(r)}": expected a Zod schema`);let s=Object.keys(r=t.shape).filter(t=>void 0!==r[t]._zod.optin&&"optional"===r[t]._zod.optout);return{...t,allKeys:n,symbolKeys:i,keySet:new Set(o),numKeys:o.length,optionalKeys:new Set(s)}}function rg(t,r,o,a,i,n,s){let l=[],c=i.keySet,u=i.catchall._zod,d=u.def.type,p=u.optin,h=u.optout,f=0;for(let i in r){if(s&&o.issues.length!==f){if(ev(o,f))break;f=o.issues.length}if(c.has(i))continue;if("__proto__"===i){"never"===d&&l.push(i);continue}if("never"===d){l.push(i);continue}let n=u.run({value:r[i],issues:[]},a);n instanceof Promise?t.push(n.then(t=>rf(t,o,i,r,p,h))):rf(n,o,i,r,p,h)}return(l.length&&o.issues.push({code:"unrecognized_keys",keys:l,input:r,inst:n,continue:!0}),t.length)?Promise.all(t).then(()=>o):o}let rv=eN("$ZodObject",(t,r)=>{let o;tT.init(t,r);let a=Object.getOwnPropertyDescriptor(r,"shape"),i=a?.get?a.get.raw:r.shape??{};if(i){let t=()=>{let o={...i};return Object.defineProperty(r,"shape",{value:o}),t.raw=o,o};t.raw=i,Object.defineProperty(r,"shape",{get:t})}let n=F(()=>ry(r));eT(t,"propValues",t=>{let r=t.def.shape,o={};for(let t in r){let a=r[t]._zod;if(a.values){for(let r of(Object.prototype.hasOwnProperty.call(o,t)||G(o,t,new Set),a.values))o[t].add(r);void 0!==a.optin&&o[t].add(void 0)}}return o});let s=r.catchall,l=eq.memoizer;l?.attach(t),t._zod.parse=(r,a)=>{o??(o=n.value);let i=r.value;if(!ea(i))return r.issues.push({expected:"object",code:"invalid_type",input:i,inst:t}),r;r.value=l?l.alloc(t,r,{},a):{};let c=[],u=o.shape,d=a?.abortEarly,p=r.issues.length;for(let t of o.allKeys){if(d&&r.issues.length!==p){if(ev(r,p))break;p=r.issues.length}if("__proto__"===t)continue;let o=u[t],n=o._zod.optin,s=o._zod.optout,l=o._zod.run({value:i[t],issues:[]},a);l instanceof Promise?c.push(l.then(o=>rf(o,r,t,i,n,s))):rf(l,r,t,i,n,s)}return s?rg(c,i,r,a,n.value,t,!0===d):c.length?Promise.all(c).then(()=>r):r}}),r_=eN("$ZodObjectJIT",(t,r)=>{let o,a;rv.init(t,r);let i=t._zod.parse,n=F(()=>ry(r)),s=eq.memoizer,l=!eq.jitless,c=l&&ei.value,u=r.catchall;t._zod.parse=(d,p)=>{a??(a=n.value);let h=d.value;return ea(h)?l&&c&&p?.async===!1&&!0!==p.jitless?(o||(o=(r=>{let o=n.value,a=o.symbolKeys,i=new tC(["payload","ctx"],{shape:r,inst:t,memo:s,syms:a}),l=t=>`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`,c=(t,r)=>`
let ${t}_ab = false;
for (let i = 0; i < ${t}.issues.length; i++) {
const iss = ${t}.issues[i];
iss.path = iss.path ? [${r}, ...iss.path] : [${r}];
payload.issues.push(iss);
if (iss.continue !== true) ${t}_ab = true;
}
if (${t}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}`;i.write("const input = payload.value;");let u=Object.create(null),d=0;for(let t of o.allKeys)u[t]=`key_${d++}`;for(let t of(i.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};"),o.allKeys)){if("__proto__"===t)continue;let o=u[t],n="symbol"==typeof t?`syms[${a.indexOf(t)}]`:JSON.stringify(t),s=`${n} in input`,d=r[t],p=d?._zod?.optin,h=void 0!==p,f=d?._zod?.optout==="optional";if(i.write(`const ${o} = ${l(n)};`),h&&f){let t="optional"===p?`${o}_present`:`${o}.value !== undefined || ${o}_present`;i.write(`
const ${o}_present = ${s};
if (!${o}.issues.length || ${o}_present) {
if (${o}.issues.length) {${c(o,n)}
}
if (${t}) {
newResult[${n}] = ${o}.value;
}
}
`)}else h?(i.write(`
if (${o}.issues.length) {${c(o,n)}
}
`),"defaulted"===p?i.write(`newResult[${n}] = ${o}.value;`):i.write(`
if (${o}.value !== undefined || ${s}) {
newResult[${n}] = ${o}.value;
}
`)):i.write(`
const ${o}_present = ${s};
if (${o}.issues.length) {${c(o,n)}
}
if (!${o}_present && !${o}.issues.length) {
payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${n}]
});
if (ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}
}
if (${o}_present) {
newResult[${n}] = ${o}.value;
}
`)}return i.write("payload.value = newResult;"),i.write("return payload;"),i.compile()})(r.shape)),d=o(d,p),u)?rg([],h,d,p,a,t,p?.abortEarly===!0):d:i(d,p):(d.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),d)}});function rb(t,r,o,a){for(let o of t)if(0===o.issues.length)return r.value=o.value,r;let i=t.filter(t=>!ev(t));return 1===i.length?(r.value=i[0].value,i[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:o,errors:t.map(t=>t.issues.map(t=>ew(t,a,eH())))}),r)}let rS=eN("$ZodUnion",(t,r)=>{tT.init(t,r),eT(t,"optin",t=>t.def.options.some(t=>"defaulted"===t._zod.optin)?"defaulted":t.def.options.some(t=>void 0!==t._zod.optin)?"optional":void 0),eT(t,"optout",t=>t.def.options.some(t=>"optional"===t._zod.optout)?"optional":void 0),eT(t,"values",t=>{if(t.def.options.every(t=>t._zod.values))return new Set(t.def.options.flatMap(t=>Array.from(t._zod.values)))}),eT(t,"pattern",t=>{if(t.def.options.every(t=>t._zod.pattern)){let r=t.def.options.map(t=>t._zod.pattern);return RegExp(`^(${r.map(t=>B(t.source)).join("|")})$`)}});let o=1===r.options.length?r.options[0]._zod.run:null;t._zod.parse=(a,i)=>{if(o)return o(a,i);let n=!1,s=[];for(let t of r.options){let r=t._zod.run({value:a.value,issues:[]},i);if(r instanceof Promise)s.push(r),n=!0;else{if(0===r.issues.length)return r;s.push(r)}}return n?Promise.all(s).then(r=>rb(r,a,t,i)):rb(s,a,t,i)}}),rw=eN("$ZodDiscriminatedUnion",(t,r)=>{r.inclusive=!1,rS.init(t,r);let o=t._zod.parse;eT(t,"propValues",t=>{let r={},o=0;for(let a of t.def.options){let i=a._zod.propValues;if(!i||0===Object.keys(i).length)throw Error(`Invalid discriminated union option at index "${t.def.options.indexOf(a)}"`);for(let[a,n]of(i[t.def.discriminator]?.has(void 0)&&o++,Object.entries(i)))for(let t of(Object.prototype.hasOwnProperty.call(r,a)||G(r,a,new Set),n))r[a].add(t)}return!t.def.unionFallback&&o>1&&r[t.def.discriminator]?.delete(void 0),r}),r.options.forEach((t,o)=>{let a=X(t._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,r.discriminator))throw Error(`Invalid discriminated union option at index "${o}"`)});let a=F(()=>(function(t){let r=new Map;for(let o of t.options){let a=o._zod.propValues?.[t.discriminator];if(!a||0===a.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let t of a)if(r.has(t)){if(void 0!==t)throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,null)}else r.set(t,o)}return r})(r));t._zod.parse=(i,n)=>{let s=i.value;if(!ea(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;let l=s?.[r.discriminator],c=a.value.get(l);return c&&(void 0!==l||"backward"!==n.direction)?c._zod.run(i,n):r.unionFallback||"backward"===n.direction?o(i,n):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,options:Array.from(a.value.keys()).filter(t=>null!==a.value.get(t)),input:s,path:[r.discriminator],inst:t}),i)}}),r$=eN("$ZodIntersection",(t,r)=>{tT.init(t,r),t._zod.parse=(t,o)=>{let a=t.value,i=r.left._zod.run({value:a,issues:[]},o),n=r.right._zod.run({value:a,issues:[]},o);return i instanceof Promise||n instanceof Promise?Promise.all([i,n]).then(([r,o])=>rE(t,r,o)):rE(t,i,n)}});function rE(t,r,o){let a,i=new Map,n=new Map,s=(t,r)=>{let o;if("unrecognized_keys"!==t.code||t.path?.length)if("invalid_key"!==t.code||"record"!==t.origin||t.path?.length!==1)return!1;else{let r=String(t.path[0]);n.has(r)||n.set(r,t),o=[r]}else a??(a=t),o=t.keys;for(let t of o)i.has(t)||i.set(t,{}),i.get(t)[r]=!0;return!0};for(let o of r.issues)s(o,"l")||t.issues.push(o);for(let r of o.issues)s(r,"r")||t.issues.push(r);let l=[...i].filter(([,t])=>t.l&&t.r).map(([t])=>t);if(l.length){let r=a?l.filter(t=>a.keys.includes(t)):[];for(let o of(r.length&&t.issues.push({...a,keys:r}),l))!r.includes(o)&&n.has(o)&&t.issues.push(n.get(o))}let c=function t(r,o){if(r===o||r instanceof Date&&o instanceof Date&&+r==+o)return{valid:!0,data:r};if(en(r)&&en(o)){let a=Object.keys(o),i=Object.keys(r).filter(t=>-1!==a.indexOf(t)),n={...r,...o};for(let a of(Object.prototype.hasOwnProperty.call(n,"__proto__")&&delete n.__proto__,i)){if("__proto__"===a)continue;let i=t(r[a],o[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};n[a]=i.data}return{valid:!0,data:n}}if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return{valid:!1,mergeErrorPath:[]};let a=[];for(let i=0;i<r.length;i++){let n=r[i],s=t(n,o[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};a.push(s.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}(r.value,o.value);if(!c.valid){if(ev(t))return t;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return t.value=c.data,t}let rP=eN("$ZodRecord",(t,r)=>{tT.init(t,r);let o=eq.memoizer;o?.attach(t),t._zod.parse=(a,i)=>{let n=a.value;if(!en(n))return a.issues.push({expected:"record",code:"invalid_type",input:n,inst:t}),a;let s=[],l=r.keyType._zod.values;if(l&&!r.partial){let c;a.value=o?o.alloc(t,a,{},i):{};let u=new Set;for(let o of l)if("string"==typeof o||"number"==typeof o||"symbol"==typeof o){if(u.add("number"==typeof o?o.toString():o),"__proto__"===o)continue;let l=r.keyType._zod.run({value:o,issues:[]},i);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){a.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(t=>ew(t,i,eH())),input:o,path:[o],inst:t});continue}let c=l.value;if("__proto__"===c)continue;let d=r.valueType._zod.run({value:n[o],issues:[]},i);d instanceof Promise?s.push(d.then(t=>{t.issues.length&&a.issues.push(...e_(o,t.issues)),a.value[c]=t.value})):(d.issues.length&&a.issues.push(...e_(o,d.issues)),a.value[c]=d.value)}for(let t in n)if(!u.has(t))if("loose"===r.mode){if("__proto__"===t)continue;a.value[t]=n[t]}else(c=c??[]).push(t);c&&c.length>0&&a.issues.push({code:"unrecognized_keys",input:n,inst:t,keys:c,continue:!0})}else{let c;for(let u of(a.value=o?o.alloc(t,a,{},i):{},Reflect.ownKeys(n))){if("__proto__"===u||!Object.prototype.propertyIsEnumerable.call(n,u))continue;let o=r.keyType._zod.run({value:u,issues:[]},i);if(o instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof u&&tn.test(u)&&o.issues.length){let t=r.keyType._zod.run({value:Number(u),issues:[]},i);if(t instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===t.issues.length&&(o=t)}if(o.issues.length){"loose"===r.mode?a.value[u]=n[u]:l?(c=c??[]).push(u):a.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(t=>ew(t,i,eH())),input:u,path:[u],inst:t});continue}let d=o.value;if("__proto__"===d)continue;let p=r.valueType._zod.run({value:n[u],issues:[]},i);p instanceof Promise?s.push(p.then(t=>{t.issues.length&&a.issues.push(...e_(u,t.issues)),a.value[d]=t.value})):(p.issues.length&&a.issues.push(...e_(u,p.issues)),a.value[d]=p.value)}c&&c.length>0&&a.issues.push({code:"unrecognized_keys",input:n,inst:t,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>a):a}}),rk=eN("$ZodEnum",(t,r)=>{tT.init(t,r);let o=K(r.entries),a=new Set(o);t._zod.values=a,eT(t,"pattern",t=>{let r=K(t.def.entries).filter(t=>el.has(typeof t));return new RegExp(r.length?`^(${r.map(t=>ec(t.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(r,i)=>{let n=r.value;return a.has(n)||r.issues.push({code:"invalid_value",values:o,input:n,inst:t}),r}}),rR=eN("$ZodLiteral",(t,r)=>{tT.init(t,r);let o=new Set(r.values);t._zod.values=o,eT(t,"pattern",t=>{let r=t.def.values;return new RegExp(r.length?`^(${r.map(t=>"string"==typeof t?ec(t):t?ec(t.toString()):String(t)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(a,i)=>{let n=a.value;return o.has(n)||a.issues.push({code:"invalid_value",values:r.values,input:n,inst:t}),a}}),rx=eN("$ZodTransform",(t,r)=>{tT.init(t,r),t._zod.optin="optional",eq.memoizer?.guard(t),t._zod.parse=(o,a)=>{if("backward"===a.direction)throw new ez(t.constructor.name);let i=r.transform(o.value,o);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(t=>(o.value=t,o));if(i instanceof Promise)throw new eM;return o.value=i,o}});function rC(t,r){return t.value=r.issues.length?void 0:r.value,t}let rA=eN("$ZodOptional",(t,r)=>{tT.init(t,r),eT(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),t._zod.optout="optional",eT(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),eT(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${B(r.source)})?$`):void 0}),t._zod.parse=(t,o)=>{if(void 0===t.value){if("defaulted"!==r.innerType._zod.optin)return t;let a=r.innerType._zod.run({value:t.value,issues:[]},o);return a instanceof Promise?a.then(r=>rC(t,r)):rC(t,a)}return r.innerType._zod.run(t,o)}}),rT=eN("$ZodExactOptional",(t,r)=>{rA.init(t,r),eT(t,"values",t=>t.def.innerType._zod.values),eT(t,"pattern",t=>t.def.innerType._zod.pattern),t._zod.parse=(t,o)=>r.innerType._zod.run(t,o)}),rO=eN("$ZodNullable",(t,r)=>{tT.init(t,r),eT(t,"optin",t=>t.def.innerType._zod.optin),eT(t,"optout",t=>t.def.innerType._zod.optout),eT(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${B(r.source)}|null)$`):void 0}),eT(t,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),t._zod.parse=(t,o)=>null===t.value?t:r.innerType._zod.run(t,o)}),rj=eN("$ZodDefault",(t,r)=>{tT.init(t,r),t._zod.optin="defaulted",eT(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,o)=>{if("backward"===o.direction)return r.innerType._zod.run(t,o);if(void 0===t.value)return t.value=r.defaultValue,t;let a=r.innerType._zod.run(t,o);return a instanceof Promise?a.then(t=>rI(t,r)):rI(a,r)}});function rI(t,r){return void 0===t.value&&(t.value=r.defaultValue),t}let rN=eN("$ZodPrefault",(t,r)=>{tT.init(t,r),t._zod.optin="defaulted",eT(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,o)=>("backward"===o.direction||void 0===t.value&&(t.value=r.defaultValue),r.innerType._zod.run(t,o))}),rM=eN("$ZodNonOptional",(t,r)=>{tT.init(t,r),eT(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter(t=>void 0!==t)):void 0}),t._zod.parse=(o,a)=>{let i=r.innerType._zod.run(o,a);return i instanceof Promise?i.then(r=>rz(r,t)):rz(i,t)}});function rz(t,r){return t.issues.length||void 0!==t.value||t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}function rq(t,r,o,a){return r.issues.length?t.value=o.catchValue({...r,value:t.value,error:{issues:r.issues.map(t=>ew(t,a,eH()))},input:t.value}):(t.value=r.value,r.memo&&(t.memo=!0)),t}let rH=eN("$ZodCatch",(t,r)=>{tT.init(t,r),eT(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),eT(t,"optout",t=>t.def.innerType._zod.optout),eT(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,o)=>{if("backward"===o.direction)return r.innerType._zod.run(t,o);let a=r.innerType._zod.run({value:t.value,issues:[]},o);return a instanceof Promise?a.then(a=>rq(t,a,r,o)):rq(t,a,r,o)}}),rU=eN("$ZodPipe",(t,r)=>{tT.init(t,r),eT(t,"values",t=>t.def.in._zod.values),eT(t,"optin",t=>t.def.in._zod.optin),eT(t,"optout",t=>t.def.out._zod.optout),eT(t,"propValues",t=>t.def.in._zod.propValues),t._zod.parse=(t,o)=>{if("backward"===o.direction){let a=r.out._zod.run(t,o);return a instanceof Promise?a.then(t=>rD(t,r.in,o)):rD(a,r.in,o)}let a=r.in._zod.run(t,o);return a instanceof Promise?a.then(t=>rD(t,r.out,o)):rD(a,r.out,o)}});function rD(t,r,o){return t.issues.some(t=>"unrecognized_keys"!==t.code)?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},o)}let rL=eN("$ZodPreprocess",(t,r)=>{rU.init(t,r)}),rK=eN("$ZodReadonly",(t,r)=>{tT.init(t,r),eT(t,"propValues",t=>t.def.innerType._zod.propValues),eT(t,"values",t=>t.def.innerType._zod.values),eT(t,"optin",t=>t.def.innerType?._zod?.optin),eT(t,"optout",t=>t.def.innerType?._zod?.optout),t._zod.parse=(t,o)=>{if("backward"===o.direction)return r.innerType._zod.run(t,o);let a=r.innerType._zod.run(t,o);return a instanceof Promise?a.then(rJ):rJ(a)}});function rJ(t){return t.memo||(t.value=Object.freeze(t.value)),t}let rV=eN("$ZodLazy",(t,r)=>{var o,a,i;let n;tT.init(t,r),o=t._zod,a="innerType",i=()=>(r._cachedInner||(r._cachedInner=r.getter()),r._cachedInner),Object.defineProperty(o,a,{get(){if(n!==Z)return void 0===n&&(n=Z,n=i()),n},set(t){Object.defineProperty(o,a,{value:t})},configurable:!0}),eT(t,"pattern",t=>t.innerType?._zod?.pattern),eT(t,"propValues",t=>t.innerType?._zod?.propValues),eT(t,"optin",t=>t.innerType?._zod?.optin??void 0),eT(t,"optout",t=>t.innerType?._zod?.optout??void 0),t._zod.parse=(r,o)=>t._zod.innerType._zod.run(r,o)}),rW=eN("$ZodCustom",(t,r)=>{td.init(t,r),tT.init(t,r),t._zod.parse=(t,r)=>t,t._zod.check=o=>{let a=o.value,i=r.fn(a);if(i instanceof Promise)return i.then(r=>rF(r,o,a,t));rF(i,o,a,t)}});function rF(t,r,o,a){if(!t){let t={code:"custom",input:o,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(t.params=a._zod.def.params),r.issues.push(ek(t))}}class rB{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let o=r[0];return this._map.set(t,o),o&&"object"==typeof o&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&"object"==typeof r&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let o={...this.get(r)??{}};delete o.id;let a={...o,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}(C=globalThis).__zod_globalRegistry??(C.__zod_globalRegistry=new rB);let rZ=globalThis.__zod_globalRegistry;function rG(t){return t.checks&&(t.checks=[...t.checks]),t}function rX(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...ed(r)})}function rY(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...ed(r)})}function rQ(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ed(r)})}function r0(t,r){return new t({type:"string",format:"date",check:"string_format",...ed(r)})}function r1(t,r){return new tf({check:"less_than",...ed(r),value:t,inclusive:!1})}function r2(t,r){return new tf({check:"less_than",...ed(r),value:t,inclusive:!0})}function r9(t,r){return new tm({check:"greater_than",...ed(r),value:t,inclusive:!1})}function r4(t,r){return new tm({check:"greater_than",...ed(r),value:t,inclusive:!0})}function r5(t,r){return new ty({check:"multiple_of",...ed(r),value:t})}function r3(t,r){return new tv({check:"max_length",...ed(r),maximum:t})}function r6(t,r){return new t_({check:"min_length",...ed(r),minimum:t})}function r8(t,r){return new tb({check:"length_equals",...ed(r),length:t})}function r7(t){return new tx({check:"overwrite",tx:t})}function oe(t,...r){for(let o of r)for(let r of Reflect.ownKeys(o))Object.prototype.propertyIsEnumerable.call(o,r)&&G(t,r,o[r]);return t}function ot(t){let r=t?.target??"draft-2020-12";return"draft-4"===r&&(r="draft-04"),"draft-7"===r&&(r="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??rZ,target:r,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function or(t,r,o,a,i){let n="function"==typeof r.unrepresentable?r.unrepresentable({zodSchema:t,path:a.path,message:i}):r.unrepresentable;if("any"===n)return!1;if(void 0===n||"throw"===n)throw Error(i);return Object.assign(o,n),!0}function oo(t,r,o={path:[],schemaPath:[]}){var a;let i=t._zod.def,n=r.seen.get(t);if(n)return n.count++,o.schemaPath.includes(t)&&(n.cycle=o.path),n.schema;let s={schema:{},count:1,cycle:void 0,path:o.path};r.seen.set(t,s),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let l=t._zod.toJSONSchema?.();if(l)s.schema=l;else{let a={...o,schemaPath:[...o.schemaPath,t],path:o.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(r,s.schema,a);else{let o=s.schema,n=r.processors[i.type];if(!n)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);n(t,r,o,a)}let n=t._zod.parent;n&&(s.ref||(s.ref=n),oo(n,r,a),r.seen.get(n).isParent=!0)}let c=r.metadataRegistry.get(t);return c&&oe(s.schema,c),"input"===r.io&&function t(r,o){let a=o??{seen:new Set};if(a.seen.has(r))return!1;a.seen.add(r);let i=r._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return t(i.element,a);if("set"===i.type)return t(i.valueType,a);if("lazy"===i.type)return t(i.getter(),a);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type||"catch"===i.type)return t(i.innerType,a);if("intersection"===i.type)return t(i.left,a)||t(i.right,a);if("record"===i.type||"map"===i.type)return t(i.keyType,a)||t(i.valueType,a);if("pipe"===i.type)return!!r._zod.traits.has("$ZodCodec")||t(i.in,a)||t(i.out,a);if("object"===i.type){for(let r in i.shape)if(t(i.shape[r],a))return!0;return!1}if("union"===i.type){for(let r of i.options)if(t(r,a))return!0;return!1}if("tuple"===i.type){for(let r of i.items)if(t(r,a))return!0;if(i.rest&&t(i.rest,a))return!0}return!1}(t)&&(delete s.schema.examples,delete s.schema.default),"input"===r.io&&"_prefault"in s.schema&&((a=s.schema).default??(a.default=s.schema._prefault)),delete s.schema._prefault,r.seen.get(t).schema}function oa(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function oi(t,r){let o=t.seen.get(r);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;let a=new Map;for(let r of t.seen.entries()){let o=t.metadataRegistry.get(r[0])?.id;if(o){let t=a.get(o);if(t&&t!==r[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(o,r[0])}}let i=r=>{if(r[1].schema.$ref)return;let a=r[1],{ref:i,defId:n}=(r=>{let a="draft-2020-12"===t.target?"$defs":"definitions";if(t.external){let o=t.external.registry.get(r[0])?.id,i=t.external.uri??(t=>t);if(o)return{ref:i(o)};let n=r[1].defId??r[1].schema.id??`schema${t.counter++}`;return r[1].defId=n,{defId:n,ref:`${i("__shared")}#/${a}/${oa(n)}`}}let i=`#/${a}/`;if(r[1]===o&&!r[1].schema.id)return{ref:"#"};let n=r[1].schema.id??`__schema${t.counter++}`;return{defId:n,ref:i+oa(n)}})(r);a.def={...a.schema},n&&(a.defId=n);let s=a.schema;for(let t in s)delete s[t];s.$ref=i};if("throw"===t.cycles)for(let r of t.seen.entries()){let t=r[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of t.seen.entries()){let a=o[1];if(r===o[0]){i(o);continue}if(t.external){let a=t.external.registry.get(o[0])?.id;if(r!==o[0]&&a){i(o);continue}}if(t.metadataRegistry.get(o[0])?.id||a.cycle){i(o);continue}a.count>1&&"ref"===t.reused&&i(o)}t.external&&(t.sharedDefsExtractedFor=t.external)}let on=new Set(["type","properties","required","additionalProperties"]),os=["oneOf","anyOf"];function ol(t){let r=t.additionalProperties;return void 0===r||!1===r||"object"!=typeof r||null===r?null:Object.keys(r).length?r:null}function oc(t){let r=[];for(let o of t){if("object"!=typeof o||"object"!==o.type)return null;for(let t in o)if(!on.has(t))return null;r.push(o)}let o={},a=new Set;for(let t of r){for(let a in t.properties){if(Object.prototype.hasOwnProperty.call(o,a))continue;let t=[];for(let o of r){let r=o.properties?.[a]??ol(o);null!=r&&(t.some(t=>JSON.stringify(t)===JSON.stringify(r))||t.push(r))}G(o,a,1===t.length?t[0]:oc(t)??{allOf:t})}for(let r of t.required??[])a.add(r)}let i={type:"object",properties:o};if(a.size&&(i.required=[...a]),r.every(t=>!1===t.additionalProperties))i.additionalProperties=!1;else{let t=[];for(let o of r){let r=ol(o);r&&!t.some(t=>JSON.stringify(t)===JSON.stringify(r))&&t.push(r)}1===t.length?i.additionalProperties=t[0]:t.length>1&&(i.additionalProperties={allOf:t})}return i}function ou(t,r){let o=t.seen.get(r);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let a=r=>{let o=t.seen.get(r);if(null===o.ref)return;let i=o.def??o.schema,n={...i},s=o.ref;if(o.ref=null,s){a(s);let o=t.seen.get(s),l=o.schema;if(l.$ref&&("draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target)?(i.allOf=i.allOf??[],i.allOf.push(l)):oe(i,l),oe(i,n),r._zod.parent===s)for(let t in i)"$ref"!==t&&"allOf"!==t&&(t in n||delete i[t]);if(l.$ref&&o.def)for(let t in i)"$ref"!==t&&"allOf"!==t&&t in o.def&&JSON.stringify(i[t])===JSON.stringify(o.def[t])&&delete i[t]}let l=r._zod.parent;if(l&&l!==s){a(l);let r=t.seen.get(l);if(r?.schema.$ref&&(i.$ref=r.schema.$ref,r.def))for(let t in i)"$ref"!==t&&"allOf"!==t&&t in r.def&&JSON.stringify(i[t])===JSON.stringify(r.def[t])&&delete i[t]}t.override({zodSchema:r,jsonSchema:i,path:o.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let r of[...t.seen.entries()].reverse())a(r[0]);if("openapi-3.0"!==t.target)for(let r of t.seen.entries())!function t(r){let o=r.anyOf;if(!Array.isArray(o)||0===o.length||void 0!==r.type)return;let a=[];for(let r of o){if(!r||"object"!=typeof r)return;t(r);let o=Object.keys(r);if(1!==o.length||"type"!==o[0])return;let i=r.type;for(let t of Array.isArray(i)?i:[i]){if("string"!=typeof t)return;a.includes(t)||a.push(t)}}delete r.anyOf,r.type=1===a.length?a[0]:a}(r[1].def??r[1].schema);for(let r of t.deferred)r();if(t.intersections.length){let r=new Map;for(let o of t.seen.values())for(let t of[o.schema,o.def]){let o=t?.allOf;if(!Array.isArray(o))continue;let a=r.get(o);a?a.push(t):r.set(o,[t])}for(let o of t.intersections)for(let t of r.get(o)??[])!function(t){let r=t.allOf;if(!Array.isArray(r)||r.length<2)return;for(let r of on)if(r in t)return;let o=r.filter(t=>os.some(r=>Array.isArray(t[r]))),a=null;if(o.length){let t=o[0],i=os.find(r=>Array.isArray(t[r]));if(1!==Object.keys(t).length)return;let n=r.filter(r=>r!==t),s=t[i].map(t=>oc([...n,t]));if(s.some(t=>!t))return;a={[i]:s}}else a=oc(r);a&&(delete t.allOf,oe(t,a))}(t)}}let i={};if("draft-2020-12"===t.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===t.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===t.target?i.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let o=t.external.registry.get(r)?.id;if(!o)throw Error("Schema is missing an `id` property");i.$id=t.external.uri(o)}oe(i,o.defId?o.schema:o.def??o.schema);let n=t.metadataRegistry.get(r)?.id;void 0!==n&&i.id===n&&delete i.id;let s=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let r of t.seen.entries()){let t=r[1];t.def&&t.defId&&(t.def.id===t.defId&&delete t.def.id,G(s,t.defId,t.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(s).length>0&&("draft-2020-12"===t.target?i.$defs=s:i.definitions=s);try{let o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...r["~standard"],jsonSchema:{input:od(r,"input",t.processors),output:od(r,"output",t.processors)}},enumerable:!1,writable:!1}),o}catch(t){throw Error("Error converting schema to JSON.")}}let od=(t,r,o={})=>a=>{let{libraryOptions:i,target:n}=a??{},s=ot({...i??{},target:n,io:r,processors:o});return oo(t,s),oi(s,t),ou(s,t)},op=(t,r,o)=>{(void 0===t[r]||o>t[r])&&(t[r]=o)},oh=(t,r,o)=>{(void 0===t[r]||o<t[r])&&(t[r]=o)},of=(t,r)=>{op(t,"minimum",r),oh(t,"maximum",r)},om=(t,r)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(r)||t.multipleOf.push(r)},oy=(t,r)=>{t.patterns??(t.patterns=new Set),t.patterns.add(r)},og=(t,r)=>{t.mime=t.mime?t.mime.filter(t=>r.includes(t)):[...r]},ov=(t,r)=>{t.format=r,r.includes("int")&&(t.isInt=!0)},o_=(t,r)=>op(t,"minimum",r.minimum),ob=(t,r)=>oh(t,"maximum",r.maximum),oS=t=>(r,o)=>{ov(r,o.format);let[a,i]=t[o.format];op(r,"minimum",a),oh(r,"maximum",i)},ow={greater_than:(t,r)=>op(t,r.inclusive?"minimum":"exclusiveMinimum",r.value),less_than:(t,r)=>oh(t,r.inclusive?"maximum":"exclusiveMaximum",r.value),multiple_of:(t,r)=>om(t,r.value),number_format:oS(eh),bigint_format:oS(ef),min_length:o_,max_length:ob,length_equals:(t,r)=>of(t,r.length),min_size:o_,max_size:ob,size_equals:(t,r)=>of(t,r.size),string_format:(t,r)=>{ov(t,r.format),r.pattern&&oy(t,r.pattern),("base64"===r.format||"base64url"===r.format)&&(t.contentEncoding=r.format),(r.local||-1===r.precision)&&(t.laxFormat=!0)},mime_type:(t,r)=>og(t,r.mime)};function o$(t){let r={},o=t._zod.def;for(let a of t._zod.traits.has("$ZodCheck")?[t,...o.checks??[]]:o.checks??[])ow[a._zod.def.check]?.(r,a._zod.def);let a=t._zod.bag;for(let t of(void 0!==a.minimum&&op(r,"minimum",a.minimum),void 0!==a.exclusiveMinimum&&op(r,"exclusiveMinimum",a.exclusiveMinimum),void 0!==a.maximum&&oh(r,"maximum",a.maximum),void 0!==a.exclusiveMaximum&&oh(r,"exclusiveMaximum",a.exclusiveMaximum),void 0!==a.multipleOf&&om(r,a.multipleOf),void 0!==a.format&&(r.format??(r.format=a.format),a.format.includes("int")&&(r.isInt=!0)),a.mime&&og(r,a.mime),a.patterns??[]))oy(r,t);return r}let oE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},oP=new Map([[t7,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[rt,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),ok=t=>oP.get(t)??t,oR=(t,r,o,a)=>{o.type="string";let{minimum:i,maximum:n,format:s,patterns:l,contentEncoding:c,laxFormat:u}=o$(t);if("number"==typeof i&&(o.minLength=i),"number"==typeof n&&(o.maxLength=n),s&&(o.format=oE[s]??s,""===o.format&&delete o.format,("time"===s||u)&&delete o.format),c&&(o.contentEncoding=c),l&&l.size>0){let t=[...l].map(ok);1===t.length?o.pattern=t[0].source:t.length>1&&(o.allOf=[...t.map(t=>({..."draft-07"===r.target||"draft-04"===r.target||"openapi-3.0"===r.target?{type:"string"}:{},pattern:t.source}))])}},ox=(t,r,o,a)=>{let{minimum:i,maximum:n,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c,isInt:u}=o$(t);o.type=u?"integer":"number";let d="number"==typeof c&&c>=(i??-1/0),p="number"==typeof l&&l<=(n??1/0),h="draft-04"===r.target||"openapi-3.0"===r.target;if(d?h?(o.minimum=c,o.exclusiveMinimum=!0):o.exclusiveMinimum=c:"number"==typeof i&&(o.minimum=i),p?h?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:"number"==typeof n&&(o.maximum=n),s){let i=new Set;for(let n of s)Number.isFinite(n)&&0!==n?i.add(Math.abs(n)):or(t,r,o,a,`A multipleOf divisor of ${n} cannot be represented in JSON Schema`);let[n,...l]=i;void 0!==n&&(o.multipleOf=n),l.length&&(o.allOf=[...o.allOf??[],...l.map(t=>({multipleOf:t}))])}},oC=(t,r,o,a)=>{o.type="boolean"},oA=(t,r,o,a)=>{"openapi-3.0"===r.target?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},oT=(t,r,o,a)=>{o.not={}},oO=(t,r,o,a)=>{},oj=(t,r,o,a)=>{},oI=(t,r,o,a)=>{let i=K(t._zod.def.entries);if(0===i.length){o.not={};return}i.every(t=>"number"==typeof t)&&(o.type="number"),i.every(t=>"string"==typeof t)&&(o.type="string"),o.enum=i},oN=(t,r,o,a)=>{let i=t._zod.def;if(0===i.values.length){o.not={};return}let n=[];for(let s of i.values)if(void 0===s){if(or(t,r,o,a,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof s){if(or(t,r,o,a,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(s))}else n.push(s);if(0===n.length);else if(1===n.length){let t=n[0];o.type=null===t?"null":typeof t,"draft-04"===r.target||"openapi-3.0"===r.target?o.enum=[t]:o.const=t}else n.every(t=>"number"==typeof t)&&(o.type="number"),n.every(t=>"string"==typeof t)&&(o.type="string"),n.every(t=>"boolean"==typeof t)&&(o.type="boolean"),n.every(t=>null===t)&&(o.type="null"),o.enum=n},oM=(t,r,o,a)=>{or(t,r,o,a,"Custom types cannot be represented in JSON Schema")},oz=(t,r,o,a)=>{or(t,r,o,a,"Transforms cannot be represented in JSON Schema")},oq=(t,r,o,a)=>{let i=t._zod.def,{minimum:n,maximum:s}=o$(t);"number"==typeof n&&(o.minItems=n),"number"==typeof s&&(o.maxItems=s),o.type="array",o.items=oo(i.element,r,{...a,path:[...a.path,"items"]})};function oH(t){let r=t._zod.def;return"pipe"===r.type&&r.in._zod.traits.has("$ZodTransform")?oH(r.out):"catch"===r.type?oH(r.innerType):t._zod.optin}let oU=(t,r,o,a)=>{let i=t._zod.def,n=i.shape;if(Object.getOwnPropertySymbols(n).length&&or(t,r,o,a,"Symbol keys cannot be represented in JSON Schema"))return;for(let t in o.type="object",o.properties={},n)G(o.properties,t,oo(n[t],r,{...a,path:[...a.path,"properties",t]}));let s=[];for(let t of Object.keys(n)){let o=i.shape[t];("input"===r.io?void 0===oH(o):void 0===o._zod.optout)&&s.push(t)}s.length>0&&(o.required=s),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=oo(i.catchall,r,{...a,path:[...a.path,"additionalProperties"]})):"output"===r.io&&(o.additionalProperties=!1)},oD=(t,r,o,a)=>{let i=t._zod.def,n=!1===i.inclusive,s=i.options.map((t,o)=>oo(t,r,{...a,path:[...a.path,n?"oneOf":"anyOf",o]}));n?o.oneOf=s:o.anyOf=s},oL=(t,r,o,a)=>{let i=t._zod.def,n=oo(i.left,r,{...a,path:[...a.path,"allOf",0]}),s=oo(i.right,r,{...a,path:[...a.path,"allOf",1]}),l=t=>"allOf"in t&&1===Object.keys(t).length,c=[...l(n)?n.allOf:[n],...l(s)?s.allOf:[s]];o.allOf=c,r.intersections.push(c)},oK=new WeakMap,oJ=(t,r,o,a)=>{let i=t._zod.def;o.type="object";let n=i.keyType,s=o$(n).patterns;if("loose"===i.mode&&s&&s.size>0){let t=oo(i.valueType,r,{...a,path:[...a.path,"patternProperties","*"]});for(let r of(o.patternProperties={},s))G(o.patternProperties,ok(r).source,t)}else{if("draft-07"===r.target||"draft-2020-12"===r.target){o.propertyNames=oo(i.keyType,r,{...a,path:[...a.path,"propertyNames"]});let n=oK.get(r);n||(n=[],oK.set(r,n),r.deferred.push(()=>(function(t){let r=new Map;for(let o of t.seen.values())o.def&&!r.has(o.schema)&&r.set(o.schema,o);let o=new Map;for(let a of oK.get(t)??[]){let i=t.seen.get(a),n=(i?.def??i?.schema)?.propertyNames;if(!n||!0===n||o.has(n))continue;let s=function t(r,o,a){if(o.$ref){if(a.has(o))return o;a.add(o);let i=r.get(o)?.def;if(!i)return o;let n=t(r,i,a);return n===i?o:n}for(let i of["anyOf","oneOf"]){let n=o[i];if(!Array.isArray(n))continue;let s=n.map(o=>t(r,o,a));s.some((t,r)=>t!==n[r])&&(o={...o,[i]:s})}let i=Array.isArray(o.type)?o.type:[o.type],n=!i.includes("string")&&i.some(t=>"number"===t||"integer"===t),s=o.enum??(void 0!==o.const?[o.const]:void 0);if(!n&&!s?.some(t=>"number"==typeof t))return o;let{minimum:l,maximum:c,exclusiveMinimum:u,exclusiveMaximum:d,multipleOf:p,format:h,id:f,...m}=o;return m.enum?m.enum=m.enum.map(t=>"number"==typeof t?String(t):t):"number"==typeof m.const&&(m.const=String(m.const)),n&&(m.type="string",s||(m.pattern=(i.includes("number")?tn:ti).source)),m}(r,n,new Set);s!==n&&o.set(n,s)}if(o.size)for(let r of t.seen.values())for(let t of[r.schema,r.def]){let r=t&&o.get(t.propertyNames);r&&(t.propertyNames=r)}})(r))),n.push(t)}o.additionalProperties=oo(i.valueType,r,{...a,path:[...a.path,"additionalProperties"]})}let l=n._zod.values,c="input"===r.io&&void 0!==oH(i.valueType);if(l&&!i.partial&&!c){let t=[...l].filter(t=>"string"==typeof t||"number"==typeof t);t.length>0&&(o.required=t.map(String))}},oV=(t,r,o,a)=>{let i=t._zod.def,n=oo(i.innerType,r,a),s=r.seen.get(t);"openapi-3.0"===r.target?(s.ref=i.innerType,o.nullable=!0):o.anyOf=[n,{type:"null"}]},oW=(t,r,o,a)=>{let i=t._zod.def;oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType},oF=Symbol();function oB(t,r,o,a,i){let n=!1,s=JSON.stringify(t,(t,r)=>"bigint"!=typeof r?r:(n=!0,null));return n?(or(r,o,a,i,"BigInt defaults cannot be represented in JSON Schema"),oF):JSON.parse(s)}let oZ=(t,r,o,a)=>{let i=t._zod.def;oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType;let n=oB(i.defaultValue,t,r,o,a);n!==oF&&(o.default=n)},oG=(t,r,o,a)=>{let i=t._zod.def;if(oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType,"input"!==r.io)return;let n=oB(i.defaultValue,t,r,o,a);n!==oF&&(o._prefault=n)},oX=(t,r,o,a)=>{let i,n=t._zod.def;oo(n.innerType,r,a),r.seen.get(t).ref=n.innerType;try{i=n.catchValue(void 0)}catch{or(t,r,o,a,"Dynamic catch values are not supported in JSON Schema");return}o.default=i},oY=(t,r,o,a)=>{let i=t._zod.def,n=i.in._zod.traits.has("$ZodTransform"),s="input"===r.io?n?i.out:i.in:i.out;oo(s,r,a),r.seen.get(t).ref=s},oQ=(t,r,o,a)=>{let i=t._zod.def;oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType,o.readOnly=!0},o0=(t,r,o,a)=>{let i=t._zod.def;oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType},o1=(t,r,o,a)=>{let i=t._zod.innerType;oo(i,r,a),r.seen.get(t).ref=i},o2={string:oR,number:ox,boolean:oC,bigint:(t,r,o,a)=>{or(t,r,o,a,"BigInt cannot be represented in JSON Schema")},symbol:(t,r,o,a)=>{or(t,r,o,a,"Symbols cannot be represented in JSON Schema")},null:oA,undefined:(t,r,o,a)=>{or(t,r,o,a,"Undefined cannot be represented in JSON Schema")},void:(t,r,o,a)=>{or(t,r,o,a,"Void cannot be represented in JSON Schema")},never:oT,any:oO,unknown:oj,date:(t,r,o,a)=>{or(t,r,o,a,"Date cannot be represented in JSON Schema")},enum:oI,literal:oN,nan:(t,r,o,a)=>{or(t,r,o,a,"NaN cannot be represented in JSON Schema")},template_literal:(t,r,o,a)=>{let i=t._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},file:(t,r,o,a)=>{o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:n,mime:s}=o$(t);void 0!==i&&(o.minLength=i),void 0!==n&&(o.maxLength=n),s&&(0===s.length?o.not={}:1===s.length?o.contentMediaType=s[0]:o.anyOf=s.map(t=>({contentMediaType:t})))},success:(t,r,o,a)=>{o.type="boolean"},custom:oM,function:(t,r,o,a)=>{or(t,r,o,a,"Function types cannot be represented in JSON Schema")},transform:oz,map:(t,r,o,a)=>{or(t,r,o,a,"Map cannot be represented in JSON Schema")},set:(t,r,o,a)=>{or(t,r,o,a,"Set cannot be represented in JSON Schema")},array:oq,object:oU,union:oD,intersection:oL,tuple:(t,r,o,a)=>{let i=t._zod.def;o.type="array";let n="draft-2020-12"===r.target?"prefixItems":"items",s="draft-2020-12"===r.target||"openapi-3.0"===r.target?"items":"additionalItems",l=i.items.map((t,o)=>oo(t,r,{...a,path:[...a.path,n,o]})),c=i.rest?oo(i.rest,r,{...a,path:[...a.path,s,..."openapi-3.0"===r.target?[i.items.length]:[]]}):null,u=i.items.length;for(;u>0;){let t=i.items[u-1];if(!("input"===r.io?void 0!==oH(t):"optional"===t._zod.optout))break;u--}let d=i.items.length,p=!i.rest;"draft-2020-12"===r.target?(o.prefixItems=l,p?o.items=!1:c&&(o.items=c)):"openapi-3.0"===r.target?(o.items={anyOf:l},c&&o.items.anyOf.push(c)):(o.items=l,p?o.additionalItems=!1:c&&(o.additionalItems=c)),u>0&&(o.minItems=u),p&&(o.maxItems=d);let{minimum:h,maximum:f}=o$(t);"number"==typeof h&&(o.minItems=h),"number"==typeof f&&(o.maxItems=f)},record:oJ,nullable:oV,nonoptional:oW,default:oZ,prefault:oG,catch:oX,pipe:oY,readonly:oQ,promise:(t,r,o,a)=>{let i=t._zod.def;oo(i.innerType,r,a),r.seen.get(t).ref=i.innerType},optional:o0,lazy:o1};function o9(t,r){if("_idmap"in t){let o=ot({...r,processors:o2}),a={};for(let r of t._idmap.entries()){let[t,a]=r;oo(a,o)}let i={};for(let n of(o.external={registry:t,uri:r?.uri,defs:a},t._idmap.entries())){let[t,r]=n;oi(o,r),G(i,t,ou(o,r))}return Object.keys(a).length>0&&(i.__shared={["draft-2020-12"===o.target?"$defs":"definitions"]:a}),{schemas:i}}let o=ot({...r,processors:o2});return oo(t,o),oi(o,t),ou(o,t)}let o4={get:function(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,V,2)),t.message},set:function(t){this._zod.message=t},enumerable:!0,configurable:!0},o5={value:void 0,enumerable:!1},o3=new WeakSet([Object.prototype,Error.prototype]),o6=(t,r)=>{t.name="$ZodError",o5.value=r,Object.defineProperty(t,"issues",o5),o5.value=void 0,Object.defineProperty(t,"message",o4);let o=Object.getPrototypeOf(t);o3.has(o)||(o3.add(o),Object.defineProperty(o,"toString",{configurable:!0,enumerable:!1,get(){let t=()=>this.message;return Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0})}}))},o8=eN("$ZodError",o6);function o7(t,r){return{callee:r?.callee??t,Err:r?.Err}}eN("$ZodError",o6,void 0,{Parent:Error});let ae=t=>{let r=(o,a,i,n)=>{let s=i?{...i,async:!1}:{async:!1},l=o._zod.run({value:a,issues:[]},s);if(l instanceof Promise)throw new eM;if(l.issues.length){let o=new(n?.Err??t)(l.issues.map(t=>ew(t,s,eH())));throw eo(o,n?.callee??r),o}return l.value};return r},at=t=>{let r=async(o,a,i,n)=>{let s=i?{...i,async:!0}:{async:!0},l=o._zod.run({value:a,issues:[]},s);if(l instanceof Promise&&(l=await l),l.issues.length){let o=new(n?.Err??t)(l.issues.map(t=>ew(t,s,eH())));throw eo(o,n?.callee??r),o}return l.value};return r},ar=t=>(r,o,a)=>{let i=a?{...a,async:!1}:{async:!1},n=r._zod.run({value:o,issues:[]},i);if(n instanceof Promise)throw new eM;return n.issues.length?ao(t,n.issues,i):{success:!0,data:n.value}};function ao(t,r,o){let a;return{success:!1,get error(){return a||(a=new t(r.map(t=>ew(t,o,eH()))),r=void 0,o=void 0),a},set error(e){a=e,r=void 0,o=void 0}}}let aa=t=>async(r,o,a)=>{let i=a?{...a,async:!0}:{async:!0},n=r._zod.run({value:o,issues:[]},i);return n instanceof Promise&&(n=await n),n.issues.length?ao(t,n.issues,i):{success:!0,data:n.value}},ai=Symbol.for("zod.compile.invalid"),an=Symbol.for("zod.compile.fallback"),as=async(t,r,o)=>{let a=o?{...o,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=t._zod.run({value:r,issues:[]},a);return i instanceof Promise&&(i=await i),0===i.issues.length},al=new WeakSet([Object.prototype,Error.prototype]);function ac(t,r,o){Object.defineProperty(t,r,{configurable:!0,enumerable:!1,get(){let t=o(this);return Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0})}})}let au=eN("ZodError",(t,r)=>{o8.init(t,r),t.name="ZodError";let o=Object.getPrototypeOf(t);al.has(o)||(al.add(o),ac(o,"format",t=>r=>(function(t,r=t=>t.message){let o={_errors:[]},a=(t,i=[])=>{for(let n of t.issues)if("invalid_union"===n.code&&n.errors.length)n.errors.map(t=>a({issues:t},[...i,...n.path]));else if("invalid_key"===n.code)a({issues:n.issues},[...i,...n.path]);else if("invalid_element"===n.code)a({issues:n.issues},[...i,...n.path]);else{let t=[...i,...n.path];if(0===t.length)o._errors.push(r(n));else{let a=o,i=0;for(;i<t.length;){let o=t[i],s=i===t.length-1;if("_errors"===o){s&&a._errors.push(r(n)),i++;continue}Object.prototype.hasOwnProperty.call(a,o)||Object.defineProperty(a,o,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let l=a[o];s&&l._errors.push(r(n)),a=l,i++}}}};return a(t),o})(t,r)),ac(o,"flatten",t=>r=>(function(t,r=t=>t.message){let o={},a=[];for(let l of t.issues)if(l.path.length>0){var i,n,s;(i=o,n=l.path[0],s=()=>[],!Object.prototype.hasOwnProperty.call(i,n)&&("__proto__"===n?Object.defineProperty(i,n,{value:s(),writable:!0,enumerable:!0,configurable:!0}):i[n]=s()),i[n]).push(r(l))}else a.push(r(l));return{formErrors:a,fieldErrors:o}})(t,r)),ac(o,"addIssue",t=>r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,V,2)}),ac(o,"addIssues",t=>r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,V,2)}),Object.defineProperty(o,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),ad=ae(au),ap=at(au),ah=ar(au),af=aa(au),am=(d=ae(au),p=(t,r,o,a)=>d(t,r,o?{...o,direction:"backward"}:{direction:"backward"},o7(p,a))),ay=(h=ae(au),f=(t,r,o,a)=>h(t,r,o,o7(f,a))),ag=(m=at(au),y=async(t,r,o,a)=>{let i=o?{...o,direction:"backward"}:{direction:"backward"};return await m(t,r,i,o7(y,a))}),av=(g=at(au),v=async(t,r,o,a)=>await g(t,r,o,o7(v,a))),a_=(_=au,(t,r,o)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return ar(_)(t,r,a)}),ab=(b=au,(t,r,o)=>ar(b)(t,r,o)),aS=(S=au,async(t,r,o)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return aa(S)(t,r,a)}),aw=(w=au,async(t,r,o)=>aa(w)(t,r,o));function a$(){eq.memoizer||eH({memoizer:eF})}let aE=eN("ZodType",(t,r)=>(eq.localeError||eH({localeError:(()=>{let t={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"}},r={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"},o={nan:"NaN"};function a(t,r){return"number"!==t||"number"!=typeof r||Number.isFinite(r)?o[t]??t:String(r)}return o=>{switch(o.code){case"invalid_type":{let t=a(o.expected),r=a(function(t){let r=typeof t;switch(r){case"number":return Number.isNaN(t)?"nan":"number";case"object":if(null===t)return"null";if(Array.isArray(t))return"array";if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}return r}(o.input),o.input);return`Invalid input: expected ${t}, received ${r}`}case"invalid_value":if(1===o.values.length)return`Invalid input: expected ${ep(o.values[0])}`;return`Invalid option: expected one of ${J(o.values,"|")}`;case"too_big":{let r=o.exact?"exactly ":o.inclusive?"<=":"<",a=t[o.origin]??null;if(a)return`Too big: expected ${o.origin??"value"} to have ${r}${o.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${o.origin??"value"} to be ${r}${o.maximum.toString()}`}case"too_small":{let r=o.exact?"exactly ":o.inclusive?">=":">",a=t[o.origin]??null;if(a)return`Too small: expected ${o.origin} to have ${r}${o.minimum.toString()} ${a.unit}`;return`Too small: expected ${o.origin} to be ${r}${o.minimum.toString()}`}case"invalid_format":if("starts_with"===o.format)return`Invalid string: must start with "${o.prefix}"`;if("ends_with"===o.format)return`Invalid string: must end with "${o.suffix}"`;if("includes"===o.format)return`Invalid string: must include "${o.includes}"`;if("regex"===o.format)return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${r[o.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":""}: ${J(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":if(o.options&&Array.isArray(o.options)&&o.options.length>0){let t=o.options.map(t=>`'${t}'`).join(" | ");return`Invalid discriminator value. Expected ${t}`}if(!1===o.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}})()}),tT.init(t,r),t.def=r,t.type=r.type,t),{check(...t){let r=this.def;return this.clone(er(r,{checks:[...r.checks??[],...t.map(t=>"function"==typeof t?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,r){return eu(this,t,r)},brand(){return this},register(t,r){return t.add(this,r),this},refine(t,r){return this.check(function(t,r={}){return new iz({type:"custom",check:"custom",fn:t,...ed(r)})}(t,r))},superRefine(t,r){var o,a,i,n,s;let l,c;return this.check((o=t,a=r,i=o,n=t=>(t.addIssue=r=>{"string"==typeof r?t.issues.push(ek(r,t.value,l._zod.def)):(r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=t.value),r.inst??(r.inst=l),r.continue??(r.continue=!l._zod.def.abort),t.issues.push(ek(r)))},i(t.value,t)),(c=new td({check:"custom",...ed(s=a)}))._zod.check=n,l=c))},overwrite(t){return this.check(r7(t))},optional(){return i$(this)},exactOptional(){var t;return t=this,new iE({type:"optional",innerType:t})},nullable(){return ik(this)},nullish(){return i$(ik(this))},nonoptional(t){var r,o;return r=this,new iC({type:"nonoptional",innerType:r,...ed(o=t)})},array(){return ir(this)},or(t){return il([this,t])},and(t){return ip(this,t)},transform(t){return iO(this,iS(t))},default(t){var r,o;return r=this,o=t,new iR({type:"default",innerType:r,get defaultValue(){return"function"==typeof o?o():es(o)}})},prefault(t){var r,o;return r=this,o=t,new ix({type:"prefault",innerType:r,get defaultValue(){return"function"==typeof o?o():es(o)}})},catch(t){var r,o,a;let i;return r=this,new iA({type:"catch",innerType:r,catchValue:"function"==typeof(o=t)?o:(a=o,(i=()=>a)["~constantCatch"]=!0,i)})},pipe(t){return iO(this,t)},readonly(){var t;return t=this,new iI({type:"readonly",innerType:t})},describe(t){let r=this.clone();return rZ.add(r,{description:t}),r},meta(...t){if(0===t.length)return rZ.get(this);let r=this.clone();return rZ.add(r,t[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...r){return 0===r.length?t(this):t(this,...r)},get"~standard"(){var aP;return aP=this,eR(aP,"~standard",{...tN(this),jsonSchema:{input:od(this,"input"),output:od(this,"output")}},!1)},set"~standard"(value){eR(this,"~standard",value)},parse:function t(r,o){return ad(this,r,o,{callee:t})},parseAsync:async function t(r,o){return await ap(this,r,o,{callee:t})},safeParse(t,r){return ah(this,t,r)},async safeParseAsync(t,r){return af(this,t,r)},get spa(){return this?.safeParseAsync},set spa(value){eR(this,"spa",value)},validate(t,r){var o=this,a=t,i=r;let n=o._zod.bag.validator;if(void 0!==n){if(n(a)!==ai)return!0;if(!0===n.definite&&void 0===i)return!1}var s=o,l=a,c=i;let u,d=c?{...c,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},p=s._zod.bag.fallbackRun;if(p?(d[an]=!0,u=p({value:l,issues:[]},d)):u=s._zod.run({value:l,issues:[]},d),u instanceof Promise)throw new eM;return 0===u.issues.length},validateAsync(t,r){return as(this,t,r)},encode:function t(r,o){return am(this,r,o,{callee:t})},decode:function t(r,o){return ay(this,r,o,{callee:t})},encodeAsync:async function t(r,o){return await ag(this,r,o,{callee:t})},decodeAsync:async function t(r,o){return await av(this,r,o,{callee:t})},safeEncode(t,r){return a_(this,t,r)},safeDecode(t,r){return ab(this,t,r)},async safeEncodeAsync(t,r){return aS(this,t,r)},async safeDecodeAsync(t,r){return aw(this,t,r)},toJSONSchema(t){return((t,r={})=>o=>{let a=ot({...o,processors:r});return oo(t,a),oi(a,t),ou(a,t)})(this,{})(t)},get description(){return rZ.get(this)?.description},get _def(){return this._zod.def}}),ak=eN("_ZodString",(t,r)=>{tM.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oR(t,r,o,a)},ex({format:t=>o$(t).format??null,minLength:t=>o$(t).minimum??null,maxLength:t=>o$(t).maximum??null},{regex(...t){return this.check(function(t,r){return new tw({check:"string_format",format:"regex",...ed(r),pattern:t})}(...t))},includes(...t){return this.check(function(t,r){return new tP({check:"string_format",format:"includes",...ed(r),includes:t})}(...t))},startsWith(...t){return this.check(function(t,r){return new tk({check:"string_format",format:"starts_with",...ed(r),prefix:t})}(...t))},endsWith(...t){return this.check(function(t,r){return new tR({check:"string_format",format:"ends_with",...ed(r),suffix:t})}(...t))},min(...t){return this.check(r6(...t))},max(...t){return this.check(r3(...t))},length(...t){return this.check(r8(...t))},nonempty(...t){return this.check(r6(1,...t))},lowercase(t){return this.check(new t$({check:"string_format",format:"lowercase",...ed(t)}))},uppercase(t){return this.check(new tE({check:"string_format",format:"uppercase",...ed(t)}))},trim(){return this.check(r7(t=>t.trim()))},normalize(...t){return this.check(function(t){return r7(r=>r.normalize(t))}(...t))},toLowerCase(){return this.check(r7(t=>t.toLowerCase()))},toUpperCase(){return this.check(r7(t=>t.toUpperCase()))},slugify(){return this.check(r7(t=>t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),aR=eN("ZodString",(t,r)=>{tM.init(t,r),ak.init(t,r)},{email(t){return this.check(rX(aI,t))},url(t){return this.check(rY(az,t))},jwt(t){return this.check(new aY({type:"string",format:"jwt",check:"string_format",abort:!1,...ed(t)}))},emoji(t){return this.check(new aq({type:"string",format:"emoji",check:"string_format",abort:!1,...ed(t)}))},guid(t){return this.check(new aN({type:"string",format:"guid",check:"string_format",abort:!1,...ed(t)}))},uuid(t){return this.check(new aM({type:"string",format:"uuid",check:"string_format",abort:!1,...ed(t)}))},uuidv4(t){return this.check(new aM({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ed(t)}))},uuidv6(t){return this.check(new aM({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ed(t)}))},uuidv7(t){return this.check(new aM({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ed(t)}))},nanoid(t){return this.check(new aH({type:"string",format:"nanoid",check:"string_format",abort:!1,...ed(t)}))},cuid(t){return this.check(new aU({type:"string",format:"cuid",check:"string_format",abort:!1,...ed(t)}))},cuid2(t){return this.check(new aD({type:"string",format:"cuid2",check:"string_format",abort:!1,...ed(t)}))},ulid(t){return this.check(new aL({type:"string",format:"ulid",check:"string_format",abort:!1,...ed(t)}))},base64(t){return this.check(new aZ({type:"string",format:"base64",check:"string_format",abort:!1,...ed(t)}))},base64url(t){return this.check(new aG({type:"string",format:"base64url",check:"string_format",abort:!1,...ed(t)}))},xid(t){return this.check(new aK({type:"string",format:"xid",check:"string_format",abort:!1,...ed(t)}))},ksuid(t){return this.check(new aJ({type:"string",format:"ksuid",check:"string_format",abort:!1,...ed(t)}))},ipv4(t){return this.check(new aV({type:"string",format:"ipv4",check:"string_format",abort:!1,...ed(t)}))},ipv6(t){return this.check(new aW({type:"string",format:"ipv6",check:"string_format",abort:!1,...ed(t)}))},cidrv4(t){return this.check(new aF({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ed(t)}))},cidrv6(t){return this.check(new aB({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ed(t)}))},e164(t){return this.check(new aX({type:"string",format:"e164",check:"string_format",abort:!1,...ed(t)}))},datetime(t){return this.check(rQ(aA,t))},date(t){return this.check(r0(aT,t))},time(t){return this.check(new aO({type:"string",format:"time",check:"string_format",precision:null,...ed(t)}))},duration(t){return this.check(new aj({type:"string",format:"duration",check:"string_format",...ed(t)}))}});function ax(t){return new aR(rG({type:"string",...ed(t)}))}let aC=eN("ZodStringFormat",(t,r)=>{tz.init(t,r),ak.init(t,r)}),aA=eN("ZodISODateTime",(t,r)=>{tY.init(t,r),aC.init(t,r)}),aT=eN("ZodISODate",(t,r)=>{tQ.init(t,r),aC.init(t,r)}),aO=eN("ZodISOTime",(t,r)=>{t0.init(t,r),aC.init(t,r)}),aj=eN("ZodISODuration",(t,r)=>{t1.init(t,r),aC.init(t,r)}),aI=eN("ZodEmail",(t,r)=>{tU.init(t,r),aC.init(t,r)}),aN=eN("ZodGUID",(t,r)=>{tq.init(t,r),aC.init(t,r)}),aM=eN("ZodUUID",(t,r)=>{tH.init(t,r),aC.init(t,r)}),az=eN("ZodURL",(t,r)=>{tJ.init(t,r),aC.init(t,r)}),aq=eN("ZodEmoji",(t,r)=>{tV.init(t,r),aC.init(t,r)}),aH=eN("ZodNanoID",(t,r)=>{tW.init(t,r),aC.init(t,r)}),aU=eN("ZodCUID",(t,r)=>{tF.init(t,r),aC.init(t,r)}),aD=eN("ZodCUID2",(t,r)=>{tB.init(t,r),aC.init(t,r)}),aL=eN("ZodULID",(t,r)=>{tZ.init(t,r),aC.init(t,r)}),aK=eN("ZodXID",(t,r)=>{tG.init(t,r),aC.init(t,r)}),aJ=eN("ZodKSUID",(t,r)=>{tX.init(t,r),aC.init(t,r)}),aV=eN("ZodIPv4",(t,r)=>{t2.init(t,r),aC.init(t,r)}),aW=eN("ZodIPv6",(t,r)=>{t5.init(t,r),aC.init(t,r)}),aF=eN("ZodCIDRv4",(t,r)=>{t3.init(t,r),aC.init(t,r)}),aB=eN("ZodCIDRv6",(t,r)=>{t6.init(t,r),aC.init(t,r)}),aZ=eN("ZodBase64",(t,r)=>{re.init(t,r),aC.init(t,r)}),aG=eN("ZodBase64URL",(t,r)=>{rr.init(t,r),aC.init(t,r)}),aX=eN("ZodE164",(t,r)=>{ro.init(t,r),aC.init(t,r)}),aY=eN("ZodJWT",(t,r)=>{ra.init(t,r),aC.init(t,r)}),aQ=eN("ZodNumber",(t,r)=>{ri.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>ox(t,r,o,a),t.isFinite=!0},ex({minValue:t=>{let{minimum:r,exclusiveMinimum:o}=o$(t);return Math.max(r??-1/0,o??-1/0)},maxValue:t=>{let{maximum:r,exclusiveMaximum:o}=o$(t);return Math.min(r??1/0,o??1/0)},isInt:t=>{let{isInt:r,multipleOf:o}=o$(t);return!!r||!!o?.some(Number.isSafeInteger)},format:t=>o$(t).format??null},{gt(t,r){return this.check(r9(t,r))},gte(t,r){return this.check(r4(t,r))},min(t,r){return this.check(r4(t,r))},lt(t,r){return this.check(r1(t,r))},lte(t,r){return this.check(r2(t,r))},max(t,r){return this.check(r2(t,r))},int(t){return this.check(a2(t))},safe(t){return this.check(a2(t))},positive(t){return this.check(r9(0,t))},nonnegative(t){return this.check(r4(0,t))},negative(t){return this.check(r1(0,t))},nonpositive(t){return this.check(r2(0,t))},multipleOf(t,r){return this.check(r5(t,r))},step(t,r){return this.check(r5(t,r))},finite(){return this}}));function a0(t){return new aQ(rG({type:"number",checks:[],...ed(t)}))}let a1=eN("ZodNumberFormat",(t,r)=>{rn.init(t,r),aQ.init(t,r)});function a2(t){return new a1({type:"number",check:"number_format",abort:!1,format:"safeint",...ed(t)})}let a9=eN("ZodBoolean",(t,r)=>{rs.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oC(t,r,o,a)});function a4(t){return new a9({type:"boolean",...ed(t)})}let a5=eN("ZodNull",(t,r)=>{rl.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oA(t,r,o,a)});function a3(t){return new a5({type:"null",...ed(t)})}let a6=eN("ZodAny",(t,r)=>{rc.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oO(t,r,o,a)}),a8=eN("ZodUnknown",(t,r)=>{ru.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oj(t,r,o,a)});function a7(){return new a8({type:"unknown"})}let ie=eN("ZodNever",(t,r)=>{rd.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oT(t,r,o,a)}),it=eN("ZodArray",(t,r)=>{a$(),rh.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oq(t,r,o,a),t.element=r.element},{min(t,r){return this.check(r6(t,r))},nonempty(t){return this.check(r6(1,t))},max(t,r){return this.check(r3(t,r))},length(t,r){return this.check(r8(t,r))},unwrap(){return this.element}});function ir(t,r){return new it({type:"array",element:t,...ed(r)})}let io=eN("ZodObject",(t,r)=>{var o,a,i,n,s,l;let c,u;a$(),r_.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oU(t,r,o,a),o=t,a="shape",i=t=>t._zod.def.shape,n=!1,s=o,l=a,c=Object.getPrototypeOf(s),(u=l in c?void 0:c)&&Object.defineProperty(u,a,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,a,t),t.value=i(this),Object.defineProperty(this,a,t),t.value},set(t){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:n,value:t})}})},{keyof(){return ig(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(er(this._zod.def,{catchall:t}))},passthrough(){return this.clone(er(this._zod.def,{catchall:a7()}))},loose(){return this.clone(er(this._zod.def,{catchall:a7()}))},strict(){return this.clone(er(this._zod.def,{catchall:new ie({type:"never",...ed(void 0)})}))},strip(){return this.clone(er(this._zod.def,{catchall:void 0}))},extend(t){var r=this,o=t;if(!en(o))throw Error("Invalid input to extend: expected a plain object");let a=r._zod.def.checks;if(a&&a.length>0){let t=Y(r);for(let r of Reflect.ownKeys(o))if(void 0!==Object.getOwnPropertyDescriptor(t,r))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eu(r,er(r._zod.def,{shape:ey(r,o)}))},safeExtend(t){var r=this,o=t;if(!en(o))throw Error("Invalid input to safeExtend: expected a plain object");return eu(r,er(r._zod.def,{shape:ey(r,o)}))},merge(t){var r=this,o=t;if(!o?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(r._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let a={};et(a,r,Reflect.ownKeys(Y(r))),et(a,o,Reflect.ownKeys(Y(o)));let i=er(r._zod.def,{shape:a,get catchall(){return o._zod.def.catchall},checks:o._zod.def.checks??[]});return eu(r,i)},pick(t){return function(t,r){let o=t._zod.def,a=o.checks;if(a&&a.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return et(i,t,em(t,r)),eu(t,er(o,{shape:i,checks:[]}))}(this,t)},omit(t){return function(t,r){let o=t._zod.def,a=o.checks;if(a&&a.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(em(t,r)),n={};return et(n,t,Reflect.ownKeys(Y(t)).filter(t=>!i.has(t))),eu(t,er(o,{shape:n,checks:[]}))}(this,t)},partial(...t){return eg(iw,this,t[0])},exactPartial(...t){return eg(iE,this,t[0],"exactPartial")},required(...t){var r,o,a;let i,n;return r=iC,o=this,i=(a=t[0])?new Set(em(o,a)):void 0,et(n={},o,Reflect.ownKeys(Y(o)),(t,o)=>i&&!i.has(o)?t:new r({type:"nonoptional",innerType:t})),eu(o,er(o._zod.def,{shape:n}))}});function ia(t,r){return new io({type:"object",shape:t??{},...ed(r)})}function ii(t,r){return new io({type:"object",shape:t,catchall:a7(),...ed(r)})}let is=eN("ZodUnion",(t,r)=>{rS.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oD(t,r,o,a),t.options=r.options});function il(t,r){return new is({type:"union",options:t,...ed(r)})}let ic=eN("ZodDiscriminatedUnion",(t,r)=>{is.init(t,r),rw.init(t,r)});function iu(t,r,o){return new ic({type:"union",options:r,discriminator:t,...ed(o)})}let id=eN("ZodIntersection",(t,r)=>{r$.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oL(t,r,o,a)});function ip(t,r){return new id({type:"intersection",left:t,right:r})}let ih=eN("ZodRecord",(t,r)=>{a$(),rP.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oJ(t,r,o,a),t.keyType=r.keyType,t.valueType=r.valueType});function im(t,r,o){return new ih(r&&r._zod?{type:"record",keyType:t,valueType:r,...ed(o)}:{type:"record",keyType:ax(),valueType:t,...ed(r)})}let iy=eN("ZodEnum",(t,r)=>{rk.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oI(t,r,o,a),t.enum=r.entries,t.options=[...t._zod.values];let o=new Set(Object.keys(r.entries));t.extract=(t,a)=>{let i={};for(let a of t)if(o.has(a))i[a]=r.entries[a];else throw Error(`Key ${a} not found in enum`);return new iy({...r,checks:[],...ed(a),entries:i})},t.exclude=(t,a)=>{let i={...r.entries};for(let r of t)if(o.has(r))delete i[r];else throw Error(`Key ${r} not found in enum`);return new iy({...r,checks:[],...ed(a),entries:i})}});function ig(t,r){return new iy({type:"enum",entries:Array.isArray(t)?Object.fromEntries(t.map(t=>[t,t])):t,...ed(r)})}let iv=eN("ZodLiteral",(t,r)=>{rR.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oN(t,r,o,a),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function i_(t,r){return new iv({type:"literal",values:Array.isArray(t)?t:[t],...ed(r)})}let ib=eN("ZodTransform",(t,r)=>{a$(),rx.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oz(t,r,o,a),t._zod.parse=(o,a)=>{if("backward"===a.direction)throw new ez(t.constructor.name);o.addIssue=a=>{"string"==typeof a?o.issues.push(ek(a,o.value,r)):(a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=o.value),a.inst??(a.inst=t),o.issues.push(ek(a)))};let i=r.transform(o.value,o);return i instanceof Promise?i.then(t=>(o.value=t,o)):(o.value=i,o)}});function iS(t){return new ib({type:"transform",transform:t})}let iw=eN("ZodOptional",(t,r)=>{rA.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>o0(t,r,o,a),t.unwrap=()=>t._zod.def.innerType});function i$(t){return new iw({type:"optional",innerType:t})}let iE=eN("ZodExactOptional",(t,r)=>{rT.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>o0(t,r,o,a),t.unwrap=()=>t._zod.def.innerType}),iP=eN("ZodNullable",(t,r)=>{rO.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oV(t,r,o,a),t.unwrap=()=>t._zod.def.innerType});function ik(t){return new iP({type:"nullable",innerType:t})}let iR=eN("ZodDefault",(t,r)=>{rj.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oZ(t,r,o,a),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap}),ix=eN("ZodPrefault",(t,r)=>{rN.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oG(t,r,o,a),t.unwrap=()=>t._zod.def.innerType}),iC=eN("ZodNonOptional",(t,r)=>{rM.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oW(t,r,o,a),t.unwrap=()=>t._zod.def.innerType}),iA=eN("ZodCatch",(t,r)=>{rH.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oX(t,r,o,a),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap}),iT=eN("ZodPipe",(t,r)=>{rU.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oY(t,r,o,a),t.in=r.in,t.out=r.out});function iO(t,r){return new iT({type:"pipe",in:t,out:r})}let ij=eN("ZodPreprocess",(t,r)=>{iT.init(t,r),rL.init(t,r)}),iI=eN("ZodReadonly",(t,r)=>{rK.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oQ(t,r,o,a),t.unwrap=()=>t._zod.def.innerType}),iN=eN("ZodLazy",(t,r)=>{rV.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>o1(t,r,o,a),t.unwrap=()=>t._zod.def.getter()});function iM(t){return new iN({type:"lazy",getter:t})}let iz=eN("ZodCustom",(t,r)=>{rW.init(t,r),aE.init(t,r),t._zod.processJSONSchema=(r,o,a)=>oM(t,r,o,a)});function iq(t,r){return new ij({type:"pipe",in:iS(t),out:r})}let iH="custom";A||(A={});let iU="2025-11-25",iD=[iU,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],iL="io.modelcontextprotocol/protocolVersion",iK="io.modelcontextprotocol/clientInfo",iJ="io.modelcontextprotocol/serverInfo",iV="io.modelcontextprotocol/clientCapabilities",iW="io.modelcontextprotocol/subscriptionId",iF="io.modelcontextprotocol/logLevel",iB=iM(()=>il([ax(),a0(),a4(),a3(),im(ax(),iB),ir(iB)])),iZ=im(ax(),iB),iG=ir(iB),iX=il([ax(),a0().int()]),iY=ax(),iQ=ia({ttl:a0().optional()}),i0=ia({taskId:ax()}),i1=ii({progressToken:iX.optional(),"io.modelcontextprotocol/related-task":i0.optional()}),i2=ia({_meta:i1.optional()}),i9=i2.extend({task:iQ.optional()}),i4=ia({method:ax(),params:i2.loose().optional()}),i5=ia({_meta:i1.optional()}),i3=ia({method:ax(),params:i5.loose().optional()}),i6=ii({get[iJ](){return np.optional().catch(void 0)}}),i8=ii({_meta:i6.optional()}),i7=il([ax(),a0().int()]),ne=ia({jsonrpc:i_("2.0"),id:i7,...i4.shape}).strict(),nt=ia({jsonrpc:i_("2.0"),...i3.shape}).strict(),nr=ia({jsonrpc:i_("2.0"),id:i7,result:i8}).strict(),no=ia({jsonrpc:i_("2.0"),id:i7.optional(),error:ia({code:a0().int(),message:ax(),data:a7().optional()})}).strict(),na=il([ne,nt,nr,no]),ni=il([nr,no]),nn=i8.strict(),ns=i5.extend({requestId:i7.optional(),reason:ax().optional()}),nl=i3.extend({method:i_("notifications/cancelled"),params:ns}),nc=ia({src:ax(),mimeType:ax().optional(),sizes:ir(ax()).optional(),theme:ig(["light","dark"]).optional()}),nu=ia({icons:ir(nc).optional()}),nd=ia({name:ax(),title:ax().optional()}),np=nd.extend({...nd.shape,...nu.shape,version:ax(),websiteUrl:ax().optional(),description:ax().optional()}),nh=ip(ia({applyDefaults:a4().optional()}),iZ),nf=iq(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,ip(ia({form:nh.optional(),url:iZ.optional()}),iZ.optional())),nm=ii({list:iZ.optional(),cancel:iZ.optional(),requests:ii({sampling:ii({createMessage:iZ.optional()}).optional(),elicitation:ii({create:iZ.optional()}).optional()}).optional()}),ny=ii({list:iZ.optional(),cancel:iZ.optional(),requests:ii({tools:ii({call:iZ.optional()}).optional()}).optional()}),ng=ia({experimental:im(ax(),iZ).optional(),sampling:ia({context:iZ.optional(),tools:iZ.optional()}).optional(),elicitation:nf.optional(),roots:ia({listChanged:a4().optional()}).optional(),tasks:nm.optional(),extensions:im(ax(),iZ).optional()}),nv=i2.extend({protocolVersion:ax(),capabilities:ng,clientInfo:np}),n_=i4.extend({method:i_("initialize"),params:nv}),nb=ia({experimental:im(ax(),iZ).optional(),logging:iZ.optional(),completions:iZ.optional(),prompts:ia({listChanged:a4().optional()}).optional(),resources:ia({subscribe:a4().optional(),listChanged:a4().optional()}).optional(),tools:ia({listChanged:a4().optional()}).optional(),tasks:ny.optional(),extensions:im(ax(),iZ).optional()}),nS=i8.extend({protocolVersion:ax(),capabilities:nb,serverInfo:np,instructions:ax().optional()}),nw=i3.extend({method:i_("notifications/initialized"),params:i5.optional()}),n$=i4.extend({method:i_("server/discover"),params:i2.optional()}),nE=i8.extend({supportedVersions:ir(ax()),capabilities:nb,instructions:ax().optional()}),nP=i4.extend({method:i_("ping"),params:i2.optional()}),nk=ia({progress:a0(),total:i$(a0()),message:i$(ax())}),nR=ia({...i5.shape,...nk.shape,progressToken:iX}),nx=i3.extend({method:i_("notifications/progress"),params:nR}),nC=i2.extend({cursor:iY.optional()}),nA=i4.extend({params:nC.optional()}),nT=i8.extend({nextCursor:iY.optional()}),nO=ia({uri:ax(),mimeType:i$(ax()),_meta:im(ax(),a7()).optional()}),nj=nO.extend({text:ax()}),nI=ax().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),nN=nO.extend({blob:nI}),nM=ig(["user","assistant"]),nz=ia({audience:ir(nM).optional(),priority:a0().min(0).max(1).optional(),lastModified:rQ(aA,{offset:!0}).optional()}),nq=ia({...nd.shape,...nu.shape,uri:ax(),description:i$(ax()),mimeType:i$(ax()),size:i$(a0()),annotations:nz.optional(),_meta:i$(ii({}))}),nH=ia({...nd.shape,...nu.shape,uriTemplate:ax(),description:i$(ax()),mimeType:i$(ax()),annotations:nz.optional(),_meta:i$(ii({}))}),nU=nA.extend({method:i_("resources/list")}),nD=nT.extend({resources:ir(nq)}),nL=nA.extend({method:i_("resources/templates/list")}),nK=nT.extend({resourceTemplates:ir(nH)}),nJ=i2.extend({uri:ax()}),nV=i4.extend({method:i_("resources/read"),params:nJ}),nW=i8.extend({contents:ir(il([nj,nN]))}),nF=i3.extend({method:i_("notifications/resources/list_changed"),params:i5.optional()}),nB=i4.extend({method:i_("resources/subscribe"),params:nJ}),nZ=i4.extend({method:i_("resources/unsubscribe"),params:nJ}),nG=ia({toolsListChanged:a4().optional(),promptsListChanged:a4().optional(),resourcesListChanged:a4().optional(),resourceSubscriptions:ir(ax()).optional()}),nX=i2.extend({notifications:nG}),nY=i4.extend({method:i_("subscriptions/listen"),params:nX}),nQ=i5.extend({notifications:nG}),n0=i3.extend({method:i_("notifications/subscriptions/acknowledged"),params:nQ}),n1=i6.extend({[iW]:i7}),n2=i8.extend({_meta:n1}),n9=i5.extend({uri:ax()}),n4=i3.extend({method:i_("notifications/resources/updated"),params:n9}),n5=ia({name:ax(),description:i$(ax()),required:i$(a4())}),n3=ia({...nd.shape,...nu.shape,description:i$(ax()),arguments:i$(ir(n5)),_meta:i$(ii({}))}),n6=nA.extend({method:i_("prompts/list")}),n8=nT.extend({prompts:ir(n3)}),n7=i2.extend({name:ax(),arguments:im(ax(),ax()).optional()}),se=i4.extend({method:i_("prompts/get"),params:n7}),st=ia({type:i_("text"),text:ax(),annotations:nz.optional(),_meta:im(ax(),a7()).optional()}),sr=ia({type:i_("image"),data:nI,mimeType:ax(),annotations:nz.optional(),_meta:im(ax(),a7()).optional()}),so=ia({type:i_("audio"),data:nI,mimeType:ax(),annotations:nz.optional(),_meta:im(ax(),a7()).optional()}),sa=ia({type:i_("tool_use"),name:ax(),id:ax(),input:im(ax(),a7()),_meta:im(ax(),a7()).optional()}),si=ia({type:i_("resource"),resource:il([nj,nN]),annotations:nz.optional(),_meta:im(ax(),a7()).optional()}),sn=nq.extend({type:i_("resource_link")}),ss=il([st,sr,so,sn,si]),sl=ia({role:nM,content:ss}),sc=i8.extend({description:ax().optional(),messages:ir(sl)}),su=i3.extend({method:i_("notifications/prompts/list_changed"),params:i5.optional()}),sd=ia({title:ax().optional(),readOnlyHint:a4().optional(),destructiveHint:a4().optional(),idempotentHint:a4().optional(),openWorldHint:a4().optional()}),sp=ia({taskSupport:ig(["required","optional","forbidden"]).optional()}),sh=ia({...nd.shape,...nu.shape,description:ax().optional(),inputSchema:ia({type:i_("object"),properties:im(ax(),iB).optional(),required:ir(ax()).optional()}).catchall(a7()),outputSchema:ii({$schema:ax().optional()}).optional(),annotations:sd.optional(),execution:sp.optional(),_meta:im(ax(),a7()).optional()}),sf=nA.extend({method:i_("tools/list")}),sm=nT.extend({tools:ir(sh)}),sy=i8.extend({content:ir(ss).default([]),structuredContent:a7().optional(),isError:a4().optional()}),sg=sy.or(i8.extend({toolResult:a7()})),sv=i9.extend({name:ax(),arguments:im(ax(),a7()).optional()}),s_=i4.extend({method:i_("tools/call"),params:sv}),sb=i3.extend({method:i_("notifications/tools/list_changed"),params:i5.optional()}),sS=ia({autoRefresh:a4().default(!0),debounceMs:a0().int().nonnegative().default(300)}),sw=ig(["debug","info","notice","warning","error","critical","alert","emergency"]),s$=i2.extend({level:sw}),sE=i4.extend({method:i_("logging/setLevel"),params:s$}),sP=i5.extend({level:sw,logger:ax().optional(),data:a7()}),sk=i3.extend({method:i_("notifications/message"),params:sP}),sR=ia({name:ax().optional()}),sx=ia({hints:ir(sR).optional(),costPriority:a0().min(0).max(1).optional(),speedPriority:a0().min(0).max(1).optional(),intelligencePriority:a0().min(0).max(1).optional()}),sC=ia({mode:ig(["auto","required","none"]).optional()}),sA=ia({type:i_("tool_result"),toolUseId:ax().describe("The unique identifier for the corresponding tool call."),content:ir(ss),structuredContent:a7().optional(),isError:a4().optional(),_meta:im(ax(),a7()).optional()}),sT=iu("type",[st,sr,so]),sO=iu("type",[st,sr,so,sa,sA]),sj=ia({role:nM,content:il([sO,ir(sO)]),_meta:im(ax(),a7()).optional()}),sI=i9.extend({messages:ir(sj),modelPreferences:sx.optional(),systemPrompt:ax().optional(),includeContext:ig(["none","thisServer","allServers"]).optional(),temperature:a0().optional(),maxTokens:a0().int(),stopSequences:ir(ax()).optional(),metadata:iZ.optional(),tools:ir(sh).optional(),toolChoice:sC.optional()}),sN=i4.extend({method:i_("sampling/createMessage"),params:sI}),sM=i8.extend({model:ax(),stopReason:i$(ig(["endTurn","stopSequence","maxTokens"]).or(ax())),role:nM,content:sT}),sz=i8.extend({model:ax(),stopReason:i$(ig(["endTurn","stopSequence","maxTokens","toolUse"]).or(ax())),role:nM,content:il([sO,ir(sO)])}),sq=ia({type:i_("boolean"),title:ax().optional(),description:ax().optional(),default:a4().optional()}),sH=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),minLength:a0().optional(),maxLength:a0().optional(),format:ig(["email","uri","date","date-time"]).optional(),default:ax().optional()}),sU=ia({type:ig(["number","integer"]),title:ax().optional(),description:ax().optional(),minimum:a0().optional(),maximum:a0().optional(),default:a0().optional()}),sD=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),default:ax().optional()}),sL=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),oneOf:ir(ia({const:ax(),title:ax()})),default:ax().optional()}),sK=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),enumNames:ir(ax()).optional(),default:ax().optional()}),sJ=il([sD,sL]),sV=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({type:i_("string"),enum:ir(ax())}),default:ir(ax()).optional()}),sW=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({anyOf:ir(ia({const:ax(),title:ax()}))}),default:ir(ax()).optional()}),sF=il([sV,sW]),sB=il([sK,sJ,sF]),sZ=il([sB,sq,sH,sU]),sG=i9.extend({mode:i_("form").optional(),message:ax(),requestedSchema:ia({type:i_("object"),properties:im(ax(),sZ),required:ir(ax()).optional()}).catchall(a7())}),sX=i9.extend({mode:i_("url"),message:ax(),elicitationId:ax(),url:ax().url()}),sY=il([sG,sX]),sQ=i4.extend({method:i_("elicitation/create"),params:sY}),s0=i5.extend({elicitationId:ax()}),s1=i3.extend({method:i_("notifications/elicitation/complete"),params:s0}),s2=i8.extend({action:ig(["accept","decline","cancel"]),content:iq(t=>null===t?void 0:t,im(ax(),il([ax(),a0(),a4(),ir(ax())])).optional())}),s9=ia({type:i_("ref/resource"),uri:ax()}),s4=ia({type:i_("ref/prompt"),name:ax()}),s5=i2.extend({ref:il([s4,s9]),argument:ia({name:ax(),value:ax()}),context:ia({arguments:im(ax(),ax()).optional()}).optional()}),s3=i4.extend({method:i_("completion/complete"),params:s5}),s6=i8.extend({completion:ii({values:ir(ax()).max(100),total:i$(a0().int()),hasMore:i$(a4())})}),s8=ia({uri:ax().startsWith("file://"),name:ax().optional(),_meta:im(ax(),a7()).optional()}),s7=i4.extend({method:i_("roots/list"),params:i2.optional()}),le=i8.extend({roots:ir(s8)}),lt=i3.extend({method:i_("notifications/roots/list_changed"),params:i5.optional()}),lr=ii({ttl:a0().optional(),pollInterval:a0().optional()}),lo=ig(["working","input_required","completed","failed","cancelled"]),la=ia({taskId:ax(),status:lo,ttl:il([a0(),a3()]),createdAt:ax(),lastUpdatedAt:ax(),pollInterval:i$(a0()),statusMessage:i$(ax())}),li=i8.extend({task:la}),ln=i5.merge(la),ls=i3.extend({method:i_("notifications/tasks/status"),params:ln}),ll=i4.extend({method:i_("tasks/get"),params:i2.extend({taskId:ax()})}),lc=i8.merge(la),lu=i4.extend({method:i_("tasks/result"),params:i2.extend({taskId:ax()})}),ld=i8.loose(),lp=nA.extend({method:i_("tasks/list")}),lh=nT.extend({tasks:ir(la)}),lf=i4.extend({method:i_("tasks/cancel"),params:i2.extend({taskId:ax()})}),lm=i8.merge(la),ly=il([nP,n_,n$,s3,sE,se,n6,nU,nL,nV,nB,nZ,nY,s_,sf]),lg=il([nl,nx,nw,lt]),lv=il([nn,sM,sz,s2,le]),l_=il([nP,sN,sQ,s7]),lb=il([nl,nx,sk,n4,nF,sb,su,n0,s1]),lS=il([nn,nS,nE,s6,sc,n8,nD,nK,nW,sy,sm,n2]),lw=rY(az,void 0).superRefine((t,r)=>{if(!URL.canParse(t))return r.addIssue({code:iH,message:"URL must be parseable",fatal:!0}),eO}).refine(t=>{let r=new URL(t);return"javascript:"!==r.protocol&&"data:"!==r.protocol&&"vbscript:"!==r.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),l$=ii({resource:ax().url(),authorization_servers:ir(lw).optional(),jwks_uri:ax().url().optional(),scopes_supported:ir(ax()).optional(),bearer_methods_supported:ir(ax()).optional(),resource_signing_alg_values_supported:ir(ax()).optional(),resource_name:ax().optional(),resource_documentation:ax().optional(),resource_policy_uri:ax().url().optional(),resource_tos_uri:ax().url().optional(),tls_client_certificate_bound_access_tokens:a4().optional(),authorization_details_types_supported:ir(ax()).optional(),dpop_signing_alg_values_supported:ir(ax()).optional(),dpop_bound_access_tokens_required:a4().optional()}),lE=ii({issuer:ax(),authorization_endpoint:lw,token_endpoint:lw,registration_endpoint:lw.optional(),scopes_supported:ir(ax()).optional(),response_types_supported:ir(ax()),response_modes_supported:ir(ax()).optional(),grant_types_supported:ir(ax()).optional(),token_endpoint_auth_methods_supported:ir(ax()).optional(),token_endpoint_auth_signing_alg_values_supported:ir(ax()).optional(),service_documentation:lw.optional(),revocation_endpoint:lw.optional(),revocation_endpoint_auth_methods_supported:ir(ax()).optional(),revocation_endpoint_auth_signing_alg_values_supported:ir(ax()).optional(),introspection_endpoint:ax().optional(),introspection_endpoint_auth_methods_supported:ir(ax()).optional(),introspection_endpoint_auth_signing_alg_values_supported:ir(ax()).optional(),code_challenge_methods_supported:ir(ax()).optional(),client_id_metadata_document_supported:a4().optional(),authorization_response_iss_parameter_supported:a4().optional().catch(void 0),dpop_signing_alg_values_supported:ir(ax()).optional()}),lP=ii({issuer:ax(),authorization_endpoint:lw,token_endpoint:lw,userinfo_endpoint:lw.optional(),jwks_uri:lw,registration_endpoint:lw.optional(),scopes_supported:ir(ax()).optional(),response_types_supported:ir(ax()),response_modes_supported:ir(ax()).optional(),grant_types_supported:ir(ax()).optional(),acr_values_supported:ir(ax()).optional(),subject_types_supported:ir(ax()),id_token_signing_alg_values_supported:ir(ax()),id_token_encryption_alg_values_supported:ir(ax()).optional(),id_token_encryption_enc_values_supported:ir(ax()).optional(),userinfo_signing_alg_values_supported:ir(ax()).optional(),userinfo_encryption_alg_values_supported:ir(ax()).optional(),userinfo_encryption_enc_values_supported:ir(ax()).optional(),request_object_signing_alg_values_supported:ir(ax()).optional(),request_object_encryption_alg_values_supported:ir(ax()).optional(),request_object_encryption_enc_values_supported:ir(ax()).optional(),token_endpoint_auth_methods_supported:ir(ax()).optional(),token_endpoint_auth_signing_alg_values_supported:ir(ax()).optional(),display_values_supported:ir(ax()).optional(),claim_types_supported:ir(ax()).optional(),claims_supported:ir(ax()).optional(),service_documentation:ax().optional(),claims_locales_supported:ir(ax()).optional(),ui_locales_supported:ir(ax()).optional(),claims_parameter_supported:a4().optional(),request_parameter_supported:a4().optional(),request_uri_parameter_supported:a4().optional(),require_request_uri_registration:a4().optional(),op_policy_uri:lw.optional(),op_tos_uri:lw.optional(),client_id_metadata_document_supported:a4().optional(),authorization_response_iss_parameter_supported:a4().optional().catch(void 0)}),lk=ia({...lP.shape,...lE.pick({code_challenge_methods_supported:!0}).shape}),lR=ia({access_token:ax(),id_token:ax().optional(),token_type:ax(),expires_in:new aQ(rG({type:"number",coerce:!0,checks:[],...ed(void 0)})).optional(),scope:ax().optional(),refresh_token:ax().optional(),issuer:ax().optional().catch(void 0)}).strip(),lx=ia({issued_token_type:i_("urn:ietf:params:oauth:token-type:id-jag"),access_token:ax(),token_type:ax().optional(),expires_in:a0().optional(),scope:ax().optional()}).strip(),lC=ia({error:ax(),error_description:ax().optional(),error_uri:ax().optional()}),lA=lw.optional().or(i_("").transform(()=>void 0)),lT=ia({redirect_uris:ir(lw),token_endpoint_auth_method:ax().optional(),grant_types:ir(ax()).optional(),response_types:ir(ax()).optional(),application_type:ax().optional(),client_name:ax().optional(),client_uri:lw.optional(),logo_uri:lA,scope:ax().optional(),contacts:ir(ax()).optional(),tos_uri:lA,policy_uri:ax().optional(),jwks_uri:lw.optional(),jwks:new a6({type:"any"}).optional(),software_id:ax().optional(),software_version:ax().optional(),software_statement:ax().optional()}).strip(),lO=ia({client_id:ax(),client_secret:ax().optional(),client_id_issued_at:a0().optional(),client_secret_expires_at:a0().optional(),issuer:ax().optional().catch(void 0)}).strip(),lj=lT.merge(lO),lI=ia({error:ax(),error_description:ax().optional()}).strip(),lN=ia({token:ax(),token_type_hint:ax().optional()}).strip(),lM=Symbol.for("mcp.sdk.errorBrands");function lz(t,r){let o=new Set,a=r;for(;"function"==typeof a;){let t=a.mcpBrand;Object.prototype.hasOwnProperty.call(a,"mcpBrand")&&"string"==typeof t&&o.add(t),a=Object.getPrototypeOf(a)}0!==o.size&&Object.defineProperty(t,lM,{value:o,enumerable:!1,configurable:!0})}function lq(t,r){try{if("object"==typeof r&&null!==r&&Object.prototype.hasOwnProperty.call(t,"mcpBrand")&&"string"==typeof t.mcpBrand&&Object.prototype.hasOwnProperty.call(r,lM)){let o=r[lM];if(o&&"function"==typeof o.has&&o.has(t.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(t,r)}let lH=((E={}).InvalidRequest="invalid_request",E.InvalidClient="invalid_client",E.InvalidGrant="invalid_grant",E.UnauthorizedClient="unauthorized_client",E.UnsupportedGrantType="unsupported_grant_type",E.InvalidScope="invalid_scope",E.AccessDenied="access_denied",E.ServerError="server_error",E.TemporarilyUnavailable="temporarily_unavailable",E.UnsupportedResponseType="unsupported_response_type",E.UnsupportedTokenType="unsupported_token_type",E.InvalidToken="invalid_token",E.MethodNotAllowed="method_not_allowed",E.TooManyRequests="too_many_requests",E.InvalidClientMetadata="invalid_client_metadata",E.InvalidRedirectUri="invalid_redirect_uri",E.InsufficientScope="insufficient_scope",E.InvalidTarget="invalid_target",E.InvalidDpopProof="invalid_dpop_proof",E.UseDpopNonce="use_dpop_nonce",E);var lU=class t extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",lz(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(r){return new t(r.error,r.error_description??r.error,r.error_uri)}};let lD=((P={}).NotConnected="NOT_CONNECTED",P.AlreadyConnected="ALREADY_CONNECTED",P.NotInitialized="NOT_INITIALIZED",P.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",P.RequestTimeout="REQUEST_TIMEOUT",P.ConnectionClosed="CONNECTION_CLOSED",P.SendFailed="SEND_FAILED",P.InvalidResult="INVALID_RESULT",P.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",P.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",P.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",P.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",P.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",P.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",P.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",P.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",P.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",P.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",P.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",P);var lL=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t,r,o,a){super(r,a),this.code=t,this.data=o,this.name="SdkError",lz(this,new.target)}},lK=class extends lL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(t,r,o,a){super(t,r,o,a),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function lJ(t){if("object"!=typeof t||null===t||Array.isArray(t))return t;let r={...t};return delete r.issuer,r}let lV="2026-07-28",lW=[lV];function lF(t){return t.filter(t=>!(t>=lV))}function lB(t){return t.filter(t=>t>=lV)}function lZ(t){let r=t.structuredContent;return void 0===r||!("object"!=typeof r||null===r||Array.isArray(r))||t.content?.some(t=>"text"===t.type)?t:{...t,content:[...t.content??[],{type:"text",text:JSON.stringify(r)}]}}let lG=["task","inputRequests","requestState"];function lX(t){return null===t||"object"!=typeof t||Array.isArray(t)||void 0!==t.content||lG.some(r=>r in t)?t:{...t,content:[]}}function lY(){let t,r,a,i,n,s,l,c,u,d,p,h,f,m,y,g,v,_,b,S,w,$,E,P,k,R,x,C,A,T,O,j,I,N,M,z,q,H,U,D,L,K,J,V,W,F,B,Z,G,X,Y,Q,ee,et,er,eo,ea,ei,en,es,el,ec,eu,ed,ep,eh,ef,em,ey,eg,ev,e_,eb,eS,ew,e$,eE,eP,ek,eR,ex,eC,eA,eT,eO,ej,eI,eN,eM,ez,eq,eH,eU,eD,eL,eK,eJ,eV,eW,eF,eB,eZ,eG,eX,eY,eQ,e0,e1,e2,e9,e4,e5,e3,e6,e8,e7,te,tt,tr,to,ta,ti,tn,ts,tl,tc,tu,td,tp,th,tf,tm,ty,tg,tv,t_,tb,tS,tw,t$;return o??=(t=iM(()=>il([ax(),a0(),a4(),a3(),im(ax(),t),ir(t)])),r=im(ax(),t),a=il([ax(),a0().int()]),i=ax(),n=ia({ttl:a0().optional()}),s=ia({taskId:ax()}),l=ii({progressToken:a.optional(),"io.modelcontextprotocol/related-task":s.optional()}),u=(c=ia({_meta:l.optional()})).extend({task:n.optional()}),d=ia({method:ax(),params:c.loose().optional()}),p=ia({_meta:l.optional()}),h=ia({method:ax(),params:p.loose().optional()}),f=ii({_meta:l.optional()}),m=il([ax(),a0().int()]),y=f.strict(),g=p.extend({requestId:m.optional(),reason:ax().optional()}),v=h.extend({method:i_("notifications/cancelled"),params:g}),_=ia({src:ax(),mimeType:ax().optional(),sizes:ir(ax()).optional(),theme:ig(["light","dark"]).optional()}),b=ia({icons:ir(_).optional()}),w=(S=ia({name:ax(),title:ax().optional()})).extend({...S.shape,...b.shape,version:ax(),websiteUrl:ax().optional(),description:ax().optional()}),$=ip(ia({applyDefaults:a4().optional()}),r),E=iq(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,ip(ia({form:$.optional(),url:r.optional()}),r.optional())),P=ii({list:r.optional(),cancel:r.optional(),requests:ii({sampling:ii({createMessage:r.optional()}).optional(),elicitation:ii({create:r.optional()}).optional()}).optional()}),k=ii({list:r.optional(),cancel:r.optional(),requests:ii({tools:ii({call:r.optional()}).optional()}).optional()}),R=ia({experimental:im(ax(),r).optional(),sampling:ia({context:r.optional(),tools:r.optional()}).optional(),elicitation:E.optional(),roots:ia({listChanged:a4().optional()}).optional(),tasks:P.optional(),extensions:im(ax(),r).optional()}),x=c.extend({protocolVersion:ax(),capabilities:R,clientInfo:w}),C=d.extend({method:i_("initialize"),params:x}),A=ia({experimental:im(ax(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:ia({listChanged:a4().optional()}).optional(),resources:ia({subscribe:a4().optional(),listChanged:a4().optional()}).optional(),tools:ia({listChanged:a4().optional()}).optional(),tasks:k.optional(),extensions:im(ax(),r).optional()}),T=f.extend({protocolVersion:ax(),capabilities:A,serverInfo:w,instructions:ax().optional()}),O=h.extend({method:i_("notifications/initialized"),params:p.optional()}),j=d.extend({method:i_("ping"),params:c.optional()}),I=ia({progress:a0(),total:i$(a0()),message:i$(ax())}),N=ia({...p.shape,...I.shape,progressToken:a}),M=h.extend({method:i_("notifications/progress"),params:N}),z=c.extend({cursor:i.optional()}),q=d.extend({params:z.optional()}),H=f.extend({nextCursor:i.optional()}),D=(U=ia({uri:ax(),mimeType:i$(ax()),_meta:im(ax(),a7()).optional()})).extend({text:ax()}),L=ax().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),K=U.extend({blob:L}),J=ig(["user","assistant"]),V=ia({audience:ir(J).optional(),priority:a0().min(0).max(1).optional(),lastModified:rQ(aA,{offset:!0}).optional()}),W=ia({...S.shape,...b.shape,uri:ax(),description:i$(ax()),mimeType:i$(ax()),size:i$(a0()),annotations:V.optional(),_meta:i$(ii({}))}),F=ia({...S.shape,...b.shape,uriTemplate:ax(),description:i$(ax()),mimeType:i$(ax()),annotations:V.optional(),_meta:i$(ii({}))}),B=q.extend({method:i_("resources/list")}),Z=H.extend({resources:ir(W)}),G=q.extend({method:i_("resources/templates/list")}),X=H.extend({resourceTemplates:ir(F)}),Y=c.extend({uri:ax()}),Q=d.extend({method:i_("resources/read"),params:Y}),ee=f.extend({contents:ir(il([D,K]))}),et=h.extend({method:i_("notifications/resources/list_changed"),params:p.optional()}),er=d.extend({method:i_("resources/subscribe"),params:Y}),eo=d.extend({method:i_("resources/unsubscribe"),params:Y}),ea=p.extend({uri:ax()}),ei=h.extend({method:i_("notifications/resources/updated"),params:ea}),en=ia({name:ax(),description:i$(ax()),required:i$(a4())}),es=ia({...S.shape,...b.shape,description:i$(ax()),arguments:i$(ir(en)),_meta:i$(ii({}))}),el=q.extend({method:i_("prompts/list")}),ec=H.extend({prompts:ir(es)}),eu=c.extend({name:ax(),arguments:im(ax(),ax()).optional()}),ed=d.extend({method:i_("prompts/get"),params:eu}),ep=ia({type:i_("text"),text:ax(),annotations:V.optional(),_meta:im(ax(),a7()).optional()}),eh=ia({type:i_("image"),data:L,mimeType:ax(),annotations:V.optional(),_meta:im(ax(),a7()).optional()}),ef=ia({type:i_("audio"),data:L,mimeType:ax(),annotations:V.optional(),_meta:im(ax(),a7()).optional()}),em=ia({type:i_("tool_use"),name:ax(),id:ax(),input:im(ax(),a7()),_meta:im(ax(),a7()).optional()}),ey=ia({type:i_("resource"),resource:il([D,K]),annotations:V.optional(),_meta:im(ax(),a7()).optional()}),eg=W.extend({type:i_("resource_link")}),ev=il([ep,eh,ef,eg,ey]),e_=ia({role:J,content:ev}),eb=f.extend({description:ax().optional(),messages:ir(e_)}),eS=h.extend({method:i_("notifications/prompts/list_changed"),params:p.optional()}),ew=ia({title:ax().optional(),readOnlyHint:a4().optional(),destructiveHint:a4().optional(),idempotentHint:a4().optional(),openWorldHint:a4().optional()}),e$=ia({taskSupport:ig(["required","optional","forbidden"]).optional()}),eE=ia({...S.shape,...b.shape,description:ax().optional(),inputSchema:ia({type:i_("object"),properties:im(ax(),t).optional(),required:ir(ax()).optional()}).catchall(a7()),outputSchema:ia({type:i_("object"),properties:im(ax(),t).optional(),required:ir(ax()).optional()}).catchall(a7()).optional(),annotations:ew.optional(),execution:e$.optional(),_meta:im(ax(),a7()).optional()}),eP=q.extend({method:i_("tools/list")}),ek=H.extend({tools:ir(eE)}),eR=f.extend({content:ir(ev),structuredContent:im(ax(),a7()).optional(),isError:a4().optional()}),ex=u.extend({name:ax(),arguments:im(ax(),a7()).optional()}),eC=d.extend({method:i_("tools/call"),params:ex}),eA=h.extend({method:i_("notifications/tools/list_changed"),params:p.optional()}),eT=ig(["debug","info","notice","warning","error","critical","alert","emergency"]),eO=c.extend({level:eT}),ej=d.extend({method:i_("logging/setLevel"),params:eO}),eI=p.extend({level:eT,logger:ax().optional(),data:a7()}),eN=h.extend({method:i_("notifications/message"),params:eI}),eM=ia({name:ax().optional()}),ez=ia({hints:ir(eM).optional(),costPriority:a0().min(0).max(1).optional(),speedPriority:a0().min(0).max(1).optional(),intelligencePriority:a0().min(0).max(1).optional()}),eq=ia({mode:ig(["auto","required","none"]).optional()}),eH=ia({type:i_("tool_result"),toolUseId:ax().describe("The unique identifier for the corresponding tool call."),content:ir(ev),structuredContent:ia({}).loose().optional(),isError:a4().optional(),_meta:im(ax(),a7()).optional()}),eU=iu("type",[ep,eh,ef]),eD=iu("type",[ep,eh,ef,em,eH]),eL=ia({role:J,content:il([eD,ir(eD)]),_meta:im(ax(),a7()).optional()}),eK=u.extend({messages:ir(eL),modelPreferences:ez.optional(),systemPrompt:ax().optional(),includeContext:ig(["none","thisServer","allServers"]).optional(),temperature:a0().optional(),maxTokens:a0().int(),stopSequences:ir(ax()).optional(),metadata:r.optional(),tools:ir(eE).optional(),toolChoice:eq.optional()}),eJ=d.extend({method:i_("sampling/createMessage"),params:eK}),eV=f.extend({model:ax(),stopReason:i$(ig(["endTurn","stopSequence","maxTokens"]).or(ax())),role:J,content:eU}),eW=f.extend({model:ax(),stopReason:i$(ig(["endTurn","stopSequence","maxTokens","toolUse"]).or(ax())),role:J,content:il([eD,ir(eD)])}),eF=ia({type:i_("boolean"),title:ax().optional(),description:ax().optional(),default:a4().optional()}),eB=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),minLength:a0().optional(),maxLength:a0().optional(),format:ig(["email","uri","date","date-time"]).optional(),default:ax().optional()}),eZ=ia({type:ig(["number","integer"]),title:ax().optional(),description:ax().optional(),minimum:a0().optional(),maximum:a0().optional(),default:a0().optional()}),eG=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),default:ax().optional()}),eX=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),oneOf:ir(ia({const:ax(),title:ax()})),default:ax().optional()}),eY=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),enumNames:ir(ax()).optional(),default:ax().optional()}),eQ=il([eG,eX]),e0=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({type:i_("string"),enum:ir(ax())}),default:ir(ax()).optional()}),e1=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({anyOf:ir(ia({const:ax(),title:ax()}))}),default:ir(ax()).optional()}),e2=il([e0,e1]),e9=il([eY,eQ,e2]),e4=il([e9,eF,eB,eZ]),e5=u.extend({mode:i_("form").optional(),message:ax(),requestedSchema:ia({type:i_("object"),properties:im(ax(),e4),required:ir(ax()).optional()}).catchall(a7())}),e3=u.extend({mode:i_("url"),message:ax(),elicitationId:ax(),url:ax().url()}),e6=il([e5,e3]),e8=d.extend({method:i_("elicitation/create"),params:e6}),e7=p.extend({elicitationId:ax()}),te=h.extend({method:i_("notifications/elicitation/complete"),params:e7}),tt=f.extend({action:ig(["accept","decline","cancel"]),content:iq(t=>null===t?void 0:t,im(ax(),il([ax(),a0(),a4(),ir(ax())])).optional())}),tr=ia({type:i_("ref/resource"),uri:ax()}),to=ia({type:i_("ref/prompt"),name:ax()}),ta=c.extend({ref:il([to,tr]),argument:ia({name:ax(),value:ax()}),context:ia({arguments:im(ax(),ax()).optional()}).optional()}),ti=d.extend({method:i_("completion/complete"),params:ta}),tn=f.extend({completion:ii({values:ir(ax()).max(100),total:i$(a0().int()),hasMore:i$(a4())})}),ts=ia({uri:ax().startsWith("file://"),name:ax().optional(),_meta:im(ax(),a7()).optional()}),tl=d.extend({method:i_("roots/list"),params:c.optional()}),tc=f.extend({roots:ir(ts)}),tu=h.extend({method:i_("notifications/roots/list_changed"),params:p.optional()}),td=ii({ttl:a0().optional(),pollInterval:a0().optional()}),tp=ig(["working","input_required","completed","failed","cancelled"]),th=ia({taskId:ax(),status:tp,ttl:il([a0(),a3()]),createdAt:ax(),lastUpdatedAt:ax(),pollInterval:i$(a0()),statusMessage:i$(ax())}),tf=f.extend({task:th}),tm=p.merge(th),ty=h.extend({method:i_("notifications/tasks/status"),params:tm}),tg=d.extend({method:i_("tasks/get"),params:c.extend({taskId:ax()})}),tv=f.merge(th),t_=d.extend({method:i_("tasks/result"),params:c.extend({taskId:ax()})}),tb=f.loose(),tS=q.extend({method:i_("tasks/list")}),tw=H.extend({tasks:ir(th)}),t$=d.extend({method:i_("tasks/cancel"),params:c.extend({taskId:ax()})}),{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:a,CursorSchema:i,TaskMetadataSchema:n,RelatedTaskMetadataSchema:s,RequestMetaSchema:l,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:u,RequestSchema:d,NotificationsParamsSchema:p,NotificationSchema:h,ResultSchema:f,RequestIdSchema:m,EmptyResultSchema:y,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:v,IconSchema:_,IconsSchema:b,BaseMetadataSchema:S,ImplementationSchema:w,ClientTasksCapabilitySchema:P,ServerTasksCapabilitySchema:k,ClientCapabilitiesSchema:R,InitializeRequestParamsSchema:x,InitializeRequestSchema:C,ServerCapabilitiesSchema:A,InitializeResultSchema:T,InitializedNotificationSchema:O,PingRequestSchema:j,ProgressSchema:I,ProgressNotificationParamsSchema:N,ProgressNotificationSchema:M,PaginatedRequestParamsSchema:z,PaginatedRequestSchema:q,PaginatedResultSchema:H,ResourceContentsSchema:U,TextResourceContentsSchema:D,BlobResourceContentsSchema:K,RoleSchema:J,AnnotationsSchema:V,ResourceSchema:W,ResourceTemplateSchema:F,ListResourcesRequestSchema:B,ListResourcesResultSchema:Z,ListResourceTemplatesRequestSchema:G,ListResourceTemplatesResultSchema:X,ResourceRequestParamsSchema:Y,ReadResourceRequestParamsSchema:Y,ReadResourceRequestSchema:Q,ReadResourceResultSchema:ee,ResourceListChangedNotificationSchema:et,SubscribeRequestParamsSchema:Y,SubscribeRequestSchema:er,UnsubscribeRequestParamsSchema:Y,UnsubscribeRequestSchema:eo,ResourceUpdatedNotificationParamsSchema:ea,ResourceUpdatedNotificationSchema:ei,PromptArgumentSchema:en,PromptSchema:es,ListPromptsRequestSchema:el,ListPromptsResultSchema:ec,GetPromptRequestParamsSchema:eu,GetPromptRequestSchema:ed,TextContentSchema:ep,ImageContentSchema:eh,AudioContentSchema:ef,ToolUseContentSchema:em,EmbeddedResourceSchema:ey,ResourceLinkSchema:eg,ContentBlockSchema:ev,PromptMessageSchema:e_,GetPromptResultSchema:eb,PromptListChangedNotificationSchema:eS,ToolAnnotationsSchema:ew,ToolExecutionSchema:e$,ToolSchema:eE,ListToolsRequestSchema:eP,ListToolsResultSchema:ek,CallToolResultSchema:eR,CallToolRequestParamsSchema:ex,CallToolRequestSchema:eC,ToolListChangedNotificationSchema:eA,LoggingLevelSchema:eT,SetLevelRequestParamsSchema:eO,SetLevelRequestSchema:ej,LoggingMessageNotificationParamsSchema:eI,LoggingMessageNotificationSchema:eN,ModelHintSchema:eM,ModelPreferencesSchema:ez,ToolChoiceSchema:eq,ToolResultContentSchema:eH,SamplingContentSchema:eU,SamplingMessageContentBlockSchema:eD,SamplingMessageSchema:eL,CreateMessageRequestParamsSchema:eK,CreateMessageRequestSchema:eJ,CreateMessageResultSchema:eV,CreateMessageResultWithToolsSchema:eW,BooleanSchemaSchema:eF,StringSchemaSchema:eB,NumberSchemaSchema:eZ,UntitledSingleSelectEnumSchemaSchema:eG,TitledSingleSelectEnumSchemaSchema:eX,LegacyTitledEnumSchemaSchema:eY,SingleSelectEnumSchemaSchema:eQ,UntitledMultiSelectEnumSchemaSchema:e0,TitledMultiSelectEnumSchemaSchema:e1,MultiSelectEnumSchemaSchema:e2,EnumSchemaSchema:e9,PrimitiveSchemaDefinitionSchema:e4,ElicitRequestFormParamsSchema:e5,ElicitRequestURLParamsSchema:e3,ElicitRequestParamsSchema:e6,ElicitRequestSchema:e8,ElicitationCompleteNotificationParamsSchema:e7,ElicitationCompleteNotificationSchema:te,ElicitResultSchema:tt,ResourceTemplateReferenceSchema:tr,PromptReferenceSchema:to,CompleteRequestParamsSchema:ta,CompleteRequestSchema:ti,CompleteResultSchema:tn,RootSchema:ts,ListRootsRequestSchema:tl,ListRootsResultSchema:tc,RootsListChangedNotificationSchema:tu,TaskCreationParamsSchema:td,TaskStatusSchema:tp,TaskSchema:th,CreateTaskResultSchema:tf,TaskStatusNotificationParamsSchema:tm,TaskStatusNotificationSchema:ty,GetTaskRequestSchema:tg,GetTaskResultSchema:tv,GetTaskPayloadRequestSchema:t_,GetTaskPayloadResultSchema:tb,ListTasksRequestSchema:tS,ListTasksResultSchema:tw,CancelTaskRequestSchema:t$,CancelTaskResultSchema:f.merge(th),ClientRequestSchema:il([j,C,ti,ej,ed,el,B,G,Q,er,eo,eC,eP,tg,t_,tS,t$]),ClientNotificationSchema:il([v,M,O,tu,ty]),ClientResultSchema:il([y,eV,eW,tt,tc,tv,tw,tf]),ServerRequestSchema:il([j,eJ,e8,tl,tg,t_,tS,t$]),ServerNotificationSchema:il([v,M,eN,ei,et,eA,eS,ty,te]),ServerResultSchema:il([y,T,tn,eb,ec,Z,X,ee,eR,ek,tv,tw,tf]),CallToolResultWireSchema:a7().superRefine((t,r)=>{if(!("object"!=typeof t||null===t||Array.isArray(t))&&void 0===t.content){for(let o of lG)if(o in t)return void r.addIssue({code:"custom",message:`content is required when the body carries '${o}' — another result family cannot default into an empty tools/call success`})}}).transform(lX).pipe(eR)})}function lQ(t){return"object"!==t.type}let l0=new Set(["const","enum","default","examples"]),l1=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function l2(t){return void 0!==t&&!("string"==typeof t&&t.startsWith("#"))}let l9={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},l4={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},l5={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function l3(){if(a)return a;let t=lY();return a={requestSchemas:{ping:t.PingRequestSchema,initialize:t.InitializeRequestSchema,"completion/complete":t.CompleteRequestSchema,"logging/setLevel":t.SetLevelRequestSchema,"prompts/get":t.GetPromptRequestSchema,"prompts/list":t.ListPromptsRequestSchema,"resources/list":t.ListResourcesRequestSchema,"resources/templates/list":t.ListResourceTemplatesRequestSchema,"resources/read":t.ReadResourceRequestSchema,"resources/subscribe":t.SubscribeRequestSchema,"resources/unsubscribe":t.UnsubscribeRequestSchema,"tools/call":t.CallToolRequestSchema,"tools/list":t.ListToolsRequestSchema,"tasks/get":t.GetTaskRequestSchema,"tasks/result":t.GetTaskPayloadRequestSchema,"tasks/list":t.ListTasksRequestSchema,"tasks/cancel":t.CancelTaskRequestSchema,"sampling/createMessage":t.CreateMessageRequestSchema,"elicitation/create":t.ElicitRequestSchema,"roots/list":t.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":t.CancelledNotificationSchema,"notifications/progress":t.ProgressNotificationSchema,"notifications/initialized":t.InitializedNotificationSchema,"notifications/roots/list_changed":t.RootsListChangedNotificationSchema,"notifications/tasks/status":t.TaskStatusNotificationSchema,"notifications/message":t.LoggingMessageNotificationSchema,"notifications/resources/updated":t.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":t.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":t.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":t.PromptListChangedNotificationSchema,"notifications/elicitation/complete":t.ElicitationCompleteNotificationSchema},resultSchemas:{ping:t.EmptyResultSchema,initialize:t.InitializeResultSchema,"completion/complete":t.CompleteResultSchema,"logging/setLevel":t.EmptyResultSchema,"prompts/get":t.GetPromptResultSchema,"prompts/list":t.ListPromptsResultSchema,"resources/list":t.ListResourcesResultSchema,"resources/templates/list":t.ListResourceTemplatesResultSchema,"resources/read":t.ReadResourceResultSchema,"resources/subscribe":t.EmptyResultSchema,"resources/unsubscribe":t.EmptyResultSchema,"tools/call":t.CallToolResultWireSchema,"tools/list":t.ListToolsResultSchema,"sampling/createMessage":t.CreateMessageResultWithToolsSchema,"elicitation/create":t.ElicitResultSchema,"roots/list":t.ListRootsResultSchema}}}function l6(t){return Object.prototype.hasOwnProperty.call(l9,t)}function l8(t){return Object.prototype.hasOwnProperty.call(l4,t)}function l7(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function ce(t,r){if(void 0===t)return{ok:!1,reason:"not-in-era"};let o=t.safeParse(r);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}Object.keys(l9),Object.keys(l4);let ct={ok:!1,reason:"not-in-era"};function cr(t){return l7(t)&&l7(t.outputSchema)&&lQ(t.outputSchema)}let co={era:"2025-11-25",hasRequestMethod:l6,hasNotificationMethod:l8,validateRequest:(t,r)=>{var o;return ce(l6(o=t)?l3().requestSchemas[o]:void 0,r)},validateResult:(t,r)=>{var o,a;return ce((a=o=t,Object.prototype.hasOwnProperty.call(l5,a))?l3().resultSchemas[o]:void 0,r)},validateNotification:(t,r)=>{var o;return ce(l8(o=t)?l3().notificationSchemas[o]:void 0,r)},hasInputRequestMethod:()=>!1,validateInputRequest:()=>ct,validateInputResponse:()=>ct,samplingResultVariant:(t,r)=>{let o=lY();return ce(t?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,r)},outboundEnvelope:t=>void 0,validateEnvelopeMeta:t=>[],projectCallToolResult(t,r){let o=lZ(t),a=o.structuredContent;if(void 0===a)return o;let i="object"!=typeof a||null===a||Array.isArray(a),n=void 0!==r&&lQ(r);return i||n?{...o,structuredContent:{result:a}}:o},decodeResult(t,r){if(l7(r)&&"resultType"in r){let t={...r};return delete t.resultType,{kind:"complete",result:t}}return{kind:"complete",result:r}},encodeResult(t,r){if("tools/list"!==t)return r;let o=r.tools;return Array.isArray(o)&&o.some(t=>cr(t))?{...r,tools:o.map(t=>cr(t)?{...t,outputSchema:function(t){var r;let o="string"==typeof t.$schema?t.$schema:void 0;if(l2(t.$id))return{...void 0!==o&&{$schema:o},type:"object",properties:{result:t},required:["result"]};let a="string"==typeof(r=t.$schema)&&U.has(r.replace(/#$/,""))&&!0!==t.$recursiveAnchor,i=(t,r)=>{if(Array.isArray(t))return t.map(t=>i(t,!1));if(null===t||"object"!=typeof t||!r&&l2(t.$id))return t;let o={},n=!1;for(let[s,l]of Object.entries(t))r?o[s]=i(l,!1):("$ref"===s||"$dynamicRef"===s)&&"string"==typeof l?o[s]="#"===l?"#/properties/result":l.startsWith("#/")?`#/properties/result${l.slice(1)}`:l:"$recursiveRef"===s&&"#"===l&&a?n=!0:l0.has(s)?o[s]=l:l1.has(s)?o[s]=i(l,!0):o[s]=i(l,!1);return n&&("$ref"in o?o.allOf=[...Array.isArray(o.allOf)?o.allOf:[],{$ref:"#/properties/result"}]:o.$ref="#/properties/result"),o};return{...void 0!==o&&{$schema:o},type:"object",properties:{result:i(t,!1)},required:["result"]}}(t.outputSchema)}:t)}:r},encodeErrorCode:t=>-32002===t?-32602:t,checkInboundEnvelope:t=>void 0};function ca(){return s??=function(){let t=iM(()=>il([ax(),a0(),a4(),a3(),im(ax(),t),ir(t)])),r=im(ax(),t),o=il([ax(),a0().int()]),a=ax(),i=il([ax(),a0().int()]),n=ig(["user","assistant"]),s=ig(["debug","info","notice","warning","error","critical","alert","emergency"]),l=ax().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=ia({ttl:a0().optional()}),u=ia({taskId:ax()}),d=ii({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),p=ia({_meta:d.optional()}),h=p.extend({task:c.optional()}),f=ia({_meta:d.optional()}),m=ia({method:ax(),params:f.loose().optional()}),y=ia({src:ax(),mimeType:ax().optional(),sizes:ir(ax()).optional(),theme:ig(["light","dark"]).optional()}),g=ia({icons:ir(y).optional()}),v=ia({name:ax(),title:ax().optional()}),_=v.extend({...v.shape,...g.shape,version:ax(),websiteUrl:ax().optional(),description:ax().optional()}),b=ip(ia({applyDefaults:a4().optional()}),r),S=iq(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,ip(ia({form:b.optional(),url:r.optional()}),r.optional())),w=ii({list:r.optional(),cancel:r.optional(),requests:ii({sampling:ii({createMessage:r.optional()}).optional(),elicitation:ii({create:r.optional()}).optional()}).optional()}),$=ii({list:r.optional(),cancel:r.optional(),requests:ii({tools:ii({call:r.optional()}).optional()}).optional()}),E=ia({experimental:im(ax(),r).optional(),sampling:ia({context:r.optional(),tools:r.optional()}).optional(),elicitation:S.optional(),roots:ia({listChanged:a4().optional()}).optional(),tasks:w.optional(),extensions:im(ax(),r).optional()}),P=ia({experimental:im(ax(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:ia({listChanged:a4().optional()}).optional(),resources:ia({subscribe:a4().optional(),listChanged:a4().optional()}).optional(),tools:ia({listChanged:a4().optional()}).optional(),tasks:$.optional(),extensions:im(ax(),r).optional()}),k=ia({progress:a0(),total:i$(a0()),message:i$(ax())}),R=ia({...f.shape,...k.shape,progressToken:o}),x=m.extend({method:i_("notifications/progress"),params:R}),C=f.extend({level:s,logger:ax().optional(),data:a7()}),A=m.extend({method:i_("notifications/message"),params:C}),T=ia({uri:ax(),mimeType:i$(ax()),_meta:im(ax(),a7()).optional()}),O=T.extend({text:ax()}),j=T.extend({blob:l}),I=ia({audience:ir(n).optional(),priority:a0().min(0).max(1).optional(),lastModified:rQ(aA,{offset:!0}).optional()}),N=ia({...v.shape,...g.shape,uri:ax(),description:i$(ax()),mimeType:i$(ax()),size:i$(a0()),annotations:I.optional(),_meta:i$(ii({}))}),M=ia({...v.shape,...g.shape,uriTemplate:ax(),description:i$(ax()),mimeType:i$(ax()),annotations:I.optional(),_meta:i$(ii({}))}),z=m.extend({method:i_("notifications/resources/list_changed"),params:f.optional()}),q=f.extend({uri:ax()}),H=m.extend({method:i_("notifications/resources/updated"),params:q}),U=ia({name:ax(),description:i$(ax()),required:i$(a4())}),D=ia({...v.shape,...g.shape,description:i$(ax()),arguments:i$(ir(U)),_meta:i$(ii({}))}),L=m.extend({method:i_("notifications/prompts/list_changed"),params:f.optional()}),K=ia({type:i_("text"),text:ax(),annotations:I.optional(),_meta:im(ax(),a7()).optional()}),J=ia({type:i_("image"),data:l,mimeType:ax(),annotations:I.optional(),_meta:im(ax(),a7()).optional()}),V=ia({type:i_("audio"),data:l,mimeType:ax(),annotations:I.optional(),_meta:im(ax(),a7()).optional()}),W=ia({type:i_("tool_use"),name:ax(),id:ax(),input:im(ax(),a7()),_meta:im(ax(),a7()).optional()}),F=ia({type:i_("resource"),resource:il([O,j]),annotations:I.optional(),_meta:im(ax(),a7()).optional()}),B=N.extend({type:i_("resource_link")}),Z=il([K,J,V,B,F]),G=ia({role:n,content:Z}),X=ia({title:ax().optional(),readOnlyHint:a4().optional(),destructiveHint:a4().optional(),idempotentHint:a4().optional(),openWorldHint:a4().optional()}),Y=m.extend({method:i_("notifications/tools/list_changed"),params:f.optional()}),Q=ia({name:ax().optional()}),ee=ia({hints:ir(Q).optional(),costPriority:a0().min(0).max(1).optional(),speedPriority:a0().min(0).max(1).optional(),intelligencePriority:a0().min(0).max(1).optional()}),et=ia({mode:ig(["auto","required","none"]).optional()}),er=ia({type:i_("boolean"),title:ax().optional(),description:ax().optional(),default:a4().optional()}),eo=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),minLength:a0().optional(),maxLength:a0().optional(),format:ig(["email","uri","date","date-time"]).optional(),default:ax().optional()}),ea=ia({type:ig(["number","integer"]),title:ax().optional(),description:ax().optional(),minimum:a0().optional(),maximum:a0().optional(),default:a0().optional()}),ei=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),default:ax().optional()}),en=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),oneOf:ir(ia({const:ax(),title:ax()})),default:ax().optional()}),es=ia({type:i_("string"),title:ax().optional(),description:ax().optional(),enum:ir(ax()),enumNames:ir(ax()).optional(),default:ax().optional()}),el=il([ei,en]),ec=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({type:i_("string"),enum:ir(ax())}),default:ir(ax()).optional()}),eu=ia({type:i_("array"),title:ax().optional(),description:ax().optional(),minItems:a0().optional(),maxItems:a0().optional(),items:ia({anyOf:ir(ia({const:ax(),title:ax()}))}),default:ir(ax()).optional()}),ed=il([ec,eu]),ep=il([es,el,ed]),eh=il([ep,er,eo,ea]),ef=h.extend({mode:i_("form").optional(),message:ax(),requestedSchema:ia({type:i_("object"),properties:im(ax(),eh),required:ir(ax()).optional()}).catchall(a7())}),em=ia({type:i_("ref/resource"),uri:ax()}),ey=ia({type:i_("ref/prompt"),name:ax()}),eg=ia({uri:ax().startsWith("file://"),name:ax().optional(),_meta:im(ax(),a7()).optional()}),ev=E.shape,e_=ia({experimental:ev.experimental,sampling:ev.sampling,elicitation:ev.elicitation,roots:ev.roots,extensions:ev.extensions}),eb=P.shape,eS=ia({experimental:eb.experimental,logging:eb.logging,completions:eb.completions,prompts:eb.prompts,resources:eb.resources,tools:eb.tools,extensions:eb.extensions}),ew=ii({progressToken:o.optional(),[iL]:ax(),[iK]:_.optional(),[iV]:e_,[iF]:s.optional()}),e$=ia({...v.shape,...g.shape,description:ax().optional(),inputSchema:ii({$schema:ax().optional(),type:i_("object")}),outputSchema:ii({$schema:ax().optional()}).optional(),annotations:X.optional(),_meta:im(ax(),a7()).optional()}),eE=ia({type:i_("tool_result"),toolUseId:ax(),content:ir(Z),structuredContent:a7().optional(),isError:a4().optional(),_meta:im(ax(),a7()).optional()}),eP=il([K,J,V,W,eE]),ek=ia({role:n,content:il([eP,ir(eP)]),_meta:im(ax(),a7()).optional()}),eR=ax(),ex=ii({[iJ]:_.optional().catch(void 0)}),eC=ex.optional();function eA(t){return ii({_meta:eC,resultType:eR.default("complete"),...t})}let eT=eA({}),eO=eA({nextCursor:a.optional()}),ej=eA({content:ir(Z),structuredContent:a7().optional(),isError:a4().optional()}),eI=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),tools:ir(e$),nextCursor:a.optional()}),eN=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),prompts:ir(D),nextCursor:a.optional()}),eM=eA({description:ax().optional(),messages:ir(G)}),ez=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),resources:ir(N),nextCursor:a.optional()}),eq=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),resourceTemplates:ir(M),nextCursor:a.optional()}),eH=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),contents:ir(il([O,j]))}),eU=eA({completion:ia({values:ir(ax()).max(100),total:a0().int().optional(),hasMore:a4().optional()}).loose()}),eD=eA({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"])}),eL=eA({ttlMs:a0().int().min(0).catch(0),cacheScope:ig(["public","private"]).catch("private"),supportedVersions:ir(ax()),capabilities:eS,instructions:ax().optional()}),eK=ia({messages:ir(ek),modelPreferences:ee.optional(),systemPrompt:ax().optional(),includeContext:ig(["none","thisServer","allServers"]).optional(),temperature:a0().optional(),maxTokens:a0().int(),stopSequences:ir(ax()).optional(),metadata:r.optional(),tools:ir(e$).optional(),toolChoice:et.optional()}),eJ=ia({method:i_("sampling/createMessage"),params:eK}),eV=ia({method:i_("roots/list"),params:ia({_meta:im(ax(),a7()).optional()}).optional()}),eW=ia({...ek.shape,model:ax(),stopReason:ax().optional()}),eF=ia({roots:ir(eg)}),eB=ia({action:ig(["accept","decline","cancel"]),content:im(ax(),il([ax(),a0(),a4(),ir(ax())])).optional()}),eZ=ia({mode:i_("url"),message:ax(),url:ax().url()}),eG=il([ef,eZ]),eX=ia({method:i_("elicitation/create"),params:eG}),eY=il([eJ,eV,eX]),eQ=il([eW,eF,eB]),e0=im(ax(),eY),e1=im(ax(),eQ),e2=eA({inputRequests:e0.optional(),requestState:ax().optional()}),e9={inputResponses:e1.optional(),requestState:ax().optional()},e4=ia({_meta:ew,...e9}),e5=ii({progressToken:o.optional()});function e3(t,r){return ia({method:i_(t),params:ia({_meta:ew,...r})})}function e6(t,r){return ia({method:i_(t),params:ia({_meta:e5.optional(),...r}).optional()})}let e8={name:ax(),arguments:im(ax(),a7()).optional(),...e9},e7={cursor:a.optional()},te=e3("tools/call",e8),tt=e3("tools/list",e7),tr=e3("prompts/list",e7),to=e3("prompts/get",{name:ax(),arguments:im(ax(),ax()).optional(),...e9}),ta=e3("resources/list",e7),ti=e3("resources/templates/list",e7),tn=e3("resources/read",{uri:ax(),...e9}),ts={ref:il([ey,em]),argument:ia({name:ax(),value:ax()}),context:ia({arguments:im(ax(),ax()).optional()}).optional()},tl=e3("completion/complete",ts),tc=e3("server/discover",{}),tu=ia({toolsListChanged:a4().optional(),promptsListChanged:a4().optional(),resourcesListChanged:a4().optional(),resourceSubscriptions:ir(ax()).optional()}),td={notifications:tu},tp=e3("subscriptions/listen",td),th=ex.extend({"io.modelcontextprotocol/subscriptionId":i}),tf=ii({_meta:th,resultType:eR.default("complete")}),tm={"tools/call":e6("tools/call",e8),"tools/list":e6("tools/list",e7),"prompts/get":e6("prompts/get",{name:ax(),arguments:im(ax(),ax()).optional()}),"prompts/list":e6("prompts/list",e7),"resources/list":e6("resources/list",e7),"resources/templates/list":e6("resources/templates/list",e7),"resources/read":e6("resources/read",{uri:ax()}),"completion/complete":e6("completion/complete",ts),"server/discover":e6("server/discover",{}),"subscriptions/listen":e6("subscriptions/listen",td)};function ty(t){return ii({_meta:eC,...t})}let tg={"tools/call":ty({content:ir(Z),structuredContent:a7().optional(),isError:a4().optional()}),"tools/list":ty({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),tools:ir(e$),nextCursor:a.optional()}),"prompts/get":ty({description:ax().optional(),messages:ir(G)}),"prompts/list":ty({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),prompts:ir(D),nextCursor:a.optional()}),"resources/list":ty({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),resources:ir(N),nextCursor:a.optional()}),"resources/templates/list":ty({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),resourceTemplates:ir(M),nextCursor:a.optional()}),"resources/read":ty({ttlMs:a0().int().min(0),cacheScope:ig(["public","private"]),contents:ir(il([O,j]))}),"completion/complete":ty({completion:ia({values:ir(ax()).max(100),total:a0().int().optional(),hasMore:a4().optional()}).loose()}),"server/discover":ty({ttlMs:a0().int().min(0).catch(0),cacheScope:ig(["public","private"]).catch("private"),supportedVersions:ir(ax()),capabilities:eS,instructions:ax().optional()}),"subscriptions/listen":ty({})},tv=ii({"io.modelcontextprotocol/subscriptionId":i.optional()}),t_=ia({method:i_("notifications/subscriptions/acknowledged"),params:ia({_meta:tv.optional(),notifications:tu})}),tb=ia({_meta:tv.optional(),requestId:i,reason:ax().optional()}),tS=ia({method:i_("notifications/cancelled"),params:tb}),tw=t=>ia({jsonrpc:i_("2.0"),id:il([ax(),a0().int()]),result:t}).strict();return{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:o,CursorSchema:a,RequestIdSchema:i,RoleSchema:n,LoggingLevelSchema:s,TaskMetadataSchema:c,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:p,TaskAugmentedRequestParamsSchema:h,NotificationsParamsSchema:f,NotificationSchema:m,IconSchema:y,IconsSchema:g,BaseMetadataSchema:v,ImplementationSchema:_,ClientTasksCapabilitySchema:w,ServerTasksCapabilitySchema:$,ClientCapabilitiesSchema:E,ServerCapabilitiesSchema:P,ProgressSchema:k,ProgressNotificationParamsSchema:R,ProgressNotificationSchema:x,LoggingMessageNotificationParamsSchema:C,LoggingMessageNotificationSchema:A,ResourceContentsSchema:T,TextResourceContentsSchema:O,BlobResourceContentsSchema:j,AnnotationsSchema:I,ResourceSchema:N,ResourceTemplateSchema:M,ResourceListChangedNotificationSchema:z,ResourceUpdatedNotificationParamsSchema:q,ResourceUpdatedNotificationSchema:H,PromptArgumentSchema:U,PromptSchema:D,PromptListChangedNotificationSchema:L,TextContentSchema:K,ImageContentSchema:J,AudioContentSchema:V,ToolUseContentSchema:W,EmbeddedResourceSchema:F,ResourceLinkSchema:B,ContentBlockSchema:Z,PromptMessageSchema:G,ToolAnnotationsSchema:X,ToolListChangedNotificationSchema:Y,ModelHintSchema:Q,ModelPreferencesSchema:ee,ToolChoiceSchema:et,BooleanSchemaSchema:er,StringSchemaSchema:eo,NumberSchemaSchema:ea,UntitledSingleSelectEnumSchemaSchema:ei,TitledSingleSelectEnumSchemaSchema:en,LegacyTitledEnumSchemaSchema:es,SingleSelectEnumSchemaSchema:el,UntitledMultiSelectEnumSchemaSchema:ec,TitledMultiSelectEnumSchemaSchema:eu,MultiSelectEnumSchemaSchema:ed,EnumSchemaSchema:ep,PrimitiveSchemaDefinitionSchema:eh,ElicitRequestFormParamsSchema:ef,ResourceTemplateReferenceSchema:em,PromptReferenceSchema:ey,RootSchema:eg,ClientCapabilities2026Schema:e_,ServerCapabilities2026Schema:eS,RequestMetaEnvelopeSchema:ew,ToolSchema:e$,ToolResultContentSchema:eE,SamplingMessageContentBlockSchema:eP,SamplingMessageSchema:ek,ResultTypeSchema:eR,ResultMetaSchema:ex,ResultSchema:eT,PaginatedResultSchema:eO,CallToolResultSchema:ej,ListToolsResultSchema:eI,ListPromptsResultSchema:eN,GetPromptResultSchema:eM,ListResourcesResultSchema:ez,ListResourceTemplatesResultSchema:eq,ReadResourceResultSchema:eH,CompleteResultSchema:eU,CacheableResultSchema:eD,DiscoverResultSchema:eL,CreateMessageRequestParamsSchema:eK,CreateMessageRequestSchema:eJ,ListRootsRequestSchema:eV,CreateMessageResultSchema:eW,ListRootsResultSchema:eF,ElicitResultSchema:eB,ElicitRequestURLParamsSchema:eZ,ElicitRequestParamsSchema:eG,ElicitRequestSchema:eX,InputRequestSchema:eY,InputResponseSchema:eQ,InputRequestsSchema:e0,InputResponsesSchema:e1,InputRequiredResultSchema:e2,InputResponseRequestParamsSchema:e4,CallToolRequestSchema:te,ListToolsRequestSchema:tt,ListPromptsRequestSchema:tr,GetPromptRequestSchema:to,ListResourcesRequestSchema:ta,ListResourceTemplatesRequestSchema:ti,ReadResourceRequestSchema:tn,CompleteRequestSchema:tl,DiscoverRequestSchema:tc,SubscriptionFilterSchema:tu,SubscriptionsListenRequestSchema:tp,SubscriptionsListenResultMetaSchema:th,SubscriptionsListenResultSchema:tf,dispatchRequestSchemas:tm,dispatchResultSchemas:tg,NotificationMetaSchema:tv,SubscriptionsAcknowledgedNotificationSchema:t_,CancelledNotificationParamsSchema:tb,CancelledNotificationSchema:tS,notificationSchemas2026:{"notifications/cancelled":tS,"notifications/progress":x,"notifications/message":A,"notifications/resources/updated":H,"notifications/resources/list_changed":z,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":L,"notifications/subscriptions/acknowledged":t_},JSONRPCResultResponseSchema:tw(eT),CallToolResultResponseSchema:tw(il([ej,e2])),ListToolsResultResponseSchema:tw(eI),ListPromptsResultResponseSchema:tw(eN),GetPromptResultResponseSchema:tw(il([eM,e2])),ListResourcesResultResponseSchema:tw(ez),ListResourceTemplatesResultResponseSchema:tw(eq),ReadResourceResultResponseSchema:tw(il([eH,e2])),CompleteResultResponseSchema:tw(eU),DiscoverResultResponseSchema:tw(eL),SubscriptionsListenResultResponseSchema:tw(tf)}}()}let ci=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],cn=Symbol("modelcontextprotocol.resultCacheHintFallback");function cs(t){return"number"==typeof t&&Number.isSafeInteger(t)&&t>=0}function cl(t){return"public"===t||"private"===t}let cc=((k={})[k.ParseError=-32700]="ParseError",k[k.InvalidRequest=-32600]="InvalidRequest",k[k.MethodNotFound=-32601]="MethodNotFound",k[k.InvalidParams=-32602]="InvalidParams",k[k.InternalError=-32603]="InternalError",k[k.ResourceNotFound=-32002]="ResourceNotFound",k[k.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",k[k.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",k[k.UrlElicitationRequired=-32042]="UrlElicitationRequired",k);var cu=class t extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",lz(this,new.target)}static fromError(r,o,a){return r===cc.UrlElicitationRequired&&a&&a.elicitations?new cp(a.elicitations,o):r===cc.UnsupportedProtocolVersion&&a&&Array.isArray(a.supported)&&"string"==typeof a.requested?new ch({supported:a.supported,requested:a.requested},o):(r===cc.InvalidParams||r===cc.ResourceNotFound)&&"string"==typeof a?.uri&&(r===cc.ResourceNotFound||1===Object.keys(a).length)?new cd(a.uri,o):r===cc.MissingRequiredClientCapability&&a&&null!==a.requiredCapabilities&&"object"==typeof a.requiredCapabilities&&!Array.isArray(a.requiredCapabilities)?new cf({requiredCapabilities:a.requiredCapabilities},o):new t(r,o,a)}},cd=class extends cu{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(t,r=`Resource not found: ${t}`){super(cc.InvalidParams,r,{uri:t})}get uri(){return this.data.uri}},cp=class extends cu{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(cc.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}},ch=class extends cu{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(t,r=`Unsupported protocol version: ${t.requested}`){super(cc.UnsupportedProtocolVersion,r,t)}get supported(){return this.data.supported}get requested(){return this.data.requested}},cf=class extends cu{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(t,r=`Missing required client capabilities: ${Object.keys(t.requiredCapabilities).join(", ")}`){super(cc.MissingRequiredClientCapability,r,t)}get requiredCapabilities(){return this.data.requiredCapabilities}};let cm=["tools/call","prompts/get","resources/read"],cy=["elicitation/create","sampling/createMessage","roots/list"];function cg(){if(l)return l;let t=ca();return l={request:{"elicitation/create":ia({method:i_("elicitation/create"),params:t.ElicitRequestParamsSchema}),"sampling/createMessage":ia({method:i_("sampling/createMessage"),params:t.CreateMessageRequestParamsSchema}),"roots/list":ia({method:i_("roots/list"),params:ii({}).optional()})},response:{"elicitation/create":t.ElicitResultSchema,"sampling/createMessage":t.CreateMessageResultSchema,"roots/list":t.ListRootsResultSchema}}}function cv(t){return cy.includes(t)}function c_(t){return cv(t)?cg().request[t]:void 0}let cb={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},cS={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function cw(t){return Object.prototype.hasOwnProperty.call(cb,t)}function c$(t){return Object.prototype.hasOwnProperty.call(cS,t)}function cE(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function cP(t,r){if(void 0===t)return{ok:!1,reason:"not-in-era"};let o=t.safeParse(r);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}Object.keys(cb),Object.keys(cS);let ck={ok:!1,reason:"not-in-era"},cR=[iL,iV],cx={era:"2026-07-28",hasRequestMethod:cw,hasNotificationMethod:c$,hasInputRequestMethod:t=>void 0!==c_(t),validateRequest:(t,r)=>{var o;return cP(cw(o=t)?ca().dispatchRequestSchemas[o]:void 0,r)},validateResult:(t,r)=>{var o,a;return cP((a=o=t,Object.prototype.hasOwnProperty.call(cb,a))?ca().dispatchResultSchemas[o]:void 0,r)},validateNotification:(t,r)=>{var o;return cP(c$(o=t)?ca().notificationSchemas2026[o]:void 0,r)},validateInputRequest:(t,r)=>cP(c_(t),r),validateInputResponse:(t,r)=>{var o;return cP(cv(o=t)?cg().response[o]:void 0,r)},samplingResultVariant:()=>ck,outboundEnvelope:t=>({[iL]:t.protocolVersion,[iK]:t.clientInfo,[iV]:t.clientCapabilities,...void 0!==t.logLevel&&{[iF]:t.logLevel}}),validateEnvelopeMeta(t){let r=[];for(let o of cR)o in t||r.push({key:o,problem:"missing"});let o=ca().RequestMetaEnvelopeSchema.safeParse(t);if(!o.success)for(let t of o.error.issues){let o=t.path.map(String),a=o.length>0?o.join("."):"_meta";1===o.length&&r.some(t=>t.key===a&&"missing"===t.problem)||r.push({key:a,problem:t.message})}return r},projectCallToolResult:t=>lZ(t),inputRequestSchema:c_,decodeResult(t,r){if(!cE(r))return{kind:"invalid",error:new lL(lD.InvalidResult,`Invalid result for ${t}: not an object`,{method:t})};let o=r.resultType;if(void 0===o)return{kind:"invalid",error:new lL(lD.InvalidResult,`Invalid result for ${t}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:t,violation:"missing-resultType"})};if("string"!=typeof o)return{kind:"invalid",error:new lL(lD.InvalidResult,`Invalid result for ${t}: non-string resultType`,{method:t,resultType:o})};if("input_required"===o){let o=r.inputRequests,a=cE(o)?o:{},i=r.requestState,n=void 0===r._meta?void 0:ca().ResultMetaSchema.safeParse(r._meta),s=n?.success?n.data:void 0;return 0===Object.keys(a).length&&"string"!=typeof i?{kind:"invalid",error:new lL(lD.InvalidResult,`Invalid result for ${t}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:t,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:a,..."string"==typeof i&&{requestState:i},...void 0!==s&&{_meta:s}}}if("complete"!==o)return{kind:"invalid",error:new lL(lD.UnsupportedResultType,`Unsupported result type '${o}' for ${t}`,{resultType:o,method:t})};let a=function(){if(c)return c;let t=ca();return c={"tools/call":t.CallToolResultSchema,"tools/list":t.ListToolsResultSchema,"prompts/get":t.GetPromptResultSchema,"prompts/list":t.ListPromptsResultSchema,"resources/list":t.ListResourcesResultSchema,"resources/templates/list":t.ListResourceTemplatesResultSchema,"resources/read":t.ReadResourceResultSchema,"completion/complete":t.CompleteResultSchema,"server/discover":t.DiscoverResultSchema}}(),i=Object.hasOwn(a,t)?a[t]:void 0;if(void 0!==i){let o=i.safeParse(r);if(!o.success)return{kind:"invalid",error:new lL(lD.InvalidResult,`Invalid result for ${t}: ${o.error}`,{method:t})}}let n={...r};return delete n.resultType,{kind:"complete",result:n}},encodeResult:(t,r,o)=>(function(t,r){var o;if(void 0===r)return t;let a=t._meta;return void 0===a?{...t,_meta:{[iJ]:r}}:null===(o=a)||"object"!=typeof o||Array.isArray(o)||void 0!==a[iJ]?t:{...t,_meta:{...a,[iJ]:r}}})(function(t,r){var o,a,i,n;let s=r[cn];if("complete"!==r.resultType||(o=t,!ci.includes(o))){let t;return void 0===s?r:(t={...a=r},delete t[cn],t)}let l=cs(r.ttlMs)?r.ttlMs:void 0!==(i=s)&&cs(i.ttlMs)?i.ttlMs:0,c=cl(r.cacheScope)?r.cacheScope:void 0!==(n=s)&&cl(n.cacheScope)?n.cacheScope:"private",u={...r,ttlMs:l,cacheScope:c};return delete u[cn],u}(t,function(t,r){let o=r.resultType;if(void 0===o)return{...r,resultType:"complete"};if("complete"===o||cm.includes(t))return r;throw new cu(cc.InternalError,`Handler for ${t} returned resultType '${String(o)}', but results of ${t} only support 'complete' on protocol revision 2026-07-28`)}(t,function(t,r){let o=r,a=!1,i=()=>(a||(o={...o},a=!0),o),n=r.tools;"tools/list"===t&&Array.isArray(n)&&n.some(t=>cE(t)&&"execution"in t)&&(i().tools=n.map(t=>{if(!cE(t)||!("execution"in t))return t;let r={...t};return delete r.execution,r}));let s=r.capabilities;if(cE(s)&&"tasks"in s){let t={...s};delete t.tasks,i().capabilities=t}return o}(t,r))),o),encodeErrorCode:t=>-32002===t?-32602:t,checkInboundEnvelope(t){if(void 0===t.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let r=ca().RequestMetaEnvelopeSchema.safeParse(t.envelope);if(!r.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${r.error.issues.map(t=>t.message).join("; ")}`}},cC="2026-07-28";function cA(t){return void 0!==t&&t>=lV?cx:co}function cT(t){return void 0!==t.revision?cA(t.revision).era:"modern"===t.era?cx.era:co.era}function cO(t){return cN.some(r=>r.hasRequestMethod(t))}function cj(t){return cN.some(r=>r.hasNotificationMethod(t))}function cI(t){return"tasks/get"===t||"tasks/cancel"===t}let cN=[co,cx];var cM=((t,r)=>{let o={};for(var a in t)O(o,a,{get:t[a],enumerable:!0});return r&&O(o,Symbol.toStringTag,{value:"Module"}),o})({AnnotationsSchema:()=>nz,AudioContentSchema:()=>so,BaseMetadataSchema:()=>nd,BaseRequestParamsSchema:()=>i2,BlobResourceContentsSchema:()=>nN,BooleanSchemaSchema:()=>sq,CallToolRequestParamsSchema:()=>sv,CallToolRequestSchema:()=>s_,CallToolResultSchema:()=>sy,CancelTaskRequestSchema:()=>lf,CancelTaskResultSchema:()=>lm,CancelledNotificationParamsSchema:()=>ns,CancelledNotificationSchema:()=>nl,ClientCapabilitiesSchema:()=>ng,ClientNotificationSchema:()=>lg,ClientRequestSchema:()=>ly,ClientResultSchema:()=>lv,ClientTasksCapabilitySchema:()=>nm,CompatibilityCallToolResultSchema:()=>sg,CompleteRequestParamsSchema:()=>s5,CompleteRequestSchema:()=>s3,CompleteResultSchema:()=>s6,ContentBlockSchema:()=>ss,CreateMessageRequestParamsSchema:()=>sI,CreateMessageRequestSchema:()=>sN,CreateMessageResultSchema:()=>sM,CreateMessageResultWithToolsSchema:()=>sz,CreateTaskResultSchema:()=>li,CursorSchema:()=>iY,DiscoverRequestSchema:()=>n$,DiscoverResultSchema:()=>nE,ElicitRequestFormParamsSchema:()=>sG,ElicitRequestParamsSchema:()=>sY,ElicitRequestSchema:()=>sQ,ElicitRequestURLParamsSchema:()=>sX,ElicitResultSchema:()=>s2,ElicitationCompleteNotificationParamsSchema:()=>s0,ElicitationCompleteNotificationSchema:()=>s1,EmbeddedResourceSchema:()=>si,EmptyResultSchema:()=>nn,EnumSchemaSchema:()=>sB,GetPromptRequestParamsSchema:()=>n7,GetPromptRequestSchema:()=>se,GetPromptResultSchema:()=>sc,GetTaskPayloadRequestSchema:()=>lu,GetTaskPayloadResultSchema:()=>ld,GetTaskRequestSchema:()=>ll,GetTaskResultSchema:()=>lc,IconSchema:()=>nc,IconsSchema:()=>nu,ImageContentSchema:()=>sr,ImplementationSchema:()=>np,InitializeRequestParamsSchema:()=>nv,InitializeRequestSchema:()=>n_,InitializeResultSchema:()=>nS,InitializedNotificationSchema:()=>nw,JSONArraySchema:()=>iG,JSONObjectSchema:()=>iZ,JSONRPCErrorResponseSchema:()=>no,JSONRPCMessageSchema:()=>na,JSONRPCNotificationSchema:()=>nt,JSONRPCRequestSchema:()=>ne,JSONRPCResponseSchema:()=>ni,JSONRPCResultResponseSchema:()=>nr,JSONValueSchema:()=>iB,LegacyTitledEnumSchemaSchema:()=>sK,ListChangedOptionsBaseSchema:()=>sS,ListPromptsRequestSchema:()=>n6,ListPromptsResultSchema:()=>n8,ListResourceTemplatesRequestSchema:()=>nL,ListResourceTemplatesResultSchema:()=>nK,ListResourcesRequestSchema:()=>nU,ListResourcesResultSchema:()=>nD,ListRootsRequestSchema:()=>s7,ListRootsResultSchema:()=>le,ListTasksRequestSchema:()=>lp,ListTasksResultSchema:()=>lh,ListToolsRequestSchema:()=>sf,ListToolsResultSchema:()=>sm,LoggingLevelSchema:()=>sw,LoggingMessageNotificationParamsSchema:()=>sP,LoggingMessageNotificationSchema:()=>sk,ModelHintSchema:()=>sR,ModelPreferencesSchema:()=>sx,MultiSelectEnumSchemaSchema:()=>sF,NotificationSchema:()=>i3,NotificationsParamsSchema:()=>i5,NumberSchemaSchema:()=>sU,PaginatedRequestParamsSchema:()=>nC,PaginatedRequestSchema:()=>nA,PaginatedResultSchema:()=>nT,PingRequestSchema:()=>nP,PrimitiveSchemaDefinitionSchema:()=>sZ,ProgressNotificationParamsSchema:()=>nR,ProgressNotificationSchema:()=>nx,ProgressSchema:()=>nk,ProgressTokenSchema:()=>iX,PromptArgumentSchema:()=>n5,PromptListChangedNotificationSchema:()=>su,PromptMessageSchema:()=>sl,PromptReferenceSchema:()=>s4,PromptSchema:()=>n3,ReadResourceRequestParamsSchema:()=>nJ,ReadResourceRequestSchema:()=>nV,ReadResourceResultSchema:()=>nW,RelatedTaskMetadataSchema:()=>i0,RequestIdSchema:()=>i7,RequestMetaSchema:()=>i1,RequestSchema:()=>i4,ResourceContentsSchema:()=>nO,ResourceLinkSchema:()=>sn,ResourceListChangedNotificationSchema:()=>nF,ResourceRequestParamsSchema:()=>nJ,ResourceSchema:()=>nq,ResourceTemplateReferenceSchema:()=>s9,ResourceTemplateSchema:()=>nH,ResourceUpdatedNotificationParamsSchema:()=>n9,ResourceUpdatedNotificationSchema:()=>n4,ResultMetaObjectSchema:()=>i6,ResultSchema:()=>i8,RoleSchema:()=>nM,RootSchema:()=>s8,RootsListChangedNotificationSchema:()=>lt,SamplingContentSchema:()=>sT,SamplingMessageContentBlockSchema:()=>sO,SamplingMessageSchema:()=>sj,ServerCapabilitiesSchema:()=>nb,ServerNotificationSchema:()=>lb,ServerRequestSchema:()=>l_,ServerResultSchema:()=>lS,ServerTasksCapabilitySchema:()=>ny,SetLevelRequestParamsSchema:()=>s$,SetLevelRequestSchema:()=>sE,SingleSelectEnumSchemaSchema:()=>sJ,StringSchemaSchema:()=>sH,SubscribeRequestParamsSchema:()=>nJ,SubscribeRequestSchema:()=>nB,SubscriptionFilterSchema:()=>nG,SubscriptionsAcknowledgedNotificationParamsSchema:()=>nQ,SubscriptionsAcknowledgedNotificationSchema:()=>n0,SubscriptionsListenRequestParamsSchema:()=>nX,SubscriptionsListenRequestSchema:()=>nY,SubscriptionsListenResultMetaSchema:()=>n1,SubscriptionsListenResultSchema:()=>n2,TaskAugmentedRequestParamsSchema:()=>i9,TaskCreationParamsSchema:()=>lr,TaskMetadataSchema:()=>iQ,TaskSchema:()=>la,TaskStatusNotificationParamsSchema:()=>ln,TaskStatusNotificationSchema:()=>ls,TaskStatusSchema:()=>lo,TextContentSchema:()=>st,TextResourceContentsSchema:()=>nj,TitledMultiSelectEnumSchemaSchema:()=>sW,TitledSingleSelectEnumSchemaSchema:()=>sL,ToolAnnotationsSchema:()=>sd,ToolChoiceSchema:()=>sC,ToolExecutionSchema:()=>sp,ToolListChangedNotificationSchema:()=>sb,ToolResultContentSchema:()=>sA,ToolSchema:()=>sh,ToolUseContentSchema:()=>sa,UnsubscribeRequestParamsSchema:()=>nJ,UnsubscribeRequestSchema:()=>nZ,UntitledMultiSelectEnumSchemaSchema:()=>sV,UntitledSingleSelectEnumSchemaSchema:()=>sD});let cz=t=>nr.safeParse(t).success,cq=t=>no.safeParse(t).success,cH=t=>"object"==typeof t&&null!==t&&!Array.isArray(t)&&"input_required"===t.resultType,cU="x-mcp-header",cD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,cL=new Set(["string","integer","boolean","number"]);function cK(t){let r=[],o=new Map,a=(t,i,n)=>{if(null===t||"object"!=typeof t)return;if(cU in t){if(!n||0===i.length)return`${cW(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let a=t[cU];if("string"!=typeof a||0===a.length)return`${cW(i)}: x-mcp-header MUST be a non-empty string`;if(!cD.test(a))return`${cW(i)}: x-mcp-header '${a}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let s="string"==typeof t.type?t.type:void 0;if(void 0===s||!cL.has(s))return`${cW(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${s??"<none>"}`;let l=a.toLowerCase(),c=o.get(l);if(void 0!==c)return`x-mcp-header '${a}' is not case-insensitively unique (also declared as '${c}')`;o.set(l,a),r.push({path:i,headerName:a,type:s})}let s=t.properties;if(null!==s&&"object"==typeof s)for(let[t,r]of Object.entries(s)){let o=a(r,[...i,t],n);if(void 0!==o)return o}for(let r of cJ){let o=t[r];if(void 0!==o)for(let t of Array.isArray(o)?o:null!==o&&"object"==typeof o&&cV.has(r)?Object.values(o):[o]){let o=a(t,[...i,`<${r}>`],!1);if(void 0!==o)return o}}},i=a(t,[],!0);return void 0===i?{valid:!0,declarations:r}:{valid:!1,reason:i}}let cJ=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],cV=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function cW(t){return 0===t.length?"<root>":t.join(".")}let cF="=?base64?";function cB(t){return!function(t){if(0===t.length||t.startsWith(cF)&&t.endsWith("?=")||t!==t.trim())return!0;for(let r=0;r<t.length;r++){let o=t.codePointAt(r);if(9!==o&&(!(o>=32)||!(o<=126)))return!0}return!1}(t)?t:`${cF}${function(t){let r=new TextEncoder().encode(t),o="";for(let t of r)o+=String.fromCodePoint(t);return btoa(o)}(t)}?=`}cc.InvalidRequest,cc.UnsupportedProtocolVersion,cc.InvalidParams,cc.MethodNotFound,cc.InvalidParams,cc.MissingRequiredClientCapability,cc.ParseError,cc.InvalidRequest,cc.MethodNotFound,cc.UnsupportedProtocolVersion,cc.MissingRequiredClientCapability;let cZ={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function cG(t){return new Set(t.flatMap(t=>Object.keys(t.shape)))}function cX(t){if(null==t)return!1;let r=typeof t;return("object"===r||"function"===r)&&"~standard"in t&&"function"==typeof t["~standard"]?.validate}let cY=!1,cQ="draft-2020-12";async function c0(t,r){let o=await t["~standard"].validate(r);return o.issues&&o.issues.length>0?{success:!1,error:o.issues.map(t=>{var r;return r=t,r.path?.length?`${r.path.map(t=>String("object"==typeof t?t.key:t)).join(".")}: ${r.message}`:r.message}).join(", ")}:{success:!0,data:o.value}}let c1=/\\\.\\d\{(\d+)\}/;function c2(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let c9=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function c4(t){return c9.has(t)||t.startsWith("x-")}let c5=new Set(["$schema",...Object.keys(sG.shape.requestedSchema.shape)]),c3={string:cG([sH,sD,sL,sK]),number:cG([sU]),integer:cG([sU]),boolean:cG([sq]),array:cG([sV,sW])},c6=new Set(sH.shape.format.unwrap().options);async function c8(t){let{config:r,method:o,originalParams:a,requestOptions:i,hooks:n,signal:s}=t,l=t.flowStartedAt??Date.now(),c=t.firstPayload,u=0;for(;;){let t;if((u+=1)>r.maxRounds){var d,p;throw new lL(lD.InputRequiredRoundsExceeded,(d=o,p=r.maxRounds,`Multi-round-trip request '${d}' still required input after ${p} rounds (inputRequired.maxRounds)`),{rounds:r.maxRounds,lastResult:{inputRequests:c.inputRequests,...void 0!==c.requestState&&{requestState:c.requestState}}})}i.onprogress?.({progress:u,message:`Fulfilling input required by '${o}' (round ${u})`});let h=Object.entries(c.inputRequests??{});if(h.length>0){let r=function(t){let r=new AbortController,o=()=>r.abort(t?.reason);return t?.addEventListener("abort",o,{once:!0}),t?.aborted&&r.abort(t.reason),{signal:r.signal,abort:t=>r.abort(t),dispose:()=>t?.removeEventListener("abort",o)}}(s);try{let o=await Promise.all(h.map(async([t,o])=>{try{return[t,await n.dispatchInputRequest(t,o,r.signal)]}catch(t){throw r.abort(t),t}}));t=Object.fromEntries(o)}finally{r.dispose()}}else await function(t,r){return new Promise((t,o)=>{if(r?.aborted)return void o(r.reason instanceof lL?r.reason:new lL(lD.RequestTimeout,String(r.reason)));let a=setTimeout(()=>{r?.removeEventListener("abort",i),t()},250),i=()=>{clearTimeout(a),o(r?.reason instanceof lL?r.reason:new lL(lD.RequestTimeout,String(r?.reason)))};r?.addEventListener("abort",i,{once:!0})})}(0,s);let f={...void 0!==i.timeout&&{timeout:i.timeout}};if(void 0!==i.maxTotalTimeout){let t=Date.now()-l,r=i.maxTotalTimeout-t;if(r<=0)throw new lL(lD.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:t});f.maxTotalTimeout=r}let m=await n.retry(function(t,r,o){let a=void 0!==r&&Object.keys(r).length>0;return a||void 0!==o?{...t,...a&&{inputResponses:r},...void 0!==o&&{requestState:o}}:t}(a,t,c.requestState),f);if(cH(m)){c={inputRequests:m.inputRequests??{},...void 0!==m.requestState&&{requestState:m.requestState}};continue}return m}}Object.assign(function(t){let r=void 0!==t.inputRequests&&Object.keys(t.inputRequests).length>0,o="string"==typeof t.requestState;if(!r&&!o)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==t.inputRequests&&{inputRequests:t.inputRequests},...void 0!==t.requestState&&{requestState:t.requestState}}},{elicit(t){try{return{method:"elicitation/create",params:function(t){var r;if(!cX(t.requestedSchema))return{...t,mode:"form",requestedSchema:t.requestedSchema};let o=t.requestedSchema["~standard"].vendor,a=function(t,r){let o={},a=[];for(let[i,n]of Object.entries(t))"properties"===i&&c2(n)?o[i]=Object.fromEntries(Object.entries(n).map(([t,o])=>[t,function(t,r,o,a){if(!c2(t))return t;let i="string"==typeof t.type&&Object.hasOwn(c3,t.type)?c3[t.type]:void 0;if(void 0===i)return t;let n={};for(let[c,u]of Object.entries(t))if(i.has(c)||c4(c))n[c]=u;else if("pattern"===c&&"string"===t.type&&"string"==typeof t.format)if(c6.has(t.format)){var s,l;"string"==typeof u&&(s=t.format,l=u,"zod"!==o||(function(t,r){var o;let a,i,n;switch(t){case"email":a=[rX(aI,void 0)];break;case"uri":a=[rY(az,void 0)];break;case"date":a=[r0(aT,void 0)];break;case"date-time":o=r,i=c1.exec(o),n=[void 0,-1,0],i&&n.push(Number(i[1])),a=[!1,!0].flatMap(t=>[!1,!0].flatMap(r=>n.map(o=>rQ(aA,{local:t,offset:r,precision:o}))))}return new Set(a.map(t=>{let r;return r=o9(t,{target:cQ,io:"input"}),"string"==typeof r.pattern?r.pattern:void 0}).filter(t=>void 0!==t))})(s,l).has(l))||a.push(`${r}.${c}`)}else n[c]=u;else a.push(`${r}.${c}`);return n}(o,`properties.${t}`,r,a)])):c5.has(i)?o[i]=n:c4(i)||a.push(i);if(a.length>0)throw new cu(cc.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);return o}(function(t){try{return function(t,r="input"){let o,a=t["~standard"];if(a.jsonSchema)o=a.jsonSchema[r]({target:cQ});else if("zod"===a.vendor){if(!("_zod"in t))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");cY||(cY=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),o=o9(t,{target:cQ,io:r})}else throw Error(`Schema library "${a.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===r)return void 0!==o.type||!function t(r){if("properties"in r||"patternProperties"in r||"additionalProperties"in r||"required"in r)return!0;for(let o of["oneOf","anyOf","allOf"]){let a=r[o];if(Array.isArray(a)&&a.length>0)return a.every(r=>null!==r&&"object"==typeof r&&("object"===r.type||t(r)))}return!1}(o)?o:{type:"object",...o};if(void 0!==o.type&&"object"!==o.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}(t,"input")}catch(r){let t=r instanceof Error?r.message:String(r);throw new cu(cc.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}(t.requestedSchema),o),i=(r=sG.shape.requestedSchema,ah(r,a));if(!i.success)throw new cu(cc.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(t,r){if(!c2(t.properties))return r;let o=Object.entries(t.properties).filter(([,t])=>!ah(sZ,t).success).map(([t])=>`properties.${t}`);return o.length>0?o.join(", "):r}(a,i.error.message)}`);let n=function t(r,o,a=""){return Array.isArray(r)&&Array.isArray(o)?r.flatMap((r,i)=>t(r,o[i],`${a}[${i}]`)):c2(r)&&c2(o)?Object.entries(r).flatMap(([r,i])=>{let n=a?`${a}.${r}`:r;return Object.prototype.hasOwnProperty.call(o,r)?t(i,o[r],n):c4(r)?[]:[n]}):[]}(a,i.data);if(n.length>0)throw new cu(cc.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let s=(i.data.required??[]).filter(t=>!Object.prototype.hasOwnProperty.call(i.data.properties,t));if(s.length>0)throw new cu(cc.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...t,mode:"form",requestedSchema:i.data}}(t)}}catch(t){throw t instanceof cu?TypeError(t.message,{cause:t}):t}},elicitUrl:t=>({method:"elicitation/create",params:{...t,mode:"url"}}),createMessage:t=>({method:"sampling/createMessage",params:t}),listRoots:()=>({method:"roots/list"})});let c7={},ue={};function ut(t,r){let o=t.slice(0,-6);c7[o]=r,ue[o]=t=>r.safeParse(t).success}for(let t of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])ut(t,cM[t]);for(let[t,r]of Object.entries({IdJagTokenExchangeResponseSchema:lx,OAuthClientInformationFullSchema:lj,OAuthClientInformationSchema:lO,OAuthClientMetadataSchema:lT,OAuthClientRegistrationErrorSchema:lI,OAuthErrorResponseSchema:lC,OAuthMetadataSchema:lE,OAuthProtectedResourceMetadataSchema:l$,OAuthTokenRevocationRequestSchema:lN,OAuthTokensSchema:lR,OpenIdProviderDiscoveryMetadataSchema:lk,OpenIdProviderMetadataSchema:lP}))ut(t,r);Object.freeze(c7);let ur=Object.freeze(ue),uo=[iL,iK,iV,iF],ua=["inputResponses","requestState"];function ui(t,r){let o=t.params;if(!uc(o))return{message:t,lifted:{}};let a=o._meta,i=uc(a)?uo.filter(t=>t in a):[],n="request"===r?ua.filter(t=>t in o):[];if(0===i.length&&0===n.length)return{message:t,lifted:{}};let s={},l={...o};if(i.length>0&&uc(a)){let t={},r={...a};for(let o of i)t[o]=a[o],delete r[o];s.envelope=t,Object.keys(r).length>0?l._meta=r:delete l._meta}for(let t of n)"inputResponses"===t&&(s.inputResponses=l[t]),"requestState"===t&&(s.requestState=l[t]),delete l[t];return{message:{...t,params:l},lifted:s}}function un(t,r){let o=t.validateResult(r,void 0);if(o.ok||"not-in-era"!==o.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let a=t.validateResult(r,o);return a.ok?{value:a.value}:{issues:[{message:"invalid"===a.reason?a.message:`not-in-era: ${r}`}]}}}}}let us=(R=void 0,()=>R);var ul=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(t){this._options=t,this._supportedProtocolVersions=t?.supportedProtocolVersions??iD,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(t){}_outboundMetaEnvelope(){}_envelopeOutbound(t){let r=this._outboundMetaEnvelope();if(void 0===r)return t;let o=t.params??{};return{...t,params:{...o,_meta:{...r,...o._meta}}}}_resolveNonCompleteResult(t,r){return Promise.reject(new lL(lD.UnsupportedResultType,`Unsupported result type '${t.kind}' for ${r.request.method}`,{resultType:t.kind,method:r.request.method}))}_getRequestHandler(t){return this._requestHandlers.get(t)}async _oncancel(t){void 0!==t.params.requestId&&this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,o,a,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(a,r),startTime:Date.now(),timeout:r,maxTotalTimeout:o,resetTimeoutOnProgress:i,onTimeout:a})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let o=Date.now()-r.startTime;if(r.maxTotalTimeout&&o>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),new lL(lD.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:o});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{try{r?.()}finally{this._onclose()}};let o=this.transport?.onerror;this._transport.onerror=t=>{o?.(t),this._onerror(t)};let a=this._transport?.onmessage;this._transport.onmessage=(t,r)=>{if(a?.(t,r),cz(t)||cq(t))this._onresponse(t);else{let o;if(o=t,ne.safeParse(o).success)this._onrequest(t,r);else{let o;(o=t,nt.safeParse(o).success)?this._onnotification(t,r):this._onerror(Error(`Unknown message type: ${JSON.stringify(t)}`))}}},t.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let t=this._responseHandlers;for(let t of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(t.timeoutId);this._timeoutInfo.clear();let r=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new lL(lD.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of t.values())r(o);for(let t of r.values())t.abort(o)}}_onerror(t){this.onerror?.(t)}_onnotification(t,r){let{message:o}=ui(t,"notification"),a=this._negotiatedWireCodec();if(r?.classification===void 0&&"drop"===this._shouldDropInbound(t))return;if(r?.classification!==void 0){let t=cT(r.classification);if(t!==a.era)return void this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${t} but this instance serves ${a.era}`))}if(cj(o.method)&&!a.hasNotificationMethod(o.method))return;let i=this._notificationHandlers.get(o.method),n=this.fallbackNotificationHandler;(void 0!==i||void 0!==n)&&Promise.resolve().then(()=>void 0===i?n(o):i(o,a)).catch(t=>this._onerror(Error(`Uncaught error in notification handler: ${t}`)))}_onrequest(t,r){var o;let{message:a,lifted:i}=ui(t,"request"),n=this._negotiatedWireCodec();if(r?.classification===void 0&&"drop"===this._shouldDropInbound(t))return void this._onerror(Error(`Dropped inbound request '${t.method}': not servable on this connection's protocol era`));let s=this._transport,l=(t,r,o)=>{let i={jsonrpc:"2.0",id:a.id,error:{code:t,message:r,...void 0!==o&&{data:o}}};s?.send(i).catch(t=>this._onerror(Error(`Failed to send an error response: ${t}`)))};if(r?.classification!==void 0){let t=cT(r.classification);if(t!==n.era){this._onerror(Error(`Era mismatch on inbound request '${a.method}': classified as ${t} but this instance serves ${n.era}`));let o=r.classification.revision??t;l(cc.UnsupportedProtocolVersion,`Unsupported protocol version: ${o}`,{supported:this._supportedProtocolVersions,requested:o});return}}if(cO(a.method)&&!n.hasRequestMethod(a.method)&&!(cI(a.method)&&this._customSchemaRequestMethods.has(a.method)))return void l(cc.MethodNotFound,"Method not found");let c=this._requestHandlers.get(a.method)??this.fallbackRequestHandler;if(void 0===c)return void l(cc.MethodNotFound,"Method not found");let u=n.checkInboundEnvelope(i);if(void 0!==u)return void l(cc.InvalidParams,u);let d=(t,r)=>this._notificationViaCodec(this._resolveOutboundCodec(t.method),t,{...r,relatedRequestId:a.id}),p=(t,r,o)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(t.method),t,r,{...o,relatedRequestId:a.id}),h=new AbortController;this._requestHandlerAbortControllers.set(a.id,h);let f=void 0===i.inputResponses?void 0:function(t){let r={},o=[];if(!uu(t))return{accepted:r,droppedKeys:o};for(let[a,i]of Object.entries(t)){if(!uu(i)||"method"in i||"result"in i){o.push(a);continue}r[a]=i}return{accepted:r,droppedKeys:o}}(i.inputResponses),m={sessionId:s?.sessionId,mcpReq:{id:a.id,method:a.method,_meta:a.params?._meta,...void 0!==i.envelope&&{envelope:i.envelope},...void 0!==f&&{inputResponses:f.accepted},...void 0!==f&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:void 0===i.requestState?us:(o=i.requestState,()=>o),signal:h.signal,send:(t,r,o)=>{let a=this._resolveOutboundCodec(t.method);if(this._assertOutboundRequestInEra(a,t.method),cX(r))return p(t,r,o);let i=un(a,t.method);if(void 0===i)throw TypeError(`'${t.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return p(t,i,r)},notify:d},http:r?.authInfo?{authInfo:r.authInfo}:void 0},y=this.buildContext(m,r);Promise.resolve().then(()=>c(a,y)).then(async t=>{let r;if(h.signal.aborted)return;try{r=n.encodeResult(a.method,t,this._outboundServerInfo())}catch(t){this._onerror(Error(`Failed to encode result for ${a.method}: ${t}`)),l(cc.InternalError,"Internal error");return}let o={result:r,jsonrpc:"2.0",id:a.id};await s?.send(o)},async t=>{if(h.signal.aborted)return;let r=Number.isSafeInteger(t.code)?t.code:cc.InternalError,o={jsonrpc:"2.0",id:a.id,error:{code:n.encodeErrorCode(r),message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};await s?.send(o)}).catch(t=>this._onerror(Error(`Failed to send response: ${t}`))).finally(()=>{this._requestHandlerAbortControllers.get(a.id)===h&&this._requestHandlerAbortControllers.delete(a.id)})}_onprogress(t){let{progressToken:r,...o}=t.params,a=Number(r),i=this._progressHandlers.get(a);if(!i)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));let n=this._responseHandlers.get(a),s=this._timeoutInfo.get(a);if(s&&n&&s.resetTimeoutOnProgress)try{this._resetTimeout(a)}catch(t){this._responseHandlers.delete(a),this._progressHandlers.delete(a),this._cleanupTimeout(a),n(t);return}i(o)}_onresponse(t){let r=Number(t.id),o=this._responseHandlers.get(r);void 0===o?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`)):(this._responseHandlers.delete(r),this._cleanupTimeout(r),this._progressHandlers.delete(r),o(cz(t)?t:cu.fromError(t.error.code,t.error.message,t.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(t,r,o){let a=this._resolveOutboundCodec(t.method);if(cX(r))return cI(t.method)||this._assertOutboundRequestInEra(a,t.method),this._requestWithSchemaViaCodec(a,t,r,o);this._assertOutboundRequestInEra(a,t.method);let i=un(a,t.method);if(void 0===i)throw TypeError(`'${t.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(a,t,i,r)}_negotiatedWireCodec(){return cA(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(t){if(void 0===this._negotiatedProtocolVersion){let r=function(t){switch(t){case"initialize":case"notifications/initialized":return cA(void 0);case"server/discover":return cA(cC);default:return}}(t);if(r)return r}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(t,r){if(cO(r)&&!t.hasRequestMethod(r))throw new lL(lD.MethodNotSupportedByProtocolVersion,`Method '${r}' is not supported by the negotiated protocol version (wire era ${t.era})`,{method:r,era:t.era})}_requestWithSchema(t,r,o){let a=this._resolveOutboundCodec(t.method);return this._assertOutboundRequestInEra(a,t.method),this._requestWithSchemaViaCodec(a,t,r,o)}_requestWithSchemaViaCodec(t,r,o,a){let i,n,{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c,headers:u}=a??{},d=Date.now();return new Promise((p,h)=>{let f=t=>{h(t)};if(!this._transport)return void f(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(r.method)}catch(t){f(t);return}if(a?.signal?.aborted){let t=a.signal.reason;throw t instanceof lL?t:new lL(lD.RequestTimeout,String(t))}let m=t.era===cC&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,y=this._requestMessageId++;n=y;let g={...r,jsonrpc:"2.0",id:y};a?.onprogress&&(this._progressHandlers.set(y,a.onprogress),g.params={...r.params,_meta:{...r.params?._meta,progressToken:y}});let v=this._envelopeOutbound(g),_=!1,b=t=>{_||(this._progressHandlers.delete(y),void 0===m?"initialize"!==r.method&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(t)}}),{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c}).catch(t=>this._onerror(Error(`Failed to send cancellation: ${t}`))):m.abort(),h(t instanceof lL?t:new lL(lD.RequestTimeout,String(t))))};this._responseHandlers.set(y,i=>{let n;if(!a?.signal?.aborted){if(_=!0,i instanceof Error)return h(i);try{n=t.decodeResult(r.method,i.result)}catch(t){return h(t instanceof Error?t:Error(String(t)))}if("invalid"===n.kind)return h(n.error);if("input_required"===n.kind){var s;return a?.allowInputRequired===!0?p({resultType:"input_required",inputRequests:(s=n).inputRequests,...void 0!==s.requestState&&{requestState:s.requestState},...void 0!==s._meta&&{_meta:s._meta}}):p(this._resolveNonCompleteResult(n,{codec:t,request:r,resultSchema:o,options:a,flowStartedAt:d,retry:(a,i)=>this._requestWithSchemaViaCodec(t,void 0===a?{method:r.method}:{method:r.method,params:a},o,i)}))}c0(o,n.result).then(t=>{t.success?p(t.data):h(new lL(lD.InvalidResult,`Invalid result for ${r.method}: ${t.error}`))},h)}}),i=()=>b(a?.signal?.reason),a?.signal?.addEventListener("abort",i,{once:!0});let S=a?.timeout??6e4;this._setupTimeout(y,S,a?.maxTotalTimeout,()=>b(new lL(lD.RequestTimeout,"Request timed out",{timeout:S})),a?.resetTimeoutOnProgress??!1),this._transport.send(v,{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c,headers:u,requestSignal:m?.signal}).catch(t=>{this._progressHandlers.delete(y),h(t)})}).finally(()=>{i&&a?.signal?.removeEventListener("abort",i),void 0!==n&&(this._responseHandlers.delete(n),this._cleanupTimeout(n))})}async notification(t,r){return await this._notificationViaCodec(this._resolveOutboundCodec(t.method),t,r)}async _notificationViaCodec(t,r,o){if(!this._transport)throw new lL(lD.NotConnected,"Not connected");if(cj(r.method)&&!t.hasNotificationMethod(r.method))throw new lL(lD.MethodNotSupportedByProtocolVersion,`Notification '${r.method}' is not supported by the negotiated protocol version (wire era ${t.era})`,{method:r.method,era:t.era});this.assertNotificationCapability(r.method);let a=this._envelopeOutbound({jsonrpc:"2.0",...r});if((this._options?.debouncedNotificationMethods??[]).includes(r.method)&&!r.params&&o?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(r.method))return;this._pendingDebouncedNotifications.add(r.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(r.method),this._transport&&this._transport?.send(a,o).catch(t=>this._onerror(t))});return}await this._transport.send(a,o)}setRequestHandler(t,r,o){let a;if(this.assertRequestHandlerCapability(t),"function"==typeof r){if(!cO(t))throw TypeError(`'${t}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);a=(o,a)=>{let i=this._negotiatedWireCodec(),n=i.validateRequest(t,o);if(n.ok||"not-in-era"!==n.reason||(n=i.validateInputRequest(t,o)),!n.ok){if("not-in-era"===n.reason)throw new cu(cc.InternalError,`No wire schema for ${t} in the resolved era`);throw Error(n.message)}return Promise.resolve(r(n.value,a))}}else if(o)a=async(a,i)=>{let n=await c0(r.params,{...a.params});if(!n.success)throw new cu(cc.InvalidParams,`Invalid params for ${t}: ${n.error}`);return o(n.data,i)};else throw TypeError("setRequestHandler: handler is required");"function"==typeof r?this._customSchemaRequestMethods.delete(t):this._customSchemaRequestMethods.add(t),this._requestHandlers.set(t,this._wrapHandler(t,a))}_wrapHandler(t,r){return r}_outboundServerInfo(){}removeRequestHandler(t){this._requestHandlers.delete(t),this._customSchemaRequestMethods.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r,o){if("function"==typeof r){if(!cj(t))throw TypeError(`'${t}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(t,(o,a)=>{let i=a.validateNotification(t,o);if(!i.ok){if("not-in-era"===i.reason)throw new cu(cc.InternalError,`No wire schema for ${t} in the resolved era`);throw Error(i.message)}return Promise.resolve(r(i.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(t,async a=>{let i=await c0(r.params,{...a.params});if(!i.success)throw new cu(cc.InvalidParams,`Invalid params for notification ${t}: ${i.error}`);await o(i.data,a)})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}};function uc(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function uu(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ud(t){throw new lL(lD.SendFailed,`ctx.mcpReq.${t} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}async function up(t,r,o,a,i){var n,s,l,c,u;if(!uu(a)||"string"!=typeof a.method)throw new lL(lD.InvalidResult,`Invalid input request '${o}': each inputRequests entry must be an embedded request object with a method`,{key:o});let d=a.method;if(!r.hasInputRequestMethod(d))throw new lL(lD.InvalidResult,`Invalid input request '${o}': '${d}' is not an embedded request the ${r.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:o,method:d});let p=t.getRequestHandler(d);if(void 0===p)throw new lL(lD.CapabilityNotSupported,`Cannot fulfil input request '${o}': no handler is registered for '${d}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:o,method:d});let h=uu(a.params)?a.params:void 0;return await p({jsonrpc:"2.0",id:o,method:d,...void 0!==h&&{params:h}},t.buildContext((n=o,s=d,l=h,c=i,{sessionId:t.sessionId,mcpReq:{id:n,method:s,_meta:l?._meta,requestState:(u=void 0,()=>u),signal:c,send:()=>ud("send"),notify:()=>ud("notify")}})))}var uh=q(z(t=>{var r=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,a=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function i(t){this.parameters=Object.create(null),this.type=t}t.parse=function(t){if(!t)throw TypeError("argument string is required");var n,s,l,c="object"==typeof t?function(t){var r;if("function"==typeof t.getHeader?r=t.getHeader("content-type"):"object"==typeof t.headers&&(r=t.headers&&t.headers["content-type"]),"string"!=typeof r)throw TypeError("content-type header is missing from object");return r}(t):t;if("string"!=typeof c)throw TypeError("argument string is required to be a string");var u=c.indexOf(";"),d=-1!==u?c.slice(0,u).trim():c.trim();if(!a.test(d))throw TypeError("invalid media type");var p=new i(d.toLowerCase());if(-1!==u){for(r.lastIndex=u;s=r.exec(c);){if(s.index!==u)throw TypeError("invalid parameter format");u+=s[0].length,n=s[1].toLowerCase(),34===(l=s[2]).charCodeAt(0)&&-1!==(l=l.slice(1,-1)).indexOf("\\")&&(l=l.replace(o,"$1")),p.parameters[n]=l}if(u!==c.length)throw TypeError("invalid parameter format")}return p}})(),1),uf=class{_buffer;_maxBufferSize;constructor(t){this._maxBufferSize=t?.maxBufferSize??0xa00000}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){for(;this._buffer;){let r=this._buffer.indexOf("\n");if(-1===r)break;let o=this._buffer.toString("utf8",0,r).replace(/\r$/,"");this._buffer=this._buffer.subarray(r+1);try{var t;return t=o,na.parse(JSON.parse(t))}catch(t){if(t instanceof SyntaxError)continue;throw t}}return null}clear(){this._buffer=void 0}};function um(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}let uy=new Set([301,302,303,307,308]);function ug(t,r){let o=uy.has(r.status)?r.headers?.get("location"):void 0;if(o)try{return new URL(o,t)}catch{return}}let uv=new WeakSet;function u_(t){return uv.has(t)?t:async(r,o)=>{if(o?.redirect==="error"||o?.redirect==="manual")return t(r,o);let a=(o?.method??"GET").toUpperCase(),i=r;for(let r=0;;r++){var n,s;let l=await t(i,{...o,redirect:"manual"}),c=ug(i,l);if(!c||5===r)return l;let u=new URL(i),d="GET"===a||307===l.status||308===l.status,p=!(c.username||c.password)||c.username===u.username&&c.password===u.password;if(!d||!p||(n=u,s=c,(n.protocol!==s.protocol||n.host!==s.host)&&("http:"!==n.protocol||"https:"!==s.protocol||n.hostname!==s.hostname||n.port||s.port)))return l;await l.text?.().catch(()=>{}),i=c}}}var ub=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;var r=class{};t._CodeOrName=r,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var o=class extends r{constructor(r){if(super(),!t.IDENTIFIER.test(r))throw Error("CodeGen: name must be a valid identifier");this.str=r}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};t.Name=o;var a=class extends r{constructor(t){super(),this._items="string"==typeof t?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return""===t||'""'===t}get str(){var t;return null!=(t=this._str)?t:this._str=this._items.reduce((t,r)=>`${t}${r}`,"")}get names(){var t;return null!=(t=this._names)?t:this._names=this._items.reduce((t,r)=>(r instanceof o&&(t[r.str]=(t[r.str]||0)+1),t),{})}};function i(t,...r){let o=[t[0]],n=0;for(;n<r.length;)l(o,r[n]),o.push(t[++n]);return new a(o)}t._Code=a,t.nil=new a(""),t._=i;let n=new a("+");function s(t,...r){let i=[c(t[0])],u=0;for(;u<r.length;)i.push(n),l(i,r[u]),i.push(n,c(t[++u]));return function(t){let r=1;for(;r<t.length-1;){if(t[r]===n){var a,i;let n=(a=t[r-1],'""'===(i=t[r+1])?a:'""'===a?i:"string"==typeof a?i instanceof o||'"'!==a[a.length-1]?void 0:"string"!=typeof i?`${a.slice(0,-1)}${i}"`:'"'===i[0]?a.slice(0,-1)+i.slice(1):void 0:"string"!=typeof i||'"'!==i[0]||a instanceof o?void 0:`"${a}${i.slice(1)}`);if(void 0!==n){t.splice(r-1,3,n);continue}t[r++]="+"}r++}}(i),new a(i)}function l(t,r){var i;r instanceof a?t.push(...r._items):r instanceof o?t.push(r):t.push("number"==typeof(i=r)||"boolean"==typeof i||null===i?i:c(Array.isArray(i)?i.join(","):i))}function c(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.str=s,t.addCodeArg=l,t.strConcat=function(t,r){return r.emptyStr()?t:t.emptyStr()?r:s`${t}${r}`},t.stringify=function(t){return new a(c(t))},t.safeStringify=c,t.getProperty=function(r){return"string"==typeof r&&t.IDENTIFIER.test(r)?new a(`.${r}`):i`[${r}]`},t.getEsmExportName=function(r){if("string"==typeof r&&t.IDENTIFIER.test(r))return new a(`${r}`);throw Error(`CodeGen: invalid export name: ${r}, use explicit $id name mapping`)},t.regexpCode=function(t){return new a(t.toString())}}),uS=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;let r=ub();var o,a,i=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}};(o=a||(t.UsedValueState=a={}))[o.Started=0]="Started",o[o.Completed=1]="Completed",t.varKinds={const:new r.Name("const"),let:new r.Name("let"),var:new r.Name("var")};var n=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof r.Name?t:this.name(t)}name(t){return new r.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,o;if((null==(o=null==(r=this._parent)?void 0:r._prefixes)?void 0:o.has(t))||this._prefixes&&!this._prefixes.has(t))throw Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};t.Scope=n;var s=class extends r.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:o,itemIndex:a}){this.value=t,this.scopePath=(0,r._)`.${new r.Name(o)}[${a}]`}};t.ValueScopeName=s;let l=(0,r._)`\n`;var c=class extends n{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?l:r.nil}}get(){return this._scope}name(t){return new s(t,this._newName(t))}value(t,r){var o;if(void 0===r.ref)throw Error("CodeGen: ref must be passed in value");let a=this.toName(t),{prefix:i}=a,n=null!=(o=r.key)?o:r.ref,s=this._values[i];if(s){let t=s.get(n);if(t)return t}else s=this._values[i]=new Map;s.set(n,a);let l=this._scope[i]||(this._scope[i]=[]),c=l.length;return l[c]=r.ref,a.setValue(r,{property:i,itemIndex:c}),a}getValue(t,r){let o=this._values[t];if(o)return o.get(r)}scopeRefs(t,o=this._values){return this._reduceValues(o,o=>{if(void 0===o.scopePath)throw Error(`CodeGen: name "${o}" has no value`);return(0,r._)`${t}${o.scopePath}`})}scopeCode(t=this._values,r,o){return this._reduceValues(t,t=>{if(void 0===t.value)throw Error(`CodeGen: name "${t}" has no value`);return t.value.code},r,o)}_reduceValues(o,n,s={},l){let c=r.nil;for(let u in o){let d=o[u];if(!d)continue;let p=s[u]=s[u]||new Map;d.forEach(o=>{if(p.has(o))return;p.set(o,a.Started);let s=n(o);if(s){let a=this.opts.es5?t.varKinds.var:t.varKinds.const;c=(0,r._)`${c}${a} ${o} = ${s};${this.opts._n}`}else if(s=null==l?void 0:l(o))c=(0,r._)`${c}${s}${this.opts._n}`;else throw new i(o);p.set(o,a.Completed)})}return c}};t.ValueScope=c}),uw=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;let r=ub(),o=uS();var a=ub();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return a._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return a.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return a.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return a.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return a.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return a.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return a.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return a.Name}});var i=uS();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),t.operators={GT:new r._Code(">"),GTE:new r._Code(">="),LT:new r._Code("<"),LTE:new r._Code("<="),EQ:new r._Code("==="),NEQ:new r._Code("!=="),NOT:new r._Code("!"),OR:new r._Code("||"),AND:new r._Code("&&"),ADD:new r._Code("+")};var n=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},s=class extends n{constructor(t,r,o){super(),this.varKind=t,this.name=r,this.rhs=o}render({es5:t,_n:r}){let a=t?o.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${a} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=T(this.rhs,t,r)),this}get names(){return this.rhs instanceof r._CodeOrName?this.rhs.names:{}}},l=class extends n{constructor(t,r,o){super(),this.lhs=t,this.rhs=r,this.sideEffects=o}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,o){if(!(this.lhs instanceof r.Name)||t[this.lhs.str]||this.sideEffects)return this.rhs=T(this.rhs,t,o),this}get names(){return A(this.lhs instanceof r.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends l{constructor(t,r,o,a){super(t,o,a),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},u=class extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},d=class extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},p=class extends n{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},h=class extends n{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=T(this.code,t,r),this}get names(){return this.code instanceof r._CodeOrName?this.code.names:{}}},f=class extends n{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,o)=>r+o.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let o=t[r].optimizeNodes();Array.isArray(o)?t.splice(r,1,...o):o?t[r]=o:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:o}=this,a=o.length;for(;a--;){let i=o[a];i.optimizeNames(t,r)||(function(t,r){for(let o in r)t[o]=(t[o]||0)-(r[o]||0)}(t,i.names),o.splice(a,1))}return o.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>C(t,r.names),{})}},m=class extends f{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},y=class extends f{},g=class extends m{};g.kind="else";var v=class t extends m{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let r=this.condition;if(!0===r)return this.nodes;let o=this.else;if(o){let t=o.optimizeNodes();o=this.else=Array.isArray(t)?new g(t):t}return o?!1===r?o instanceof t?o:o.nodes:this.nodes.length?this:new t(O(r),o instanceof t?[o]:o.nodes):!1!==r&&this.nodes.length?this:void 0}optimizeNames(t,r){var o;if(this.else=null==(o=this.else)?void 0:o.optimizeNames(t,r),super.optimizeNames(t,r)||this.else)return this.condition=T(this.condition,t,r),this}get names(){let t=super.names;return A(t,this.condition),this.else&&C(t,this.else.names),t}};v.kind="if";var _=class extends m{};_.kind="for";var b=class extends _{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=T(this.iteration,t,r),this}get names(){return C(super.names,this.iteration.names)}},S=class extends _{constructor(t,r,o,a){super(),this.varKind=t,this.name=r,this.from=o,this.to=a}render(t){let r=t.es5?o.varKinds.var:this.varKind,{name:a,from:i,to:n}=this;return`for(${r} ${a}=${i}; ${a}<${n}; ${a}++)`+super.render(t)}get names(){return A(A(super.names,this.from),this.to)}},w=class extends _{constructor(t,r,o,a){super(),this.loop=t,this.varKind=r,this.name=o,this.iterable=a}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=T(this.iterable,t,r),this}get names(){return C(super.names,this.iterable.names)}},$=class extends m{constructor(t,r,o){super(),this.name=t,this.args=r,this.async=o}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};$.kind="func";var E=class extends f{render(t){return"return "+super.render(t)}};E.kind="return";var P=class extends m{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),null==(t=this.catch)||t.optimizeNodes(),null==(r=this.finally)||r.optimizeNodes(),this}optimizeNames(t,r){var o,a;return super.optimizeNames(t,r),null==(o=this.catch)||o.optimizeNames(t,r),null==(a=this.finally)||a.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&C(t,this.catch.names),this.finally&&C(t,this.finally.names),t}},k=class extends m{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};k.kind="catch";var R=class extends m{render(t){return"finally"+super.render(t)}};R.kind="finally";var x=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?"\n":""},this._extScope=t,this._scope=new o.Scope({parent:t}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let o=this._extScope.value(t,r);return(this._values[o.prefix]||(this._values[o.prefix]=new Set)).add(o),o}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,o,a){let i=this._scope.toName(r);return void 0!==o&&a&&(this._constants[i.str]=o),this._leafNode(new s(t,i,o)),i}const(t,r,a){return this._def(o.varKinds.const,t,r,a)}let(t,r,a){return this._def(o.varKinds.let,t,r,a)}var(t,r,a){return this._def(o.varKinds.var,t,r,a)}assign(t,r,o){return this._leafNode(new l(t,r,o))}add(r,o){return this._leafNode(new c(r,t.operators.ADD,o))}code(t){return"function"==typeof t?t():t!==r.nil&&this._leafNode(new h(t)),this}object(...t){let o=["{"];for(let[a,i]of t)o.length>1&&o.push(","),o.push(a),(a!==i||this.opts.es5)&&(o.push(":"),(0,r.addCodeArg)(o,i));return o.push("}"),new r._Code(o)}if(t,r,o){if(this._blockNode(new v(t)),r&&o)this.code(r).else().code(o).endIf();else if(r)this.code(r).endIf();else if(o)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new v(t))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(v,g)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new b(t),r)}forRange(t,r,a,i,n=this.opts.es5?o.varKinds.var:o.varKinds.let){let s=this._scope.toName(t);return this._for(new S(n,s,r,a),()=>i(s))}forOf(t,a,i,n=o.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let t=a instanceof r.Name?a:this.var("_arr",a);return this.forRange("_i",0,(0,r._)`${t}.length`,o=>{this.var(s,(0,r._)`${t}[${o}]`),i(s)})}return this._for(new w("of",n,s,a),()=>i(s))}forIn(t,a,i,n=this.opts.es5?o.varKinds.var:o.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,r._)`Object.keys(${a})`,i);let s=this._scope.toName(t);return this._for(new w("in",n,s,a),()=>i(s))}endFor(){return this._endBlockNode(_)}label(t){return this._leafNode(new u(t))}break(t){return this._leafNode(new d(t))}return(t){let r=new E;if(this._blockNode(r),this.code(t),1!==r.nodes.length)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(t,r,o){if(!r&&!o)throw Error('CodeGen: "try" without "catch" and "finally"');let a=new P;if(this._blockNode(a),this.code(t),r){let t=this.name("e");this._currNode=a.catch=new k(t),r(t)}return o&&(this._currNode=a.finally=new R,this.code(o)),this._endBlockNode(k,R)}throw(t){return this._leafNode(new p(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(void 0===r)throw Error("CodeGen: not in self-balancing block");let o=this._nodes.length-r;if(o<0||void 0!==t&&o!==t)throw Error(`CodeGen: wrong number of nodes: ${o} vs ${t} expected`);return this._nodes.length=r,this}func(t,o=r.nil,a,i){return this._blockNode(new $(t,o,a)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode($)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let o=this._currNode;if(o instanceof t||r&&o instanceof r)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof v))throw Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};function C(t,r){for(let o in r)t[o]=(t[o]||0)+(r[o]||0);return t}function A(t,o){return o instanceof r._CodeOrName?C(t,o.names):t}function T(t,o,a){var i;if(t instanceof r.Name)return n(t);if(!((i=t)instanceof r._Code&&i._items.some(t=>t instanceof r.Name&&1===o[t.str]&&void 0!==a[t.str])))return t;return new r._Code(t._items.reduce((t,o)=>(o instanceof r.Name&&(o=n(o)),o instanceof r._Code?t.push(...o._items):t.push(o),t),[]));function n(t){let r=a[t.str];return void 0===r||1!==o[t.str]?t:(delete o[t.str],r)}}function O(t){return"boolean"==typeof t||"number"==typeof t||null===t?!t:(0,r._)`!${M(t)}`}t.CodeGen=x,t.not=O;let j=N(t.operators.AND);t.and=function(...t){return t.reduce(j)};let I=N(t.operators.OR);function N(t){return(o,a)=>o===r.nil?a:a===r.nil?o:(0,r._)`${M(o)} ${t} ${M(a)}`}function M(t){return t instanceof r.Name?t:(0,r._)`(${t})`}t.or=function(...t){return t.reduce(I)}}),u$=z(t=>{var r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.checkStrictMode=t.getErrorPath=t.Type=t.useFunc=t.setEvaluated=t.evaluatedPropsToName=t.mergeEvaluated=t.eachItem=t.unescapeJsonPointer=t.escapeJsonPointer=t.escapeFragment=t.unescapeFragment=t.schemaRefOrVal=t.schemaHasRulesButRef=t.schemaHasRules=t.checkUnknownRules=t.alwaysValidSchema=t.toHash=void 0;let a=uw(),i=ub();function n(t,r=t.schema){let{opts:o,self:a}=t;if(!o.strictSchema||"boolean"==typeof r)return;let i=a.RULES.keywords;for(let o in r)i[o]||f(t,`unknown keyword: "${o}"`)}function s(t,r){if("boolean"==typeof t)return!t;for(let o in t)if(r[o])return!0;return!1}function l(t){return"number"==typeof t?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}function c(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function u({mergeNames:t,mergeToName:r,mergeValues:o,resultToName:i}){return(n,s,l,c)=>{let u=void 0===l?s:l instanceof a.Name?(s instanceof a.Name?t(n,s,l):r(n,s,l),l):s instanceof a.Name?(r(n,l,s),s):o(s,l);return c!==a.Name||u instanceof a.Name?u:i(n,u)}}function d(t,r){if(!0===r)return t.var("props",!0);let o=t.var("props",(0,a._)`{}`);return void 0!==r&&p(t,o,r),o}function p(t,r,o){Object.keys(o).forEach(o=>t.assign((0,a._)`${r}${(0,a.getProperty)(o)}`,!0))}t.toHash=function(t){let r={};for(let o of t)r[o]=!0;return r},t.alwaysValidSchema=function(t,r){return"boolean"==typeof r?r:0===Object.keys(r).length||(n(t,r),!s(r,t.self.RULES.all))},t.checkUnknownRules=n,t.schemaHasRules=s,t.schemaHasRulesButRef=function(t,r){if("boolean"==typeof t)return!t;for(let o in t)if("$ref"!==o&&r.all[o])return!0;return!1},t.schemaRefOrVal=function({topSchemaRef:t,schemaPath:r},o,i,n){if(!n){if("number"==typeof o||"boolean"==typeof o)return o;if("string"==typeof o)return(0,a._)`${o}`}return(0,a._)`${t}${r}${(0,a.getProperty)(i)}`},t.unescapeFragment=function(t){return c(decodeURIComponent(t))},t.escapeFragment=function(t){return encodeURIComponent(l(t))},t.escapeJsonPointer=l,t.unescapeJsonPointer=c,t.eachItem=function(t,r){if(Array.isArray(t))for(let o of t)r(o);else r(t)},t.mergeEvaluated={props:u({mergeNames:(t,r,o)=>t.if((0,a._)`${o} !== true && ${r} !== undefined`,()=>{t.if((0,a._)`${r} === true`,()=>t.assign(o,!0),()=>t.assign(o,(0,a._)`${o} || {}`).code((0,a._)`Object.assign(${o}, ${r})`))}),mergeToName:(t,r,o)=>t.if((0,a._)`${o} !== true`,()=>{!0===r?t.assign(o,!0):(t.assign(o,(0,a._)`${o} || {}`),p(t,o,r))}),mergeValues:(t,r)=>!0===t||{...t,...r},resultToName:d}),items:u({mergeNames:(t,r,o)=>t.if((0,a._)`${o} !== true && ${r} !== undefined`,()=>t.assign(o,(0,a._)`${r} === true ? true : ${o} > ${r} ? ${o} : ${r}`)),mergeToName:(t,r,o)=>t.if((0,a._)`${o} !== true`,()=>t.assign(o,!0===r||(0,a._)`${o} > ${r} ? ${o} : ${r}`)),mergeValues:(t,r)=>!0===t||Math.max(t,r),resultToName:(t,r)=>t.var("items",r)})},t.evaluatedPropsToName=d,t.setEvaluated=p;let h={};function f(t,r,o=t.opts.strictSchema){if(o){if(r=`strict mode: ${r}`,!0===o)throw Error(r);t.self.logger.warn(r)}}t.useFunc=function(t,r){return t.scopeValue("func",{ref:r,code:h[r.code]||(h[r.code]=new i._Code(r.code))})},(o=r||(t.Type=r={}))[o.Num=0]="Num",o[o.Str=1]="Str",t.getErrorPath=function(t,o,i){if(t instanceof a.Name){let n=o===r.Num;return i?n?(0,a._)`"[" + ${t} + "]"`:(0,a._)`"['" + ${t} + "']"`:n?(0,a._)`"/" + ${t}`:(0,a._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return i?(0,a.getProperty)(t).toString():"/"+l(t)},t.checkStrictMode=f}),uE=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw();t.default={data:new r.Name("data"),valCxt:new r.Name("valCxt"),instancePath:new r.Name("instancePath"),parentData:new r.Name("parentData"),parentDataProperty:new r.Name("parentDataProperty"),rootData:new r.Name("rootData"),dynamicAnchors:new r.Name("dynamicAnchors"),vErrors:new r.Name("vErrors"),errors:new r.Name("errors"),this:new r.Name("this"),self:new r.Name("self"),scope:new r.Name("scope"),json:new r.Name("json"),jsonPos:new r.Name("jsonPos"),jsonLen:new r.Name("jsonLen"),jsonPart:new r.Name("jsonPart")}}),uP=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;let r=uw(),o=u$(),a=uE();function i(t,o){let i=t.const("err",o);t.if((0,r._)`${a.default.vErrors} === null`,()=>t.assign(a.default.vErrors,(0,r._)`[${i}]`),(0,r._)`${a.default.vErrors}.push(${i})`),t.code((0,r._)`${a.default.errors}++`)}function n(t,o){let{gen:a,validateName:i,schemaEnv:n}=t;n.$async?a.throw((0,r._)`new ${t.ValidationError}(${o})`):(a.assign((0,r._)`${i}.errors`,o),a.return(!1))}t.keywordError={message:({keyword:t})=>(0,r.str)`must pass "${t}" keyword validation`},t.keyword$DataError={message:({keyword:t,schemaType:o})=>o?(0,r.str)`"${t}" keyword must be ${o} ($data)`:(0,r.str)`"${t}" keyword is invalid ($data)`},t.reportError=function(o,a=t.keywordError,s,c){let{it:u}=o,{gen:d,compositeRule:p,allErrors:h}=u,f=l(o,a,s);(null!=c?c:p||h)?i(d,f):n(u,(0,r._)`[${f}]`)},t.reportExtraError=function(r,o=t.keywordError,s){let{it:c}=r,{gen:u,compositeRule:d,allErrors:p}=c;i(u,l(r,o,s)),d||p||n(c,a.default.vErrors)},t.resetErrorsCount=function(t,o){t.assign(a.default.errors,o),t.if((0,r._)`${a.default.vErrors} !== null`,()=>t.if(o,()=>t.assign((0,r._)`${a.default.vErrors}.length`,o),()=>t.assign(a.default.vErrors,null)))},t.extendErrors=function({gen:t,keyword:o,schemaValue:i,data:n,errsCount:s,it:l}){if(void 0===s)throw Error("ajv implementation error");let c=t.name("err");t.forRange("i",s,a.default.errors,s=>{t.const(c,(0,r._)`${a.default.vErrors}[${s}]`),t.if((0,r._)`${c}.instancePath === undefined`,()=>t.assign((0,r._)`${c}.instancePath`,(0,r.strConcat)(a.default.instancePath,l.errorPath))),t.assign((0,r._)`${c}.schemaPath`,(0,r.str)`${l.errSchemaPath}/${o}`),l.opts.verbose&&(t.assign((0,r._)`${c}.schema`,i),t.assign((0,r._)`${c}.data`,n))})};let s={keyword:new r.Name("keyword"),schemaPath:new r.Name("schemaPath"),params:new r.Name("params"),propertyName:new r.Name("propertyName"),message:new r.Name("message"),schema:new r.Name("schema"),parentSchema:new r.Name("parentSchema")};function l(t,i,n){let{createErrors:l}=t.it;return!1===l?(0,r._)`{}`:function(t,i,n={}){let{gen:l,it:c}=t,u=[function({errorPath:t},{instancePath:i}){let n=i?(0,r.str)`${t}${(0,o.getErrorPath)(i,o.Type.Str)}`:t;return[a.default.instancePath,(0,r.strConcat)(a.default.instancePath,n)]}(c,n),function({keyword:t,it:{errSchemaPath:a}},{schemaPath:i,parentSchema:n}){let l=n?a:(0,r.str)`${a}/${t}`;return i&&(l=(0,r.str)`${l}${(0,o.getErrorPath)(i,o.Type.Str)}`),[s.schemaPath,l]}(t,n)];return function(t,{params:o,message:i},n){let{keyword:l,data:c,schemaValue:u,it:d}=t,{opts:p,propertyName:h,topSchemaRef:f,schemaPath:m}=d;n.push([s.keyword,l],[s.params,"function"==typeof o?o(t):o||(0,r._)`{}`]),p.messages&&n.push([s.message,"function"==typeof i?i(t):i]),p.verbose&&n.push([s.schema,u],[s.parentSchema,(0,r._)`${f}${m}`],[a.default.data,c]),h&&n.push([s.propertyName,h])}(t,i,u),l.object(...u)}(t,i,n)}}),uk=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.boolOrEmptySchema=t.topBoolOrEmptySchema=void 0;let r=uP(),o=uw(),a=uE(),i={message:"boolean schema is false"};function n(t,o){let{gen:a,data:n}=t;(0,r.reportError)({gen:a,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t},i,void 0,o)}t.topBoolOrEmptySchema=function(t){let{gen:r,schema:i,validateName:s}=t;!1===i?n(t,!1):"object"==typeof i&&!0===i.$async?r.return(a.default.data):(r.assign((0,o._)`${s}.errors`,null),r.return(!0))},t.boolOrEmptySchema=function(t,r){let{gen:o,schema:a}=t;!1===a?(o.var(r,!1),n(t)):o.var(r,!0)}}),uR=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRules=t.isJSONType=void 0;let r=new Set(["string","number","integer","boolean","null","object","array"]);t.isJSONType=function(t){return"string"==typeof t&&r.has(t)},t.getRules=function(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}}),ux=z(t=>{function r(t,r){return r.rules.some(r=>o(t,r))}function o(t,r){var o;return void 0!==t[r.keyword]||(null==(o=r.definition.implements)?void 0:o.some(r=>void 0!==t[r]))}Object.defineProperty(t,"__esModule",{value:!0}),t.shouldUseRule=t.shouldUseGroup=t.schemaHasRulesForType=void 0,t.schemaHasRulesForType=function({schema:t,self:o},a){let i=o.RULES.types[a];return i&&!0!==i&&r(t,i)},t.shouldUseGroup=r,t.shouldUseRule=o}),uC=z(t=>{var r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.reportTypeError=t.checkDataTypes=t.checkDataType=t.coerceAndCheckDataType=t.getJSONTypes=t.getSchemaTypes=t.DataType=void 0;let a=uR(),i=ux(),n=uP(),s=uw(),l=u$();function c(t){let r=Array.isArray(t)?t:t?[t]:[];if(r.every(a.isJSONType))return r;throw Error("type must be JSONType or JSONType[]: "+r.join(","))}(o=r||(t.DataType=r={}))[o.Correct=0]="Correct",o[o.Wrong=1]="Wrong",t.getSchemaTypes=function(t){let r=c(t.type);if(r.includes("null")){if(!1===t.nullable)throw Error("type: null contradicts nullable: false")}else{if(!r.length&&void 0!==t.nullable)throw Error('"nullable" cannot be used without "type"');!0===t.nullable&&r.push("null")}return r},t.getJSONTypes=c,t.coerceAndCheckDataType=function(t,o){var a,n;let{gen:l,data:c,opts:d}=t,h=(a=o,(n=d.coerceTypes)?a.filter(t=>u.has(t)||"array"===n&&"array"===t):[]),m=o.length>0&&!(0===h.length&&1===o.length&&(0,i.schemaHasRulesForType)(t,o[0]));if(m){let a=p(o,c,d.strictNumbers,r.Wrong);l.if(a,()=>{h.length?function(t,r,o){let{gen:a,data:i,opts:n}=t,l=a.let("dataType",(0,s._)`typeof ${i}`),c=a.let("coerced",(0,s._)`undefined`);for(let t of("array"===n.coerceTypes&&a.if((0,s._)`${l} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>a.assign(i,(0,s._)`${i}[0]`).assign(l,(0,s._)`typeof ${i}`).if(p(r,i,n.strictNumbers),()=>a.assign(c,i))),a.if((0,s._)`${c} !== undefined`),o))(u.has(t)||"array"===t&&"array"===n.coerceTypes)&&function(t){switch(t){case"string":a.elseIf((0,s._)`${l} == "number" || ${l} == "boolean"`).assign(c,(0,s._)`"" + ${i}`).elseIf((0,s._)`${i} === null`).assign(c,(0,s._)`""`);return;case"number":a.elseIf((0,s._)`${l} == "boolean" || ${i} === null
|| (${l} == "string" && ${i} && ${i} == +${i})`).assign(c,(0,s._)`+${i}`);return;case"integer":a.elseIf((0,s._)`${l} === "boolean" || ${i} === null
|| (${l} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(c,(0,s._)`+${i}`);return;case"boolean":a.elseIf((0,s._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(c,!1).elseIf((0,s._)`${i} === "true" || ${i} === 1`).assign(c,!0);return;case"null":a.elseIf((0,s._)`${i} === "" || ${i} === 0 || ${i} === false`),a.assign(c,null);return;case"array":a.elseIf((0,s._)`${l} === "string" || ${l} === "number"
|| ${l} === "boolean" || ${i} === null`).assign(c,(0,s._)`[${i}]`)}}(t);a.else(),f(t),a.endIf(),a.if((0,s._)`${c} !== undefined`,()=>{a.assign(i,c),function({gen:t,parentData:r,parentDataProperty:o},a){t.if((0,s._)`${r} !== undefined`,()=>t.assign((0,s._)`${r}[${o}]`,a))}(t,c)})}(t,o,h):f(t)})}return m};let u=new Set(["string","number","integer","boolean","null"]);function d(t,o,a,i=r.Correct){let n,l=i===r.Correct?s.operators.EQ:s.operators.NEQ;switch(t){case"null":return(0,s._)`${o} ${l} null`;case"array":n=(0,s._)`Array.isArray(${o})`;break;case"object":n=(0,s._)`${o} && typeof ${o} == "object" && !Array.isArray(${o})`;break;case"integer":n=c((0,s._)`!(${o} % 1) && !isNaN(${o})`);break;case"number":n=c();break;default:return(0,s._)`typeof ${o} ${l} ${t}`}return i===r.Correct?n:(0,s.not)(n);function c(t=s.nil){return(0,s.and)((0,s._)`typeof ${o} == "number"`,t,a?(0,s._)`isFinite(${o})`:s.nil)}}function p(t,r,o,a){let i;if(1===t.length)return d(t[0],r,o,a);let n=(0,l.toHash)(t);if(n.array&&n.object){let t=(0,s._)`typeof ${r} != "object"`;i=n.null?t:(0,s._)`!${r} || ${t}`,delete n.null,delete n.array,delete n.object}else i=s.nil;for(let t in n.number&&delete n.integer,n)i=(0,s.and)(i,d(t,r,o,a));return i}t.checkDataType=d,t.checkDataTypes=p;let h={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:r})=>"string"==typeof t?(0,s._)`{type: ${t}}`:(0,s._)`{type: ${r}}`};function f(t){let r=function(t){let{gen:r,data:o,schema:a}=t,i=(0,l.schemaRefOrVal)(t,a,"type");return{gen:r,keyword:"type",data:o,schema:a.type,schemaCode:i,schemaValue:i,parentSchema:a,params:{},it:t}}(t);(0,n.reportError)(r,h)}t.reportTypeError=f}),uA=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assignDefaults=void 0;let r=uw(),o=u$();function a(t,a,i){let{gen:n,compositeRule:s,data:l,opts:c}=t;if(void 0===i)return;let u=(0,r._)`${l}${(0,r.getProperty)(a)}`;if(s)return void(0,o.checkStrictMode)(t,`default is ignored for: ${u}`);let d=(0,r._)`${u} === undefined`;"empty"===c.useDefaults&&(d=(0,r._)`${d} || ${u} === null || ${u} === ""`),n.if(d,(0,r._)`${u} = ${(0,r.stringify)(i)}`)}t.assignDefaults=function(t,r){let{properties:o,items:i}=t.schema;if("object"===r&&o)for(let r in o)a(t,r,o[r].default);else"array"===r&&Array.isArray(i)&&i.forEach((r,o)=>a(t,o,r.default))}}),uT=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;let r=uw(),o=u$(),a=uE(),i=u$();function n(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,r._)`Object.prototype.hasOwnProperty`})}function s(t,o,a){return(0,r._)`${n(t)}.call(${o}, ${a})`}function l(t,o,a,i){let n=(0,r._)`${o}${(0,r.getProperty)(a)} === undefined`;return i?(0,r.or)(n,(0,r.not)(s(t,o,a))):n}function c(t){return t?Object.keys(t).filter(t=>"__proto__"!==t):[]}t.checkReportMissingProp=function(t,o){let{gen:a,data:i,it:n}=t;a.if(l(a,i,o,n.opts.ownProperties),()=>{t.setParams({missingProperty:(0,r._)`${o}`},!0),t.error()})},t.checkMissingProp=function({gen:t,data:o,it:{opts:a}},i,n){return(0,r.or)(...i.map(i=>(0,r.and)(l(t,o,i,a.ownProperties),(0,r._)`${n} = ${i}`)))},t.reportMissingProp=function(t,r){t.setParams({missingProperty:r},!0),t.error()},t.hasPropFunc=n,t.isOwnProperty=s,t.propertyInData=function(t,o,a,i){let n=(0,r._)`${o}${(0,r.getProperty)(a)} !== undefined`;return i?(0,r._)`${n} && ${s(t,o,a)}`:n},t.noPropertyInData=l,t.allSchemaProperties=c,t.schemaProperties=function(t,r){return c(r).filter(a=>!(0,o.alwaysValidSchema)(t,r[a]))},t.callValidateCode=function({schemaCode:t,data:o,it:{gen:i,topSchemaRef:n,schemaPath:s,errorPath:l},it:c},u,d,p){let h=p?(0,r._)`${t}, ${o}, ${n}${s}`:o,f=[[a.default.instancePath,(0,r.strConcat)(a.default.instancePath,l)],[a.default.parentData,c.parentData],[a.default.parentDataProperty,c.parentDataProperty],[a.default.rootData,a.default.rootData]];c.opts.dynamicRef&&f.push([a.default.dynamicAnchors,a.default.dynamicAnchors]);let m=(0,r._)`${h}, ${i.object(...f)}`;return d!==r.nil?(0,r._)`${u}.call(${d}, ${m})`:(0,r._)`${u}(${m})`};let u=(0,r._)`new RegExp`;t.usePattern=function({gen:t,it:{opts:o}},a){let n=o.unicodeRegExp?"u":"",{regExp:s}=o.code,l=s(a,n);return t.scopeValue("pattern",{key:l.toString(),ref:l,code:(0,r._)`${"new RegExp"===s.code?u:(0,i.useFunc)(t,s)}(${a}, ${n})`})},t.validateArray=function(t){let{gen:a,data:i,keyword:n,it:s}=t,l=a.name("valid");if(s.allErrors){let t=a.let("valid",!0);return c(()=>a.assign(t,!1)),t}return a.var(l,!0),c(()=>a.break()),l;function c(s){let c=a.const("len",(0,r._)`${i}.length`);a.forRange("i",0,c,i=>{t.subschema({keyword:n,dataProp:i,dataPropType:o.Type.Num},l),a.if((0,r.not)(l),s)})}},t.validateUnion=function(t){let{gen:a,schema:i,keyword:n,it:s}=t;if(!Array.isArray(i))throw Error("ajv implementation error");if(i.some(t=>(0,o.alwaysValidSchema)(s,t))&&!s.opts.unevaluated)return;let l=a.let("valid",!1),c=a.name("_valid");a.block(()=>i.forEach((o,i)=>{let s=t.subschema({keyword:n,schemaProp:i,compositeRule:!0},c);a.assign(l,(0,r._)`${l} || ${c}`),t.mergeValidEvaluated(s,c)||a.if((0,r.not)(l))})),t.result(l,()=>t.reset(),()=>t.error(!0))}}),uO=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;let r=uw(),o=uE(),a=uT(),i=uP();function n(t){let{gen:o,data:a,it:i}=t;o.if(i.parentData,()=>o.assign(a,(0,r._)`${i.parentData}[${i.parentDataProperty}]`))}function s(t,o,a){if(void 0===a)throw Error(`keyword "${o}" failed to compile`);return t.scopeValue("keyword","function"==typeof a?{ref:a}:{ref:a,code:(0,r.stringify)(a)})}t.macroKeywordCode=function(t,o){let{gen:a,keyword:i,schema:n,parentSchema:l,it:c}=t,u=o.macro.call(c.self,n,l,c),d=s(a,i,u);!1!==c.opts.validateSchema&&c.self.validateSchema(u,!0);let p=a.name("valid");t.subschema({schema:u,schemaPath:r.nil,errSchemaPath:`${c.errSchemaPath}/${i}`,topSchemaRef:d,compositeRule:!0},p),t.pass(p,()=>t.error(!0))},t.funcKeywordCode=function(t,l){var c;let{gen:u,keyword:d,schema:p,parentSchema:h,$data:f,it:m}=t;!function({schemaEnv:t},r){if(r.async&&!t.$async)throw Error("async keyword in sync schema")}(m,l);let y=s(u,d,!f&&l.compile?l.compile.call(m.self,p,h,m):l.validate),g=u.let("valid");function v(i=l.async?(0,r._)`await `:r.nil){let n=m.opts.passContext?o.default.this:o.default.self,s=!("compile"in l&&!f||!1===l.schema);u.assign(g,(0,r._)`${i}${(0,a.callValidateCode)(t,y,n,s)}`,l.modifying)}function _(t){var o;u.if((0,r.not)(null!=(o=l.valid)?o:g),t)}t.block$data(g,function(){if(!1===l.errors)v(),l.modifying&&n(t),_(()=>t.error());else{let a,s,c=l.async?(a=u.let("ruleErrs",null),u.try(()=>v((0,r._)`await `),t=>u.assign(g,!1).if((0,r._)`${t} instanceof ${m.ValidationError}`,()=>u.assign(a,(0,r._)`${t}.errors`),()=>u.throw(t))),a):(s=(0,r._)`${y}.errors`,u.assign(s,null),v(r.nil),s);l.modifying&&n(t),_(()=>(function(t,a){let{gen:n}=t;n.if((0,r._)`Array.isArray(${a})`,()=>{n.assign(o.default.vErrors,(0,r._)`${o.default.vErrors} === null ? ${a} : ${o.default.vErrors}.concat(${a})`).assign(o.default.errors,(0,r._)`${o.default.vErrors}.length`),(0,i.extendErrors)(t)},()=>t.error())})(t,c))}}),t.ok(null!=(c=l.valid)?c:g)},t.validSchemaType=function(t,r,o=!1){return!r.length||r.some(r=>"array"===r?Array.isArray(t):"object"===r?t&&"object"==typeof t&&!Array.isArray(t):typeof t==r||o&&void 0===t)},t.validateKeywordUsage=function({schema:t,opts:r,self:o,errSchemaPath:a},i,n){if(Array.isArray(i.keyword)?!i.keyword.includes(n):i.keyword!==n)throw Error("ajv implementation error");let s=i.dependencies;if(null==s?void 0:s.some(r=>!Object.prototype.hasOwnProperty.call(t,r)))throw Error(`parent schema must have dependencies of ${n}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[n])){let t=`keyword "${n}" value is invalid at path "${a}": `+o.errorsText(i.validateSchema.errors);if("log"===r.validateSchema)o.logger.error(t);else throw Error(t)}}}),uj=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extendSubschemaMode=t.extendSubschemaData=t.getSubschema=void 0;let r=uw(),o=u$();t.getSubschema=function(t,{keyword:a,schemaProp:i,schema:n,schemaPath:s,errSchemaPath:l,topSchemaRef:c}){if(void 0!==a&&void 0!==n)throw Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==a){let n=t.schema[a];return void 0===i?{schema:n,schemaPath:(0,r._)`${t.schemaPath}${(0,r.getProperty)(a)}`,errSchemaPath:`${t.errSchemaPath}/${a}`}:{schema:n[i],schemaPath:(0,r._)`${t.schemaPath}${(0,r.getProperty)(a)}${(0,r.getProperty)(i)}`,errSchemaPath:`${t.errSchemaPath}/${a}/${(0,o.escapeFragment)(i)}`}}if(void 0!==n){if(void 0===s||void 0===l||void 0===c)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:c,errSchemaPath:l}}throw Error('either "keyword" or "schema" must be passed')},t.extendSubschemaData=function(t,a,{dataProp:i,dataPropType:n,data:s,dataTypes:l,propertyName:c}){if(void 0!==s&&void 0!==i)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:u}=a;if(void 0!==i){let{errorPath:s,dataPathArr:l,opts:c}=a;d(u.let("data",(0,r._)`${a.data}${(0,r.getProperty)(i)}`,!0)),t.errorPath=(0,r.str)`${s}${(0,o.getErrorPath)(i,n,c.jsPropertySyntax)}`,t.parentDataProperty=(0,r._)`${i}`,t.dataPathArr=[...l,t.parentDataProperty]}function d(r){t.data=r,t.dataLevel=a.dataLevel+1,t.dataTypes=[],a.definedProperties=new Set,t.parentData=a.data,t.dataNames=[...a.dataNames,r]}void 0!==s&&(d(s instanceof r.Name?s:u.let("data",s,!0)),void 0!==c&&(t.propertyName=c)),l&&(t.dataTypes=l)},t.extendSubschemaMode=function(t,{jtdDiscriminator:r,jtdMetadata:o,compositeRule:a,createErrors:i,allErrors:n}){void 0!==a&&(t.compositeRule=a),void 0!==i&&(t.createErrors=i),void 0!==n&&(t.allErrors=n),t.jtdDiscriminator=r,t.jtdMetadata=o}}),uI=z((t,r)=>{r.exports=function t(r,o){if(r===o)return!0;if(r&&o&&"object"==typeof r&&"object"==typeof o){if(r.constructor!==o.constructor)return!1;if(Array.isArray(r)){if((a=r.length)!=o.length)return!1;for(i=a;0!=i--;)if(!t(r[i],o[i]))return!1;return!0}if(r.constructor===RegExp)return r.source===o.source&&r.flags===o.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===o.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===o.toString();if((a=(n=Object.keys(r)).length)!==Object.keys(o).length)return!1;for(i=a;0!=i--;)if(!Object.prototype.hasOwnProperty.call(o,n[i]))return!1;for(i=a;0!=i--;){var a,i,n,s=n[i];if(!t(r[s],o[s]))return!1}return!0}return r!=r&&o!=o}}),uN=z((t,r)=>{var o=r.exports=function(t,r,a){"function"==typeof r&&(a=r,r={});var i="function"==typeof(a=r.cb||a)?a:a.pre||function(){};!function t(r,a,i,n,s,l,c,u,d,p){if(n&&"object"==typeof n&&!Array.isArray(n)){for(var h in a(n,s,l,c,u,d,p),n){var f,m=n[h];if(Array.isArray(m)){if(h in o.arrayKeywords)for(var y=0;y<m.length;y++)t(r,a,i,m[y],s+"/"+h+"/"+y,l,s,h,n,y)}else if(h in o.propsKeywords){if(m&&"object"==typeof m)for(var g in m){t(r,a,i,m[g],s+"/"+h+"/"+(f=g).replace(/~/g,"~0").replace(/\//g,"~1"),l,s,h,n,g)}}else(h in o.keywords||r.allKeys&&!(h in o.skipKeywords))&&t(r,a,i,m,s+"/"+h,l,s,h,n)}i(n,s,l,c,u,d,p)}}(r,i,a.post||function(){},t,"",t)};o.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},o.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},o.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},o.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}}),uM=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSchemaRefs=t.resolveUrl=t.normalizeId=t._getFullPath=t.getFullPath=t.inlineRef=void 0;let r=u$(),o=uI(),a=uN(),i=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);t.inlineRef=function(t,o=!0){return"boolean"==typeof t||(!0===o?!function t(r){for(let o in r){if(n.has(o))return!0;let a=r[o];if(Array.isArray(a)&&a.some(t)||"object"==typeof a&&t(a))return!0}return!1}(t):!!o&&function t(o){let a=0;for(let n in o)if("$ref"===n||(a++,!i.has(n)&&("object"==typeof o[n]&&(0,r.eachItem)(o[n],r=>a+=t(r)),a===1/0)))return 1/0;return a}(t)<=o)};let n=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function s(t,r="",o){return!1!==o&&(r=u(r)),l(t,t.parse(r))}function l(t,r){return t.serialize(r).split("#")[0]+"#"}t.getFullPath=s,t._getFullPath=l;let c=/#\/?$/;function u(t){return t?t.replace(c,""):""}t.normalizeId=u,t.resolveUrl=function(t,r,o){return o=u(o),t.resolve(r,o)};let d=/^[a-z_][-a-z0-9._]*$/i;t.getSchemaRefs=function(t,r){if("boolean"==typeof t)return{};let{schemaId:i,uriResolver:n}=this.opts,l=u(t[i]||r),c={"":l},p=s(n,l,!1),h={},f=new Set;return a(t,{allKeys:!0},(t,r,o,a)=>{if(void 0===a)return;let n=p+r,s=c[a];function l(r){let o=this.opts.uriResolver.resolve;if(r=u(s?o(s,r):r),f.has(r))throw y(r);f.add(r);let a=this.refs[r];return"string"==typeof a&&(a=this.refs[a]),"object"==typeof a?m(t,a.schema,r):r!==u(n)&&("#"===r[0]?(m(t,h[r],r),h[r]=t):this.refs[r]=n),r}function g(t){if("string"==typeof t){if(!d.test(t))throw Error(`invalid anchor "${t}"`);l.call(this,`#${t}`)}}"string"==typeof t[i]&&(s=l.call(this,t[i])),g.call(this,t.$anchor),g.call(this,t.$dynamicAnchor),c[r]=s}),h;function m(t,r,a){if(void 0!==r&&!o(t,r))throw y(a)}function y(t){return Error(`reference "${t}" resolves to more than one schema`)}}}),uz=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getData=t.KeywordCxt=t.validateFunctionCode=void 0;let r=uk(),o=uC(),a=ux(),i=uC(),n=uA(),s=uO(),l=uj(),c=uw(),u=uE(),d=uM(),p=u$(),h=uP();function f({gen:t,validateName:r,schema:o,schemaEnv:a,opts:i},n){var s;i.code.es5?t.func(r,(0,c._)`${u.default.data}, ${u.default.valCxt}`,a.$async,()=>{var r,a;t.code((0,c._)`"use strict"; ${m(o,i)}`),r=t,a=i,r.if(u.default.valCxt,()=>{r.var(u.default.instancePath,(0,c._)`${u.default.valCxt}.${u.default.instancePath}`),r.var(u.default.parentData,(0,c._)`${u.default.valCxt}.${u.default.parentData}`),r.var(u.default.parentDataProperty,(0,c._)`${u.default.valCxt}.${u.default.parentDataProperty}`),r.var(u.default.rootData,(0,c._)`${u.default.valCxt}.${u.default.rootData}`),a.dynamicRef&&r.var(u.default.dynamicAnchors,(0,c._)`${u.default.valCxt}.${u.default.dynamicAnchors}`)},()=>{r.var(u.default.instancePath,(0,c._)`""`),r.var(u.default.parentData,(0,c._)`undefined`),r.var(u.default.parentDataProperty,(0,c._)`undefined`),r.var(u.default.rootData,u.default.data),a.dynamicRef&&r.var(u.default.dynamicAnchors,(0,c._)`{}`)}),t.code(n)}):t.func(r,(0,c._)`${u.default.data}, ${(s=i,(0,c._)`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${s.dynamicRef?(0,c._)`, ${u.default.dynamicAnchors}={}`:c.nil}}={}`)}`,a.$async,()=>t.code(m(o,i)).code(n))}function m(t,r){let o="object"==typeof t&&t[r.schemaId];return o&&(r.code.source||r.code.process)?(0,c._)`/*# sourceURL=${o} */`:c.nil}function y({schema:t,self:r}){if("boolean"==typeof t)return!t;for(let o in t)if(r.RULES.all[o])return!0;return!1}function g(t){return"boolean"!=typeof t.schema}function v(t){(0,p.checkUnknownRules)(t),function(t){let{schema:r,errSchemaPath:o,opts:a,self:i}=t;r.$ref&&a.ignoreKeywordsWithRef&&(0,p.schemaHasRulesButRef)(r,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${o}"`)}(t)}function _(t,r){if(t.opts.jtd)return S(t,[],!1,r);let a=(0,o.getSchemaTypes)(t.schema);S(t,a,!(0,o.coerceAndCheckDataType)(t,a),r)}function b({gen:t,schemaEnv:r,schema:o,errSchemaPath:a,opts:i}){let n=o.$comment;if(!0===i.$comment)t.code((0,c._)`${u.default.self}.logger.log(${n})`);else if("function"==typeof i.$comment){let o=(0,c.str)`${a}/$comment`,i=t.scopeValue("root",{ref:r.root});t.code((0,c._)`${u.default.self}.opts.$comment(${n}, ${o}, ${i}.schema)`)}}function S(t,r,o,n){var s,l,d,h;let{gen:f,schema:m,data:y,allErrors:g,opts:v,self:_}=t,{RULES:b}=_;if(m.$ref&&(v.ignoreKeywordsWithRef||!(0,p.schemaHasRulesButRef)(m,b)))return void f.block(()=>k(t,"$ref",b.all.$ref.definition));function S(s){(0,a.shouldUseGroup)(m,s)&&(s.type?(f.if((0,i.checkDataType)(s.type,y,v.strictNumbers)),w(t,s),1===r.length&&r[0]===s.type&&o&&(f.else(),(0,i.reportTypeError)(t)),f.endIf()):w(t,s),g||f.if((0,c._)`${u.default.errors} === ${n||0}`))}v.jtd||(s=t,l=r,!s.schemaEnv.meta&&s.opts.strictTypes&&(function(t,r){if(r.length){if(!t.dataTypes.length){t.dataTypes=r;return}r.forEach(r=>{$(t.dataTypes,r)||E(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),function(t,r){let o=[];for(let a of t.dataTypes)$(r,a)?o.push(a):r.includes("integer")&&"number"===a&&o.push("integer");t.dataTypes=o}(t,r)}}(s,l),s.opts.allowUnionTypes||(d=s,(h=l).length>1&&!(2===h.length&&h.includes("null"))&&E(d,"use allowUnionTypes to allow union type keyword")),function(t,r){let o=t.self.RULES.all;for(let i in o){let n=o[i];if("object"==typeof n&&(0,a.shouldUseRule)(t.schema,n)){let{type:o}=n.definition;o.length&&!o.some(t=>{var o,a;return o=r,a=t,o.includes(a)||"number"===a&&o.includes("integer")})&&E(t,`missing type "${o.join(",")}" for keyword "${i}"`)}}}(s,s.dataTypes))),f.block(()=>{for(let t of b.rules)S(t);S(b.post)})}function w(t,r){let{gen:o,schema:i,opts:{useDefaults:s}}=t;s&&(0,n.assignDefaults)(t,r.type),o.block(()=>{for(let o of r.rules)(0,a.shouldUseRule)(i,o)&&k(t,o.keyword,o.definition,r.type)})}function $(t,r){return t.includes(r)||"integer"===r&&t.includes("number")}function E(t,r){let o=t.schemaEnv.baseId+t.errSchemaPath;r+=` at "${o}" (strictTypes)`,(0,p.checkStrictMode)(t,r,t.opts.strictTypes)}t.validateFunctionCode=function(t){g(t)&&(v(t),y(t))?function(t){let{schema:r,opts:o,gen:a}=t;f(t,()=>{o.$comment&&r.$comment&&b(t),function(t){let{schema:r,opts:o}=t;void 0!==r.default&&o.useDefaults&&o.strictSchema&&(0,p.checkStrictMode)(t,"default is ignored in the schema root")}(t),a.let(u.default.vErrors,null),a.let(u.default.errors,0),o.unevaluated&&function(t){let{gen:r,validateName:o}=t;t.evaluated=r.const("evaluated",(0,c._)`${o}.evaluated`),r.if((0,c._)`${t.evaluated}.dynamicProps`,()=>r.assign((0,c._)`${t.evaluated}.props`,(0,c._)`undefined`)),r.if((0,c._)`${t.evaluated}.dynamicItems`,()=>r.assign((0,c._)`${t.evaluated}.items`,(0,c._)`undefined`))}(t),_(t),function(t){let{gen:r,schemaEnv:o,validateName:a,ValidationError:i,opts:n}=t;o.$async?r.if((0,c._)`${u.default.errors} === 0`,()=>r.return(u.default.data),()=>r.throw((0,c._)`new ${i}(${u.default.vErrors})`)):(r.assign((0,c._)`${a}.errors`,u.default.vErrors),n.unevaluated&&function({gen:t,evaluated:r,props:o,items:a}){o instanceof c.Name&&t.assign((0,c._)`${r}.props`,o),a instanceof c.Name&&t.assign((0,c._)`${r}.items`,a)}(t),r.return((0,c._)`${u.default.errors} === 0`))}(t)})}(t):f(t,()=>(0,r.topBoolOrEmptySchema)(t))};var P=class{constructor(t,r,o){if((0,s.validateKeywordUsage)(t,r,o),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=o,this.data=t.data,this.schema=t.schema[o],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,p.schemaRefOrVal)(t,this.schema,o,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",C(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw Error(`${o} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:!1!==r.errors)&&(this.errsCount=t.gen.const("_errs",u.default.errors))}result(t,r,o){this.failResult((0,c.not)(t),r,o)}failResult(t,r,o){this.gen.if(t),o?o():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,c.not)(t),void 0,r)}fail(t){if(void 0===t){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,c._)`${r} !== undefined && (${(0,c.or)(this.invalid$data(),t)})`)}error(t,r,o){if(r){this.setParams(r),this._error(t,o),this.setParams({});return}this._error(t,o)}_error(t,r){(t?h.reportExtraError:h.reportError)(this,this.def.error,r)}$dataError(){(0,h.reportError)(this,this.def.$dataError||h.keyword$DataError)}reset(){if(void 0===this.errsCount)throw Error('add "trackErrors" to keyword definition');(0,h.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,o=c.nil){this.gen.block(()=>{this.check$data(t,o),r()})}check$data(t=c.nil,r=c.nil){if(!this.$data)return;let{gen:o,schemaCode:a,schemaType:i,def:n}=this;o.if((0,c.or)((0,c._)`${a} === undefined`,r)),t!==c.nil&&o.assign(t,!0),(i.length||n.validateSchema)&&(o.elseIf(this.invalid$data()),this.$dataError(),t!==c.nil&&o.assign(t,!1)),o.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:o,def:a,it:n}=this;return(0,c.or)(function(){if(o.length){if(!(r instanceof c.Name))throw Error("ajv implementation error");let t=Array.isArray(o)?o:[o];return(0,c._)`${(0,i.checkDataTypes)(t,r,n.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}(),function(){if(a.validateSchema){let o=t.scopeValue("validate$data",{ref:a.validateSchema});return(0,c._)`!${o}(${r})`}return c.nil}())}subschema(t,o){let a=(0,l.getSubschema)(this.it,t);(0,l.extendSubschemaData)(a,this.it,t),(0,l.extendSubschemaMode)(a,t);let i={...this.it,...a,items:void 0,props:void 0};return!function(t,o){if(g(t)&&(v(t),y(t)))return function(t,r){var o;let a,{schema:i,gen:n,opts:s}=t;s.$comment&&i.$comment&&b(t),(a=(o=t).schema[o.opts.schemaId])&&(o.baseId=(0,d.resolveUrl)(o.opts.uriResolver,o.baseId,a)),function(t){if(t.schema.$async&&!t.schemaEnv.$async)throw Error("async schema in sync schema")}(t);let l=n.const("_errs",u.default.errors);_(t,l),n.var(r,(0,c._)`${l} === ${u.default.errors}`)}(t,o);(0,r.boolOrEmptySchema)(t,o)}(i,o),i}mergeEvaluated(t,r){let{it:o,gen:a}=this;o.opts.unevaluated&&(!0!==o.props&&void 0!==t.props&&(o.props=p.mergeEvaluated.props(a,t.props,o.props,r)),!0!==o.items&&void 0!==t.items&&(o.items=p.mergeEvaluated.items(a,t.items,o.items,r)))}mergeValidEvaluated(t,r){let{it:o,gen:a}=this;if(o.opts.unevaluated&&(!0!==o.props||!0!==o.items))return a.if(r,()=>this.mergeEvaluated(t,c.Name)),!0}};function k(t,r,o,a){let i=new P(t,o,r);"code"in o?o.code(i,a):i.$data&&o.validate?(0,s.funcKeywordCode)(i,o):"macro"in o?(0,s.macroKeywordCode)(i,o):(o.compile||o.validate)&&(0,s.funcKeywordCode)(i,o)}t.KeywordCxt=P;let R=/^\/(?:[^~]|~0|~1)*$/,x=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function C(t,{dataLevel:r,dataNames:o,dataPathArr:a}){let i,n;if(""===t)return u.default.rootData;if("/"===t[0]){if(!R.test(t))throw Error(`Invalid JSON-pointer: ${t}`);i=t,n=u.default.rootData}else{let s=x.exec(t);if(!s)throw Error(`Invalid JSON-pointer: ${t}`);let c=+s[1];if("#"===(i=s[2])){if(c>=r)throw Error(l("property/index",c));return a[r-c]}if(c>r)throw Error(l("data",c));if(n=o[r-c],!i)return n}let s=n;for(let t of i.split("/"))t&&(n=(0,c._)`${n}${(0,c.getProperty)((0,p.unescapeJsonPointer)(t))}`,s=(0,c._)`${s} && ${n}`);return s;function l(t,o){return`Cannot access ${t} ${o} levels up, current level is ${r}`}}t.getData=C}),uq=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}}),uH=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uM();t.default=class extends Error{constructor(t,o,a,i){super(i||`can't resolve reference ${a} from id ${o}`),this.missingRef=(0,r.resolveUrl)(t,o,a),this.missingSchema=(0,r.normalizeId)((0,r.getFullPath)(t,this.missingRef))}}}),uU=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;let r=uw(),o=uq(),a=uE(),i=uM(),n=u$(),s=uz();var l=class{constructor(t){var r;let o;this.refs={},this.dynamicAnchors={},"object"==typeof t.schema&&(o=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=null!=(r=t.baseId)?r:(0,i.normalizeId)(null==o?void 0:o[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=null==o?void 0:o.$async,this.refs={}}};function c(t){let n,l,c=d.call(this,t);if(c)return c;let u=(0,i.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:p,lines:h}=this.opts.code,{ownProperties:f}=this.opts,m=new r.CodeGen(this.scope,{es5:p,lines:h,ownProperties:f});t.$async&&(n=m.scopeValue("Error",{ref:o.default,code:(0,r._)`require("ajv/dist/runtime/validation_error").default`}));let y=m.scopeName("validate");t.validateName=y;let g={gen:m,allErrors:this.opts.allErrors,data:a.default.data,parentData:a.default.parentData,parentDataProperty:a.default.parentDataProperty,dataNames:[a.default.data],dataPathArr:[r.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:m.scopeValue("schema",!0===this.opts.code.source?{ref:t.schema,code:(0,r.stringify)(t.schema)}:{ref:t.schema}),validateName:y,ValidationError:n,schema:t.schema,schemaEnv:t,rootId:u,baseId:t.baseId||u,schemaPath:r.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,r._)`""`,opts:this.opts,self:this};try{this._compilations.add(t),(0,s.validateFunctionCode)(g),m.optimize(this.opts.code.optimize);let o=m.toString();l=`${m.scopeRefs(a.default.scope)}return ${o}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let i=Function(`${a.default.self}`,`${a.default.scope}`,l)(this,this.scope.get());if(this.scope.value(y,{ref:i}),i.errors=null,i.schema=t.schema,i.schemaEnv=t,t.$async&&(i.$async=!0),!0===this.opts.code.source&&(i.source={validateName:y,validateCode:o,scopeValues:m._values}),this.opts.unevaluated){let{props:t,items:o}=g;i.evaluated={props:t instanceof r.Name?void 0:t,items:o instanceof r.Name?void 0:o,dynamicProps:t instanceof r.Name,dynamicItems:o instanceof r.Name},i.source&&(i.source.evaluated=(0,r.stringify)(i.evaluated))}return t.validate=i,t}catch(r){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),r}finally{this._compilations.delete(t)}}function u(t){return(0,i.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:c.call(this,t)}function d(t){for(let a of this._compilations){var r,o;if(r=a,o=t,r.schema===o.schema&&r.root===o.root&&r.baseId===o.baseId)return a}}function p(t,r){let o;for(;"string"==typeof(o=this.refs[r]);)r=o;return o||this.schemas[r]||h.call(this,t,r)}function h(t,r){let o=this.opts.uriResolver.parse(r),a=(0,i._getFullPath)(this.opts.uriResolver,o),n=(0,i.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&a===n)return m.call(this,o,t);let s=(0,i.normalizeId)(a),u=this.refs[s]||this.schemas[s];if("string"==typeof u){let r=h.call(this,t,u);if("object"!=typeof(null==r?void 0:r.schema))return;return m.call(this,o,r)}if("object"==typeof(null==u?void 0:u.schema)){if(u.validate||c.call(this,u),s===(0,i.normalizeId)(r)){let{schema:r}=u,{schemaId:o}=this.opts,a=r[o];return a&&(n=(0,i.resolveUrl)(this.opts.uriResolver,n,a)),new l({schema:r,schemaId:o,root:t,baseId:n})}return m.call(this,o,u)}}t.SchemaEnv=l,t.compileSchema=c,t.resolveRef=function(t,r,o){var a;o=(0,i.resolveUrl)(this.opts.uriResolver,r,o);let n=t.refs[o];if(n)return n;let s=p.call(this,t,o);if(void 0===s){let i=null==(a=t.localRefs)?void 0:a[o],{schemaId:n}=this.opts;i&&(s=new l({schema:i,schemaId:n,root:t,baseId:r}))}if(void 0!==s)return t.refs[o]=u.call(this,s)},t.getCompilingSchema=d,t.resolveSchema=h;let f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function m(t,{baseId:r,schema:o,root:a}){var s;let c;if((null==(s=t.fragment)?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if("boolean"==typeof o)return;let t=o[(0,n.unescapeFragment)(a)];if(void 0===t)return;let s="object"==typeof(o=t)&&o[this.opts.schemaId];!f.has(a)&&s&&(r=(0,i.resolveUrl)(this.opts.uriResolver,r,s))}if("boolean"!=typeof o&&o.$ref&&!(0,n.schemaHasRulesButRef)(o,this.RULES)){let t=(0,i.resolveUrl)(this.opts.uriResolver,r,o.$ref);c=h.call(this,a,t)}let{schemaId:u}=this.opts;if((c=c||new l({schema:o,schemaId:u,root:a,baseId:r})).schema!==c.root.schema)return c}}),uD=z((t,r)=>{r.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}}),uL=z((t,r)=>{let o=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),a=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function i(t){let r="",o=0,a=0;for(a=0;a<t.length;a++)if(48!==(o=t[a].charCodeAt(0))){if(!(o>=48&&o<=57||o>=65&&o<=70||o>=97&&o<=102))return"";r+=t[a];break}for(a+=1;a<t.length;a++){if(!((o=t[a].charCodeAt(0))>=48&&o<=57||o>=65&&o<=70||o>=97&&o<=102))return"";r+=t[a]}return r}let n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(t){return t.length=0,!0}function l(t,r,o){if(t.length){let a=i(t);if(""===a)return o.error=!0,!1;r.push(a),t.length=0}return!0}function c(t){if(2>function(t,r){let o=0;for(let r=0;r<t.length;r++)":"===t[r]&&o++;return o}(t,":"))return{host:t,isIPV6:!1};let r=function(t){let r=0,o={error:!1,address:"",zone:""},a=[],n=[],c=!1,u=!1,d=l;for(let i=0;i<t.length;i++){let l=t[i];if("["!==l&&"]"!==l)if(":"===l){if(!0===c&&(u=!0),!d(n,a,o))break;if(++r>7){o.error=!0;break}i>0&&":"===t[i-1]&&(c=!0),a.push(":");continue}else if("%"===l){if(!d(n,a,o))break;d=s}else{n.push(l);continue}}return n.length&&(d===s?o.zone=n.join(""):u?a.push(n.join("")):a.push(i(n))),o.address=a.join(""),o}(t);if(r.error)return{host:t,isIPV6:!1};{let t=r.address,o=r.address;return r.zone&&(t+="%"+r.zone,o+="%25"+r.zone),{host:t,isIPV6:!0,escapedHost:o}}}r.exports={nonSimpleDomain:n,recomposeAuthority:function(t){let r=[];if(void 0!==t.userinfo&&(r.push(t.userinfo),r.push("@")),void 0!==t.host){let o=unescape(t.host);if(!a(o)){let r=c(o);o=!0===r.isIPV6?`[${r.escapedHost}]`:t.host}r.push(o)}return("number"==typeof t.port||"string"==typeof t.port)&&(r.push(":"),r.push(String(t.port))),r.length?r.join(""):void 0},normalizeComponentEncoding:function(t,r){let o=!0!==r?escape:unescape;return void 0!==t.scheme&&(t.scheme=o(t.scheme)),void 0!==t.userinfo&&(t.userinfo=o(t.userinfo)),void 0!==t.host&&(t.host=o(t.host)),void 0!==t.path&&(t.path=o(t.path)),void 0!==t.query&&(t.query=o(t.query)),void 0!==t.fragment&&(t.fragment=o(t.fragment)),t},removeDotSegments:function(t){let r=t,o=[],a=-1,i=0;for(;i=r.length;){if(1===i)if("."===r)break;else if("/"===r){o.push("/");break}else{o.push(r);break}if(2===i){if("."===r[0]){if("."===r[1])break;else if("/"===r[1]){r=r.slice(2);continue}}else if("/"===r[0]&&("."===r[1]||"/"===r[1])){o.push("/");break}}else if(3===i&&"/.."===r){0!==o.length&&o.pop(),o.push("/");break}if("."===r[0]){if("."===r[1]){if("/"===r[2]){r=r.slice(3);continue}}else if("/"===r[1]){r=r.slice(2);continue}}else if("/"===r[0]&&"."===r[1]){if("/"===r[2]){r=r.slice(2);continue}else if("."===r[2]&&"/"===r[3]){r=r.slice(3),0!==o.length&&o.pop();continue}}if(-1===(a=r.indexOf("/",1))){o.push(r);break}o.push(r.slice(0,a)),r=r.slice(a)}return o.join("")},isIPv4:a,isUUID:o,normalizeIPv6:c,stringArrayToHexStripped:i}}),uK=z((t,r)=>{let{isUUID:o}=uL(),a=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=["http","https","ws","wss","urn","urn:uuid"];function n(t){return!0===t.secure||!1!==t.secure&&!!t.scheme&&3===t.scheme.length&&("w"===t.scheme[0]||"W"===t.scheme[0])&&("s"===t.scheme[1]||"S"===t.scheme[1])&&("s"===t.scheme[2]||"S"===t.scheme[2])}function s(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function l(t){let r="https"===String(t.scheme).toLowerCase();return(t.port===(r?443:80)||""===t.port)&&(t.port=void 0),t.path||(t.path="/"),t}let c={scheme:"http",domainHost:!0,parse:s,serialize:l},u={scheme:"https",domainHost:c.domainHost,parse:s,serialize:l},d={scheme:"ws",domainHost:!0,parse:function(t){return t.secure=n(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t},serialize:function(t){if((t.port===(n(t)?443:80)||""===t.port)&&(t.port=void 0),"boolean"==typeof t.secure&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[r,o]=t.resourceName.split("?");t.path=r&&"/"!==r?r:void 0,t.query=o,t.resourceName=void 0}return t.fragment=void 0,t}},p={scheme:"wss",domainHost:d.domainHost,parse:d.parse,serialize:d.serialize},h={http:c,https:u,ws:d,wss:p,urn:{scheme:"urn",parse:function(t,r){if(!t.path)return t.error="URN can not be parsed",t;let o=t.path.match(a);if(o){let a=r.scheme||t.scheme||"urn";t.nid=o[1].toLowerCase(),t.nss=o[2];let i=f(`${a}:${r.nid||t.nid}`);t.path=void 0,i&&(t=i.parse(t,r))}else t.error=t.error||"URN can not be parsed.";return t},serialize:function(t,r){if(void 0===t.nid)throw Error("URN without nid cannot be serialized");let o=r.scheme||t.scheme||"urn",a=t.nid.toLowerCase(),i=f(`${o}:${r.nid||a}`);i&&(t=i.serialize(t,r));let n=t,s=t.nss;return n.path=`${a||r.nid}:${s}`,r.skipEscape=!0,n},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,r){return t.uuid=t.nss,t.nss=void 0,r.tolerant||t.uuid&&o(t.uuid)||(t.error=t.error||"UUID is not valid."),t},serialize:function(t){return t.nss=(t.uuid||"").toLowerCase(),t},skipNormalize:!0}};function f(t){return t&&(h[t]||h[t.toLowerCase()])||void 0}Object.setPrototypeOf(h,null),r.exports={wsIsSecure:n,SCHEMES:h,isValidSchemeName:function(t){return -1!==i.indexOf(t)},getSchemeHandler:f}}),uJ=z((t,r)=>{let{normalizeIPv6:o,removeDotSegments:a,recomposeAuthority:i,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:l}=uL(),{SCHEMES:c,getSchemeHandler:u}=uK();function d(t,r,o,i){let n={};return i||(t=f(p(t,o),o),r=f(p(r,o),o)),!(o=o||{}).tolerant&&r.scheme?(n.scheme=r.scheme,n.userinfo=r.userinfo,n.host=r.host,n.port=r.port,n.path=a(r.path||""),n.query=r.query):(void 0!==r.userinfo||void 0!==r.host||void 0!==r.port?(n.userinfo=r.userinfo,n.host=r.host,n.port=r.port,n.path=a(r.path||""),n.query=r.query):(r.path?("/"===r.path[0]?n.path=a(r.path):(void 0===t.userinfo&&void 0===t.host&&void 0===t.port||t.path?t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+r.path:n.path=r.path:n.path="/"+r.path,n.path=a(n.path)),n.query=r.query):(n.path=t.path,void 0!==r.query?n.query=r.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=r.fragment,n}function p(t,r){let o={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},r),s=[],l=u(n.scheme||o.scheme);l&&l.serialize&&l.serialize(o,n),void 0!==o.path&&(n.skipEscape?o.path=unescape(o.path):(o.path=escape(o.path),void 0!==o.scheme&&(o.path=o.path.split("%3A").join(":")))),"suffix"!==n.reference&&o.scheme&&s.push(o.scheme,":");let c=i(o);if(void 0!==c&&("suffix"!==n.reference&&s.push("//"),s.push(c),o.path&&"/"!==o.path[0]&&s.push("/")),void 0!==o.path){let t=o.path;n.absolutePath||l&&l.absolutePath||(t=a(t)),void 0===c&&"/"===t[0]&&"/"===t[1]&&(t="/%2F"+t.slice(2)),s.push(t)}return void 0!==o.query&&s.push("?",o.query),void 0!==o.fragment&&s.push("#",o.fragment),s.join("")}let h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function f(t,r){let a=Object.assign({},r),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1;"suffix"===a.reference&&(t=a.scheme?a.scheme+":"+t:"//"+t);let c=t.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||"",i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(!1===s(i.host)){let t=o(i.host);i.host=t.host.toLowerCase(),n=t.isIPV6}else n=!0;void 0!==i.scheme||void 0!==i.userinfo||void 0!==i.host||void 0!==i.port||void 0!==i.query||i.path?void 0===i.scheme?i.reference="relative":void 0===i.fragment?i.reference="absolute":i.reference="uri":i.reference="same-document",a.reference&&"suffix"!==a.reference&&a.reference!==i.reference&&(i.error=i.error||"URI is not a "+a.reference+" reference.");let r=u(a.scheme||i.scheme);if(!a.unicodeSupport&&(!r||!r.unicodeSupport)&&i.host&&(a.domainHost||r&&r.domainHost)&&!1===n&&l(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(t){i.error=i.error||"Host's domain name can not be converted to ASCII: "+t}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==i.scheme&&(i.scheme=unescape(i.scheme)),void 0!==i.host&&(i.host=unescape(i.host))),i.path&&(i.path=escape(unescape(i.path))),i.fragment&&(i.fragment=encodeURI(decodeURIComponent(i.fragment)))),r&&r.parse&&r.parse(i,a)}else i.error=i.error||"URI can not be parsed.";return i}let m={SCHEMES:c,normalize:function(t,r){return"string"==typeof t?t=p(f(t,r),r):"object"==typeof t&&(t=f(p(t,r),r)),t},resolve:function(t,r,o){let a=o?Object.assign({scheme:"null"},o):{scheme:"null"},i=d(f(t,a),f(r,a),a,!0);return a.skipEscape=!0,p(i,a)},resolveComponent:d,equal:function(t,r,o){return"string"==typeof t?t=p(n(f(t=unescape(t),o),!0),{...o,skipEscape:!0}):"object"==typeof t&&(t=p(n(t,!0),{...o,skipEscape:!0})),"string"==typeof r?r=p(n(f(r=unescape(r),o),!0),{...o,skipEscape:!0}):"object"==typeof r&&(r=p(n(r,!0),{...o,skipEscape:!0})),t.toLowerCase()===r.toLowerCase()},serialize:p,parse:f};r.exports=m,r.exports.default=m,r.exports.fastUri=m}),uV=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uJ();r.code='require("ajv/dist/runtime/uri").default',t.default=r}),uW=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var r=uz();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return r.KeywordCxt}});var o=uw();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return o.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return o.CodeGen}});let a=uq(),i=uH(),n=uR(),s=uU(),l=uw(),c=uM(),u=uC(),d=u$(),p=uD(),h=uV(),f=(t,r)=>new RegExp(t,r);f.code="new RegExp";let m=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};var _=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...function(t){var r,o,a,i,n,s,l,c,u,d,p,m,y,g,v,_,b,S,w,$,E,P,k,R,x;let C=t.strict,A=null==(r=t.code)?void 0:r.optimize,T=!0===A||void 0===A?1:A||0,O=null!=(a=null==(o=t.code)?void 0:o.regExp)?a:f,j=null!=(i=t.uriResolver)?i:h.default;return{strictSchema:null==(s=null!=(n=t.strictSchema)?n:C)||s,strictNumbers:null==(c=null!=(l=t.strictNumbers)?l:C)||c,strictTypes:null!=(d=null!=(u=t.strictTypes)?u:C)?d:"log",strictTuples:null!=(m=null!=(p=t.strictTuples)?p:C)?m:"log",strictRequired:null!=(g=null!=(y=t.strictRequired)?y:C)&&g,code:t.code?{...t.code,optimize:T,regExp:O}:{optimize:T,regExp:O},loopRequired:null!=(v=t.loopRequired)?v:200,loopEnum:null!=(_=t.loopEnum)?_:200,meta:null==(b=t.meta)||b,messages:null==(S=t.messages)||S,inlineRefs:null==(w=t.inlineRefs)||w,schemaId:null!=($=t.schemaId)?$:"$id",addUsedSchema:null==(E=t.addUsedSchema)||E,validateSchema:null==(P=t.validateSchema)||P,validateFormats:null==(k=t.validateFormats)||k,unicodeRegExp:null==(R=t.unicodeRegExp)||R,int32range:null==(x=t.int32range)||x,uriResolver:j}}(t)};const{es5:r,lines:o}=this.opts.code;this.scope=new l.ValueScope({scope:{},prefixes:y,es5:r,lines:o}),this.logger=function(t){if(!1===t)return k;if(void 0===t)return console;if(t.log&&t.warn&&t.error)return t;throw Error("logger must implement log, warn and error methods")}(t.logger);const a=t.validateFormats;t.validateFormats=!1,this.RULES=(0,n.getRules)(),b.call(this,g,t,"NOT SUPPORTED"),b.call(this,v,t,"DEPRECATED","warn"),this._metaOpts=P.call(this),t.formats&&$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&E.call(this,t.keywords),"object"==typeof t.meta&&this.addMetaSchema(t.meta),w.call(this),t.validateFormats=a}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:o}=this.opts,a=p;"id"===o&&((a={...p}).id=a.$id,delete a.$id),r&&t&&this.addMetaSchema(a,a[o],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta="object"==typeof t?t[r]||t:void 0}validate(t,r){let o;if("string"==typeof t){if(!(o=this.getSchema(t)))throw Error(`no schema with key or ref "${t}"`)}else o=this.compile(t);let a=o(r);return"$async"in o||(this.errors=o.errors),a}compile(t,r){let o=this._addSchema(t,r);return o.validate||this._compileSchemaEnv(o)}compileAsync(t,r){if("function"!=typeof this.opts.loadSchema)throw Error("options.loadSchema should be a function");let{loadSchema:o}=this.opts;return a.call(this,t,r);async function a(t,r){await n.call(this,t.$schema);let o=this._addSchema(t,r);return o.validate||s.call(this,o)}async function n(t){t&&!this.getSchema(t)&&await a.call(this,{$ref:t},!0)}async function s(t){try{return this._compileSchemaEnv(t)}catch(r){if(!(r instanceof i.default))throw r;return l.call(this,r),await c.call(this,r.missingSchema),s.call(this,t)}}function l({missingSchema:t,missingRef:r}){if(this.refs[t])throw Error(`AnySchema ${t} is loaded but ${r} cannot be resolved`)}async function c(t){let o=await u.call(this,t);this.refs[t]||await n.call(this,o.$schema),this.refs[t]||this.addSchema(o,t,r)}async function u(t){let r=this._loading[t];if(r)return r;try{return await (this._loading[t]=o(t))}finally{delete this._loading[t]}}}addSchema(t,r,o,a=this.opts.validateSchema){let i;if(Array.isArray(t)){for(let r of t)this.addSchema(r,void 0,o,a);return this}if("object"==typeof t){let{schemaId:r}=this.opts;if(void 0!==(i=t[r])&&"string"!=typeof i)throw Error(`schema ${r} must be string`)}return r=(0,c.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(t,o,r,a,!0),this}addMetaSchema(t,r,o=this.opts.validateSchema){return this.addSchema(t,r,!0,o),this}validateSchema(t,r){let o;if("boolean"==typeof t)return!0;if(void 0!==(o=t.$schema)&&"string"!=typeof o)throw Error("$schema must be a string");if(!(o=o||this.opts.defaultMeta||this.defaultMeta()))return this.logger.warn("meta-schema not available"),this.errors=null,!0;let a=this.validate(o,t);if(!a&&r){let t="schema is invalid: "+this.errorsText();if("log"===this.opts.validateSchema)this.logger.error(t);else throw Error(t)}return a}getSchema(t){let r;for(;"string"==typeof(r=S.call(this,t));)t=r;if(void 0===r){let{schemaId:o}=this.opts,a=new s.SchemaEnv({schema:{},schemaId:o});if(!(r=s.resolveSchema.call(this,a,t)))return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=S.call(this,t);return"object"==typeof r&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{this._cache.delete(t);let r=t[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let o;if("string"==typeof t)o=t,"object"==typeof r&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=o);else if("object"==typeof t&&void 0===r){if(Array.isArray(o=(r=t).keyword)&&!o.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(x.call(this,o,r),!r)return(0,d.eachItem)(o,t=>C.call(this,t)),this;T.call(this,r);let a={...r,type:(0,u.getJSONTypes)(r.type),schemaType:(0,u.getJSONTypes)(r.schemaType)};return(0,d.eachItem)(o,0===a.type.length?t=>C.call(this,t,a):t=>a.type.forEach(r=>C.call(this,t,a,r))),this}getKeyword(t){let r=this.RULES.all[t];return"object"==typeof r?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;for(let o of(delete r.keywords[t],delete r.all[t],r.rules)){let r=o.rules.findIndex(r=>r.keyword===t);r>=0&&o.rules.splice(r,1)}return this}addFormat(t,r){return"string"==typeof r&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:o="data"}={}){return t&&0!==t.length?t.map(t=>`${o}${t.instancePath} ${t.message}`).reduce((t,o)=>t+r+o):"No errors"}$dataMetaSchema(t,r){let o=this.RULES.all;for(let a of(t=JSON.parse(JSON.stringify(t)),r)){let r=a.split("/").slice(1),i=t;for(let t of r)i=i[t];for(let t in o){let r=o[t];if("object"!=typeof r)continue;let{$data:a}=r.definition,n=i[t];a&&n&&(i[t]=j(n))}}return t}_removeAllSchemas(t,r){for(let o in t){let a=t[o];(!r||r.test(o))&&("string"==typeof a?delete t[o]:a&&!a.meta&&(this._cache.delete(a.schema),delete t[o]))}}_addSchema(t,r,o,a=this.opts.validateSchema,i=this.opts.addUsedSchema){let n,{schemaId:l}=this.opts;if("object"==typeof t)n=t[l];else if(this.opts.jtd)throw Error("schema must be object");else if("boolean"!=typeof t)throw Error("schema must be object or boolean");let u=this._cache.get(t);if(void 0!==u)return u;o=(0,c.normalizeId)(n||o);let d=c.getSchemaRefs.call(this,t,o);return u=new s.SchemaEnv({schema:t,schemaId:l,meta:r,baseId:o,localRefs:d}),this._cache.set(u.schema,u),i&&!o.startsWith("#")&&(o&&this._checkUnique(o),this.refs[o]=u),a&&this.validateSchema(t,!0),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):s.compileSchema.call(this,t),!t.validate)throw Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{s.compileSchema.call(this,t)}finally{this.opts=r}}};function b(t,r,o,a="error"){for(let i in t)i in r&&this.logger[a](`${o}: option ${i}. ${t[i]}`)}function S(t){return t=(0,c.normalizeId)(t),this.schemas[t]||this.refs[t]}function w(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let r in t)this.addSchema(t[r],r)}function $(){for(let t in this.opts.formats){let r=this.opts.formats[t];r&&this.addFormat(t,r)}}function E(t){if(Array.isArray(t))return void this.addVocabulary(t);for(let r in this.logger.warn("keywords option as map is deprecated, pass array"),t){let o=t[r];o.keyword||(o.keyword=r),this.addKeyword(o)}}function P(){let t={...this.opts};for(let r of m)delete t[r];return t}_.ValidationError=a.default,_.MissingRefError=i.default,t.default=_;let k={log(){},warn(){},error(){}},R=/^[a-z_$][a-z0-9_$:-]*$/i;function x(t,r){let{RULES:o}=this;if((0,d.eachItem)(t,t=>{if(o.keywords[t])throw Error(`Keyword ${t} is already defined`);if(!R.test(t))throw Error(`Keyword ${t} has invalid name`)}),r&&r.$data&&!("code"in r||"validate"in r))throw Error('$data keyword must have "code" or "validate" function')}function C(t,r,o){var a;let i=null==r?void 0:r.post;if(o&&i)throw Error('keyword with "post" flag cannot have "type"');let{RULES:n}=this,s=i?n.post:n.rules.find(({type:t})=>t===o);if(s||(s={type:o,rules:[]},n.rules.push(s)),n.keywords[t]=!0,!r)return;let l={keyword:t,definition:{...r,type:(0,u.getJSONTypes)(r.type),schemaType:(0,u.getJSONTypes)(r.schemaType)}};r.before?A.call(this,s,l,r.before):s.rules.push(l),n.all[t]=l,null==(a=r.implements)||a.forEach(t=>this.addKeyword(t))}function A(t,r,o){let a=t.rules.findIndex(t=>t.keyword===o);a>=0?t.rules.splice(a,0,r):(t.rules.push(r),this.logger.warn(`rule ${o} is not defined`))}function T(t){let{metaSchema:r}=t;void 0!==r&&(t.$data&&this.opts.$data&&(r=j(r)),t.validateSchema=this.compile(r,!0))}let O={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function j(t){return{anyOf:[t,O]}}}),uF=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}}}),uB=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;let r=uH(),o=uT(),a=uw(),i=uE(),n=uU(),s=u$();function l(t,r){let{gen:o}=t;return r.validate?o.scopeValue("validate",{ref:r.validate}):(0,a._)`${o.scopeValue("wrapper",{ref:r})}.validate`}function c(t,r,n,l){let{gen:c,it:u}=t,{allErrors:d,schemaEnv:p,opts:h}=u,f=h.passContext?i.default.this:a.nil;function m(t){let r=(0,a._)`${t}.errors`;c.assign(i.default.vErrors,(0,a._)`${i.default.vErrors} === null ? ${r} : ${i.default.vErrors}.concat(${r})`),c.assign(i.default.errors,(0,a._)`${i.default.vErrors}.length`)}function y(t){var r;if(!u.opts.unevaluated)return;let o=null==(r=null==n?void 0:n.validate)?void 0:r.evaluated;if(!0!==u.props)if(o&&!o.dynamicProps)void 0!==o.props&&(u.props=s.mergeEvaluated.props(c,o.props,u.props));else{let r=c.var("props",(0,a._)`${t}.evaluated.props`);u.props=s.mergeEvaluated.props(c,r,u.props,a.Name)}if(!0!==u.items)if(o&&!o.dynamicItems)void 0!==o.items&&(u.items=s.mergeEvaluated.items(c,o.items,u.items));else{let r=c.var("items",(0,a._)`${t}.evaluated.items`);u.items=s.mergeEvaluated.items(c,r,u.items,a.Name)}}l?function(){if(!p.$async)throw Error("async schema referenced by sync schema");let i=c.let("valid");c.try(()=>{c.code((0,a._)`await ${(0,o.callValidateCode)(t,r,f)}`),y(r),d||c.assign(i,!0)},t=>{c.if((0,a._)`!(${t} instanceof ${u.ValidationError})`,()=>c.throw(t)),m(t),d||c.assign(i,!1)}),t.ok(i)}():t.result((0,o.callValidateCode)(t,r,f),()=>y(r),()=>m(r))}t.getValidate=l,t.callRef=c,t.default={keyword:"$ref",schemaType:"string",code(t){var o,i;let s,u,d,{gen:p,schema:h,it:f}=t,{baseId:m,schemaEnv:y,validateName:g,opts:v,self:_}=f,{root:b}=y;if(("#"===h||"#/"===h)&&m===b.baseId){if(y===b)return c(t,g,y,y.$async);let r=p.scopeValue("root",{ref:b});return c(t,(0,a._)`${r}.validate`,b,b.$async)}let S=n.resolveRef.call(_,b,m,h);if(void 0===S)throw new r.default(f.opts.uriResolver,m,h);return S instanceof n.SchemaEnv?void c(t,l(t,o=S),o,o.$async):(i=S,s=p.scopeValue("schema",!0===v.code.source?{ref:i,code:(0,a.stringify)(i)}:{ref:i}),u=p.name("valid"),d=t.subschema({schema:i,dataTypes:[],schemaPath:a.nil,topSchemaRef:s,errSchemaPath:h},u),void(t.mergeEvaluated(d),t.ok(u)))}}}),uZ=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uF(),o=uB();t.default=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",r.default,o.default]}),uG=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=r.operators,a={maximum:{okStr:"<=",ok:o.LTE,fail:o.GT},minimum:{okStr:">=",ok:o.GTE,fail:o.LT},exclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},exclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}};t.default={keyword:Object.keys(a),type:"number",schemaType:"number",$data:!0,error:{message:({keyword:t,schemaCode:o})=>(0,r.str)`must be ${a[t].okStr} ${o}`,params:({keyword:t,schemaCode:o})=>(0,r._)`{comparison: ${a[t].okStr}, limit: ${o}}`},code(t){let{keyword:o,data:i,schemaCode:n}=t;t.fail$data((0,r._)`${i} ${a[o].fail} ${n} || isNaN(${i})`)}}}),uX=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw();t.default={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>(0,r.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,r._)`{multipleOf: ${t}}`},code(t){let{gen:o,data:a,schemaCode:i,it:n}=t,s=n.opts.multipleOfPrecision,l=o.let("res"),c=s?(0,r._)`Math.abs(Math.round(${l}) - ${l}) > 1e-${s}`:(0,r._)`${l} !== parseInt(${l})`;t.fail$data((0,r._)`(${i} === 0 || (${l} = ${a}/${i}, ${c}))`)}}}),uY=z(t=>{function r(t){let r,o=t.length,a=0,i=0;for(;i<o;)a++,(r=t.charCodeAt(i++))>=55296&&r<=56319&&i<o&&(64512&(r=t.charCodeAt(i)))==56320&&i++;return a}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.code='require("ajv/dist/runtime/ucs2length").default'}),uQ=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$(),a=uY();t.default={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message:({keyword:t,schemaCode:o})=>(0,r.str)`must NOT have ${"maxLength"===t?"more":"fewer"} than ${o} characters`,params:({schemaCode:t})=>(0,r._)`{limit: ${t}}`},code(t){let{keyword:i,data:n,schemaCode:s,it:l}=t,c="maxLength"===i?r.operators.GT:r.operators.LT,u=!1===l.opts.unicode?(0,r._)`${n}.length`:(0,r._)`${(0,o.useFunc)(t.gen,a.default)}(${n})`;t.fail$data((0,r._)`${u} ${c} ${s}`)}}}),u0=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uT(),o=u$(),a=uw();t.default={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>(0,a.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,a._)`{pattern: ${t}}`},code(t){let{gen:i,data:n,$data:s,schema:l,schemaCode:c,it:u}=t,d=u.opts.unicodeRegExp?"u":"";if(s){let{regExp:r}=u.opts.code,s="new RegExp"===r.code?(0,a._)`new RegExp`:(0,o.useFunc)(i,r),l=i.let("valid");i.try(()=>i.assign(l,(0,a._)`${s}(${c}, ${d}).test(${n})`),()=>i.assign(l,!1)),t.fail$data((0,a._)`!${l}`)}else{let o=(0,r.usePattern)(t,l);t.fail$data((0,a._)`!${o}.test(${n})`)}}}}),u1=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw();t.default={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message:({keyword:t,schemaCode:o})=>(0,r.str)`must NOT have ${"maxProperties"===t?"more":"fewer"} than ${o} properties`,params:({schemaCode:t})=>(0,r._)`{limit: ${t}}`},code(t){let{keyword:o,data:a,schemaCode:i}=t,n="maxProperties"===o?r.operators.GT:r.operators.LT;t.fail$data((0,r._)`Object.keys(${a}).length ${n} ${i}`)}}}),u2=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uT(),o=uw(),a=u$();t.default={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>(0,o.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,o._)`{missingProperty: ${t}}`},code(t){let{gen:i,schema:n,schemaCode:s,data:l,$data:c,it:u}=t,{opts:d}=u;if(!c&&0===n.length)return;let p=n.length>=d.loopRequired;if(u.allErrors?function(){if(p||c)t.block$data(o.nil,h);else for(let o of n)(0,r.checkReportMissingProp)(t,o)}():function(){let a=i.let("missing");if(p||c){let n=i.let("valid",!0);t.block$data(n,()=>{var c,u;return c=a,u=n,void(t.setParams({missingProperty:c}),i.forOf(c,s,()=>{i.assign(u,(0,r.propertyInData)(i,l,c,d.ownProperties)),i.if((0,o.not)(u),()=>{t.error(),i.break()})},o.nil))}),t.ok(n)}else i.if((0,r.checkMissingProp)(t,n,a)),(0,r.reportMissingProp)(t,a),i.else()}(),d.strictRequired){let r=t.parentSchema.properties,{definedProperties:o}=t.it;for(let t of n)if((null==r?void 0:r[t])===void 0&&!o.has(t)){let r=`required property "${t}" is not defined at "${u.schemaEnv.baseId+u.errSchemaPath}" (strictRequired)`;(0,a.checkStrictMode)(u,r,u.opts.strictRequired)}}function h(){i.forOf("prop",s,o=>{t.setParams({missingProperty:o}),i.if((0,r.noPropertyInData)(i,l,o,d.ownProperties),()=>t.error())})}}}}),u9=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw();t.default={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message:({keyword:t,schemaCode:o})=>(0,r.str)`must NOT have ${"maxItems"===t?"more":"fewer"} than ${o} items`,params:({schemaCode:t})=>(0,r._)`{limit: ${t}}`},code(t){let{keyword:o,data:a,schemaCode:i}=t,n="maxItems"===o?r.operators.GT:r.operators.LT;t.fail$data((0,r._)`${a}.length ${n} ${i}`)}}}),u4=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uI();r.code='require("ajv/dist/runtime/equal").default',t.default=r}),u5=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uC(),o=uw(),a=u$(),i=u4();t.default={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:r}})=>(0,o.str)`must NOT have duplicate items (items ## ${r} and ${t} are identical)`,params:({params:{i:t,j:r}})=>(0,o._)`{i: ${t}, j: ${r}}`},code(t){let{gen:n,data:s,$data:l,schema:c,parentSchema:u,schemaCode:d,it:p}=t;if(!l&&!c)return;let h=n.let("valid"),f=u.items?(0,r.getSchemaTypes)(u.items):[];t.block$data(h,function(){let l=n.let("i",(0,o._)`${s}.length`),c=n.let("j");t.setParams({i:l,j:c}),n.assign(h,!0),n.if((0,o._)`${l} > 1`,()=>(f.length>0&&!f.some(t=>"object"===t||"array"===t)?function(a,i){let l=n.name("item"),c=(0,r.checkDataTypes)(f,l,p.opts.strictNumbers,r.DataType.Wrong),u=n.const("indices",(0,o._)`{}`);n.for((0,o._)`;${a}--;`,()=>{n.let(l,(0,o._)`${s}[${a}]`),n.if(c,(0,o._)`continue`),f.length>1&&n.if((0,o._)`typeof ${l} == "string"`,(0,o._)`${l} += "_"`),n.if((0,o._)`typeof ${u}[${l}] == "number"`,()=>{n.assign(i,(0,o._)`${u}[${l}]`),t.error(),n.assign(h,!1).break()}).code((0,o._)`${u}[${l}] = ${a}`)})}:function(r,l){let c=(0,a.useFunc)(n,i.default),u=n.name("outer");n.label(u).for((0,o._)`;${r}--;`,()=>n.for((0,o._)`${l} = ${r}; ${l}--;`,()=>n.if((0,o._)`${c}(${s}[${r}], ${s}[${l}])`,()=>{t.error(),n.assign(h,!1).break(u)})))})(l,c))},(0,o._)`${d} === false`),t.ok(h)}}}),u3=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$(),a=u4();t.default={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>(0,r._)`{allowedValue: ${t}}`},code(t){let{gen:i,data:n,$data:s,schemaCode:l,schema:c}=t;s||c&&"object"==typeof c?t.fail$data((0,r._)`!${(0,o.useFunc)(i,a.default)}(${n}, ${l})`):t.fail((0,r._)`${c} !== ${n}`)}}}),u6=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$(),a=u4();t.default={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,r._)`{allowedValues: ${t}}`},code(t){let i,n,{gen:s,data:l,$data:c,schema:u,schemaCode:d,it:p}=t;if(!c&&0===u.length)throw Error("enum must have non-empty array");let h=u.length>=p.opts.loopEnum,f=()=>null!=i?i:i=(0,o.useFunc)(s,a.default);if(h||c)n=s.let("valid"),t.block$data(n,function(){s.assign(n,!1),s.forOf("v",d,t=>s.if((0,r._)`${f()}(${l}, ${t})`,()=>s.assign(n,!0).break()))});else{if(!Array.isArray(u))throw Error("ajv implementation error");let t=s.const("vSchema",d);n=(0,r.or)(...u.map((o,a)=>{var i,n;let s;return i=t,"object"==typeof(s=u[n=a])&&null!==s?(0,r._)`${f()}(${l}, ${i}[${n}])`:(0,r._)`${l} === ${s}`}))}t.pass(n)}}}),u8=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uG(),o=uX(),a=uQ(),i=u0(),n=u1(),s=u2(),l=u9(),c=u5(),u=u3(),d=u6();t.default=[r.default,o.default,a.default,i.default,n.default,s.default,l.default,c.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u.default,d.default]}),u7=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateAdditionalItems=void 0;let r=uw(),o=u$();function a(t,a){let{gen:i,schema:n,data:s,keyword:l,it:c}=t;c.items=!0;let u=i.const("len",(0,r._)`${s}.length`);if(!1===n)t.setParams({len:a.length}),t.pass((0,r._)`${u} <= ${a.length}`);else if("object"==typeof n&&!(0,o.alwaysValidSchema)(c,n)){let n=i.var("valid",(0,r._)`${u} <= ${a.length}`);i.if((0,r.not)(n),()=>{var s;return s=n,void i.forRange("i",a.length,u,a=>{t.subschema({keyword:l,dataProp:a,dataPropType:o.Type.Num},s),c.allErrors||i.if((0,r.not)(s),()=>i.break())})}),t.ok(n)}}t.validateAdditionalItems=a,t.default={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>(0,r.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,r._)`{limit: ${t}}`},code(t){let{parentSchema:r,it:i}=t,{items:n}=r;Array.isArray(n)?a(t,n):(0,o.checkStrictMode)(i,'"additionalItems" is ignored when "items" is not an array of schemas')}}}),de=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;let r=uw(),o=u$(),a=uT();function i(t,a,n=t.schema){let{gen:s,parentSchema:l,data:c,keyword:u,it:d}=t;(function(t){let{opts:r,errSchemaPath:i}=d,s=n.length,l=s===t.minItems&&(s===t.maxItems||!1===t[a]);if(r.strictTuples&&!l){let t=`"${u}" is ${s}-tuple, but minItems or maxItems/${a} are not specified or different at path "${i}"`;(0,o.checkStrictMode)(d,t,r.strictTuples)}})(l),d.opts.unevaluated&&n.length&&!0!==d.items&&(d.items=o.mergeEvaluated.items(s,n.length,d.items));let p=s.name("valid"),h=s.const("len",(0,r._)`${c}.length`);n.forEach((a,i)=>{(0,o.alwaysValidSchema)(d,a)||(s.if((0,r._)`${h} > ${i}`,()=>t.subschema({keyword:u,schemaProp:i,dataProp:i},p)),t.ok(p))})}t.validateTuple=i,t.default={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:r,it:n}=t;if(Array.isArray(r))return i(t,"additionalItems",r);n.items=!0,(0,o.alwaysValidSchema)(n,r)||t.ok((0,a.validateArray)(t))}}}),dt=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=de();t.default={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,r.validateTuple)(t,"items")}}),dr=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$(),a=uT(),i=u7();t.default={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>(0,r.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,r._)`{limit: ${t}}`},code(t){let{schema:r,parentSchema:n,it:s}=t,{prefixItems:l}=n;s.items=!0,(0,o.alwaysValidSchema)(s,r)||(l?(0,i.validateAdditionalItems)(t,l):t.ok((0,a.validateArray)(t)))}}}),da=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$();t.default={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:o}})=>void 0===o?(0,r.str)`must contain at least ${t} valid item(s)`:(0,r.str)`must contain at least ${t} and no more than ${o} valid item(s)`,params:({params:{min:t,max:o}})=>void 0===o?(0,r._)`{minContains: ${t}}`:(0,r._)`{minContains: ${t}, maxContains: ${o}}`},code(t){let a,i,{gen:n,schema:s,parentSchema:l,data:c,it:u}=t,{minContains:d,maxContains:p}=l;u.opts.next?(a=void 0===d?1:d,i=p):a=1;let h=n.const("len",(0,r._)`${c}.length`);if(t.setParams({min:a,max:i}),void 0===i&&0===a)return void(0,o.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==i&&a>i){(0,o.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,o.alwaysValidSchema)(u,s)){let o=(0,r._)`${h} >= ${a}`;void 0!==i&&(o=(0,r._)`${o} && ${h} <= ${i}`),t.pass(o);return}u.items=!0;let f=n.name("valid");function m(){let t=n.name("_valid"),o=n.let("count",0);y(t,()=>n.if(t,()=>{var t;return t=o,void(n.code((0,r._)`${t}++`),void 0===i?n.if((0,r._)`${t} >= ${a}`,()=>n.assign(f,!0).break()):(n.if((0,r._)`${t} > ${i}`,()=>n.assign(f,!1).break()),1===a?n.assign(f,!0):n.if((0,r._)`${t} >= ${a}`,()=>n.assign(f,!0))))}))}function y(r,a){n.forRange("i",0,h,i=>{t.subschema({keyword:"contains",dataProp:i,dataPropType:o.Type.Num,compositeRule:!0},r),a()})}void 0===i&&1===a?y(f,()=>n.if(f,()=>n.break())):0===a?(n.let(f,!0),void 0!==i&&n.if((0,r._)`${c}.length > 0`,m)):(n.let(f,!1),m()),t.result(f,()=>t.reset())}}}),di=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;let r=uw(),o=u$(),a=uT();t.error={message:({params:{property:t,depsCount:o,deps:a}})=>(0,r.str)`must have ${1===o?"property":"properties"} ${a} when property ${t} is present`,params:({params:{property:t,depsCount:o,deps:a,missingProperty:i}})=>(0,r._)`{property: ${t},
missingProperty: ${i},
depsCount: ${o},
deps: ${a}}`};let i={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(t){let[r,o]=function({schema:t}){let r={},o={};for(let a in t)"__proto__"!==a&&((Array.isArray(t[a])?r:o)[a]=t[a]);return[r,o]}(t);n(t,r),s(t,o)}};function n(t,o=t.schema){let{gen:i,data:s,it:l}=t;if(0===Object.keys(o).length)return;let c=i.let("missing");for(let n in o){let u=o[n];if(0===u.length)continue;let d=(0,a.propertyInData)(i,s,n,l.opts.ownProperties);t.setParams({property:n,depsCount:u.length,deps:u.join(", ")}),l.allErrors?i.if(d,()=>{for(let r of u)(0,a.checkReportMissingProp)(t,r)}):(i.if((0,r._)`${d} && (${(0,a.checkMissingProp)(t,u,c)})`),(0,a.reportMissingProp)(t,c),i.else())}}function s(t,r=t.schema){let{gen:i,data:n,keyword:l,it:c}=t,u=i.name("valid");for(let s in r)(0,o.alwaysValidSchema)(c,r[s])||(i.if((0,a.propertyInData)(i,n,s,c.opts.ownProperties),()=>{let r=t.subschema({keyword:l,schemaProp:s},u);t.mergeValidEvaluated(r,u)},()=>i.var(u,!0)),t.ok(u))}t.validatePropertyDeps=n,t.validateSchemaDeps=s,t.default=i}),dn=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$();t.default={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>(0,r._)`{propertyName: ${t.propertyName}}`},code(t){let{gen:a,schema:i,data:n,it:s}=t;if((0,o.alwaysValidSchema)(s,i))return;let l=a.name("valid");a.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},l),a.if((0,r.not)(l),()=>{t.error(!0),s.allErrors||a.break()})}),t.ok(l)}}}),ds=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uT(),o=uw(),a=uE(),i=u$();t.default={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>(0,o._)`{additionalProperty: ${t.additionalProperty}}`},code(t){let{gen:n,schema:s,parentSchema:l,data:c,errsCount:u,it:d}=t;if(!u)throw Error("ajv implementation error");let{allErrors:p,opts:h}=d;if(d.props=!0,"all"!==h.removeAdditional&&(0,i.alwaysValidSchema)(d,s))return;let f=(0,r.allSchemaProperties)(l.properties),m=(0,r.allSchemaProperties)(l.patternProperties);function y(t){n.code((0,o._)`delete ${c}[${t}]`)}function g(r){if("all"===h.removeAdditional||h.removeAdditional&&!1===s)return void y(r);if(!1===s){t.setParams({additionalProperty:r}),t.error(),p||n.break();return}if("object"==typeof s&&!(0,i.alwaysValidSchema)(d,s)){let a=n.name("valid");"failing"===h.removeAdditional?(v(r,a,!1),n.if((0,o.not)(a),()=>{t.reset(),y(r)})):(v(r,a),p||n.if((0,o.not)(a),()=>n.break()))}}function v(r,o,a){let n={keyword:"additionalProperties",dataProp:r,dataPropType:i.Type.Str};!1===a&&Object.assign(n,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(n,o)}n.forIn("key",c,a=>{f.length||m.length?n.if(function(a){let s;if(f.length>8){let t=(0,i.schemaRefOrVal)(d,l.properties,"properties");s=(0,r.isOwnProperty)(n,t,a)}else s=f.length?(0,o.or)(...f.map(t=>(0,o._)`${a} === ${t}`)):o.nil;return m.length&&(s=(0,o.or)(s,...m.map(i=>(0,o._)`${(0,r.usePattern)(t,i)}.test(${a})`))),(0,o.not)(s)}(a),()=>g(a)):g(a)}),t.ok((0,o._)`${u} === ${a.default.errors}`)}}}),dl=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uz(),o=uT(),a=u$(),i=ds();t.default={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:n,schema:s,parentSchema:l,data:c,it:u}=t;"all"===u.opts.removeAdditional&&void 0===l.additionalProperties&&i.default.code(new r.KeywordCxt(u,i.default,"additionalProperties"));let d=(0,o.allSchemaProperties)(s);for(let t of d)u.definedProperties.add(t);u.opts.unevaluated&&d.length&&!0!==u.props&&(u.props=a.mergeEvaluated.props(n,(0,a.toHash)(d),u.props));let p=d.filter(t=>!(0,a.alwaysValidSchema)(u,s[t]));if(0===p.length)return;let h=n.name("valid");for(let r of p){var f;(f=r,u.opts.useDefaults&&!u.compositeRule&&void 0!==s[f].default)?m(r):(n.if((0,o.propertyInData)(n,c,r,u.opts.ownProperties)),m(r),u.allErrors||n.else().var(h,!0),n.endIf()),t.it.definedProperties.add(r),t.ok(h)}function m(r){t.subschema({keyword:"properties",schemaProp:r,dataProp:r},h)}}}}),dc=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uT(),o=uw(),a=u$(),i=u$();t.default={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:n,schema:s,data:l,parentSchema:c,it:u}=t,{opts:d}=u,p=(0,r.allSchemaProperties)(s),h=p.filter(t=>(0,a.alwaysValidSchema)(u,s[t]));if(0===p.length||h.length===p.length&&(!u.opts.unevaluated||!0===u.props))return;let f=d.strictSchema&&!d.allowMatchingProperties&&c.properties,m=n.name("valid");!0===u.props||u.props instanceof o.Name||(u.props=(0,i.evaluatedPropsToName)(n,u.props));let{props:y}=u;for(let t of p)f&&function(t){for(let r in f)new RegExp(t).test(r)&&(0,a.checkStrictMode)(u,`property ${r} matches pattern ${t} (use allowMatchingProperties)`)}(t),u.allErrors?g(t):(n.var(m,!0),g(t),n.if(m));function g(a){n.forIn("key",l,s=>{n.if((0,o._)`${(0,r.usePattern)(t,a)}.test(${s})`,()=>{let r=h.includes(a);r||t.subschema({keyword:"patternProperties",schemaProp:a,dataProp:s,dataPropType:i.Type.Str},m),u.opts.unevaluated&&!0!==y?n.assign((0,o._)`${y}[${s}]`,!0):r||u.allErrors||n.if((0,o.not)(m),()=>n.break())})})}}}}),du=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=u$();t.default={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:o,schema:a,it:i}=t;if((0,r.alwaysValidSchema)(i,a))return void t.fail();let n=o.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),t.failResult(n,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}}}),dd=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:uT().validateUnion,error:{message:"must match a schema in anyOf"}}}),dp=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$();t.default={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>(0,r._)`{passingSchemas: ${t.passing}}`},code(t){let{gen:a,schema:i,parentSchema:n,it:s}=t;if(!Array.isArray(i))throw Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let l=a.let("valid",!1),c=a.let("passing",null),u=a.name("_valid");t.setParams({passing:c}),a.block(function(){i.forEach((i,n)=>{let d;(0,o.alwaysValidSchema)(s,i)?a.var(u,!0):d=t.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},u),n>0&&a.if((0,r._)`${u} && ${l}`).assign(l,!1).assign(c,(0,r._)`[${c}, ${n}]`).else(),a.if(u,()=>{a.assign(l,!0),a.assign(c,n),d&&t.mergeEvaluated(d,r.Name)})})}),t.result(l,()=>t.reset(),()=>t.error(!0))}}}),dh=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=u$();t.default={keyword:"allOf",schemaType:"array",code(t){let{gen:o,schema:a,it:i}=t;if(!Array.isArray(a))throw Error("ajv implementation error");let n=o.name("valid");a.forEach((o,a)=>{if((0,r.alwaysValidSchema)(i,o))return;let s=t.subschema({keyword:"allOf",schemaProp:a},n);t.ok(n),t.mergeEvaluated(s)})}}}),df=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$();function a(t,r){let a=t.schema[r];return void 0!==a&&!(0,o.alwaysValidSchema)(t,a)}t.default={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>(0,r.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,r._)`{failingKeyword: ${t.ifClause}}`},code(t){let i,{gen:n,parentSchema:s,it:l}=t;void 0===s.then&&void 0===s.else&&(0,o.checkStrictMode)(l,'"if" without "then" and "else" is ignored');let c=a(l,"then"),u=a(l,"else");if(!c&&!u)return;let d=n.let("valid",!0),p=n.name("_valid");if(i=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},p),t.mergeEvaluated(i),t.reset(),c&&u){let r=n.let("ifClause");t.setParams({ifClause:r}),n.if(p,h("then",r),h("else",r))}else c?n.if(p,h("then")):n.if((0,r.not)(p),h("else"));function h(o,a){return()=>{let i=t.subschema({keyword:o},p);n.assign(d,p),t.mergeValidEvaluated(i,d),a?n.assign(a,(0,r._)`${o}`):t.setParams({ifClause:o})}}t.pass(d,()=>t.error(!0))}}}),dm=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=u$();t.default={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:o,it:a}){void 0===o.if&&(0,r.checkStrictMode)(a,`"${t}" without "if" is ignored`)}}}),dy=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=u7(),o=dt(),a=de(),i=dr(),n=da(),s=di(),l=dn(),c=ds(),u=dl(),d=dc(),p=du(),h=dd(),f=dp(),m=dh(),y=df(),g=dm();t.default=function(t=!1){let v=[p.default,h.default,f.default,m.default,y.default,g.default,l.default,c.default,s.default,u.default,d.default];return t?v.push(o.default,i.default):v.push(r.default,a.default),v.push(n.default),v}}),dg=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw();t.default={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>(0,r.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,r._)`{format: ${t}}`},code(t,o){let a,i,n,s,l,c,{gen:u,data:d,$data:p,schema:h,schemaCode:f,it:m}=t,{opts:y,errSchemaPath:g,schemaEnv:v,self:_}=m;y.validateFormats&&(p?(a=u.scopeValue("formats",{ref:_.formats,code:y.code.formats}),i=u.const("fDef",(0,r._)`${a}[${f}]`),n=u.let("fType"),s=u.let("format"),u.if((0,r._)`typeof ${i} == "object" && !(${i} instanceof RegExp)`,()=>u.assign(n,(0,r._)`${i}.type || "string"`).assign(s,(0,r._)`${i}.validate`),()=>u.assign(n,(0,r._)`"string"`).assign(s,i)),t.fail$data((0,r.or)(!1===y.strictSchema?r.nil:(0,r._)`${f} && !${s}`,(l=v.$async?(0,r._)`(${i}.async ? await ${s}(${d}) : ${s}(${d}))`:(0,r._)`${s}(${d})`,c=(0,r._)`(typeof ${s} == "function" ? ${l} : ${s}.test(${d}))`,(0,r._)`${s} && ${s} !== true && ${n} === ${o} && !${c}`)))):function(){var a;let i,n,s=_.formats[h];if(!s){if(!1===y.strictSchema)return _.logger.warn(l());throw Error(l());function l(){return`unknown format "${h}" ignored in schema at path "${g}"`}}if(!0===s)return;let[c,p,f]=(i=(a=s)instanceof RegExp?(0,r.regexpCode)(a):y.code.formats?(0,r._)`${y.code.formats}${(0,r.getProperty)(h)}`:void 0,n=u.scopeValue("formats",{key:h,ref:a,code:i}),"object"!=typeof a||a instanceof RegExp?["string",a,n]:[a.type||"string",a.validate,(0,r._)`${n}.validate`]);c===o&&t.pass(function(){if("object"==typeof s&&!(s instanceof RegExp)&&s.async){if(!v.$async)throw Error("async format in sync schema");return(0,r._)`await ${f}(${d})`}return"function"==typeof p?(0,r._)`${f}(${d})`:(0,r._)`${f}.test(${d})`}())}())}}}),dv=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=[dg().default]}),d_=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]}),db=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uZ(),o=u8(),a=dy(),i=dv(),n=d_();t.default=[r.default,o.default,(0,a.default)(),i.default,n.metadataVocabulary,n.contentVocabulary]}),dS=z(t=>{var r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,(o=r||(t.DiscrError=r={})).Tag="tag",o.Mapping="mapping"}),dw=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=dS(),a=uU(),i=uH(),n=u$();t.default={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:r}})=>t===o.DiscrError.Tag?`tag "${r}" must be string`:`value of tag "${r}" must be in oneOf`,params:({params:{discrError:t,tag:o,tagName:a}})=>(0,r._)`{error: ${t}, tag: ${a}, tagValue: ${o}}`},code(t){let{gen:s,data:l,schema:c,parentSchema:u,it:d}=t,{oneOf:p}=u;if(!d.opts.discriminator)throw Error("discriminator: requires discriminator option");let h=c.propertyName;if("string"!=typeof h)throw Error("discriminator: requires propertyName");if(c.mapping)throw Error("discriminator: mapping is not supported");if(!p)throw Error("discriminator: requires oneOf keyword");let f=s.let("valid",!1),m=s.const("tag",(0,r._)`${l}${(0,r.getProperty)(h)}`);s.if((0,r._)`typeof ${m} == "string"`,()=>(function(){let l=function(){var t;let r={},o=l(u),s=!0;for(let r=0;r<p.length;r++){let u=p[r];if((null==u?void 0:u.$ref)&&!(0,n.schemaHasRulesButRef)(u,d.self.RULES)){let t=u.$ref;if((u=a.resolveRef.call(d.self,d.schemaEnv.root,d.baseId,t))instanceof a.SchemaEnv&&(u=u.schema),void 0===u)throw new i.default(d.opts.uriResolver,d.baseId,t)}let f=null==(t=null==u?void 0:u.properties)?void 0:t[h];if("object"!=typeof f)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${h}"`);s=s&&(o||l(u)),function(t,r){if(t.const)c(t.const,r);else if(t.enum)for(let o of t.enum)c(o,r);else throw Error(`discriminator: "properties/${h}" must have "const" or "enum"`)}(f,r)}if(!s)throw Error(`discriminator: "${h}" must be required`);return r;function l({required:t}){return Array.isArray(t)&&t.includes(h)}function c(t,o){if("string"!=typeof t||t in r)throw Error(`discriminator: "${h}" values must be unique strings`);r[t]=o}}();for(let o in s.if(!1),l)s.elseIf((0,r._)`${m} === ${o}`),s.assign(f,function(o){let a=s.name("valid"),i=t.subschema({keyword:"oneOf",schemaProp:o},a);return t.mergeEvaluated(i,r.Name),a}(l[o]));s.else(),t.error(!1,{discrError:o.DiscrError.Mapping,tag:m,tagName:h}),s.endIf()})(),()=>t.error(!1,{discrError:o.DiscrError.Tag,tag:m,tagName:h})),t.ok(f)}}}),d$=z((t,r)=>{r.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}}),dE=z((t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;let o=uW(),a=db(),i=dw(),n=d$(),s=["/properties"],l="http://json-schema.org/draft-07/schema";var c=class extends o.default{_addVocabularies(){super._addVocabularies(),a.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(n,s):n;this.addMetaSchema(t,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};t.Ajv=c,r.exports=t=c,r.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=uz();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=uw();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var p=uq();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return p.default}});var h=uH();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})}),dP=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicAnchor=void 0;let r=uw(),o=uE(),a=uU(),i=uB();function n(t,n){let{gen:s,it:l}=t;l.schemaEnv.root.dynamicAnchors[n]=!0;let c=(0,r._)`${o.default.dynamicAnchors}${(0,r.getProperty)(n)}`,u="#"===l.errSchemaPath?l.validateName:function(t){let{schemaEnv:r,schema:o,self:n}=t.it,{root:s,baseId:l,localRefs:c,meta:u}=r.root,{schemaId:d}=n.opts,p=new a.SchemaEnv({schema:o,schemaId:d,root:s,baseId:l,localRefs:c,meta:u});return a.compileSchema.call(n,p),(0,i.getValidate)(t,p)}(t);s.if((0,r._)`!${c}`,()=>s.assign(c,u))}t.dynamicAnchor=n,t.default={keyword:"$dynamicAnchor",schemaType:"string",code:t=>n(t,t.schema)}}),dk=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dynamicRef=void 0;let r=uw(),o=uE(),a=uB();function i(t,i){let{gen:n,keyword:s,it:l}=t;if("#"!==i[0])throw Error(`"${s}" only supports hash fragment reference`);let c=i.slice(1);if(l.allErrors)u();else{let r=n.let("valid",!1);u(r),t.ok(r)}function u(t){if(l.schemaEnv.root.dynamicAnchors[c]){let a=n.let("_v",(0,r._)`${o.default.dynamicAnchors}${(0,r.getProperty)(c)}`);n.if(a,d(a,t),d(l.validateName,t))}else d(l.validateName,t)()}function d(r,o){return o?()=>n.block(()=>{(0,a.callRef)(t,r),n.let(o,!0)}):()=>(0,a.callRef)(t,r)}}t.dynamicRef=i,t.default={keyword:"$dynamicRef",schemaType:"string",code:t=>i(t,t.schema)}}),dR=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dP(),o=u$();t.default={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,r.dynamicAnchor)(t,""):(0,o.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}}}),dx=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dk();t.default={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,r.dynamicRef)(t,t.schema)}}),dC=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dP(),o=dk(),a=dR(),i=dx();t.default=[r.default,o.default,a.default,i.default]}),dA=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=di();t.default={keyword:"dependentRequired",type:"object",schemaType:"object",error:r.error,code:t=>(0,r.validatePropertyDeps)(t)}}),dT=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=di();t.default={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,r.validateSchemaDeps)(t)}}),dO=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=u$();t.default={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:o,it:a}){void 0===o.contains&&(0,r.checkStrictMode)(a,`"${t}" without "contains" is ignored`)}}}),dj=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dA(),o=dT(),a=dO();t.default=[r.default,o.default,a.default]}),dI=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$(),a=uE();t.default={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:t})=>(0,r._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},code(t){let{gen:i,schema:n,data:s,errsCount:l,it:c}=t;if(!l)throw Error("ajv implementation error");let{allErrors:u,props:d}=c;function p(a){if(!1===n){t.setParams({unevaluatedProperty:a}),t.error(),u||i.break();return}if(!(0,o.alwaysValidSchema)(c,n)){let n=i.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:a,dataPropType:o.Type.Str},n),u||i.if((0,r.not)(n),()=>i.break())}}d instanceof r.Name?i.if((0,r._)`${d} !== true`,()=>i.forIn("key",s,t=>{var o,a;return i.if((o=d,a=t,(0,r._)`!${o} || !${o}[${a}]`),()=>p(t))})):!0!==d&&i.forIn("key",s,t=>void 0===d?p(t):i.if(function(t,o){let a=[];for(let i in t)!0===t[i]&&a.push((0,r._)`${o} !== ${i}`);return(0,r.and)(...a)}(d,t),()=>p(t))),c.props=!0,t.ok((0,r._)`${l} === ${a.default.errors}`)}}}),dN=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uw(),o=u$();t.default={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:t}})=>(0,r.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,r._)`{limit: ${t}}`},code(t){let{gen:a,schema:i,data:n,it:s}=t,l=s.items||0;if(!0===l)return;let c=a.const("len",(0,r._)`${n}.length`);if(!1===i)t.setParams({len:l}),t.fail((0,r._)`${c} > ${l}`);else if("object"==typeof i&&!(0,o.alwaysValidSchema)(s,i)){let i=a.var("valid",(0,r._)`${c} <= ${l}`);a.if((0,r.not)(i),()=>{var n,u;return n=i,u=l,void a.forRange("i",u,c,i=>{t.subschema({keyword:"unevaluatedItems",dataProp:i,dataPropType:o.Type.Num},n),s.allErrors||a.if((0,r.not)(n),()=>a.break())})}),t.ok(i)}s.items=!0}}}),dM=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dI(),o=dN();t.default=[r.default,o.default]}),dz=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}}),dq=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}}),dH=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}}),dU=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}}),dD=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}}),dL=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}}),dK=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}}),dJ=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dz(),o=dq(),a=dH(),i=dU(),n=dD(),s=dL(),l=dK(),c=["/properties"];t.default=function(t){return[r,o,a,i,u(this,n),s,u(this,l)].forEach(t=>this.addMetaSchema(t,void 0,!1)),this;function u(r,o){return t?r.$dataMetaSchema(o,c):o}}}),dV=z((t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2019=void 0;let o=uW(),a=db(),i=dC(),n=dj(),s=dM(),l=dw(),c=dJ(),u="https://json-schema.org/draft/2019-09/schema";var d=class extends o.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),a.default.forEach(t=>this.addVocabulary(t)),this.addVocabulary(n.default),this.addVocabulary(s.default),this.opts.discriminator&&this.addKeyword(l.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:t,meta:r}=this.opts;r&&(c.default.call(this,t),this.refs["http://json-schema.org/schema"]=u)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(u)?u:void 0)}};t.Ajv2019=d,r.exports=t=d,r.exports.Ajv2019=d,Object.defineProperty(t,"__esModule",{value:!0}),t.default=d;var p=uz();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return p.KeywordCxt}});var h=uw();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return h._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return h.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return h.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return h.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return h.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return h.CodeGen}});var f=uq();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=uH();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})}),dW=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=uZ(),o=u8(),a=dy(),i=dC(),n=dj(),s=dM(),l=dv(),c=d_();t.default=[i.default,r.default,o.default,(0,a.default)(!0),l.default,c.metadataVocabulary,c.contentVocabulary,n.default,s.default]}),dF=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}}),dB=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}}),dZ=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}}),dG=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}}),dX=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}}),dY=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}}),dQ=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}}),d0=z((t,r)=>{r.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}}),d1=z(t=>{Object.defineProperty(t,"__esModule",{value:!0});let r=dF(),o=dB(),a=dZ(),i=dG(),n=dX(),s=dY(),l=dQ(),c=d0(),u=["/properties"];t.default=function(t){return[r,o,a,i,n,d(this,s),l,d(this,c)].forEach(t=>this.addMetaSchema(t,void 0,!1)),this;function d(r,o){return t?r.$dataMetaSchema(o,u):o}}}),d2=z((t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;let o=uW(),a=dW(),i=dw(),n=d1(),s="https://json-schema.org/draft/2020-12/schema";var l=class extends o.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),a.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:t,meta:r}=this.opts;r&&(n.default.call(this,t),this.refs["http://json-schema.org/schema"]=s)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};t.Ajv2020=l,r.exports=t=l,r.exports.Ajv2020=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=uz();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=uw();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=uq();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=uH();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}),d9=z(t=>{function r(t,r){return{validate:t,compare:r}}Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0,t.fullFormats={date:r(i,n),time:r(l(!0),c),"date-time":r(p(!0),h),"iso-time":r(l(),u),"iso-date-time":r(p(),f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(t){return m.test(t)&&y.test(t)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(t){if(S.test(t))return!1;try{return new RegExp(t),!0}catch(t){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(t){return g.lastIndex=0,g.test(t)},int32:{type:"number",validate:function(t){return Number.isInteger(t)&&t<=_&&t>=v}},int64:{type:"number",validate:function(t){return Number.isInteger(t)}},float:{type:"number",validate:b},double:{type:"number",validate:b},password:!0,binary:!0},t.fastFormats={...t.fullFormats,date:r(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,n),time:r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":r(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,h),"iso-time":r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":r(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},t.formatNames=Object.keys(t.fullFormats);let o=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,a=[0,31,28,31,30,31,30,31,31,30,31,30,31];function i(t){var r;let i=o.exec(t);if(!i)return!1;let n=+i[1],s=+i[2],l=+i[3];return s>=1&&s<=12&&l>=1&&l<=(2===s&&(r=n)%4==0&&(r%100!=0||r%400==0)?29:a[s])}function n(t,r){if(t&&r)return t>r?1:t<r?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function l(t){return function(r){let o=s.exec(r);if(!o)return!1;let a=+o[1],i=+o[2],n=+o[3],l=o[4],c="-"===o[5]?-1:1,u=+(o[6]||0),d=+(o[7]||0);if(u>23||d>59||t&&!l)return!1;if(a<=23&&i<=59&&n<60)return!0;let p=i-d*c,h=a-u*c-(p<0);return(23===h||-1===h)&&(59===p||-1===p)&&n<61}}function c(t,r){if(!(t&&r))return;let o=new Date("2020-01-01T"+t).valueOf(),a=new Date("2020-01-01T"+r).valueOf();if(o&&a)return o-a}function u(t,r){if(!(t&&r))return;let o=s.exec(t),a=s.exec(r);if(o&&a)return(t=o[1]+o[2]+o[3])>(r=a[1]+a[2]+a[3])?1:t<r?-1:0}let d=/t|\s/i;function p(t){let r=l(t);return function(t){let o=t.split(d);return 2===o.length&&i(o[0])&&r(o[1])}}function h(t,r){if(!(t&&r))return;let o=new Date(t).valueOf(),a=new Date(r).valueOf();if(o&&a)return o-a}function f(t,r){if(!(t&&r))return;let[o,a]=t.split(d),[i,s]=r.split(d),l=n(o,i);if(void 0!==l)return l||c(a,s)}let m=/\/|:/,y=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm,v=-0x80000000,_=0x80000000-1;function b(){return!0}let S=/[^\\]\\Z/}),d4=z(t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;let r=dE(),o=uw(),a=o.operators,i={formatMaximum:{okStr:"<=",ok:a.LTE,fail:a.GT},formatMinimum:{okStr:">=",ok:a.GTE,fail:a.LT},formatExclusiveMaximum:{okStr:"<",ok:a.LT,fail:a.GTE},formatExclusiveMinimum:{okStr:">",ok:a.GT,fail:a.LTE}};t.formatLimitDefinition={keyword:Object.keys(i),type:"string",schemaType:"string",$data:!0,error:{message:({keyword:t,schemaCode:r})=>(0,o.str)`should be ${i[t].okStr} ${r}`,params:({keyword:t,schemaCode:r})=>(0,o._)`{comparison: ${i[t].okStr}, limit: ${r}}`},code(t){let a,n,{gen:s,data:l,schemaCode:c,keyword:u,it:d}=t,{opts:p,self:h}=d;if(!p.validateFormats)return;let f=new r.KeywordCxt(d,h.RULES.all.format.definition,"format");function m(t){return(0,o._)`${t}.compare(${l}, ${c}) ${i[u].fail} 0`}f.$data?(a=s.scopeValue("formats",{ref:h.formats,code:p.code.formats}),n=s.const("fmt",(0,o._)`${a}[${f.schemaCode}]`),t.fail$data((0,o.or)((0,o._)`typeof ${n} != "object"`,(0,o._)`${n} instanceof RegExp`,(0,o._)`typeof ${n}.compare != "function"`,m(n)))):function(){let r=f.schema,a=h.formats[r];if(!a||!0===a)return;if("object"!=typeof a||a instanceof RegExp||"function"!=typeof a.compare)throw Error(`"${u}": format "${r}" does not define "compare" function`);let i=s.scopeValue("formats",{key:r,ref:a,code:p.code.formats?(0,o._)`${p.code.formats}${(0,o.getProperty)(r)}`:void 0});t.fail$data(m(i))}()},dependencies:["format"]},t.default=r=>(r.addKeyword(t.formatLimitDefinition),r)}),d5=z((t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});let o=d9(),a=d4(),i=uw(),n=new i.Name("fullFormats"),s=new i.Name("fastFormats"),l=(t,r={keywords:!0})=>{if(Array.isArray(r))return c(t,r,o.fullFormats,n),t;let[i,l]="fast"===r.mode?[o.fastFormats,s]:[o.fullFormats,n];return c(t,r.formats||o.formatNames,i,l),r.keywords&&(0,a.default)(t),t};function c(t,r,o,a){var n;for(let s of(null!=(n=t.opts.code).formats||(n.formats=(0,i._)`require("ajv-formats/dist/formats").${a}`),r))t.addFormat(s,o[s])}l.get=(t,r="full")=>{let a=("fast"===r?o.fastFormats:o.fullFormats)[t];if(!a)throw Error(`Unknown format "${t}"`);return a},r.exports=t=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l}),d3=dE(),d6=dV(),d8=d2();let d7=q(d5(),1).default;function pe(t){let r=new t({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return d7(r),r}var pt=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(t){this._userAjv=void 0!==t,this._ajv=t}get ajv(){return this._ajv??=pe(d8.Ajv2020)}_engineFor(t){if(this._userAjv)return this.ajv;let r=function(t,r){if(!("$schema"in t)||"string"!=typeof t.$schema)return"2020-12";let o=t.$schema.replace(/#$/,"");if(H.has(o))return"2020-12";if(U.has(o))return"2019-09";if(D.has(o)||L.has(o))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${t.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${r}`)}(t,"pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.");return"2020-12"===r?this.ajv:"2019-09"===r?this._ajv2019??=pe(d6.Ajv2019):this._ajvDraft7??=pe(d3.Ajv)}getValidator(t){let r=this._engineFor(t),o="$id"in t&&"string"==typeof t.$id?r.getSchema(t.$id)??r.compile(t):r.compile(t);return t=>o(t)?{valid:!0,data:t,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errorsText(o.errors)}}};async function pr(t){return(await u).getRandomValues(new Uint8Array(t))}async function po(t){let r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",o=256-256%r.length,a="";for(;a.length<t;)for(let i of(await pr(t-a.length)))i<o&&(a+=r[i%r.length]);return a}async function pa(t){return await po(t)}async function pi(t){return btoa(String.fromCharCode(...new Uint8Array(await (await u).subtle.digest("SHA-256",new TextEncoder().encode(t))))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function pn(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;let r=await pa(t),o=await pi(r);return{code_verifier:r,code_challenge:o}}d3.Ajv,u=globalThis.crypto?.webcrypto??globalThis.crypto??Promise.resolve().then(i.t.bind(i,7598,19)).then(t=>t.webcrypto);class ps extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}function pl(t){}function pc(t,r,o){return 100===o&&97===t.charCodeAt(r+1)&&116===t.charCodeAt(r+2)&&97===t.charCodeAt(r+3)&&58===t.charCodeAt(r+4)}function pu(t,r,o){return 101===o&&118===t.charCodeAt(r+1)&&101===t.charCodeAt(r+2)&&110===t.charCodeAt(r+3)&&116===t.charCodeAt(r+4)&&58===t.charCodeAt(r+5)}class pd extends TransformStream{constructor({onError:t,onRetry:r,onComment:o,maxBufferSize:a}={}){let i;super({start(n){i=function(t){if("function"==typeof t)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:r=pl,onError:o=pl,onRetry:a=pl,onComment:i,maxBufferSize:n}=t,s=[],l=0,c=!0,u,d="",p=0,h,f=!1;function m(){void 0!==n&&(l+d.length<=n||(f=!0,s.length=0,l=0,u=void 0,d="",p=0,h=void 0,o(new ps(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function y(t){let o=0;if(-1===t.indexOf("\r")){let a=t.indexOf(`
`,o);for(;-1!==a;){if(o===a){p>0&&r({id:u,event:h,data:d}),u=void 0,d="",p=0,h=void 0,o=a+1,a=t.indexOf(`
`,o);continue}let i=t.charCodeAt(o);if(pc(t,o,i)){let i=32===t.charCodeAt(o+5)?o+6:o+5,n=t.slice(i,a);if(0===p&&10===t.charCodeAt(a+1)){r({id:u,event:h,data:n}),u=void 0,d="",h=void 0,o=a+2,a=t.indexOf(`
`,o);continue}d=0===p?n:`${d}
${n}`,p++}else pu(t,o,i)?h=t.slice(32===t.charCodeAt(o+6)?o+7:o+6,a)||void 0:g(t,o,a);o=a+1,a=t.indexOf(`
`,o)}return t.slice(o)}for(;o<t.length;){let r=t.indexOf("\r",o),a=t.indexOf(`
`,o),i=-1;if(-1!==r&&-1!==a?i=r<a?r:a:-1!==r?i=r===t.length-1?-1:r:-1!==a&&(i=a),-1===i)break;g(t,o,i),o=i+1,13===t.charCodeAt(o-1)&&10===t.charCodeAt(o)&&o++}return t.slice(o)}function g(t,o,a){if(o===a)return void(p>0&&r({id:u,event:h,data:d}),u=void 0,d="",p=0,h=void 0);let n=t.charCodeAt(o);if(pc(t,o,n)){let r=32===t.charCodeAt(o+5)?o+6:o+5,i=t.slice(r,a);d=0===p?i:`${d}
${i}`,p++;return}if(pu(t,o,n)){h=t.slice(32===t.charCodeAt(o+6)?o+7:o+6,a)||void 0;return}if(105===n&&100===t.charCodeAt(o+1)&&58===t.charCodeAt(o+2)){let r=t.slice(32===t.charCodeAt(o+3)?o+4:o+3,a);u=r.includes("\0")?void 0:r;return}if(58===n){i&&i(t.slice(o,a).slice(32===t.charCodeAt(o+1)?2:1));return}let s=t.slice(o,a),l=s.indexOf(":");if(-1===l)return void v(s,"",s);let c=s.slice(0,l),f=32===s.charCodeAt(l+1)?2:1;v(c,s.slice(l+f),s)}function v(t,r,i){switch(t){case"event":h=r||void 0;break;case"data":d=0===p?r:`${d}
${r}`,p++;break;case"id":u=r.includes("\0")?void 0:r;break;case"retry":/^\d+$/.test(r)?a(parseInt(r,10)):o(new ps(`Invalid \`retry\` value: "${r}"`,{type:"invalid-retry",value:r,line:i}));break;default:o(new ps(`Unknown field "${t.length>20?`${t.slice(0,20)}\u2026`:t}"`,{type:"unknown-field",field:t,value:r,line:i}))}}return{feed:function(t){if(f)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,239===t.charCodeAt(0)&&187===t.charCodeAt(1)&&191===t.charCodeAt(2)&&(t=t.slice(3))),0===s.length){let r=y(t);""!==r&&(s.push(r),l=r.length),m();return}if(-1===t.indexOf(`
`)&&-1===t.indexOf("\r")){s.push(t),l+=t.length,m();return}s.push(t);let r=s.join("");s.length=0,l=0;let o=y(r);""!==o&&(s.push(o),l=o.length),m()},reset:function(t={}){if(t.consume&&s.length>0){let t=s.join("");g(t,0,t.length)}c=!0,u=void 0,d="",p=0,h=void 0,s.length=0,l=0,f=!1}}}({onEvent:t=>{n.enqueue(t)},onError(r){"function"==typeof t&&t(r),("terminate"===t||"max-buffer-size-exceeded"===r.type)&&n.error(r)},onRetry:r,onComment:o,maxBufferSize:a})},transform(t){i.feed(t)}})}}var pp=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t){super(t),this.name=new.target.name,lz(this,new.target)}},ph=class extends pp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(t,r,o){super(`Issuer mismatch in ${"metadata"===t?"authorization server metadata (RFC 8414 \xa73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(r)}, received ${JSON.stringify(o)}`),this.kind=t,this.expected=r,this.received=o}},pf=class extends pp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(t){super(`Dynamic Client Registration rejected (HTTP ${t.status}): ${t.body}`),this.status=t.status,this.body=t.body,this.submittedMetadata=t.submittedMetadata}},pm=class extends pp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(t){super(`Refusing to send credentials to non-https token endpoint '${t}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=t}},py=class extends pp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(t,r){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(t)} but this call resolved ${JSON.stringify(r)}; refusing to present them to a different authorization server`),this.recordedIssuer=t,this.currentIssuer=r}},pg=class extends pp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(t){super(`Insufficient scope${t.requiredScope?`: required "${t.requiredScope}"`:""}`),this.requiredScope=t.requiredScope,this.resourceMetadataUrl=t.resourceMetadataUrl,this.errorDescription=t.errorDescription}};function pv(t,r,o){if(t)return"string"!=typeof t.issuer?(o?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),void 0===t.issuer?t:{...t,issuer:void 0}):p_(t.issuer,r)?t:void 0}function p_(t,r){return t===r||t.endsWith("/")&&t.slice(0,-1)===r||r.endsWith("/")&&r.slice(0,-1)===t}async function pb(t,r,o){let{resourceMetadataUrl:a,scope:i}=pN(r.response);if(await pT(t,{serverUrl:r.serverUrl,resourceMetadataUrl:a,scope:i,fetchFn:r.fetchFn,...o})!=="AUTHORIZED")throw new pS}var pS=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t){super(t??"Unauthorized"),this.name="UnauthorizedError",lz(this,new.target)}};function pw(t){return t?.authorization_response_iss_parameter_supported===!0}function p$({iss:t,expectedIssuer:r,issParameterSupported:o}){if(void 0!==r){if(void 0===t){if(o)throw new ph("authorization_response",r,void 0);return}if(t!==r)throw new ph("authorization_response",r,t)}}function pE(...t){let r=new Set;for(let o of t)if(o)for(let t of o.split(/\s+/))t&&r.add(t);return r.size>0?[...r].join(" "):void 0}async function pP(t,r,o,a,i){if("string"==typeof t)return{authorizationCode:t,iss:r};let n=t.get("iss")??void 0,s=t.get("code");if(s)return{authorizationCode:s,iss:n};let l=(await o.discoveryState?.())?.authorizationServerMetadata;if(!l)try{l=(await pL(a,i)).authorizationServerMetadata}catch{l=void 0}if(!l)throw new pS("Authorization callback failed and the issuer could not be verified");p$({iss:n,expectedIssuer:l.issuer,issParameterSupported:pw(l)});let c=t.get("error");if(c)throw new lU(c,t.get("error_description")??c,t.get("error_uri")??void 0);throw new pS("Authorization callback contained neither `code` nor `error`")}let pk="code",pR="S256";function px(t){return"localhost"===t||t.endsWith(".localhost")||"127.0.0.1"===t||"[::1]"===t||"::1"===t}async function pC(t){let r=t instanceof Response?t.status:void 0,o=t instanceof Response?await t.text():t;try{let t=lC.parse(JSON.parse(o));return lU.fromResponse(t)}catch(a){let t=`${r?`HTTP ${r}: `:""}Invalid OAuth error response: ${a}. Raw body: ${o}`;return new lU(lH.ServerError,t)}}function pA(t,r,o){let a=void 0===t.invalidateCredentials?`retrying authorization without discarding the stored ${o} (provider implements no invalidateCredentials())`:`invalidating the stored ${o} and retrying authorization`;console.warn(`[mcp-sdk] OAuth ${JSON.stringify(r.code)} — ${a}. Cause: ${JSON.stringify(r.message)}`)}async function pT(t,r){try{return await pO(t,r)}catch(o){if(o instanceof lU){if(o.code===lH.InvalidClient||o.code===lH.UnauthorizedClient)return pA(t,o,"client credentials and tokens"),await t.invalidateCredentials?.("client"),await t.invalidateCredentials?.("tokens"),await pO(t,r);else if(o.code===lH.InvalidGrant||o.code===lH.InvalidDpopProof)return pA(t,o,"tokens"),await t.invalidateCredentials?.("tokens"),await pO(t,r)}throw o}}async function pO(t,{serverUrl:r,authorizationCode:o,iss:a,scope:i,resourceMetadataUrl:n,fetchFn:s,skipIssuerMetadataValidation:l,forceReauthorization:c}){var u;let d,p,h,f,m,y={...m=(u=t).clientMetadata,grant_types:m.grant_types??(void 0===u.redirectUrl?void 0:["authorization_code","refresh_token"]),application_type:m.application_type??function(t){for(let r of t??[]){let t;try{t=new URL(r)}catch{continue}if("http:"!==t.protocol&&"https:"!==t.protocol||px(t.hostname))return"native"}return"web"}(m.redirect_uris)},g=await t.discoveryState?.(),v=n;if(!v&&g?.resourceMetadataUrl&&(v=new URL(g.resourceMetadataUrl)),g?.authorizationServerUrl){if(p=g.authorizationServerUrl,d=g.resourceMetadata,h=g.authorizationServerMetadata??await pD(p,{fetchFn:s,skipIssuerValidation:l}),!d)try{d=await pz(r,{resourceMetadataUrl:v},s)}catch(t){if(t instanceof TypeError)throw t}(h!==g.authorizationServerMetadata||d!==g.resourceMetadata)&&await t.saveDiscoveryState?.({authorizationServerUrl:String(p),resourceMetadataUrl:v?.toString(),resourceMetadata:d,authorizationServerMetadata:h})}else{let t=await pL(r,{resourceMetadataUrl:v,fetchFn:s,skipIssuerMetadataValidation:l});p=t.authorizationServerUrl,h=t.authorizationServerMetadata,d=t.resourceMetadata,f={authorizationServerUrl:String(p),resourceMetadataUrl:v?.toString(),resourceMetadata:d,authorizationServerMetadata:h}}let _=h?.issuer??String(p),b={issuer:_};if(await t.saveAuthorizationServerUrl?.(_),void 0!==o){let r=g?.authorizationServerMetadata?.issuer??g?.authorizationServerUrl;if(void 0===r){if(void 0!==t.saveDiscoveryState)throw new py("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",_);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside codeVerifier) — see docs/migration/upgrade-to-v2.md \xa7SEP-2352.")}else if(!p_(r,_))throw new py(r,_)}f&&await t.saveDiscoveryState?.(f);let S=await pj(r,t,d),w=S&&d&&!t.validateResourceURL?d.resource:S;w&&await t.saveResourceUrl?.(pK(w));let $=function(t){let{requestedScope:r,resourceMetadata:o,authServerMetadata:a,clientMetadata:i}=t,n=r||o?.scopes_supported?.join(" ")||i.scope;return n&&a?.scopes_supported?.includes("offline_access")&&!n.split(" ").includes("offline_access")&&i.grant_types?.includes("refresh_token")&&(n=`${n} offline_access`),n}({requestedScope:i,resourceMetadata:d,authServerMetadata:h,clientMetadata:t.clientMetadata}),E=await Promise.resolve(t.clientInformation(b)),P=pv(E,_,{canPersistStamp:void 0!==t.saveClientInformation});if(void 0===P&&E?.issuer&&void 0===t.saveClientInformation)throw new py(E.issuer,_);if(P&&void 0===P.issuer&&(P={...P,issuer:_},await t.saveClientInformation?.(P,b)),!P){if(void 0!==o)throw Error("Existing OAuth client information is required when exchanging an authorization code");let r=h?.client_id_metadata_document_supported===!0,a=t.clientMetadataUrl;if(a&&!function(t){if(!t)return!1;try{let r=new URL(t);return"https:"===r.protocol&&"/"!==r.pathname}catch{return!1}}(a))throw new lU(lH.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${a}`);if(r&&a)P={client_id:a,issuer:_},await t.saveClientInformation?.(P,b);else{if(!t.saveClientInformation)throw Error("OAuth client information must be saveable for dynamic registration");P={...await pB(p,{metadata:h,clientMetadata:y,scope:$,fetchFn:s}),issuer:_},await t.saveClientInformation(P,b)}}let k=!t.redirectUrl;if(void 0!==o||k){void 0!==o&&p$({iss:a,expectedIssuer:h?.issuer,issParameterSupported:pw(h)});let r=await pF(t,p,{metadata:h,resource:w,authorizationCode:o,iss:a,scope:$,fetchFn:s});return await t.saveTokens({...r,issuer:_},b),"AUTHORIZED"}let R=pv(await t.tokens(b),_);if(R&&void 0===R.issuer&&(R={...R,issuer:_},await t.saveTokens(R,b)),R?.refresh_token&&!c){let r;try{r=await pW(p,{metadata:h,clientInformation:P,refreshToken:R.refresh_token,resource:w,addClientAuthentication:t.addClientAuthentication,dpop:await t.dpop?.(),fetchFn:s})}catch(t){if(t instanceof pm||t instanceof lU&&t.code!==lH.ServerError)throw t;console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(t instanceof Error?t.message:String(t))}`)}if(r)return await t.saveTokens({...r,issuer:_},b),"AUTHORIZED"}let x=t.state?await t.state():void 0,{authorizationUrl:C,codeVerifier:A}=await pJ(p,{metadata:h,clientInformation:P,state:x,redirectUrl:t.redirectUrl,scope:$,resource:w});return await t.saveCodeVerifier(A),await t.redirectToAuthorization(C),"REDIRECT"}async function pj(t,r,o){var a;let i,n=((i=new URL("string"==typeof(a=t)?a:a.href)).hash="",i);if(r.validateResourceURL)return await r.validateResourceURL(n,o?.resource);if(o){if(!function({requestedResource:t,configuredResource:r}){let o=new URL("string"==typeof t?t:t.href),a=new URL("string"==typeof r?r:r.href);if(o.origin!==a.origin||o.pathname.length<a.pathname.length)return!1;let i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/",n=a.pathname.endsWith("/")?a.pathname:a.pathname+"/";return i.startsWith(n)}({requestedResource:n,configuredResource:o.resource}))throw Error(`Protected resource ${o.resource} does not match expected ${n} (or origin)`);return new URL(o.resource)}}let pI=new Set(["bearer","dpop"]);function pN(t){let r,o=t.headers.get("WWW-Authenticate");if(!o)return{};let[a,i]=o.split(" ");if(!a||!pI.has(a.toLowerCase())||!i)return{};let n=pM(t,"resource_metadata")||void 0;if(n)try{r=new URL(n)}catch{}let s=pM(t,"scope")||void 0,l=pM(t,"error")||void 0;return{resourceMetadataUrl:r,scope:s,error:l,errorDescription:pM(t,"error_description")||void 0}}function pM(t,r){let o=t.headers.get("WWW-Authenticate");if(!o)return null;let a=new RegExp(String.raw`${r}=(?:"([^"]+)"|([^\s,]+))`),i=o.match(a);if(i){let t=i[1]||i[2];if(t)return t}return null}async function pz(t,r,o=fetch){let a=await pU(t,"oauth-protected-resource",o,{protocolVersion:r?.protocolVersion,metadataUrl:r?.resourceMetadataUrl});if(!a||404===a.status)throw await a?.text?.().catch(()=>{}),Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!a.ok)throw await a.text?.().catch(()=>{}),Error(`HTTP ${a.status} trying to load well-known OAuth protected resource metadata.`);return l$.parse(await a.json())}async function pq(t,r,o=fetch){let a=u_(o);try{return await a(t,{headers:r})}catch(t){throw t}}async function pH(t,r,o=fetch){return await pq(t,{"MCP-Protocol-Version":r},o)}async function pU(t,r,o,a){var i,n;let s,l=new URL(t),c=a?.protocolVersion??iU;a?.metadataUrl?s=new URL(a.metadataUrl):(s=new URL(function(t,r="",o={}){return r.endsWith("/")&&(r=r.slice(0,-1)),o.prependPathname?`${r}/.well-known/${t}`:`/.well-known/${t}${r}`}(r,l.pathname),a?.metadataServerUrl??l)).search=l.search;let u=await pH(s,c,o);return a?.metadataUrl||(i=u,n=l.pathname,i&&("/"===n||(i.ok||!(i.status<500))&&502!==i.status))||(u=await pH(new URL(`/.well-known/${r}`,l),c,o)),u}async function pD(t,{fetchFn:r=fetch,protocolVersion:o=iU,skipIssuerValidation:a=!1}={}){let i={"MCP-Protocol-Version":o,Accept:"application/json"};for(let{url:o,type:n}of function(t){let r="string"==typeof t?new URL(t):t,o="/"!==r.pathname,a=[];if(!o)return a.push({url:new URL("/.well-known/oauth-authorization-server",r.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",r.origin),type:"oidc"}),a;let i=r.pathname;return i.endsWith("/")&&(i=i.slice(0,-1)),a.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,r.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${i}`,r.origin),type:"oidc"},{url:new URL(`${i}/.well-known/openid-configuration`,r.origin),type:"oidc"}),a}(t)){let s=await pq(o,i,r);if(!s)continue;if(!s.ok){if(await s.text?.().catch(()=>{}),s.status<500||502===s.status)continue;throw Error(`HTTP ${s.status} trying to load ${"oauth"===n?"OAuth":"OpenID provider"} metadata from ${o}`)}let l="oauth"===n?lE.parse(await s.json()):lk.parse(await s.json());if(!a){let r="string"==typeof t?t:t.href;if(!(l.issuer===r||r.endsWith("/")&&l.issuer===r.slice(0,-1)))throw new ph("metadata",r,l.issuer)}return l}}async function pL(t,r){let o,a;try{(o=await pz(t,{resourceMetadataUrl:r?.resourceMetadataUrl},r?.fetchFn)).authorization_servers&&o.authorization_servers.length>0&&(a=o.authorization_servers[0])}catch(t){if(t instanceof TypeError)throw t}a||(a=String(new URL("/",t)));let i=await pD(a,{fetchFn:r?.fetchFn,skipIssuerValidation:r?.skipIssuerMetadataValidation});return{authorizationServerUrl:a,authorizationServerMetadata:i,resourceMetadata:o}}function pK(t){return"string"==typeof t?t:t.href}async function pJ(t,{metadata:r,clientInformation:o,redirectUrl:a,scope:i,state:n,resource:s}){let l;if(r){if(l=new URL(r.authorization_endpoint),!r.response_types_supported.includes(pk))throw Error(`Incompatible auth server: does not support response type ${pk}`);if(r.code_challenge_methods_supported&&!r.code_challenge_methods_supported.includes(pR))throw Error(`Incompatible auth server: does not support code challenge method ${pR}`)}else l=new URL("/authorize",t);let c=await pn(),u=c.code_verifier,d=c.code_challenge;return l.searchParams.set("response_type",pk),l.searchParams.set("client_id",o.client_id),l.searchParams.set("code_challenge",d),l.searchParams.set("code_challenge_method",pR),l.searchParams.set("redirect_uri",String(a)),n&&l.searchParams.set("state",n),i&&l.searchParams.set("scope",i),i?.split(" ").includes("offline_access")&&l.searchParams.append("prompt","consent"),s&&l.searchParams.set("resource",pK(s)),{authorizationUrl:l,codeVerifier:u}}async function pV(t,{metadata:r,tokenRequestParams:o,clientInformation:a,addClientAuthentication:i,resource:n,dpop:s,fetchFn:l}){var c,u;let d,p=function(t){let r=new URL(String(t));if("https:"!==r.protocol&&!px(r.hostname))throw new pm(r.href);return r}(r?.token_endpoint??new URL("/token",t)),h=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});n&&o.set("resource",pK(n)),!i&&a&&function(t,r,o,a){let{client_id:i,client_secret:n}=r;switch(t){case"client_secret_basic":var s,l,c,u,d=i,p=n,h=o;if(!p)throw Error("client_secret_basic authentication requires a client_secret");let f=btoa(`${d}:${p}`);h.set("Authorization",`Basic ${f}`);return;case"client_secret_post":s=i,l=n,(c=a).set("client_id",s),l&&c.set("client_secret",l);return;case"none":u=i,a.set("client_id",u);return;default:throw Error(`Unsupported client authentication method: ${t}`)}}((c=a,u=r?.token_endpoint_auth_methods_supported??[],d=void 0!==c.client_secret,"token_endpoint_auth_method"in c&&c.token_endpoint_auth_method&&["client_secret_basic","client_secret_post","none"].includes(c.token_endpoint_auth_method)&&(0===u.length||u.includes(c.token_endpoint_auth_method))?c.token_endpoint_auth_method:0===u.length?d?"client_secret_basic":"none":d&&u.includes("client_secret_basic")?"client_secret_basic":d&&u.includes("client_secret_post")?"client_secret_post":u.includes("none")?"none":d?"client_secret_post":"none"),a,h,o);let f=async()=>{let t=new Headers(h);return i&&await i(t,o,p,r),s&&t.set("DPoP",await s.buildProof({htm:"POST",htu:p})),u_(l??fetch)(p,{method:"POST",headers:t,body:o})},m=await f();if(s&&400===m.status&&(await m.clone().json().catch(()=>{}))?.error===lH.UseDpopNonce&&(s.observeNonce(m,p),m=await f()),s?.observeNonce(m,p),!m.ok)throw await pC(m);let y=await m.json();try{return lR.parse(lJ(y))}catch(t){if("object"==typeof y&&null!==y&&"error"in y)throw await pC(JSON.stringify(y));throw t}}async function pW(t,{metadata:r,clientInformation:o,refreshToken:a,resource:i,addClientAuthentication:n,dpop:s,fetchFn:l}){return{refresh_token:a,...await pV(t,{metadata:r,tokenRequestParams:new URLSearchParams({grant_type:"refresh_token",refresh_token:a}),clientInformation:o,addClientAuthentication:n,resource:i,dpop:s,fetchFn:l})}}async function pF(t,r,{metadata:o,resource:a,authorizationCode:i,iss:n,scope:s,fetchFn:l}={}){let c;void 0!==i&&p$({iss:n,expectedIssuer:o?.issuer,issParameterSupported:pw(o)});let u=o?.issuer??String(r),d=async()=>{let r=await t.clientInformation({issuer:u}),o=pv(r,u,{canPersistStamp:!1});if(r&&void 0===o)throw new py(String(r.issuer),u);return o},p=await d(),h=s??t.clientMetadata.scope;if(t.prepareTokenRequest&&(c=await t.prepareTokenRequest(h)),!c){var f,m;if(!i)throw Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw Error("redirectUrl is required for authorization_code flow");f=i,m=await t.codeVerifier(),c=new URLSearchParams({grant_type:"authorization_code",code:f,code_verifier:m,redirect_uri:String(t.redirectUrl)})}return pV(r,{metadata:o,tokenRequestParams:c,clientInformation:p??=await d(),addClientAuthentication:t.addClientAuthentication,resource:a,dpop:await t.dpop?.(),fetchFn:l})}async function pB(t,{metadata:r,clientMetadata:o,scope:a,fetchFn:i}){let n;if(r){if(!r.registration_endpoint)throw Error("Incompatible auth server: does not support dynamic client registration");n=new URL(r.registration_endpoint)}else n=new URL("/register",t);let s={...o,...void 0===a?{}:{scope:a}},l=await u_(i??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok)throw new pf({status:l.status,body:await l.text(),submittedMetadata:s});return lj.parse(lJ(await l.json()))}let pZ=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]);var pG=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(t){this._maxEntries=t?.maxEntries??512}get size(){return this._entries.size}get(t){return this._entries.get(pX(t))}set(t,r){let o=pX(t),a=pZ.has(t.method),i=!this._entries.has(o);if(!a&&i&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let t of this._entries.keys())if(!pZ.has(t.slice(0,t.indexOf("\0")))){this._entries.delete(t),this._cappedSize--;break}}let n=++this._stamp;return this._entries.set(o,{...r,stamp:n}),i&&!a&&this._cappedSize++,n}delete(t){this._entries.delete(pX(t))&&!pZ.has(t.method)&&this._cappedSize--}evict(t){let r=`${t}\0`,o=pZ.has(t);for(let t of this._entries.keys())t.startsWith(r)&&(this._entries.delete(t),!o&&this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}};function pX(t){return`${t.method}\0${JSON.stringify([t.partition??"",t.params??""])}`}function pY(t,r){return void 0===r?t:`${t}\0${r}`}var pQ=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity="";constructor(t,r,o=()=>{},a="",i=Date.now){this._store=t,this._isUserSupplied=r,this._reportError=o,this._cachePartition=a,this._now=i}now(){return this._now()}setServerIdentity(t){this._serverIdentity=t}_partitionFor(t){return JSON.stringify([this._serverIdentity,"public"===t?"":this._cachePartition])}async _probe(t,r){let o={method:t,params:r??""},a=this._partitionFor("private"),i=await this._store.get({...o,partition:a});if(void 0!==i)return i;let n=this._partitionFor("public");if(n===a)return;let s=await this._store.get({...o,partition:n});return s?.scope==="public"?s:void 0}async evict(t){this._evictionGeneration.set(t,(this._evictionGeneration.get(t)??0)+1),await this._deleteBoth(t,"")}async _deleteBoth(t,r){let o=this._partitionFor("private"),a=this._partitionFor("public");try{await this._store.delete({method:t,params:r,partition:o})}catch(t){this._reportError(t)}if(a!==o)try{await this._store.delete({method:t,params:r,partition:a})}catch(t){this._reportError(t)}}async evictKey(t,r){let o=pY(t,r),a=this._evictionGeneration.get(o);void 0!==a&&this._evictionGeneration.set(o,a+1),await this._deleteBoth(t,r)}captureGeneration(t,r){let o=pY(t,r),a=this._evictionGeneration.get(o)??0;return this._evictionGeneration.set(o,a),a}async write(t,r,o,a){if((this._evictionGeneration.get(pY(t,a?.params))??0)!==o)return;let i=a?.params??"",n=this._partitionFor("private"),s=this._partitionFor("public"),l=(a?.scope??"private")==="public"?s:n;try{await this._store.set({method:t,params:i,partition:l},{value:function(t){let r;try{r=JSON.stringify(t)}catch(t){throw TypeError(`cache value is not JSON-serializable: ${t instanceof Error?t.message:String(t)}`)}if("string"!=typeof r)throw TypeError("cache value is not JSON-serializable: it has no JSON representation");return r}(r),expiresAt:a?.expiresAt,scope:a?.scope})}catch(t){this._reportError(t)}if(s!==n)try{await this._store.delete({method:t,params:i,partition:l===n?s:n})}catch(t){this._reportError(t)}}async read(t,r){let o=await this._probe(t,r);if(o?.expiresAt!==void 0&&o.expiresAt>this.now())try{let t=JSON.parse(o.value);if("object"!=typeof t||null===t||Array.isArray(t))throw TypeError("cached document is not an object");return{value:t}}catch(o){this._reportError(o),await this._deleteBoth(t,r??"");return}}resetForReconnect(){this._isUserSupplied||this._store.clear(),this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=""}async toolDefinition(t){let r=await this._probe("tools/list");if(void 0===r){this._toolIndex=void 0;return}if(this._toolIndex?.stamp!==r.stamp){let t=this._decodeListTools(r),o=new Map;if(void 0!==t)for(let r of t.tools)o.set(r.name,r);this._toolIndex={stamp:r.stamp,byName:o}}return this._toolIndex.byName.get(t)}async outputValidator(t,r){let o=await this._probe("tools/list");if(void 0===o){this._toolOutputValidatorIndex=void 0;return}if(this._toolOutputValidatorIndex?.stamp!==o.stamp){let t=this._decodeListTools(o)??{tools:[]},a=new Map;for(let o of t.tools){let t=r(o);void 0!==t&&a.set(o.name,t)}this._toolOutputValidatorIndex={stamp:o.stamp,byName:a}}return this._toolOutputValidatorIndex.byName.get(t)}_decodeListTools(t){try{let r=JSON.parse(t.value);if(!Array.isArray(r?.tools)||!r.tools.every(t=>null!==t&&"object"==typeof t))throw TypeError("cached tools/list document has a malformed tools array");return r}catch(t){this._reportError(t);return}}};let p0=Symbol.for("mcp.authSeamEscape");function p1(t){if("object"==typeof t&&null!==t||"function"==typeof t)try{Object.defineProperty(t,p0,{value:!0,configurable:!0})}catch{}return t}let p2=new Set([-32001,-32020,-32021]);function p9(t,r){let{code:o,message:a,data:i}=t;if(-32022===o){let t=function(t){if("object"!=typeof t||null===t)return;let r=t.supported;if(Array.isArray(r)&&0!==r.length&&r.every(t=>"string"==typeof t))return r}(i);if(void 0===t)return{kind:"legacy"};let o=new ch({supported:t,requested:function(t){if("object"!=typeof t||null===t)return;let r=t.requested;return"string"==typeof r?r:void 0}(i)??r.requestedVersion},a),n=lB(t),s=r.clientModernVersions.find(t=>n.includes(t));return void 0!==s?{kind:"corrective",version:s,error:o}:n.length>0?{kind:"error",error:o}:r.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:o}}return p2.has(o),{kind:"legacy"}}function p4(t,r){var o;return"browser"===r.environment&&((o=t)instanceof TypeError||o instanceof Error&&"TypeError"===o.name)?{kind:"legacy"}:{kind:"error",error:new lL(lD.EraNegotiationFailed,`Version negotiation probe failed: ${p5(t)}`,{cause:t},{cause:t})}}function p5(t){return t instanceof Error?t.message:String(t)}function p3(){let t=globalThis;return void 0!==t.window&&void 0!==t.document?"browser":"node"}function p6(t){return"stderr"in t&&"pid"in t?"stdio":"http"}var p8=class t{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(t){this._transport=t,this._savedOnMessage=t.onmessage,this._savedOnError=t.onerror,this._savedOnClose=t.onclose}static async open(r){let o=new t(r);r.onmessage=t=>{let r=o._pending;if(void 0!==r&&(cz(t)||cq(t))&&t.id===r.id){o._pending=void 0,cz(t)?r.resolve({kind:"response",result:t.result}):r.resolve({kind:"response",error:t.error});return}},r.onerror=t=>{o._savedOnError?.(t)},r.onclose=()=>{let t=o._pending;void 0!==t&&(o._pending=void 0,t.resolve({kind:"closed"})),o._closeDelivered=!0,o._savedOnClose?.()};try{await r.start()}catch(t){throw o.detach(),t}return o}async exchange(t,r){let o=`server-discover-probe-${++this._probeCounter}`;return new Promise(a=>{let i=!1,n=t=>{i||(i=!0,clearTimeout(s),this._pending?.id===o&&(this._pending=void 0),a(t))},s=setTimeout(()=>n({kind:"timeout"}),r);this._pending={id:o,resolve:n},this._transport.send(t(o)).catch(t=>n({kind:"send-error",error:t}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&void 0!==this._savedOnClose){let t=this._savedOnClose,r=this._transport,o=!1,a=()=>{if(!o){o=!0;return}t()};r.onclose=a,p7.set(r,()=>{r.onclose===a&&(r.onclose=t)})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let t=this._transport,r=t.start,o=!0;t.start=async function(){if(o){o=!1,t.start=r;return}return r.call(t)}}};let p7=new WeakMap;function he(t){let r=p7.get(t);p7.delete(t),r?.()}async function ht(t,r){let o,a=t.probe.timeoutMs??r.defaultTimeoutMs,i=Math.max(0,t.probe.maxRetries??0),n="pin"===t.kind?[t.version]:t.modernVersions,s="auto"===t.kind&&t.fallbackAvailable,l=await p8.open(r.transport),c=async()=>{let o=n[0],c=!1,u=i;for(;;){let i=await l.exchange(t=>{var a,i,n,s;return a=t,i=o,n=r.clientInfo,s=r.capabilities,{jsonrpc:"2.0",id:a,method:"server/discover",params:{_meta:cA(i).outboundEnvelope({protocolVersion:i,clientInfo:n,clientCapabilities:s})}}},a);if("timeout"===i.kind&&u>0){u--;continue}let d=function(t,r){switch(t.kind){case"response":return void 0===t.error?{kind:"result",result:t.result}:{kind:"rpc-error",...t.error};case"send-error":{var o,a;let r=t.error;if(("object"==typeof(o=r)&&null!==o||"function"==typeof o)&&!0===o[p0]||r instanceof pS||r instanceof Error&&"UnauthorizedError"===r.name)return{kind:"auth-required",error:r};if(r instanceof lK){let t=r.data?.text;return{kind:"http-error",status:r.data.status,body:"string"==typeof t?t:void 0,statusText:r.data.statusText}}if((a=r)instanceof lL&&a.code===lD.ClientHttpUnexpectedContent||a instanceof Error&&"SyntaxError"===a.name)return{kind:"unusable-reply",error:r};return{kind:"network-error",error:r}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:r}}}(i,a),p=function(t,r){switch(t.kind){case"result":return function(t,r){let o=cA(cC).validateResult("server/discover",t);if(!o.ok)return{kind:"legacy"};let a=o.value.supportedVersions,i=r.clientModernVersions.find(t=>a.includes(t));return void 0!==i?{kind:"modern",version:i,discover:o.value}:r.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:new ch({supported:[...a],requested:r.requestedVersion})}}(t.result,r);case"rpc-error":return p9(t,r);case"http-error":return function(t,r){if(401===t.status||403===t.status){let r=403===t.status;return{kind:"error",error:new lK(r?lD.ClientHttpForbidden:lD.ClientHttpAuthentication,`Version negotiation failed: ${r?"the server denied access (HTTP 403)":"the server requires authorization (HTTP 401)"}`,{status:t.status,statusText:t.statusText,text:t.body})}}if(t.status>=500)return{kind:"error",error:new lK(lD.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${t.status}`,{status:t.status,statusText:t.statusText,text:t.body})};let o=function(t){let r;if(void 0===t||""===t)return;try{r=JSON.parse(t)}catch{return}if("object"!=typeof r||null===r)return;let o=r.error;if("object"!=typeof o||null===o)return;let{code:a,message:i,data:n}=o;if("number"==typeof a)return{code:a,message:"string"==typeof i?i:"",data:n}}(t.body);return void 0!==o?p9(o,r):{kind:"legacy"}}(t,r);case"network-error":return p4(t.error,r);case"unusable-reply":return{kind:"error",error:new lL(lD.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${p5(t.error)})`,{cause:t.error},{cause:t.error})};case"auth-required":return{kind:"error",error:t.error};case"closed":if("stdio"===r.transportKind)return{kind:"legacy"};return p4(Error("Connection closed during the version negotiation probe"),r);case"timeout":if("stdio"===r.transportKind)return{kind:"legacy"};return{kind:"error",error:new lL(lD.RequestTimeout,`Version negotiation probe timed out after ${t.timeoutMs}ms`,{timeout:t.timeoutMs})}}}(d,{clientModernVersions:n,requestedVersion:o,fallbackAvailable:s,environment:r.environment,transportKind:r.transportKind});switch(p.kind){case"modern":return{era:"modern",version:p.version,discover:p.discover};case"corrective":if(c)throw p.error;c=!0,o=p.version;continue;case"legacy":{let o="closed"===d.kind?"the connection closed during the server/discover probe":void 0;if("pin"===t.kind)throw new lL(lD.EraNegotiationFailed,void 0===o?`Version negotiation failed: the server did not offer pinned protocol version ${t.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${o} before the server offered pinned protocol version ${t.version} (no fallback in pin mode)`);if(!t.fallbackAvailable)throw new lL(lD.EraNegotiationFailed,void 0===o?"Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to":`Version negotiation failed: ${o} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(void 0!==o&&!0!==r.disposableProbe)throw new lL(lD.EraNegotiationFailed,`Version negotiation failed: ${o} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw p.error}}};try{o=await c()}catch(t){throw l.detach(),t}return l.release(),o}async function hr(t,r,o,a){let i,n,s=new r.constructor({...o,stderr:"ignore"}),l=r.close,c=!1,u=new Promise((t,r)=>{i=()=>r(ho())});r.close=async function(){return c=!0,i?.(),l.call(r)};try{let r=ht(t,{...a,transport:s,transportKind:"stdio",disposableProbe:!0});r.catch(()=>{}),n=await Promise.race([r,u])}finally{await ha(s),r.close=l}if(c)throw ho();return n}function ho(){return new lL(lD.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function ha(t){try{let r=t._dispose;await ("function"==typeof r?r.call(t):t.close())}catch{}}function hi(t){let r=t._meta?.[iJ];return ur.Implementation(r)?r:void 0}let hn={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]};var hs=class extends ul{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let t=new lL(lD.ConnectionClosed,"subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset");for(let r of this._listenState.values())r.settle({cause:"remote",error:t})}for(let t of(this._listenState.clear(),this._listChangedDebounceTimers.values()))clearTimeout(t);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(t,r){super(r),this._clientInfo=t,this._capabilities=r?.capabilities?{...r.capabilities}:{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new pt,this._enforceStrictCapabilities=r?.enforceStrictCapabilities??!1,this._versionNegotiation=r?.versionNegotiation,this._supportedProtocolVersionsOption=r?.supportedProtocolVersions,this._inputRequiredDriverConfig=function(t){return{autoFulfill:t?.autoFulfill??!0,maxRounds:t?.maxRounds??10}}(r?.inputRequired),this._cache=new pQ(r?.responseCacheStore??new pG,r?.responseCacheStore!==void 0,t=>this._reportStoreError(t),r?.cachePartition??""),this._defaultCacheTtlMs=r?.defaultCacheTtlMs??0,this._listMaxPages=r?.listMaxPages??64,r?.listChanged&&(this._listChangedConfig=r.listChanged)}buildContext(t,r){return t}_shouldDropInbound(t){let r;if(void 0!==this._negotiatedProtocolVersion&&this._negotiatedProtocolVersion>=lV&&(r=t,ne.safeParse(r).success))return"drop"}_outboundMetaEnvelope(){let t=this._negotiatedProtocolVersion;if(void 0!==t)return this._wireCodec().outboundEnvelope({protocolVersion:t,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(t,r){return this._inputRequiredDriverConfig.autoFulfill?function(t,r,o,a){let{codec:i,request:n,options:s,flowStartedAt:l}=a,c={inputRequests:o.inputRequests,...void 0!==o.requestState&&{requestState:o.requestState}};return c8({config:r,method:n.method,originalParams:n.params,firstPayload:c,flowStartedAt:l,signal:s?.signal,requestOptions:{...s?.timeout!==void 0&&{timeout:s.timeout},...s?.maxTotalTimeout!==void 0&&{maxTotalTimeout:s.maxTotalTimeout},...s?.onprogress!==void 0&&{onprogress:s.onprogress}},hooks:{dispatchInputRequest:(r,o,a)=>up(t,i,r,o,a),retry:(t,r)=>{var o,i;return a.retry(t,(o=s,i=r,{...o?.signal!==void 0&&{signal:o.signal},...o?.onprogress!==void 0&&{onprogress:o.onprogress},...o?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:o.resetTimeoutOnProgress},...o?.headers!==void 0&&{headers:o.headers},...void 0!==i.timeout&&{timeout:i.timeout},...void 0!==i.maxTotalTimeout&&{maxTotalTimeout:i.maxTotalTimeout},allowInputRequired:!0}))}}})}({getRequestHandler:t=>this._getRequestHandler(t),buildContext:t=>this.buildContext(t,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,t,r):Promise.reject(new lL(lD.UnsupportedResultType,`Unsupported result type 'input_required' for ${r.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance — pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:r.request.method}))}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools","notifications/tools/list_changed",t.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts","notifications/prompts/list_changed",t.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources","notifications/resources/list_changed",t.resources,async()=>(await this.listResources(void 0,{cacheMode:"refresh"})).resources)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=function(t,r){let o={...t};for(let t in r){let a=r[t];if(void 0===a)continue;let i=o[t];o[t]=uc(i)&&uc(a)?{...i,...a}:a}return o}(this._capabilities,t)}setVersionNegotiation(t){if(this.transport)throw Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=t}_wrapHandler(t,r){return"elicitation/create"===t?async(t,o)=>{let a=cA(this._negotiatedProtocolVersion),i=a.validateRequest("elicitation/create",t);if(i.ok||"not-in-era"!==i.reason||(i=a.validateInputRequest("elicitation/create",t)),!i.ok)throw new cu("not-in-era"===i.reason?cc.InternalError:cc.InvalidParams,"not-in-era"===i.reason?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation request: ${i.message}`);let{params:n}=i.value;n.mode=n.mode??"form";let{supportsFormMode:s,supportsUrlMode:l}=function(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let r=void 0!==t.form,o=void 0!==t.url;return{supportsFormMode:r||!r&&!o,supportsUrlMode:o}}(this._capabilities.elicitation);if("form"===n.mode&&!s)throw new cu(cc.InvalidParams,"Client does not support form-mode elicitation requests");if("url"===n.mode&&!l)throw new cu(cc.InvalidParams,"Client does not support URL-mode elicitation requests");let c=await r(t,o),u=a.validateResult("elicitation/create",c);if(u.ok||"not-in-era"!==u.reason||(u=a.validateInputResponse("elicitation/create",c)),!u.ok)throw new cu("not-in-era"===u.reason?cc.InternalError:cc.InvalidParams,"not-in-era"===u.reason?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${u.message}`);let d=u.value,p="form"===n.mode?n.requestedSchema:void 0;if("form"===n.mode&&"accept"===d.action&&d.content&&p&&this._capabilities.elicitation?.form?.applyDefaults)try{!function t(r,o){if(r&&null!==o&&"object"==typeof o){if("object"===r.type&&r.properties&&"object"==typeof r.properties){let a=r.properties;for(let r of Object.keys(a)){let i=a[r];void 0===o[r]&&Object.prototype.hasOwnProperty.call(i,"default")&&(o[r]=i.default),void 0!==o[r]&&t(i,o[r])}}if(Array.isArray(r.anyOf))for(let a of r.anyOf)"boolean"!=typeof a&&t(a,o);if(Array.isArray(r.oneOf))for(let a of r.oneOf)"boolean"!=typeof a&&t(a,o)}}(p,d.content)}catch{}return d}:"sampling/createMessage"===t?async(t,o)=>{let a=cA(this._negotiatedProtocolVersion),i=a.validateRequest("sampling/createMessage",t);if(i.ok||"not-in-era"!==i.reason||(i=a.validateInputRequest("sampling/createMessage",t)),!i.ok)throw new cu("not-in-era"===i.reason?cc.InternalError:cc.InvalidParams,"not-in-era"===i.reason?"No wire schema for sampling/createMessage in the resolved era":`Invalid sampling request: ${i.message}`);let{params:n}=i.value,s=await r(t,o),l=!!(n.tools||n.toolChoice),c=a.samplingResultVariant(l,s);if(c.ok||"not-in-era"!==c.reason||(c=a.validateInputResponse("sampling/createMessage",s)),!c.ok)throw new cu("not-in-era"===c.reason?cc.InternalError:cc.InvalidParams,"not-in-era"===c.reason?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${c.message}`);return c.value}:r}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new lL(lD.CapabilityNotSupported,`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(r?.prior!=null)return this._connectFromPrior(t,function(t){if("object"==typeof t&&null!==t&&("legacy"===t.kind&&!("supportedVersions"in t)&&!("discover"in t)||"modern"===t.kind&&nE.safeParse(t.discover).success))return t;throw new lL(lD.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}(r.prior),r);let o=function(t,r){let o=t?.mode??"legacy";if("legacy"===o)return{kind:"legacy"};let a=t?.probe??{};if("object"==typeof o){if(!(o.pin>=lV))throw TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision — pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:"pin",version:o.pin,probe:a}}let i=r?lB(r):[];return{kind:"auto",modernVersions:i.length>0?i:[...lW],fallbackAvailable:!r||lF(r).length>0,probe:a}}(this._versionNegotiation,this._supportedProtocolVersionsOption);return"legacy"!==o.kind?this._connectNegotiated(t,o,r):this._connectPlainLegacy(t,r)}async _connectPlainLegacy(t,r){if(await super.connect(t),void 0!==t.sessionId){let r=this._negotiatedProtocolVersion;void 0!==r&&t.setProtocolVersion?.(r);return}this._resetConnectionState(),await this._legacyHandshake(t,r)}async _legacyHandshake(t,r){let o=lF(this._supportedProtocolVersions);try{let a=o[0];if(void 0===a)throw new lL(lD.EraNegotiationFailed,"Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version");let i=await this.request({method:"initialize",params:{protocolVersion:a,capabilities:this._capabilities,clientInfo:this._clientInfo}},r);if(void 0===i)throw Error(`Server sent invalid initialize result: ${i}`);if(!o.includes(i.protocolVersion))throw Error(`Server's protocol version is not supported: ${i.protocolVersion}`);this._serverCapabilities=i.capabilities,this._serverVersion=i.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(t)),t.setProtocolVersion&&t.setProtocolVersion(i.protocolVersion),this._instructions=i.instructions,await this.notification({method:"notifications/initialized"}),this._negotiatedProtocolVersion=i.protocolVersion,this._listChangedConfig&&this._setupListChangedHandlers(this._listChangedConfig)}catch(t){throw this.close(),t}}async _connectNegotiated(t,r,o){let a;if(void 0!==t.sessionId){await super.connect(t);let r=this._negotiatedProtocolVersion;void 0!==r&&t.setProtocolVersion&&t.setProtocolVersion(r);return}this._resetConnectionState();try{let i=p6(t),n={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:p3(),defaultTimeoutMs:o?.timeout??6e4},s="stdio"===i?function(t){let r=Object.getPrototypeOf(t);if(null===r||!Object.prototype.hasOwnProperty.call(r,"_dispose"))return;let o=t._serverParams;return"object"==typeof o&&null!==o&&"string"==typeof o.command?o:void 0}(t):void 0;a=void 0===s?await ht(r,{...n,transport:t,transportKind:i}):await hr(r,t,s,n)}catch(r){throw await t.close().catch(()=>{}),he(t),r}if(he(t),await super.connect(t),"legacy"===a.era)return void await this._legacyHandshake(t,o);if(this._serverCapabilities=a.discover.capabilities,this._serverVersion=hi(a.discover),this._cache.setServerIdentity(this._deriveServerIdentity(t)),this._instructions=a.discover.instructions,this._discoverResult=a.discover,this._negotiatedProtocolVersion=a.version,t.setProtocolVersion&&t.setProtocolVersion(a.version),this._listChangedConfig){let t=this._listChangedConfig,r=this._serverCapabilities,a={...t.tools&&r?.tools?.listChanged&&{tools:t.tools},...t.prompts&&r?.prompts?.listChanged&&{prompts:t.prompts},...t.resources&&r?.resources?.listChanged&&{resources:t.resources}},i=!0;try{this._setupListChangedHandlers(a)}catch(t){i=!1,this.onerror?.(t instanceof Error?t:Error(String(t)))}let n=i?{...a.tools&&{toolsListChanged:!0},...a.prompts&&{promptsListChanged:!0},...a.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(n).length>0){let t=new AbortController,r=()=>t.abort(o?.signal?.reason);o?.signal?.aborted&&r(),o?.signal?.addEventListener("abort",r);try{this._autoOpenedSubscription=await this.listen(n,{timeout:o?.timeout,signal:t.signal})}catch(t){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),t;this.onerror?.(t instanceof Error?t:Error(String(t)))}finally{o?.signal?.removeEventListener("abort",r)}}}}async _connectFromPrior(t,r,o){if("legacy"===r.kind)return this._connectPlainLegacy(t,o);let a=r.discover;this._resetConnectionState();let i=this._supportedProtocolVersionsOption,n=(i&&lB(i).length>0?lB(i):lW).find(t=>a.supportedVersions.includes(t));if(void 0===n)throw new lL(lD.EraNegotiationFailed,"connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.");if(await super.connect(t),this._discoverResult=a,this._serverCapabilities=a.capabilities,this._serverVersion=hi(a),this._cache.setServerIdentity(this._deriveServerIdentity(t)),this._instructions=a.instructions,this._negotiatedProtocolVersion=n,t.setProtocolVersion?.(n),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(t){this.onerror?.(t instanceof Error?t:Error(String(t)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(t){let r=this._serverVersion;return void 0!==r?`${r.name}@${r.version}`:t.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let t=this._negotiatedProtocolVersion;if(void 0!==t)return t>=lV?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new lL(lD.CapabilityNotSupported,`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new lL(lD.CapabilityNotSupported,`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new lL(lD.CapabilityNotSupported,`Server does not support resources (required for ${t})`);if("resources/subscribe"===t&&!this._serverCapabilities.resources.subscribe)throw new lL(lD.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new lL(lD.CapabilityNotSupported,`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new lL(lD.CapabilityNotSupported,`Server does not support completions (required for ${t})`)}}assertNotificationCapability(t){if("notifications/roots/list_changed"===t&&!this._capabilities.roots?.listChanged)throw new lL(lD.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${t})`)}assertRequestHandlerCapability(t){switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new lL(lD.CapabilityNotSupported,`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new lL(lD.CapabilityNotSupported,`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new lL(lD.CapabilityNotSupported,`Client does not support roots capability (required for ${t})`)}}async ping(t){return this.request({method:"ping"},t)}async discover(t){let r=await this._requestWithSchema({method:"server/discover"},nE,t);return this._discoverResult=r,r}async complete(t,r){return this.request({method:"completion/complete",params:t},r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},r)}async listPrompts(t,r){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug("Client.listPrompts() called but server does not advertise prompts capability - returning empty list"),{prompts:[]};if(t?.cursor!==void 0)return this.request({method:"prompts/list",params:t},r);let o=await this._serveFromCache("prompts/list",void 0,r);return void 0!==o?o:this._listAllPages("prompts/list",t,r,t=>t.prompts)}async listResources(t,r){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResources() called but server does not advertise resources capability - returning empty list"),{resources:[]};if(t?.cursor!==void 0)return this.request({method:"resources/list",params:t},r);let o=await this._serveFromCache("resources/list",void 0,r);return void 0!==o?o:this._listAllPages("resources/list",t,r,t=>t.resources)}async listResourceTemplates(t,r){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list"),{resourceTemplates:[]};if(t?.cursor!==void 0)return this.request({method:"resources/templates/list",params:t},r);let o=await this._serveFromCache("resources/templates/list",void 0,r);return void 0!==o?o:this._listAllPages("resources/templates/list",t,r,t=>t.resourceTemplates)}async _listAllPages(t,r,o,a,i){let n=o?.cacheMode==="bypass",s=this._cache.captureGeneration(t),l=await this.request({method:t,...r&&{params:{...r}}},o),c=l.nextCursor,u=l,d=1;for(;void 0!==c;){if(0!==this._listMaxPages&&d>=this._listMaxPages)throw new lL(lD.ListPaginationExceeded,`${t}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:t,listMaxPages:this._listMaxPages});let i=await this.request({method:t,params:{...r,cursor:c}},o);if(i.nextCursor===c&&JSON.stringify(a(i))===JSON.stringify(a(u)))break;a(l).push(...a(i)),u=i,c=i.nextCursor,d++}return delete l.nextCursor,i?.(l),n||await this._cache.write(t,l,s,this._freshness(l)),l}_freshness(t,r){let o="number"==typeof t.ttlMs?t.ttlMs:this._defaultCacheTtlMs,a="public"===t.cacheScope?"public":"private";return{expiresAt:this._cache.now()+Math.min(Math.max(0,o),864e5),scope:a,params:r}}async _serveFromCache(t,r,o){if(o?.cacheMode==="bypass"||o?.cacheMode==="refresh")return;let a=await this._cache.read(t,r).catch(t=>void this._reportStoreError(t));if(void 0!==a){if(o?.signal?.aborted){let t=o.signal.reason;throw t instanceof lL?t:new lL(lD.RequestTimeout,String(t))}return a.value}}_reportStoreError(t){this.onerror?.(t instanceof Error?t:Error(String(t)))}_compileOutputValidator(t){if(t.outputSchema)try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(t.outputSchema)}}catch(t){return{ok:!1,compileError:t}}}async _resolveXMcpHeaderScan(t,r){let o=r??await this._cache.toolDefinition(t);return void 0===o?void 0:cK(o.inputSchema)}async readResource(t,r){let o=await this._serveFromCache("resources/read",t.uri,r);if(void 0!==o)return o;let a=this._cache.captureGeneration("resources/read",t.uri),i=await this.request({method:"resources/read",params:t},r);if(r?.cacheMode!=="bypass"){let o=this._freshness(i,t.uri);o.expiresAt>this._cache.now()?await this._cache.write("resources/read",i,a,o):r?.cacheMode==="refresh"&&await this._cache.evictKey("resources/read",t.uri)}return i}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},r)}async listen(t,r){let o,a,i,n,s;if(void 0===this.transport)throw new lL(lD.NotConnected,"Not connected");let l=this._negotiatedProtocolVersion;if(void 0===l||!(l>=lV))throw new lL(lD.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${l??"none"}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:"subscriptions/listen",protocolVersion:l});if(r?.signal?.aborted){let t=r.signal.reason;throw t instanceof lL?t:new lL(lD.RequestTimeout,String(t))}let c=new AbortController,u=`listen:${this._nextListenId++}`,d="opening",p=new Promise((t,r)=>{i=t,n=r}),h=new Promise(t=>{s=t}),f=t=>{if("closed"===d)return;let l="opening"===d;if(void 0!==o&&(clearTimeout(o),o=void 0),"ack"in t){d="open",i(t.ack);return}d="closed",void 0!==a&&r?.signal?.removeEventListener("abort",a),this._listenState.delete(u),c.abort(),s(t.cause),l&&n(t.error??new lL(lD.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},m=async()=>{c.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:u}}).catch(()=>{})},y=async()=>{"closed"!==d&&(f({cause:"local"}),await m())};this._listenState.set(u,{settle:f});let g=r?.timeout??6e4;if(o=setTimeout(()=>{f({cause:"remote",error:new lL(lD.RequestTimeout,"subscriptions/listen ack timed out",{timeout:g})}),m().catch(()=>{})},g),r?.signal){let t=r.signal;a=()=>{if("closed"===d)return;let r=t.reason;f({cause:"local",error:r instanceof Error?r:Error(String(r??"Aborted"))}),m().catch(()=>{})},t.addEventListener("abort",a,{once:!0})}let v={jsonrpc:"2.0",id:u,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:t}},_=t=>{f({cause:"remote",error:t instanceof Error?t:Error(String(t))})};try{this.transport.send(v,{requestSignal:c.signal,onRequestStreamEnd:()=>f({cause:"remote",error:Error("subscriptions/listen: stream ended")})}).catch(_)}catch(t){_(t)}return{honoredFilter:await p,close:y,closed:h}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(t,r){let o=Object.hasOwn(hn,t.method)?hn[t.method]:void 0;if("notifications/resources/updated"===t.method){let r=t.params?.uri;"string"==typeof r&&this._cache.evictKey("resources/read",r)}else if(void 0!==o)for(let t of o)this._cache.evict(t);if("notifications/subscriptions/acknowledged"===t.method){let r=t.params?._meta?.[iW],o="string"==typeof r?this._listenState.get(r):void 0;if(void 0!==o){let r=this._wireCodec().validateNotification("notifications/subscriptions/acknowledged",t);o.settle({ack:r.ok?r.value.params.notifications:{}});return}}if("notifications/cancelled"===t.method){let r=t.params?.requestId,o="string"==typeof r?this._listenState.get(r):void 0;if(void 0!==o)return void o.settle({cause:"remote",error:Error("subscriptions/listen: server cancelled the subscription")})}super._onnotification(t,r)}_onresponse(t){let r=t.id,o="string"==typeof r?this._listenState.get(r):void 0;void 0!==o?cq(t)?o.settle({cause:"remote",error:cu.fromError(t.error.code,t.error.message,t.error.data)}):o.settle({cause:"graceful",error:new lL(lD.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")}):super._onresponse(t)}_onclose(){if(this._listenState.size>0){let t=new lL(lD.ConnectionClosed,"Connection closed");for(let r of this._listenState.values())r.settle({cause:"remote",error:t});this._listenState.clear()}super._onclose()}async callTool(t,r){let o,a="modern"===this.getProtocolEra()&&"browser"!==p3(),i=async()=>{let o;if(!a)return r;try{o=await this._resolveXMcpHeaderScan(t.name,r?.toolDefinition)}catch(t){this._reportStoreError(t)}if(!o?.valid||0===o.declarations.length)return r;let i=function(t,r){let o={};for(let a of t){let t=function(t,r){let o=t;for(let t of r){if(null===o||"object"!=typeof o)return;o=o[t]}return o}(r,a.path);if(null==t)continue;let i=function(t){if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t){if(!Number.isFinite(t)||Number.isInteger(t)&&!Number.isSafeInteger(t))return;return String(t)}}(t);void 0!==i&&(o[`Mcp-Param-${a.headerName}`]=cB(i))}return o}(o.declarations,t.arguments);return 0===Object.keys(i).length?r:{...r,headers:{...r?.headers,...i}}},n=r?.toolDefinition===void 0?await this._cache.outputValidator(t.name,t=>this._compileOutputValidator(t)).catch(t=>void this._reportStoreError(t)):this._compileOutputValidator(r.toolDefinition),s=()=>{if(void 0===n||n.ok)return;let r=n.compileError,o=(r instanceof Error?r.message:String(r)).slice(0,200);throw new cu(cc.InvalidParams,`Tool '${t.name}' has an invalid outputSchema: ${o}`)};s();try{o=await this.request({method:"tools/call",params:t},await i())}catch(u){let l=u instanceof cu&&-32020===u.code;if(!a||!l||r?.toolDefinition!==void 0)throw u;let c={signal:r?.signal,timeout:r?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,c).catch(t=>this._reportStoreError(t)),n=await this._cache.outputValidator(t.name,t=>this._compileOutputValidator(t)).catch(t=>void this._reportStoreError(t)),s(),o=await this.request({method:"tools/call",params:t},await i())}let l=void 0!==n&&n.ok?n.validator:void 0;if(l){if(void 0===o.structuredContent&&!o.isError)throw new cu(cc.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(void 0!==o.structuredContent&&!o.isError)try{let t=l(o.structuredContent);if(!t.valid)throw new cu(cc.InvalidParams,`Structured content does not match the tool's output schema: ${t.errorMessage}`)}catch(t){if(t instanceof cu)throw t;throw new cu(cc.InvalidParams,`Failed to validate structured content: ${t instanceof Error?t.message:String(t)}`)}}return o}async listTools(t,r){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug("Client.listTools() called but server does not advertise tools capability - returning empty list"),{tools:[]};if(t?.cursor!==void 0){let o=await this.request({method:"tools/list",params:t},r);return this._excludeInvalidXMcpHeaderTools(o),o}let o=await this._serveFromCache("tools/list",void 0,r);return void 0!==o?o:this._listAllPages("tools/list",t,r,t=>t.tools,t=>this._excludeInvalidXMcpHeaderTools(t))}_excludeInvalidXMcpHeaderTools(t){if("modern"!==this.getProtocolEra()||!this.transport||"stdio"===p6(this.transport))return;let r=t.tools.filter(t=>{let r=cK(t.inputSchema);return!!r.valid||(console.warn(`[mcp-sdk] excluding tool '${t.name}' from tools/list: invalid x-mcp-header declaration — ${r.reason}`),!1)});r.length!==t.tools.length&&(t.tools=r)}_setupListChangedHandler(t,r,o,a){let i=ah(sS,o);if(!i.success)throw Error(`Invalid ${t} listChanged options: ${i.error.message}`);if("function"!=typeof o.onChanged)throw TypeError(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:n,debounceMs:s}=i.data,{onChanged:l}=o,c=async()=>{if(!n)return void l(null,null);try{l(null,await a())}catch(t){l(t instanceof Error?t:Error(String(t)),null)}},u=()=>{if(s){let r=this._listChangedDebounceTimers.get(t);r&&clearTimeout(r);let o=setTimeout(c,s);this._listChangedDebounceTimers.set(t,o)}else c()};this.setNotificationHandler(r,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};async function hl(){if(void 0===globalThis.crypto)throw TypeError("crypto is not available, please ensure you have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)");return Promise.resolve().then(i.bind(i,8775))}async function hc(t={}){let r=t.alg??"ES256",o=await hl(),{publicKey:a,privateKey:i}=await o.generateKeyPair(r,{extractable:t.extractable??!1}),n=await o.exportJWK(a);return{privateKey:i,publicKey:a,publicJwk:n,thumbprint:await o.calculateJwkThumbprint(n,"sha256"),alg:r}}async function hu(t){if(globalThis.crypto?.subtle===void 0)throw TypeError("crypto.subtle is not available, please ensure you have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)");return hd(new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))))}function hd(t){let r="";for(let o of t)r+=String.fromCodePoint(o);return btoa(r).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(class t{nonces=new Map;constructor(t){this.keyPair=t}static async create(r={}){return new t(r.keyPair??await hc({alg:r.alg}))}get thumbprint(){return this.keyPair.thumbprint}get alg(){return this.keyPair.alg}get publicJwk(){return this.keyPair.publicJwk}nonceFor(t){return this.nonces.get(new URL(t.toString()).origin)}rememberNonce(t,r){this.nonces.set(new URL(t.toString()).origin,r)}observeNonce(t,r){let o=t.headers.get("dpop-nonce");o&&this.rememberNonce(r,o)}async buildProof(t){let r,o,a=await hl(),i=(r=new URL(t.htu.toString()),`${r.origin}${r.pathname}`),n=t.nonce??this.nonceFor(t.htu),s={jti:(o=new Uint8Array(16),globalThis.crypto.getRandomValues(o),hd(o)),htm:t.htm.toUpperCase(),htu:i,iat:Math.floor(Date.now()/1e3)};return void 0!==t.accessToken&&(s.ath=await hu(t.accessToken)),void 0!==n&&(s.nonce=n),new a.SignJWT(s).setProtectedHeader({alg:this.keyPair.alg,typ:"dpop+jwt",jwk:this.keyPair.publicJwk}).sign(this.keyPair.privateKey)}}),class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](t){return lq(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lq(this,t)}constructor(t,r,o){super(`SSE error: ${r}`),this.code=t,this.event=o,lz(this,new.target)}};let hp={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},hh=new Set(["authorization","dpop","content-type","mcp-protocol-version","mcp-method","mcp-name","mcp-session-id"]);function hf(t,r){if("function"==typeof AbortSignal.any)return AbortSignal.any([t,r]);let o=new AbortController;if(t.aborted)return o.abort(t.reason),o.signal;if(r.aborted)return o.abort(r.reason),o.signal;let a=()=>{t.removeEventListener("abort",i),r.removeEventListener("abort",n)};function i(){a(),o.abort(t.reason)}function n(){a(),o.abort(r.reason)}return t.addEventListener("abort",i,{once:!0}),r.addEventListener("abort",n,{once:!0}),o.signal}var hm=class{_abortController;_url;_resourceMetadataUrl;_scope;_requestInit;_authProvider;_oauthProvider;_skipIssuerMetadataValidation;_fetch;_fetchWithInit;_redirectPolicy;_sessionId;_reconnectionOptions;_protocolVersion;_onInsufficientScope;_maxStepUpRetries;_serverRetryMs;_reconnectionScheduler;_cancelReconnection;onclose;onerror;onmessage;hasPerRequestStream=!0;constructor(t,r){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._skipIssuerMetadataValidation=r?.skipIssuerMetadataValidation,this._fetch=r?.fetch,function(t){return null!=t&&"function"==typeof t.tokens&&"function"==typeof t.clientInformation}(r?.authProvider)?(this._oauthProvider=r.authProvider,this._authProvider=function(t,r){return{token:async()=>(await t.tokens())?.access_token,onUnauthorized:async o=>pb(t,o,r)}}(r.authProvider,{skipIssuerMetadataValidation:r.skipIssuerMetadataValidation}),r.authProvider.dpop&&(this._fetch=(t=>{let r,o;return r=async()=>{try{return await t.dpop?.()}catch(t){throw p1(t)}},o=async()=>{let r;try{r=await t.tokens()}catch(t){throw p1(t)}return r?.token_type?.toLowerCase()==="dpop"?r.access_token:void 0},t=>{let a="function"==typeof r?r:()=>r;return async(r,i)=>{let n=(i?.method??"GET").toUpperCase(),s=new URL(r.toString()),l=await a();if(!l)return t(r,i);let c=async()=>{let a=await o();if(!a)return t(r,i);let c=new Headers(i?.headers),u=await l.buildProof({htm:n,htu:s,accessToken:a});return c.set("Authorization",`DPoP ${a}`),c.set("DPoP",u),t(r,{...i,headers:c})},u=await c();return function(t){var r;if(401!==t.status)return!1;let o=t.headers.get("www-authenticate")??"";return r=o,/(?:^|,)\s*dpop(?:\s|$|,)/i.test(r)&&/use_dpop_nonce/i.test(o)}(u)&&u.headers.has("dpop-nonce")&&(l.observeNonce(u,s),await u.text?.().catch(()=>{}),u=await c()),l.observeNonce(u,s),u}}})(r.authProvider)(r.fetch??fetch))):this._authProvider=r?.authProvider,this._redirectPolicy=r?.redirectPolicy,this._fetchWithInit=function(t=fetch,r){return r?async(o,a)=>t(o,{...r,...a,headers:a?.headers?{...um(r.headers),...um(a.headers)}:r.headers}):t}(r?.fetch,r?.requestInit),"follow"===this._redirectPolicy&&(this._fetchWithInit=function(t){let r=(r,o)=>t(r,o);return uv.add(r),r}(this._fetchWithInit)),this._sessionId=r?.sessionId,this._protocolVersion=r?.protocolVersion,this._reconnectionOptions=r?.reconnectionOptions??hp,this._reconnectionScheduler=r?.reconnectionScheduler,this._onInsufficientScope=r?.onInsufficientScope??"reauthorize",this._maxStepUpRetries=Math.max(0,r?.maxStepUpRetries??1)}async _stepUpAuthorize(t,r){try{return await this._stepUpAuthorizeInner(t,r)}catch(t){throw p1(t)}}async _stepUpAuthorizeInner(t,r){if("throw"===this._onInsufficientScope||!this._oauthProvider)throw new pg({requiredScope:t.scope,resourceMetadataUrl:t.resourceMetadataUrl,errorDescription:t.errorDescription});if(r>=this._maxStepUpRetries)throw new lK(lD.ClientHttpForbidden,`Server returned 403 insufficient_scope after step-up re-authorization (retry limit ${this._maxStepUpRetries} reached)`,{status:403,statusText:t.statusText??"Forbidden",text:t.text});t.resourceMetadataUrl&&(this._resourceMetadataUrl=t.resourceMetadataUrl);let o=await this._oauthProvider.tokens(),a=pE(this._scope,o?.scope,t.scope);this._scope=a;let i=function(t,r){if(!t)return!1;let o=new Set((r??"").split(/\s+/).filter(Boolean));for(let r of t.split(/\s+/))if(r&&!o.has(r))return!0;return!1}(a,o?.scope);return pT(this._oauthProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:a,forceReauthorization:i,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})}_redirects(t){return"follow"===this._redirectPolicy?t:u_(t)}_unfollowedRedirect(t,r){let o="follow"===this._redirectPolicy?void 0:function(t,r){if("opaqueredirect"===r.type)return"Redirect not followed: this runtime does not expose where it points";let o=ug(r.url||t,r);if(o)return(o.username=o.password=o.search=o.hash="","http:"===o.protocol&&"https:"===new URL(r.url||t).protocol)?(o.protocol="https:",`Redirect from https to plain http not followed; try ${o.href} as the endpoint`):`Redirect to ${o.href} not followed; use that URL as the endpoint if it is the intended server`}(t,r);return o&&`${o} (redirectPolicy: 'same-origin')`}async _commonHeaders(){let t,r=new Headers(this._requestInit?.headers||void 0);try{t=await this._authProvider?.token()}catch(t){throw p1(t)}return t&&r.set("Authorization",`Bearer ${t}`),this._sessionId&&r.set("mcp-session-id",this._sessionId),this._protocolVersion&&r.set("mcp-protocol-version",this._protocolVersion),r}_applyBodyDerivedHeaders(t,r){let o;if(Array.isArray(r)||(o=r,!ne.safeParse(o).success))return;let a=r.params?._meta?.[iL];if("string"!=typeof a)return;t.set("mcp-protocol-version",a),t.set("mcp-method",r.method);let i=function(t,r){var o;let a=Object.hasOwn(cZ,t)?cZ[t]:void 0;if(void 0===a)return;let i=null===(o=r)||"object"!=typeof o||Array.isArray(o)?void 0:r[a];return{field:a,value:"string"==typeof i?i:void 0}}(r.method,r.params);i?.value!==void 0&&t.set("mcp-name",cB(i.value))}_isModernEnvelopedRequest(t){let r;if(Array.isArray(t)||(r=t,!ne.safeParse(r).success))return!1;let o=t.params?._meta?.[iL];return"string"==typeof o&&o>=lV}async _startOrAuthSse(t,r=!1,o=0){let{resumptionToken:a,requestSignal:i}=t,n=()=>this._abortController?.signal.aborted===!0||i?.aborted===!0;try{let n=await this._commonHeaders(),s=[...n.get("accept")?.split(",").map(t=>t.trim().toLowerCase())??[],"text/event-stream"];n.set("accept",[...new Set(s)].join(", ")),a&&n.set("last-event-id",a);let l=this._abortController?.signal,c=void 0!==i&&void 0!==l?hf(l,i):i??l,u=await this._redirects(this._fetch??fetch)(this._url,{...this._requestInit,method:"GET",headers:n,signal:c});if(!u.ok){if(401===u.status&&this._authProvider){if(u.headers.has("www-authenticate")){let{resourceMetadataUrl:t,scope:r}=pN(u);this._resourceMetadataUrl=t,this._scope=pE(this._scope,r)}if(this._authProvider.onUnauthorized&&!r){try{await this._authProvider.onUnauthorized({response:u,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(t){throw p1(t)}return await u.text?.().catch(()=>{}),this._startOrAuthSse(t,!0,o)}if(await u.text?.().catch(()=>{}),r)throw p1(new lK(lD.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:u.statusText}));throw p1(new pS)}if(403===u.status){let{resourceMetadataUrl:a,scope:i,error:n,errorDescription:s}=pN(u);if("insufficient_scope"===n){let n=await u.text?.().catch(()=>null);if(await this._stepUpAuthorize({scope:i,resourceMetadataUrl:a,errorDescription:s,statusText:u.statusText,text:n},o)!=="AUTHORIZED")throw p1(new pS);return this._startOrAuthSse(t,r,o+1)}}if(await u.text?.().catch(()=>{}),405===u.status)return void t.onRequestStreamEnd?.();let a=this._unfollowedRedirect(this._url,u)??u.statusText;throw new lK(lD.ClientHttpFailedToOpenStream,`Failed to open SSE stream: ${a}`,{status:u.status,statusText:u.statusText})}this._handleSseStream(u.body,t,!0)}catch(t){throw n()||this.onerror?.(t),t}}_getNextReconnectionDelay(t){if(void 0!==this._serverRetryMs)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor;return Math.min(r*Math.pow(o,t),this._reconnectionOptions.maxReconnectionDelay)}_scheduleReconnection(t,r=0){let o=this._reconnectionOptions.maxRetries;if(r>=o){this.onerror?.(Error(`Maximum reconnection attempts (${o}) exceeded.`)),t.onRequestStreamEnd?.();return}let a=this._getNextReconnectionDelay(r),i=()=>{this._cancelReconnection=void 0,this._abortController?.signal.aborted||t.requestSignal?.aborted||this._startOrAuthSse(t).catch(o=>{if(!(this._abortController?.signal.aborted||t.requestSignal?.aborted)){this.onerror?.(Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`));try{this._scheduleReconnection(t,r+1)}catch(t){this.onerror?.(t instanceof Error?t:Error(String(t)))}}})};if(this._reconnectionScheduler){let t=this._reconnectionScheduler(i,a,r);this._cancelReconnection="function"==typeof t?t:void 0}else{let t=setTimeout(i,a);this._cancelReconnection=()=>clearTimeout(t)}}_handleSseStream(t,r,o){let a;if(!t)return void r.onRequestStreamEnd?.();let{onresumptiontoken:i,replayMessageId:n,requestSignal:s,onRequestStreamEnd:l}=r,c=()=>this._abortController?.signal.aborted===!0||s?.aborted===!0,u=!1,d=!1;(async()=>{try{let r=t.pipeThrough(new TextDecoderStream).pipeThrough(new pd({onRetry:t=>{this._serverRetryMs=t}})).getReader();for(;;){let{value:t,done:o}=await r.read();if(o)break;if((t.id&&(a=t.id,u=!0,i?.(t.id)),t.data)&&(!t.event||"message"===t.event))try{let r=na.parse(JSON.parse(t.data));(cz(r)||cq(r))&&(d=!0,void 0!==n&&(r.id=n)),this.onmessage?.(r)}catch(t){this.onerror?.(t)}}(o||u)&&!d&&this._abortController&&!c()?this._scheduleReconnection({resumptionToken:a,onresumptiontoken:i,replayMessageId:n,requestSignal:s,onRequestStreamEnd:l},0):c()||l?.()}catch(t){if(c())return;if(this.onerror?.(Error(`SSE stream disconnected: ${t}`)),(o||u)&&!d&&this._abortController&&!c())try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:i,replayMessageId:n,requestSignal:s,onRequestStreamEnd:l},0)}catch(t){this.onerror?.(Error(`Failed to reconnect: ${t instanceof Error?t.message:String(t)}`)),l?.()}else l?.()}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t,r){if(!this._oauthProvider)throw new pS("finishAuth requires an OAuthClientProvider");let{authorizationCode:o,iss:a}=await pP(t,r,this._oauthProvider,this._url,{fetchFn:this._fetchWithInit,resourceMetadataUrl:this._resourceMetadataUrl});if(await pT(this._oauthProvider,{serverUrl:this._url,authorizationCode:o,iss:a,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})!=="AUTHORIZED")throw new pS("Failed to authorize")}async close(){try{this._cancelReconnection?.()}finally{this._cancelReconnection=void 0,this._abortController?.abort(),this.onclose?.()}}async send(t,r){return this._send(t,r,!1)}async _send(t,r,o,a=0){try{let i,{resumptionToken:n,onresumptiontoken:s}=r||{};if(n){let o;return void this._startOrAuthSse({resumptionToken:n,replayMessageId:(o=t,ne.safeParse(o).success)?t.id:void 0,requestSignal:r?.requestSignal}).catch(t=>this.onerror?.(t))}let l=await this._commonHeaders();this._applyBodyDerivedHeaders(l,t);let c=Array.isArray(t)?t.some(t=>{let r;return r=t,n_.safeParse(r).success}):(i=t,n_.safeParse(i).success);if(c&&l.delete("mcp-session-id"),r?.headers!==void 0)for(let[t,o]of Object.entries(r.headers))hh.has(t.toLowerCase())||l.set(t,o);l.set("content-type","application/json");let u=[...l.get("accept")?.split(",").map(t=>t.trim().toLowerCase())??[],"application/json","text/event-stream"];l.set("accept",[...new Set(u)].join(", "));let d=this._abortController?.signal,p=r?.requestSignal!==void 0&&void 0!==d?hf(d,r.requestSignal):r?.requestSignal??d,h={...this._requestInit,method:"POST",headers:l,body:JSON.stringify(t),signal:p},f=await this._redirects(this._fetch??fetch)(this._url,h);if(c&&f.ok&&(this._sessionId=f.headers.get("mcp-session-id")||void 0),!f.ok){if(401===f.status&&this._authProvider){if(f.headers.has("www-authenticate")){let{resourceMetadataUrl:t,scope:r}=pN(f);this._resourceMetadataUrl=t,this._scope=pE(this._scope,r)}if(this._authProvider.onUnauthorized&&!o){try{await this._authProvider.onUnauthorized({response:f,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(t){throw p1(t)}return await f.text?.().catch(()=>{}),this._send(t,r,!0,a)}if(await f.text?.().catch(()=>{}),o)throw p1(new lK(lD.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:f.statusText}));throw p1(new pS)}let i=await f.text?.().catch(()=>null);if(403===f.status){let{resourceMetadataUrl:n,scope:s,error:l,errorDescription:c}=pN(f);if("insufficient_scope"===l){if(await this._stepUpAuthorize({scope:s,resourceMetadataUrl:n,errorDescription:c,statusText:f.statusText,text:i},a)!=="AUTHORIZED")throw p1(new pS);return this._send(t,r,o,a+1)}}if(400===f.status&&"string"==typeof i&&this._isModernEnvelopedRequest(t))try{let r=na.parse(JSON.parse(i)),o=(Array.isArray(t)?t:[t]).filter(t=>{let r;return r=t,ne.safeParse(r).success});if(cq(r)&&o.some(t=>t.id===r.id))return void this.onmessage?.(r)}catch{}let n=this._unfollowedRedirect(this._url,f)??i;throw new lK(lD.ClientHttpNotImplemented,`Error POSTing to endpoint: ${n}`,{status:f.status,statusText:f.statusText,text:i})}if(202===f.status){let r;await f.text?.().catch(()=>{}),r=t,nw.safeParse(r).success&&this._startOrAuthSse({resumptionToken:void 0}).catch(t=>this.onerror?.(t));return}let m=(Array.isArray(t)?t:[t]).some(t=>"method"in t&&"id"in t&&void 0!==t.id),y=f.headers.get("content-type"),g=function(t){if(t)try{return uh.parse(t).type}catch{let r=(t.split(";",1)[0]??"").trim().toLowerCase();if(""===r||t.slice(r.length).includes(","))return;return r}}(y);if(m)if("text/event-stream"===g)this._handleSseStream(f.body,{onresumptiontoken:s,requestSignal:r?.requestSignal,onRequestStreamEnd:r?.onRequestStreamEnd},!1);else if("application/json"===g){let t=await f.json();for(let r of Array.isArray(t)?t.map(t=>na.parse(t)):[na.parse(t)])this.onmessage?.(r)}else throw await f.text?.().catch(()=>{}),new lL(lD.ClientHttpUnexpectedContent,`Unexpected content type: ${y}`,{contentType:y});else await f.text?.().catch(()=>{})}catch(t){throw r?.requestSignal?.aborted!==!0&&this.onerror?.(t),t}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},o=await this._redirects(this._fetch??fetch)(this._url,r);if(await o.text?.().catch(()=>{}),!o.ok&&405!==o.status)throw new lK(lD.ClientHttpFailedToTerminateSession,`Failed to terminate session: ${this._unfollowedRedirect(this._url,o)??o.statusText}`,{status:o.status,statusText:o.statusText});this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};let hy=require("node:process"),hg=require("node:stream");var hv=i(6507);let h_="win32"===hy.platform?["APPDATA","COMSPEC","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PATHEXT","PROCESSOR_ARCHITECTURE","PROGRAMDATA","PROGRAMFILES","PROGRAMFILES(X86)","PROGRAMW6432","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","WINDIR"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];var hb=class{_process;_readBuffer;_serverParams;_stderrStream=null;onclose;onerror;onmessage;constructor(t){this._serverParams=t,this._readBuffer=new uf({maxBufferSize:t.maxBufferSize}),("pipe"===t.stderr||"overlapped"===t.stderr)&&(this._stderrStream=new hg.PassThrough)}async start(){if(this._process)throw Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((t,r)=>{this._process=hv(this._serverParams.command,this._serverParams.args??[],{env:{...function(){let t={};for(let r of h_){let o=hy.env[r];void 0!==o&&(o.startsWith("()")||(t[r]=o))}return t}(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:"win32"===hy.platform,cwd:this._serverParams.cwd}),this._process.on("error",t=>{r(t),this.onerror?.(t)}),this._process.on("spawn",()=>{t()}),this._process.on("close",t=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",t=>{this.onerror?.(t)}),this._process.stdout?.on("data",t=>{try{this._readBuffer.append(t),this.processReadBuffer()}catch(t){this.onerror?.(t),this.close().catch(()=>{})}}),this._process.stdout?.on("error",t=>{this.onerror?.(t)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(null===t)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async _dispose(){let t=this._process;if(this._process=void 0,t&&null===t.exitCode&&null===t.signalCode){let r=new Promise(r=>t.once("exit",()=>r()));try{t.stdin?.end()}catch{}try{t.kill("SIGTERM")}catch{}if(await Promise.race([r,new Promise(t=>setTimeout(t,1e3).unref())]),null===t.exitCode&&null===t.signalCode)try{t.kill("SIGKILL")}catch{}await r}try{t?.stdout?.destroy()}catch{}try{t?.stdin?.destroy()}catch{}try{t?.stderr?.destroy()}catch{}this._readBuffer.clear()}async close(){if(this._process){let t=this._process;this._process=void 0;let r=new Promise(r=>{t.once("close",()=>{r()})});try{t.stdin?.end()}catch{}if(await Promise.race([r,new Promise(t=>setTimeout(t,2e3).unref())]),null===t.exitCode){try{t.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(t=>setTimeout(t,2e3).unref())])}if(null===t.exitCode)try{t.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(t){return new Promise(r=>{if(!this._process?.stdin)throw new lL(lD.NotConnected,"Not connected");let o=JSON.stringify(t)+"\n";this._process.stdin.write(o)?r():this._process.stdin.once("drain",r)})}};let hS=i(8330),hw={name:hS.name,version:hS.version};async function h$(t,r={}){var o;let a,i,{handlers:n={}}=r,s={};n.sampling&&(s.sampling={}),n.elicitation&&(s.elicitation={form:{},url:{}}),n.roots&&(s.roots={});let l=new hs(hw,{capabilities:s,versionNegotiation:r.versionNegotiation??{mode:"auto"}});n.sampling&&l.setRequestHandler("sampling/createMessage",n.sampling),n.elicitation&&l.setRequestHandler("elicitation/create",n.elicitation),n.roots&&l.setRequestHandler("roots/list",n.roots);let c="http"===t.type?new hm(new URL(t.url),{requestInit:{headers:(o=t.headers??[],i={},o.forEach(t=>{let r,o=t.name.trim();if("env"in(r=t)&&"string"==typeof r.env){let r=process.env[t.env];if(void 0===r)throw Error(`Environment variable "${t.env}" is not set (required for header "${o}")`);i[o]=r}else i[o]=t.value.trim()}),i)}}):new hb({command:t.command,args:t.args,env:t.env,cwd:t.cwd,stderr:t.stderr??(r.onStderrData?"pipe":"inherit")});c instanceof hb&&c.stderr?.on("data",r.onStderrData??(t=>{process.stderr.write(t)}));let u=c.close.bind(c);c.close=()=>a??(a=u());let d=l.close.bind(l);l.close=async()=>{try{await d()}finally{await c.close()}};let p=r.connect?.signal,h=()=>{c.close().catch(()=>{})};try{return p?.throwIfAborted(),p?.addEventListener("abort",h,{once:!0}),await l.connect(c,r.connect),p?.throwIfAborted(),l}catch(t){try{await l.close()}catch(r){throw AggregateError([t,r],"Client connection and cleanup failed",{cause:t})}throw p?.throwIfAborted(),t}finally{p?.removeEventListener("abort",h)}}async function hE(t,r,o){let a=await h$(t,o);try{return await r(a)}finally{await a.close()}}})(),exports.createClient=n.createClient,exports.withClient=n.withClient,n)-1===["createClient","withClient"].indexOf(s)&&(exports[s]=n[s]);Object.defineProperty(exports,"__esModule",{value:!0})})();