xmcp 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  !function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("zod/v3"));else if("function"==typeof define&&define.amd)define(["zod/v3"],r);else{var a="object"==typeof exports?r(require("zod/v3")):r(t["zod/v3"]);for(var o in a)("object"==typeof exports?exports:t)[o]=a[o]}}(this,t=>(()=>{var r,a,o={9454(t,r,a){"use strict";var o=a(181).Buffer,i=a(181).SlowBuffer;function n(t,r){if(!o.isBuffer(t)||!o.isBuffer(r)||t.length!==r.length)return!1;for(var a=0,i=0;i<t.length;i++)a|=t[i]^r[i];return 0===a}t.exports=n,n.install=function(){o.prototype.equal=i.prototype.equal=function(t){return n(this,t)}};var s=o.prototype.equal,l=i.prototype.equal;n.restore=function(){o.prototype.equal=s,i.prototype.equal=l}},6507(t,r,a){"use strict";let o=a(5317),i=a(8388),n=a(442);function s(t,r,a){let s=i(t,r,a),l=o.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,a){let s=i(t,r,a),l=o.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 a(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 o(t,o){return r&&1===t&&!o.file?a(o.original,"spawn"):null}t.exports={hookChildProcess:function(t,a){if(!r)return;let i=t.emit;t.emit=function(r,n){if("exit"===r){let r=o(n,a);if(r)return i.call(t,"error",r)}return i.apply(t,arguments)}},verifyENOENT:o,verifyENOENTSync:function(t,o){return r&&1===t&&!o.file?a(o.original,"spawnSync"):null},notFoundError:a}},8388(t,r,a){"use strict";let o=a(6928),i=a(3803),n=a(2077),s=a(1880),l="win32"===process.platform,c=/\.(?:com|exe)$/i,u=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;t.exports=function(t,r,a){r&&!Array.isArray(r)&&(a=r,r=null);let d={command:t,args:r=r?r.slice(0):[],options:a=Object.assign({},a),file:void 0,original:{command:t,args:r}};return a.shell?d:function(t){let r;if(!l)return t;let a=(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(a);if(t.options.forceShell||d){let r=u.test(a);t.command=o.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,a){return t=(t=(t=`${t}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1"),t=(t=`"${t}"`).replace(r,"^$1"),a&&(t=t.replace(r,"^$1")),t}},1880(t,r,a){"use strict";let o=a(9896),i=a(600);t.exports=function(t){let r,a=Buffer.alloc(150);try{r=o.openSync(t,"r"),o.readSync(r,a,0,150,0),o.closeSync(r)}catch(t){}return i(a.toString())}},3803(t,r,a){"use strict";let o=a(6928),i=a(1905),n=a(9695);function s(t,r){let a,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{a=i.sync(t.command,{path:s[n({env:s})],pathExt:r?o.delimiter:void 0})}catch(t){}finally{u&&process.chdir(l)}return a&&(a=o.resolve(c?t.options.cwd:"",a)),a}t.exports=function(t){return s(t)||s(t,!0)}},8583(t,r,a){let o=a(9896),i=a(6928),n=a(857),s=a(6982),l=a(4519).version,c=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function u(t){console.log(`[dotenv@${l}][DEBUG] ${t}`)}function d(t){console.log(`[dotenv@${l}] ${t}`)}function p(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function h(t){let r=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let a of t.path)o.existsSync(a)&&(r=a.endsWith(".vault")?a:`${a}.vault`);else r=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else r=i.resolve(process.cwd(),".env.vault");return o.existsSync(r)?r:null}function f(t){return"~"===t[0]?i.join(n.homedir(),t.slice(1)):t}let m={configDotenv:function(t){let r,a=i.resolve(process.cwd(),".env"),n="utf8",s=!!(t&&t.debug),l=!t||!("quiet"in t)||t.quiet;t&&t.encoding?n=t.encoding:s&&u("No encoding is specified. UTF-8 is used by default");let c=[a];if(t&&t.path)if(Array.isArray(t.path))for(let r of(c=[],t.path))c.push(f(r));else c=[f(t.path)];let p={};for(let a of c)try{let r=m.parse(o.readFileSync(a,{encoding:n}));m.populate(p,r,t)}catch(t){s&&u(`Failed to load ${a} ${t.message}`),r=t}let h=process.env;if(t&&null!=t.processEnv&&(h=t.processEnv),m.populate(h,p,t),s||!l){let t=Object.keys(p).length,a=[];for(let t of c)try{let r=i.relative(process.cwd(),t);a.push(r)}catch(a){s&&u(`Failed to load ${t} ${a.message}`),r=a}d(`injecting env (${t}) from ${a.join(",")}`)}return r?{parsed:p,error:r}:{parsed:p}},_configVault:function(t){let r=!!(t&&t.debug),a=!t||!("quiet"in t)||t.quiet;(r||!a)&&d("Loading env from encrypted .env.vault");let o=m._parseVault(t),i=process.env;return t&&null!=t.processEnv&&(i=t.processEnv),m.populate(i,o,t),{parsed:o}},_parseVault:function(t){let r,a=h(t=t||{});t.path=a;let o=m.configDotenv(t);if(!o.parsed){let t=Error(`MISSING_DATA: Cannot parse ${a} for an unknown reason`);throw t.code="MISSING_DATA",t}let i=p(t).split(","),n=i.length;for(let t=0;t<n;t++)try{let a=i[t].trim(),n=function(t,r){let a;try{a=new URL(r)}catch(t){if("ERR_INVALID_URL"===t.code){let t=Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw t.code="INVALID_DOTENV_KEY",t}throw t}let o=a.password;if(!o){let t=Error("INVALID_DOTENV_KEY: Missing key part");throw t.code="INVALID_DOTENV_KEY",t}let i=a.searchParams.get("environment");if(!i){let t=Error("INVALID_DOTENV_KEY: Missing environment part");throw t.code="INVALID_DOTENV_KEY",t}let n=`DOTENV_VAULT_${i.toUpperCase()}`,s=t.parsed[n];if(!s){let t=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${n} in your .env.vault file.`);throw t.code="NOT_FOUND_DOTENV_ENVIRONMENT",t}return{ciphertext:s,key:o}}(o,a);r=m.decrypt(n.ciphertext,n.key);break}catch(r){if(t+1>=n)throw r}return m.parse(r)},config:function(t){if(0===p(t).length)return m.configDotenv(t);let r=h(t);if(!r){var a;return a=`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`,console.log(`[dotenv@${l}][WARN] ${a}`),m.configDotenv(t)}return m._configVault(t)},decrypt:function(t,r){let a=Buffer.from(r.slice(-64),"hex"),o=Buffer.from(t,"base64"),i=o.subarray(0,12),n=o.subarray(-16);o=o.subarray(12,-16);try{let t=s.createDecipheriv("aes-256-gcm",a,i);return t.setAuthTag(n),`${t.update(o)}${t.final()}`}catch(o){let t=o instanceof RangeError,r="Invalid key length"===o.message,a="Unsupported state or unable to authenticate data"===o.message;if(t||r){let t=Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw t.code="INVALID_DOTENV_KEY",t}if(a){let t=Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw t.code="DECRYPTION_FAILED",t}throw o}},parse:function(t){let r,a={},o=t.toString();for(o=o.replace(/\r\n?/mg,"\n");null!=(r=c.exec(o));){let t=r[1],o=r[2]||"",i=(o=o.trim())[0];o=o.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),'"'===i&&(o=(o=o.replace(/\\n/g,"\n")).replace(/\\r/g,"\r")),a[t]=o}return a},populate:function(t,r,a={}){let o=!!(a&&a.debug),i=!!(a&&a.override);if("object"!=typeof r){let t=Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw t.code="OBJECT_REQUIRED",t}for(let a of Object.keys(r))Object.prototype.hasOwnProperty.call(t,a)?(!0===i&&(t[a]=r[a]),o&&(!0===i?u(`"${a}" is already defined and WAS overwritten`):u(`"${a}" is already defined and was NOT overwritten`))):t[a]=r[a]}};t.exports.configDotenv=m.configDotenv,t.exports._configVault=m._configVault,t.exports._parseVault=m._parseVault,t.exports.config=m.config,t.exports.decrypt=m.decrypt,t.exports.parse=m.parse,t.exports.populate=m.populate,t.exports=m},9053(t,r,a){"use strict";var o=a(6608).Buffer,i=a(2188);function n(t){if(o.isBuffer(t))return t;if("string"==typeof t)return o.from(t,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function s(t,r,a){for(var o=0;r+o<a&&0===t[r+o];)++o;return t[r+o]>=128&&--o,o}t.exports={derToJose:function(t,r){t=n(t);var a=i(r),s=a+1,l=t.length,c=0;if(48!==t[c++])throw Error('Could not find expected "seq"');var u=t[c++];if(129===u&&(u=t[c++]),l-c<u)throw Error('"seq" specified length of "'+u+'", only "'+(l-c)+'" remaining');if(2!==t[c++])throw Error('Could not find expected "int" for "r"');var d=t[c++];if(l-c-2<d)throw Error('"r" specified length of "'+d+'", only "'+(l-c-2)+'" available');if(s<d)throw Error('"r" specified length of "'+d+'", max of "'+s+'" is acceptable');var p=c;if(c+=d,2!==t[c++])throw Error('Could not find expected "int" for "s"');var h=t[c++];if(l-c!==h)throw Error('"s" specified length of "'+h+'", expected "'+(l-c)+'"');if(s<h)throw Error('"s" specified length of "'+h+'", max of "'+s+'" is acceptable');var f=c;if((c+=h)!==l)throw Error('Expected to consume entire buffer, but "'+(l-c)+'" bytes remain');var m=a-d,y=a-h,g=o.allocUnsafe(m+d+y+h);for(c=0;c<m;++c)g[c]=0;t.copy(g,c,p+Math.max(-m,0),p+d),c=a;for(var v=c;c<v+y;++c)g[c]=0;return t.copy(g,c,f+Math.max(-y,0),f+h),g=(g=g.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(t,r){t=n(t);var a=i(r),l=t.length;if(l!==2*a)throw TypeError('"'+r+'" signatures must be "'+2*a+'" bytes, saw "'+l+'"');var c=s(t,0,a),u=s(t,a,t.length),d=a-c,p=a-u,h=2+d+1+1+p,f=h<128,m=o.allocUnsafe((f?2:3)+h),y=0;return m[y++]=48,f?m[y++]=h:(m[y++]=129,m[y++]=255&h),m[y++]=2,m[y++]=d,c<0?(m[y++]=0,y+=t.copy(m,y,0,a)):y+=t.copy(m,y,c,a),m[y++]=2,m[y++]=p,u<0?(m[y++]=0,t.copy(m,y,a)):t.copy(m,y,a+u),m}}},2188(t){"use strict";function r(t){return(t/8|0)+ +(t%8!=0)}var a={ES256:r(256),ES384:r(384),ES512:r(521)};t.exports=function(t){var r=a[t];if(r)return r;throw Error('Unknown algorithm "'+t+'"')}},9344(t,r,a){var o;function i(t,r,a){if("function"==typeof r&&(a=r,r={}),!a){if("function"!=typeof Promise)throw TypeError("callback not provided");return new Promise(function(a,o){i(t,r||{},function(t,r){t?o(t):a(r)})})}o(t,r||{},function(t,o){t&&("EACCES"===t.code||r&&r.ignoreErrors)&&(t=null,o=!1),a(t,o)})}a(9896),o="win32"===process.platform||global.TESTING_WINDOWS?a(8541):a(709),t.exports=i,i.sync=function(t,r){try{return o.sync(t,r||{})}catch(t){if(r&&r.ignoreErrors||"EACCES"===t.code)return!1;throw t}}},709(t,r,a){t.exports=i,i.sync=function(t,r){return n(o.statSync(t),r)};var o=a(9896);function i(t,r,a){o.stat(t,function(t,o){a(t,!t&&n(o,r))})}function n(t,r){var a,o,i,n,s,l,c,u,d;return t.isFile()&&(a=t,o=r,i=a.mode,n=a.uid,s=a.gid,l=void 0!==o.uid?o.uid:process.getuid&&process.getuid(),c=void 0!==o.gid?o.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,a){t.exports=n,n.sync=function(t,r){return i(o.statSync(t),t,r)};var o=a(9896);function i(t,r,a){if(!t.isSymbolicLink()&&!t.isFile())return!1;var o=void 0!==a.pathExt?a.pathExt:process.env.PATHEXT;if(!o||-1!==(o=o.split(";")).indexOf(""))return!0;for(var i=0;i<o.length;i++){var n=o[i].toLowerCase();if(n&&r.substr(-n.length).toLowerCase()===n)return!0}return!1}function n(t,r,a){o.stat(t,function(o,n){a(o,!o&&i(n,t,r))})}},2548(t,r,a){var o=a(3263);t.exports=function(t,r){r=r||{};var a=o.decode(t,r);if(!a)return null;var i=a.payload;if("string"==typeof i)try{var n=JSON.parse(i);null!==n&&"object"==typeof n&&(i=n)}catch(t){}return!0===r.complete?{header:a.header,payload:i,signature:a.signature}:i}},8400(t,r,a){t.exports={decode:a(2548),verify:a(6467),sign:a(9147),JsonWebTokenError:a(1957),NotBeforeError:a(4470),TokenExpiredError:a(7788)}},1957(t){var r=function(t,r){Error.call(this,t),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=t,r&&(this.inner=r)};r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,t.exports=r},4470(t,r,a){var o=a(1957),i=function(t,r){o.call(this,t),this.name="NotBeforeError",this.date=r};i.prototype=Object.create(o.prototype),i.prototype.constructor=i,t.exports=i},7788(t,r,a){var o=a(1957),i=function(t,r){o.call(this,t),this.name="TokenExpiredError",this.expiredAt=r};i.prototype=Object.create(o.prototype),i.prototype.constructor=i,t.exports=i},5841(t,r,a){t.exports=a(3895).satisfies(process.version,">=15.7.0")},953(t,r,a){t.exports=a(3895).satisfies(process.version,"^6.12.0 || >=8.0.0")},455(t,r,a){t.exports=a(3895).satisfies(process.version,">=16.9.0")},4559(t,r,a){var o=a(3866);t.exports=function(t,r){var a=r||Math.floor(Date.now()/1e3);if("string"==typeof t){var i=o(t);if(void 0===i)return;return Math.floor(a+i/1e3)}if("number"==typeof t)return a+t}},723(t,r,a){let o=a(5841),i=a(455),n={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},s={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};t.exports=function(t,r){if(!t||!r)return;let a=r.asymmetricKeyType;if(!a)return;let l=n[a];if(!l)throw Error(`Unknown key type "${a}".`);if(!l.includes(t))throw Error(`"alg" parameter for "${a}" key type must be one of: ${l.join(", ")}.`);if(o)switch(a){case"ec":let c=r.asymmetricKeyDetails.namedCurve,u=s[t];if(c!==u)throw Error(`"alg" parameter "${t}" requires curve "${u}".`);break;case"rsa-pss":if(i){let a=parseInt(t.slice(-3),10),{hashAlgorithm:o,mgf1HashAlgorithm:i,saltLength:n}=r.asymmetricKeyDetails;if(o!==`sha${a}`||i!==o)throw Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${t}.`);if(void 0!==n&&n>a>>3)throw Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${t}.`)}}}},9147(t,r,a){let o=a(4559),i=a(953),n=a(723),s=a(3263),l=a(5357),c=a(6782),u=a(5250),d=a(8094),p=a(6052),h=a(1251),f=a(8430),{KeyObject:m,createSecretKey:y,createPrivateKey:g}=a(6982),v=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];i&&v.splice(3,0,"PS256","PS384","PS512");let b={expiresIn:{isValid:function(t){return u(t)||h(t)&&t},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(t){return u(t)||h(t)&&t},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(t){return h(t)||Array.isArray(t)},message:'"audience" must be a string or array'},algorithm:{isValid:l.bind(null,v),message:'"algorithm" must be a valid string enum value'},header:{isValid:p,message:'"header" must be an object'},encoding:{isValid:h,message:'"encoding" must be a string'},issuer:{isValid:h,message:'"issuer" must be a string'},subject:{isValid:h,message:'"subject" must be a string'},jwtid:{isValid:h,message:'"jwtid" must be a string'},noTimestamp:{isValid:c,message:'"noTimestamp" must be a boolean'},keyid:{isValid:h,message:'"keyid" must be a string'},mutatePayload:{isValid:c,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:c,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:c,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},S={iat:{isValid:d,message:'"iat" should be a number of seconds'},exp:{isValid:d,message:'"exp" should be a number of seconds'},nbf:{isValid:d,message:'"nbf" should be a number of seconds'}};function _(t,r,a,o){if(!p(a))throw Error('Expected "'+o+'" to be a plain object.');Object.keys(a).forEach(function(i){let n=t[i];if(!n){if(!r)throw Error('"'+i+'" is not allowed in "'+o+'"');return}if(!n.isValid(a[i]))throw Error(n.message)})}let w={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},$=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];t.exports=function(t,r,a,i){var l,c;"function"==typeof a?(i=a,a={}):a=a||{};let u="object"==typeof t&&!Buffer.isBuffer(t),d=Object.assign({alg:a.algorithm||"HS256",typ:u?"JWT":void 0,kid:a.keyid},a.header);function p(t){if(i)return i(t);throw t}if(!r&&"none"!==a.algorithm)return p(Error("secretOrPrivateKey must have a value"));if(null!=r&&!(r instanceof m))try{r=g(r)}catch(t){try{r=y("string"==typeof r?Buffer.from(r):r)}catch(t){return p(Error("secretOrPrivateKey is not valid key material"))}}if(d.alg.startsWith("HS")&&"secret"!==r.type)return p(Error(`secretOrPrivateKey must be a symmetric key when using ${d.alg}`));if(/^(?:RS|PS|ES)/.test(d.alg)){if("private"!==r.type)return p(Error(`secretOrPrivateKey must be an asymmetric key when using ${d.alg}`));if(!a.allowInsecureKeySizes&&!d.alg.startsWith("ES")&&void 0!==r.asymmetricKeyDetails&&r.asymmetricKeyDetails.modulusLength<2048)return p(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${d.alg}`))}if(void 0===t)return p(Error("payload is required"));if(u){try{l=t,_(S,!0,l,"payload")}catch(t){return p(t)}a.mutatePayload||(t=Object.assign({},t))}else{let r=$.filter(function(t){return void 0!==a[t]});if(r.length>0)return p(Error("invalid "+r.join(",")+" option for "+typeof t+" payload"))}if(void 0!==t.exp&&void 0!==a.expiresIn)return p(Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==t.nbf&&void 0!==a.notBefore)return p(Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{c=a,_(b,!1,c,"options")}catch(t){return p(t)}if(!a.allowInvalidAsymmetricKeyTypes)try{n(d.alg,r)}catch(t){return p(t)}let h=t.iat||Math.floor(Date.now()/1e3);if(a.noTimestamp?delete t.iat:u&&(t.iat=h),void 0!==a.notBefore){try{t.nbf=o(a.notBefore,h)}catch(t){return p(t)}if(void 0===t.nbf)return p(Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==a.expiresIn&&"object"==typeof t){try{t.exp=o(a.expiresIn,h)}catch(t){return p(t)}if(void 0===t.exp)return p(Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(w).forEach(function(r){let o=w[r];if(void 0!==a[r]){if(void 0!==t[o])return p(Error('Bad "options.'+r+'" option. The payload already has an "'+o+'" property.'));t[o]=a[r]}});let v=a.encoding||"utf8";if("function"==typeof i)i=i&&f(i),s.createSign({header:d,privateKey:r,payload:t,encoding:v}).once("error",i).once("done",function(t){if(!a.allowInsecureKeySizes&&/^(?:RS|PS)/.test(d.alg)&&t.length<256)return i(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${d.alg}`));i(null,t)});else{let o=s.sign({header:d,payload:t,secret:r,encoding:v});if(!a.allowInsecureKeySizes&&/^(?:RS|PS)/.test(d.alg)&&o.length<256)throw Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${d.alg}`);return o}}},6467(t,r,a){let o=a(1957),i=a(4470),n=a(7788),s=a(2548),l=a(4559),c=a(723),u=a(953),d=a(3263),{KeyObject:p,createSecretKey:h,createPublicKey:f}=a(6982),m=["RS256","RS384","RS512"],y=["ES256","ES384","ES512"],g=["RS256","RS384","RS512"],v=["HS256","HS384","HS512"];u&&(m.splice(m.length,0,"PS256","PS384","PS512"),g.splice(g.length,0,"PS256","PS384","PS512")),t.exports=function(t,r,a,u){let b,S,_;if("function"!=typeof a||u||(u=a,a={}),a||(a={}),a=Object.assign({},a),b=u||function(t,r){if(t)throw t;return r},a.clockTimestamp&&"number"!=typeof a.clockTimestamp)return b(new o("clockTimestamp must be a number"));if(void 0!==a.nonce&&("string"!=typeof a.nonce||""===a.nonce.trim()))return b(new o("nonce must be a non-empty string"));if(void 0!==a.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof a.allowInvalidAsymmetricKeyTypes)return b(new o("allowInvalidAsymmetricKeyTypes must be a boolean"));let w=a.clockTimestamp||Math.floor(Date.now()/1e3);if(!t)return b(new o("jwt must be provided"));if("string"!=typeof t)return b(new o("jwt must be a string"));let $=t.split(".");if(3!==$.length)return b(new o("jwt malformed"));try{S=s(t,{complete:!0})}catch(t){return b(t)}if(!S)return b(new o("invalid token"));let E=S.header;if("function"==typeof r){if(!u)return b(new o("verify must be called asynchronous if secret or public key is provided as a callback"));_=r}else _=function(t,a){return a(null,r)};return _(E,function(r,s){let u;if(r)return b(new o("error in secret or public key callback: "+r.message));let _=""!==$[2].trim();if(!_&&s)return b(new o("jwt signature is required"));if(_&&!s)return b(new o("secret or public key must be provided"));if(!_&&!a.algorithms)return b(new o('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=s&&!(s instanceof p))try{s=f(s)}catch(t){try{s=h("string"==typeof s?Buffer.from(s):s)}catch(t){return b(new o("secretOrPublicKey is not valid key material"))}}if(a.algorithms||("secret"===s.type?a.algorithms=v:["rsa","rsa-pss"].includes(s.asymmetricKeyType)?a.algorithms=g:"ec"===s.asymmetricKeyType?a.algorithms=y:a.algorithms=m),-1===a.algorithms.indexOf(S.header.alg))return b(new o("invalid algorithm"));if(E.alg.startsWith("HS")&&"secret"!==s.type)return b(new o(`secretOrPublicKey must be a symmetric key when using ${E.alg}`));if(/^(?:RS|PS|ES)/.test(E.alg)&&"public"!==s.type)return b(new o(`secretOrPublicKey must be an asymmetric key when using ${E.alg}`));if(!a.allowInvalidAsymmetricKeyTypes)try{c(E.alg,s)}catch(t){return b(t)}try{u=d.verify(t,S.header.alg,s)}catch(t){return b(t)}if(!u)return b(new o("invalid signature"));let P=S.payload;if(void 0!==P.nbf&&!a.ignoreNotBefore){if("number"!=typeof P.nbf)return b(new o("invalid nbf value"));if(P.nbf>w+(a.clockTolerance||0))return b(new i("jwt not active",new Date(1e3*P.nbf)))}if(void 0!==P.exp&&!a.ignoreExpiration){if("number"!=typeof P.exp)return b(new o("invalid exp value"));if(w>=P.exp+(a.clockTolerance||0))return b(new n("jwt expired",new Date(1e3*P.exp)))}if(a.audience){let t=Array.isArray(a.audience)?a.audience:[a.audience];if(!(Array.isArray(P.aud)?P.aud:[P.aud]).some(function(r){return t.some(function(t){return t instanceof RegExp?t.test(r):t===r})}))return b(new o("jwt audience invalid. expected: "+t.join(" or ")))}if(a.issuer&&("string"==typeof a.issuer&&P.iss!==a.issuer||Array.isArray(a.issuer)&&-1===a.issuer.indexOf(P.iss)))return b(new o("jwt issuer invalid. expected: "+a.issuer));if(a.subject&&P.sub!==a.subject)return b(new o("jwt subject invalid. expected: "+a.subject));if(a.jwtid&&P.jti!==a.jwtid)return b(new o("jwt jwtid invalid. expected: "+a.jwtid));if(a.nonce&&P.nonce!==a.nonce)return b(new o("jwt nonce invalid. expected: "+a.nonce));if(a.maxAge){if("number"!=typeof P.iat)return b(new o("iat required when maxAge is specified"));let t=l(a.maxAge,P.iat);if(void 0===t)return b(new o('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(w>=t+(a.clockTolerance||0))return b(new n("maxAge exceeded",new Date(1e3*t)))}return!0===a.complete?b(null,{header:E,payload:P,signature:S.signature}):b(null,P)})}},2357(t,r,a){var o,i=a(6608).Buffer,n=a(6982),s=a(9053),l=a(9023),c="secret must be a string or buffer",u="key must be a string or a buffer",d="function"==typeof n.createPublicKey;function p(t){if(!i.isBuffer(t)&&"string"!=typeof t&&(!d||"object"!=typeof t||"string"!=typeof t.type||"string"!=typeof t.asymmetricKeyType||"function"!=typeof t.export))throw y(u)}function h(t){if(!i.isBuffer(t)&&"string"!=typeof t&&"object"!=typeof t)throw y("key must be a string, a buffer or an object")}function f(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function m(t){var r=4-(t=t.toString()).length%4;if(4!==r)for(var a=0;a<r;++a)t+="=";return t.replace(/\-/g,"+").replace(/_/g,"/")}function y(t){var r=[].slice.call(arguments,1);return TypeError(l.format.bind(l,t).apply(null,r))}function g(t){var r;return r=t,i.isBuffer(r)||"string"==typeof r||(t=JSON.stringify(t)),t}function v(t){return function(r,a){!function(t){if(!i.isBuffer(t)){if("string"!=typeof t){if(!d||"object"!=typeof t||"secret"!==t.type||"function"!=typeof t.export)throw y(c)}}}(a),r=g(r);var o=n.createHmac("sha"+t,a);return f((o.update(r),o.digest("base64")))}}d&&(u+=" or a KeyObject",c+="or a KeyObject");var b="timingSafeEqual"in n?function(t,r){return t.byteLength===r.byteLength&&n.timingSafeEqual(t,r)}:function(t,r){return o||(o=a(9454)),o(t,r)};function S(t){return function(r,a,o){var n=v(t)(r,o);return b(i.from(a),i.from(n))}}function _(t){return function(r,a){h(a),r=g(r);var o=n.createSign("RSA-SHA"+t);return f((o.update(r),o.sign(a,"base64")))}}function w(t){return function(r,a,o){p(o),r=g(r),a=m(a);var i=n.createVerify("RSA-SHA"+t);return i.update(r),i.verify(o,a,"base64")}}function $(t){return function(r,a){h(a),r=g(r);var o=n.createSign("RSA-SHA"+t);return f((o.update(r),o.sign({key:a,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function E(t){return function(r,a,o){p(o),r=g(r),a=m(a);var i=n.createVerify("RSA-SHA"+t);return i.update(r),i.verify({key:o,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},a,"base64")}}function P(t){var r=_(t);return function(){var a=r.apply(null,arguments);return s.derToJose(a,"ES"+t)}}function R(t){var r=w(t);return function(a,o,i){return r(a,o=s.joseToDer(o,"ES"+t).toString("base64"),i)}}function k(){return function(){return""}}function T(){return function(t,r){return""===r}}t.exports=function(t){var r=t.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!r)throw y('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',t);var a=(r[1]||r[3]).toLowerCase(),o=r[2];return{sign:({hs:v,rs:_,ps:$,es:P,none:k})[a](o),verify:({hs:S,rs:w,ps:E,es:R,none:T})[a](o)}}},3263(t,r,a){var o=a(9615),i=a(6747);r.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],r.sign=o.sign,r.verify=i.verify,r.decode=i.decode,r.isValid=i.isValid,r.createSign=function(t){return new o(t)},r.createVerify=function(t){return new i(t)}},6360(t,r,a){var o=a(6608).Buffer,i=a(2203);function n(t){if(this.buffer=null,this.writable=!0,this.readable=!0,!t)return this.buffer=o.alloc(0),this;if("function"==typeof t.pipe)return this.buffer=o.alloc(0),t.pipe(this),this;if(t.length||"object"==typeof t)return this.buffer=t,this.writable=!1,process.nextTick((function(){this.emit("end",t),this.readable=!1,this.emit("close")}).bind(this)),this;throw TypeError("Unexpected data type ("+typeof t+")")}a(9023).inherits(n,i),n.prototype.write=function(t){this.buffer=o.concat([this.buffer,o.from(t)]),this.emit("data",t)},n.prototype.end=function(t){t&&this.write(t),this.emit("end",t),this.emit("close"),this.writable=!1,this.readable=!1},t.exports=n},9615(t,r,a){var o=a(6608).Buffer,i=a(6360),n=a(2357),s=a(2203),l=a(5911),c=a(9023);function u(t,r){return o.from(t,r).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function d(t){var r,a,o,i=t.header,s=t.payload,d=t.secret||t.privateKey,p=t.encoding,h=n(i.alg),f=(r=(r=p)||"utf8",a=u(l(i),"binary"),o=u(l(s),r),c.format("%s.%s",a,o)),m=h.sign(f,d);return c.format("%s.%s",f,m)}function p(t){var r=t.secret;if(r=null==(r=null==r?t.privateKey:r)?t.key:r,!0===/^hs/i.test(t.header.alg)&&null==r)throw TypeError("secret must be a string or buffer or a KeyObject");var a=new i(r);this.readable=!0,this.header=t.header,this.encoding=t.encoding,this.secret=this.privateKey=this.key=a,this.payload=new i(t.payload),this.secret.once("close",(function(){!this.payload.writable&&this.readable&&this.sign()}).bind(this)),this.payload.once("close",(function(){!this.secret.writable&&this.readable&&this.sign()}).bind(this))}c.inherits(p,s),p.prototype.sign=function(){try{var t=d({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",t),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(t){this.readable=!1,this.emit("error",t),this.emit("close")}},p.sign=d,t.exports=p},5911(t,r,a){var o=a(181).Buffer;t.exports=function(t){return"string"==typeof t?t:"number"==typeof t||o.isBuffer(t)?t.toString():JSON.stringify(t)}},6747(t,r,a){var o=a(6608).Buffer,i=a(6360),n=a(2357),s=a(2203),l=a(5911),c=a(9023),u=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function d(t){var r=t.split(".",1)[0],a=o.from(r,"base64").toString("binary");if("[object Object]"===Object.prototype.toString.call(a))return a;try{return JSON.parse(a)}catch(t){return}}function p(t){return t.split(".")[2]}function h(t){return u.test(t)&&!!d(t)}function f(t,r,a){if(!r){var o=Error("Missing algorithm parameter for jws.verify");throw o.code="MISSING_ALGORITHM",o}var i=p(t=l(t)),s=t.split(".",2).join(".");return n(r).verify(s,i,a)}function m(t,r){if(r=r||{},!h(t=l(t)))return null;var a,i,n=d(t);if(!n)return null;var s=(a=a||"utf8",i=t.split(".")[1],o.from(i,"base64").toString(a));return("JWT"===n.typ||r.json)&&(s=JSON.parse(s,r.encoding)),{header:n,payload:s,signature:p(t)}}function y(t){var r=(t=t||{}).secret;if(r=null==(r=null==r?t.publicKey:r)?t.key:r,!0===/^hs/i.test(t.algorithm)&&null==r)throw TypeError("secret must be a string or buffer or a KeyObject");var a=new i(r);this.readable=!0,this.algorithm=t.algorithm,this.encoding=t.encoding,this.secret=this.publicKey=this.key=a,this.signature=new i(t.signature),this.secret.once("close",(function(){!this.signature.writable&&this.readable&&this.verify()}).bind(this)),this.signature.once("close",(function(){!this.secret.writable&&this.readable&&this.verify()}).bind(this))}c.inherits(y,s),y.prototype.verify=function(){try{var t=f(this.signature.buffer,this.algorithm,this.key.buffer),r=m(this.signature.buffer,this.encoding);return this.emit("done",t,r),this.emit("data",t),this.emit("end"),this.readable=!1,t}catch(t){this.readable=!1,this.emit("error",t),this.emit("close")}},y.decode=m,y.isValid=h,y.verify=f,t.exports=y},5357(t){var r,a,o=1/0,i=0/0,n=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=/^(?:0|[1-9]\d*)$/,d=parseInt;function p(t){return t!=t}var h=Object.prototype,f=h.hasOwnProperty,m=h.toString,y=h.propertyIsEnumerable,g=(r=Object.keys,a=Object,function(t){return r(a(t))}),v=Math.max,b=Array.isArray;function S(t){var r,a,o;return null!=t&&"number"==typeof(r=t.length)&&r>-1&&r%1==0&&r<=0x1fffffffffffff&&"[object Function]"!=(o=_(a=t)?m.call(a):"")&&"[object GeneratorFunction]"!=o}function _(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}function w(t){return!!t&&"object"==typeof t}t.exports=function(t,r,a,$){t=S(t)?t:function(t){return t?function(t,r){for(var a=-1,o=t?t.length:0,i=Array(o);++a<o;)i[a]=r(t[a],a,t);return i}(S(t)?function(t,r){var a,o,i,n,s=b(t)||w(o=a=t)&&S(o)&&f.call(a,"callee")&&(!y.call(a,"callee")||"[object Arguments]"==m.call(a))?function(t,r){for(var a=-1,o=Array(t);++a<t;)o[a]=r(a);return o}(t.length,String):[],l=s.length,c=!!l;for(var d in t){f.call(t,d)&&!(c&&("length"==d||(i=d,(n=null==(n=l)?0x1fffffffffffff:n)&&("number"==typeof i||u.test(i))&&i>-1&&i%1==0&&i<n)))&&s.push(d)}return s}(t):function(t){if(a=(r=t)&&r.constructor,r!==("function"==typeof a&&a.prototype||h))return g(t);var r,a,o=[];for(var i in Object(t))f.call(t,i)&&"constructor"!=i&&o.push(i);return o}(t),function(r){return t[r]}):[]}(t),a=a&&!$?(R=(P=(E=a)?(E=function(t){if("number"==typeof t)return t;if("symbol"==typeof(r=t)||w(r)&&"[object Symbol]"==m.call(r))return i;if(_(t)){var r,a="function"==typeof t.valueOf?t.valueOf():t;t=_(a)?a+"":a}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(n,"");var o=l.test(t);return o||c.test(t)?d(t.slice(2),o?2:8):s.test(t)?i:+t}(E))===o||E===-o?(E<0?-1:1)*17976931348623157e292:E==E?E:0:0===E?E:0)%1,P==P?R?P-R:P:0):0;var E,P,R,k,T=t.length;return a<0&&(a=v(T+a,0)),"string"==typeof(k=t)||!b(k)&&w(k)&&"[object String]"==m.call(k)?a<=T&&t.indexOf(r,a)>-1:!!T&&function(t,r,a){if(r!=r){for(var o=t.length,i=a+-1;++i<o;)if(p(t[i],i,t))return i;return -1}for(var n=a-1,s=t.length;++n<s;)if(t[n]===r)return n;return -1}(t,r,a)>-1}},6782(t){var r=Object.prototype.toString;t.exports=function(t){var a;return!0===t||!1===t||!!(a=t)&&"object"==typeof a&&"[object Boolean]"==r.call(t)}},5250(t){var r=1/0,a=0/0,o=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,c=Object.prototype.toString;function u(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}t.exports=function(t){var d,p,h;return"number"==typeof t&&t==(h=(p=(d=t)?(d=function(t){if("number"==typeof t)return t;if("symbol"==typeof(r=t)||r&&"object"==typeof r&&"[object Symbol]"==c.call(r))return a;if(u(t)){var r,d="function"==typeof t.valueOf?t.valueOf():t;t=u(d)?d+"":d}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(o,"");var p=n.test(t);return p||s.test(t)?l(t.slice(2),p?2:8):i.test(t)?a:+t}(d))===r||d===-r?(d<0?-1:1)*17976931348623157e292:d==d?d:0:0===d?d:0)%1,p==p?h?p-h:p:0)}},8094(t){var r=Object.prototype.toString;t.exports=function(t){return"number"==typeof t||!!t&&"object"==typeof t&&"[object Number]"==r.call(t)}},6052(t){var r,a,o=Object.prototype,i=Function.prototype.toString,n=o.hasOwnProperty,s=i.call(Object),l=o.toString,c=(r=Object.getPrototypeOf,a=Object,function(t){return r(a(t))});t.exports=function(t){if(!(t&&"object"==typeof t)||"[object Object]"!=l.call(t)||function(t){var r=!1;if(null!=t&&"function"!=typeof t.toString)try{r=!!(t+"")}catch(t){}return r}(t))return!1;var r=c(t);if(null===r)return!0;var a=n.call(r,"constructor")&&r.constructor;return"function"==typeof a&&a instanceof a&&i.call(a)==s}},1251(t){var r=Object.prototype.toString,a=Array.isArray;t.exports=function(t){var o;return"string"==typeof t||!a(t)&&!!(o=t)&&"object"==typeof o&&"[object String]"==r.call(t)}},8430(t){var r=1/0,a=0/0,o=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,c=Object.prototype.toString;function u(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}t.exports=function(t){var d,p,h,f,m=2,y=t;if("function"!=typeof y)throw TypeError("Expected a function");return h=(p=(d=m)?(d=function(t){if("number"==typeof t)return t;if("symbol"==typeof(r=t)||r&&"object"==typeof r&&"[object Symbol]"==c.call(r))return a;if(u(t)){var r,d="function"==typeof t.valueOf?t.valueOf():t;t=u(d)?d+"":d}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(o,"");var p=n.test(t);return p||s.test(t)?l(t.slice(2),p?2:8):i.test(t)?a:+t}(d))===r||d===-r?(d<0?-1:1)*17976931348623157e292:d==d?d:0:0===d?d:0)%1,m=p==p?h?p-h:p:0,function(){return--m>0&&(f=y.apply(this,arguments)),m<=1&&(y=void 0),f}}},3866(t){function r(t,r,a,o){return Math.round(t/a)+" "+o+(r>=1.5*a?"s":"")}t.exports=function(t,a){a=a||{};var o,i,n,s,l=typeof t;if("string"===l&&t.length>0){var c=t;if(!((c=String(c)).length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(u){var d=parseFloat(u[1]);switch((u[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*d;case"weeks":case"week":case"w":return 6048e5*d;case"days":case"day":case"d":return 864e5*d;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*d;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*d;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*d;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:break}}}return}if("number"===l&&isFinite(t)){return a.long?(i=Math.abs(o=t))>=864e5?r(o,i,864e5,"day"):i>=36e5?r(o,i,36e5,"hour"):i>=6e4?r(o,i,6e4,"minute"):i>=1e3?r(o,i,1e3,"second"):o+" ms":(s=Math.abs(n=t))>=864e5?Math.round(n/864e5)+"d":s>=36e5?Math.round(n/36e5)+"h":s>=6e4?Math.round(n/6e4)+"m":s>=1e3?Math.round(n/1e3)+"s":n+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},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},6608(t,r,a){var o=a(181),i=o.Buffer;function n(t,r){for(var a in t)r[a]=t[a]}function s(t,r,a){return i(t,r,a)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=o:(n(o,r),r.Buffer=s),s.prototype=Object.create(i.prototype),n(i,s),s.from=function(t,r,a){if("number"==typeof t)throw TypeError("Argument must not be a number");return i(t,r,a)},s.alloc=function(t,r,a){if("number"!=typeof t)throw TypeError("Argument must be a number");var o=i(t);return void 0!==r?"string"==typeof a?o.fill(r,a):o.fill(r):o.fill(0),o},s.allocUnsafe=function(t){if("number"!=typeof t)throw TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw TypeError("Argument must be a number");return o.SlowBuffer(t)}},8610(t,r,a){"use strict";let o=Symbol("SemVer ANY");class i{static get ANY(){return o}constructor(t,r){if(r=n(r),t instanceof i)if(!!r.loose===t.loose)return t;else t=t.value;u("comparator",t=t.trim().split(/\s+/).join(" "),r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===o?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(t){let r=this.options.loose?s[l.COMPARATORLOOSE]:s[l.COMPARATOR],a=t.match(r);if(!a)throw TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==a[1]?a[1]:"","="===this.operator&&(this.operator=""),a[2]?this.semver=new d(a[2],this.options.loose):this.semver=o}toString(){return this.value}test(t){if(u("Comparator.test",t,this.options.loose),this.semver===o||t===o)return!0;if("string"==typeof t)try{t=new d(t,this.options)}catch(t){return!1}return c(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof i))throw TypeError("a Comparator is required");return""===this.operator?""===this.value||new p(t.value,r).test(this.value):""===t.operator?""===t.value||new p(this.value,r).test(t.semver):!((r=n(r)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===t.value)||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0")))&&!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||c(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||c(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">"))}}t.exports=i;let n=a(4621),{safeRe:s,t:l}=a(152),c=a(5461),u=a(674),d=a(2398),p=a(2069)},2069(t,r,a){"use strict";let o=/\s+/g;class i{constructor(t,r){if(r=s(r),t instanceof i)if(!!r.loose===t.loose&&!!r.includePrerelease===t.includePrerelease)return t;else return new i(t.raw,r);if(t instanceof l)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(o," "),this.set=this.raw.split("||").map(t=>this.parseRange(t.trim())).filter(t=>t.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter(t=>!v(t[0])),0===this.set.length)this.set=[t];else if(this.set.length>1){for(const t of this.set)if(1===t.length&&b(t[0])){this.set=[t];break}}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let t=0;t<r.length;t++)t>0&&(this.formatted+=" "),this.formatted+=r[t].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let r=((this.options.includePrerelease&&y)|(this.options.loose&&g))+":"+t,a=n.get(r);if(a)return a;let o=this.options.loose,i=o?d[p.HYPHENRANGELOOSE]:d[p.HYPHENRANGE];c("hyphen replace",t=t.replace(i,C(this.options.includePrerelease))),c("comparator trim",t=t.replace(d[p.COMPARATORTRIM],h)),c("tilde trim",t=t.replace(d[p.TILDETRIM],f)),c("caret trim",t=t.replace(d[p.CARETTRIM],m));let s=t.split(" ").map(t=>_(t,this.options)).join(" ").split(/\s+/).map(t=>x(t,this.options));o&&(s=s.filter(t=>(c("loose invalid filter",t,this.options),!!t.match(d[p.COMPARATORLOOSE])))),c("range list",s);let u=new Map;for(let t of s.map(t=>new l(t,this.options))){if(v(t))return[t];u.set(t.value,t)}u.size>1&&u.has("")&&u.delete("");let b=[...u.values()];return n.set(r,b),b}intersects(t,r){if(!(t instanceof i))throw TypeError("a Range is required");return this.set.some(a=>S(a,r)&&t.set.some(t=>S(t,r)&&a.every(a=>t.every(t=>a.intersects(t,r)))))}test(t){if(!t)return!1;if("string"==typeof t)try{t=new u(t,this.options)}catch(t){return!1}for(let r=0;r<this.set.length;r++)if(j(this.set[r],t,this.options))return!0;return!1}}t.exports=i;let n=new(a(2044)),s=a(4621),l=a(8610),c=a(674),u=a(2398),{safeRe:d,t:p,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:m}=a(152),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:g}=a(5076),v=t=>"<0.0.0-0"===t.value,b=t=>""===t.value,S=(t,r)=>{let a=!0,o=t.slice(),i=o.pop();for(;a&&o.length;)a=o.every(t=>i.intersects(t,r)),i=o.pop();return a},_=(t,r)=>(c("comp",t=t.replace(d[p.BUILD],""),r),c("caret",t=P(t,r)),c("tildes",t=$(t,r)),c("xrange",t=k(t,r)),c("stars",t=O(t,r)),t),w=t=>!t||"x"===t.toLowerCase()||"*"===t,$=(t,r)=>t.trim().split(/\s+/).map(t=>E(t,r)).join(" "),E=(t,r)=>{let a=r.loose?d[p.TILDELOOSE]:d[p.TILDE];return t.replace(a,(r,a,o,i,n)=>{let s;return c("tilde",t,r,a,o,i,n),w(a)?s="":w(o)?s=`>=${a}.0.0 <${+a+1}.0.0-0`:w(i)?s=`>=${a}.${o}.0 <${a}.${+o+1}.0-0`:n?(c("replaceTilde pr",n),s=`>=${a}.${o}.${i}-${n} <${a}.${+o+1}.0-0`):s=`>=${a}.${o}.${i} <${a}.${+o+1}.0-0`,c("tilde return",s),s})},P=(t,r)=>t.trim().split(/\s+/).map(t=>R(t,r)).join(" "),R=(t,r)=>{c("caret",t,r);let a=r.loose?d[p.CARETLOOSE]:d[p.CARET],o=r.includePrerelease?"-0":"";return t.replace(a,(r,a,i,n,s)=>{let l;return c("caret",t,r,a,i,n,s),w(a)?l="":w(i)?l=`>=${a}.0.0${o} <${+a+1}.0.0-0`:w(n)?l="0"===a?`>=${a}.${i}.0${o} <${a}.${+i+1}.0-0`:`>=${a}.${i}.0${o} <${+a+1}.0.0-0`:s?(c("replaceCaret pr",s),l="0"===a?"0"===i?`>=${a}.${i}.${n}-${s} <${a}.${i}.${+n+1}-0`:`>=${a}.${i}.${n}-${s} <${a}.${+i+1}.0-0`:`>=${a}.${i}.${n}-${s} <${+a+1}.0.0-0`):(c("no pr"),l="0"===a?"0"===i?`>=${a}.${i}.${n}${o} <${a}.${i}.${+n+1}-0`:`>=${a}.${i}.${n}${o} <${a}.${+i+1}.0-0`:`>=${a}.${i}.${n} <${+a+1}.0.0-0`),c("caret return",l),l})},k=(t,r)=>(c("replaceXRanges",t,r),t.split(/\s+/).map(t=>T(t,r)).join(" ")),T=(t,r)=>{t=t.trim();let a=r.loose?d[p.XRANGELOOSE]:d[p.XRANGE];return t.replace(a,(a,o,i,n,s,l)=>{c("xRange",t,a,o,i,n,s,l);let u=w(i),d=u||w(n),p=d||w(s);return"="===o&&p&&(o=""),l=r.includePrerelease?"-0":"",u?a=">"===o||"<"===o?"<0.0.0-0":"*":o&&p?(d&&(n=0),s=0,">"===o?(o=">=",d?(i=+i+1,n=0):n=+n+1,s=0):"<="===o&&(o="<",d?i=+i+1:n=+n+1),"<"===o&&(l="-0"),a=`${o+i}.${n}.${s}${l}`):d?a=`>=${i}.0.0${l} <${+i+1}.0.0-0`:p&&(a=`>=${i}.${n}.0${l} <${i}.${+n+1}.0-0`),c("xRange return",a),a})},O=(t,r)=>(c("replaceStars",t,r),t.trim().replace(d[p.STAR],"")),x=(t,r)=>(c("replaceGTE0",t,r),t.trim().replace(d[r.includePrerelease?p.GTE0PRE:p.GTE0],"")),C=t=>(r,a,o,i,n,s,l,c,u,d,p,h)=>(a=w(o)?"":w(i)?`>=${o}.0.0${t?"-0":""}`:w(n)?`>=${o}.${i}.0${t?"-0":""}`:s?`>=${a}`:`>=${a}${t?"-0":""}`,c=w(u)?"":w(d)?`<${+u+1}.0.0-0`:w(p)?`<${u}.${+d+1}.0-0`:h?`<=${u}.${d}.${p}-${h}`:t?`<${u}.${d}.${+p+1}-0`:`<=${c}`,`${a} ${c}`.trim()),j=(t,r,a)=>{for(let a=0;a<t.length;a++)if(!t[a].test(r))return!1;if(r.prerelease.length&&!a.includePrerelease){for(let a=0;a<t.length;a++)if(c(t[a].semver),t[a].semver!==l.ANY&&t[a].semver.prerelease.length>0){let o=t[a].semver;if(o.major===r.major&&o.minor===r.minor&&o.patch===r.patch)return!0}return!1}return!0}},2398(t,r,a){"use strict";let o=a(674),{MAX_LENGTH:i,MAX_SAFE_INTEGER:n}=a(5076),{safeRe:s,t:l}=a(152),c=a(4621),{compareIdentifiers:u}=a(9101);class d{constructor(t,r){if(r=c(r),t instanceof d)if(!!r.loose===t.loose&&!!r.includePrerelease===t.includePrerelease)return t;else t=t.version;else if("string"!=typeof t)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>i)throw TypeError(`version is longer than ${i} characters`);o("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const a=t.trim().match(r.loose?s[l.LOOSE]:s[l.FULL]);if(!a)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+a[1],this.minor=+a[2],this.patch=+a[3],this.major>n||this.major<0)throw TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw TypeError("Invalid patch version");a[4]?this.prerelease=a[4].split(".").map(t=>{if(/^[0-9]+$/.test(t)){let r=+t;if(r>=0&&r<n)return r}return t}):this.prerelease=[],this.build=a[5]?a[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(o("SemVer.compare",this.version,this.options,t),!(t instanceof d)){if("string"==typeof t&&t===this.version)return 0;t=new d(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return(t instanceof d||(t=new d(t,this.options)),this.major<t.major)?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof d||(t=new d(t,this.options)),this.prerelease.length&&!t.prerelease.length)return -1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let a=this.prerelease[r],i=t.prerelease[r];if(o("prerelease compare",r,a,i),void 0===a&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===a)return -1;else if(a===i)continue;else return u(a,i)}while(++r)}compareBuild(t){t instanceof d||(t=new d(t,this.options));let r=0;do{let a=this.build[r],i=t.build[r];if(o("build compare",r,a,i),void 0===a&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===a)return -1;else if(a===i)continue;else return u(a,i)}while(++r)}inc(t,r,a){if(t.startsWith("pre")){if(!r&&!1===a)throw Error("invalid increment argument: identifier is empty");if(r){let t=`-${r}`.match(this.options.loose?s[l.PRERELEASELOOSE]:s[l.PRERELEASE]);if(!t||t[1]!==r)throw Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,a);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,a);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,a),this.inc("pre",r,a);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",r,a),this.inc("pre",r,a);break;case"release":if(0===this.prerelease.length)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(0!==this.minor||0!==this.patch||0===this.prerelease.length)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(0!==this.patch||0===this.prerelease.length)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{let t=+!!Number(a);if(0===this.prerelease.length)this.prerelease=[t];else{let o=this.prerelease.length;for(;--o>=0;)"number"==typeof this.prerelease[o]&&(this.prerelease[o]++,o=-2);if(-1===o){if(r===this.prerelease.join(".")&&!1===a)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(t)}}if(r){let o=[r,t];!1===a&&(o=[r]),0===u(this.prerelease[0],r)?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}t.exports=d},5608(t,r,a){"use strict";let o=a(6802);t.exports=(t,r)=>{let a=o(t.trim().replace(/^[=v]+/,""),r);return a?a.version:null}},5461(t,r,a){"use strict";let o=a(8271),i=a(733),n=a(1686),s=a(6479),l=a(7257),c=a(5850);t.exports=(t,r,a,u)=>{switch(r){case"===":return"object"==typeof t&&(t=t.version),"object"==typeof a&&(a=a.version),t===a;case"!==":return"object"==typeof t&&(t=t.version),"object"==typeof a&&(a=a.version),t!==a;case"":case"=":case"==":return o(t,a,u);case"!=":return i(t,a,u);case">":return n(t,a,u);case">=":return s(t,a,u);case"<":return l(t,a,u);case"<=":return c(t,a,u);default:throw TypeError(`Invalid operator: ${r}`)}}},7771(t,r,a){"use strict";let o=a(2398),i=a(6802),{safeRe:n,t:s}=a(152);t.exports=(t,r)=>{if(t instanceof o)return t;if("number"==typeof t&&(t=String(t)),"string"!=typeof t)return null;let a=null;if((r=r||{}).rtl){let o,i=r.includePrerelease?n[s.COERCERTLFULL]:n[s.COERCERTL];for(;(o=i.exec(t))&&(!a||a.index+a[0].length!==t.length);)a&&o.index+o[0].length===a.index+a[0].length||(a=o),i.lastIndex=o.index+o[1].length+o[2].length;i.lastIndex=-1}else a=t.match(r.includePrerelease?n[s.COERCEFULL]:n[s.COERCE]);if(null===a)return null;let l=a[2],c=a[3]||"0",u=a[4]||"0",d=r.includePrerelease&&a[5]?`-${a[5]}`:"",p=r.includePrerelease&&a[6]?`+${a[6]}`:"";return i(`${l}.${c}.${u}${d}${p}`,r)}},8767(t,r,a){"use strict";let o=a(2398);t.exports=(t,r,a)=>{let i=new o(t,a),n=new o(r,a);return i.compare(n)||i.compareBuild(n)}},6293(t,r,a){"use strict";let o=a(6958);t.exports=(t,r)=>o(t,r,!0)},6958(t,r,a){"use strict";let o=a(2398);t.exports=(t,r,a)=>new o(t,a).compare(new o(r,a))},3086(t,r,a){"use strict";let o=a(6802);t.exports=(t,r)=>{let a=o(t,null,!0),i=o(r,null,!0),n=a.compare(i);if(0===n)return null;let s=n>0,l=s?a:i,c=s?i:a,u=!!l.prerelease.length;if(c.prerelease.length&&!u){if(!c.patch&&!c.minor)return"major";if(0===c.compareMain(l))return c.minor&&!c.patch?"minor":"patch"}let d=u?"pre":"";return a.major!==i.major?d+"major":a.minor!==i.minor?d+"minor":a.patch!==i.patch?d+"patch":"prerelease"}},8271(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>0===o(t,r,a)},1686(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>o(t,r,a)>0},6479(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>o(t,r,a)>=0},3625(t,r,a){"use strict";let o=a(2398);t.exports=(t,r,a,i,n)=>{"string"==typeof a&&(n=i,i=a,a=void 0);try{return new o(t instanceof o?t.version:t,a).inc(r,i,n).version}catch(t){return null}}},7257(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>0>o(t,r,a)},5850(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>0>=o(t,r,a)},7744(t,r,a){"use strict";let o=a(2398);t.exports=(t,r)=>new o(t,r).major},4812(t,r,a){"use strict";let o=a(2398);t.exports=(t,r)=>new o(t,r).minor},733(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>0!==o(t,r,a)},6802(t,r,a){"use strict";let o=a(2398);t.exports=(t,r,a=!1)=>{if(t instanceof o)return t;try{return new o(t,r)}catch(t){if(!a)return null;throw t}}},8643(t,r,a){"use strict";let o=a(2398);t.exports=(t,r)=>new o(t,r).patch},9283(t,r,a){"use strict";let o=a(6802);t.exports=(t,r)=>{let a=o(t,r);return a&&a.prerelease.length?a.prerelease:null}},7032(t,r,a){"use strict";let o=a(6958);t.exports=(t,r,a)=>o(r,t,a)},9839(t,r,a){"use strict";let o=a(8767);t.exports=(t,r)=>t.sort((t,a)=>o(a,t,r))},4056(t,r,a){"use strict";let o=a(2069);t.exports=(t,r,a)=>{try{r=new o(r,a)}catch(t){return!1}return r.test(t)}},7697(t,r,a){"use strict";let o=a(8767);t.exports=(t,r)=>t.sort((t,a)=>o(t,a,r))},6807(t,r,a){"use strict";let o=a(6802);t.exports=(t,r)=>{let a=o(t,r);return a?a.version:null}},3895(t,r,a){"use strict";let o=a(152),i=a(5076),n=a(2398),s=a(9101),l=a(6802),c=a(6807),u=a(5608),d=a(3625),p=a(3086),h=a(7744),f=a(4812),m=a(8643),y=a(9283),g=a(6958),v=a(7032),b=a(6293),S=a(8767),_=a(7697),w=a(9839),$=a(1686),E=a(7257),P=a(8271),R=a(733),k=a(6479),T=a(5850),O=a(5461),x=a(7771),C=a(8610),j=a(2069),A=a(4056),I=a(6613),N=a(7114),M=a(1008),q=a(203),z=a(5372),D=a(4713),L=a(4497),U=a(9272),H=a(3490);t.exports={parse:l,valid:c,clean:u,inc:d,diff:p,major:h,minor:f,patch:m,prerelease:y,compare:g,rcompare:v,compareLoose:b,compareBuild:S,sort:_,rsort:w,gt:$,lt:E,eq:P,neq:R,gte:k,lte:T,cmp:O,coerce:x,Comparator:C,Range:j,satisfies:A,toComparators:I,maxSatisfying:N,minSatisfying:M,minVersion:q,validRange:z,outside:D,gtr:L,ltr:U,intersects:H,simplifyRange:a(4039),subset:a(22),SemVer:n,re:o.re,src:o.src,tokens:o.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},5076(t){"use strict";t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||0x1fffffffffffff,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},674(t){"use strict";t.exports="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{}},9101(t){"use strict";let r=/^[0-9]+$/,a=(t,a)=>{if("number"==typeof t&&"number"==typeof a)return t===a?0:t<a?-1:1;let o=r.test(t),i=r.test(a);return o&&i&&(t*=1,a*=1),t===a?0:o&&!i?-1:i&&!o?1:t<a?-1:1};t.exports={compareIdentifiers:a,rcompareIdentifiers:(t,r)=>a(r,t)}},2044(t){"use strict";t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(void 0!==r)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&void 0!==r){if(this.map.size>=this.max){let t=this.map.keys().next().value;this.delete(t)}this.map.set(t,r)}return this}}},4621(t){"use strict";let r=Object.freeze({loose:!0}),a=Object.freeze({});t.exports=t=>t?"object"!=typeof t?r:t:a},152(t,r,a){"use strict";let{MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:n}=a(5076),s=a(674),l=(r=t.exports={}).re=[],c=r.safeRe=[],u=r.src=[],d=r.safeSrc=[],p=r.t={},h=0,f="[a-zA-Z0-9-]",m=[["\\s",1],["\\d",n],[f,i]],y=(t,r,a)=>{let o=(t=>{for(let[r,a]of m)t=t.split(`${r}*`).join(`${r}{0,${a}}`).split(`${r}+`).join(`${r}{1,${a}}`);return t})(r),i=h++;s(t,i,r),p[t]=i,u[i]=r,d[i]=o,l[i]=new RegExp(r,a?"g":void 0),c[i]=new RegExp(o,a?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${u[p.NUMERICIDENTIFIER]})\\.(${u[p.NUMERICIDENTIFIER]})\\.(${u[p.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${u[p.NUMERICIDENTIFIERLOOSE]})\\.(${u[p.NUMERICIDENTIFIERLOOSE]})\\.(${u[p.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${u[p.NONNUMERICIDENTIFIER]}|${u[p.NUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${u[p.NONNUMERICIDENTIFIER]}|${u[p.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASE",`(?:-(${u[p.PRERELEASEIDENTIFIER]}(?:\\.${u[p.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${u[p.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[p.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${u[p.BUILDIDENTIFIER]}(?:\\.${u[p.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${u[p.MAINVERSION]}${u[p.PRERELEASE]}?${u[p.BUILD]}?`),y("FULL",`^${u[p.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${u[p.MAINVERSIONLOOSE]}${u[p.PRERELEASELOOSE]}?${u[p.BUILD]}?`),y("LOOSE",`^${u[p.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${u[p.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${u[p.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${u[p.XRANGEIDENTIFIER]})(?:\\.(${u[p.XRANGEIDENTIFIER]})(?:\\.(${u[p.XRANGEIDENTIFIER]})(?:${u[p.PRERELEASE]})?${u[p.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${u[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[p.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[p.XRANGEIDENTIFIERLOOSE]})(?:${u[p.PRERELEASELOOSE]})?${u[p.BUILD]}?)?)?`),y("XRANGE",`^${u[p.GTLT]}\\s*${u[p.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${u[p.GTLT]}\\s*${u[p.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${o}})(?:\\.(\\d{1,${o}}))?(?:\\.(\\d{1,${o}}))?`),y("COERCE",`${u[p.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",u[p.COERCEPLAIN]+`(?:${u[p.PRERELEASE]})?`+`(?:${u[p.BUILD]})?`+"(?:$|[^\\d])"),y("COERCERTL",u[p.COERCE],!0),y("COERCERTLFULL",u[p.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${u[p.LONETILDE]}\\s+`,!0),r.tildeTrimReplace="$1~",y("TILDE",`^${u[p.LONETILDE]}${u[p.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${u[p.LONETILDE]}${u[p.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${u[p.LONECARET]}\\s+`,!0),r.caretTrimReplace="$1^",y("CARET",`^${u[p.LONECARET]}${u[p.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${u[p.LONECARET]}${u[p.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${u[p.GTLT]}\\s*(${u[p.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${u[p.GTLT]}\\s*(${u[p.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${u[p.GTLT]}\\s*(${u[p.LOOSEPLAIN]}|${u[p.XRANGEPLAIN]})`,!0),r.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${u[p.XRANGEPLAIN]})\\s+-\\s+(${u[p.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${u[p.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[p.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},4497(t,r,a){"use strict";let o=a(4713);t.exports=(t,r,a)=>o(t,r,">",a)},3490(t,r,a){"use strict";let o=a(2069);t.exports=(t,r,a)=>(t=new o(t,a),r=new o(r,a),t.intersects(r,a))},9272(t,r,a){"use strict";let o=a(4713);t.exports=(t,r,a)=>o(t,r,"<",a)},7114(t,r,a){"use strict";let o=a(2398),i=a(2069);t.exports=(t,r,a)=>{let n=null,s=null,l=null;try{l=new i(r,a)}catch(t){return null}return t.forEach(t=>{l.test(t)&&(!n||-1===s.compare(t))&&(s=new o(n=t,a))}),n}},1008(t,r,a){"use strict";let o=a(2398),i=a(2069);t.exports=(t,r,a)=>{let n=null,s=null,l=null;try{l=new i(r,a)}catch(t){return null}return t.forEach(t=>{l.test(t)&&(!n||1===s.compare(t))&&(s=new o(n=t,a))}),n}},203(t,r,a){"use strict";let o=a(2398),i=a(2069),n=a(1686);t.exports=(t,r)=>{t=new i(t,r);let a=new o("0.0.0");if(t.test(a)||(a=new o("0.0.0-0"),t.test(a)))return a;a=null;for(let r=0;r<t.set.length;++r){let i=t.set[r],s=null;i.forEach(t=>{let r=new o(t.semver.version);switch(t.operator){case">":0===r.prerelease.length?r.patch++:r.prerelease.push(0),r.raw=r.format();case"":case">=":(!s||n(r,s))&&(s=r);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${t.operator}`)}}),s&&(!a||n(a,s))&&(a=s)}return a&&t.test(a)?a:null}},4713(t,r,a){"use strict";let o=a(2398),i=a(8610),{ANY:n}=i,s=a(2069),l=a(4056),c=a(1686),u=a(7257),d=a(5850),p=a(6479);t.exports=(t,r,a,h)=>{let f,m,y,g,v;switch(t=new o(t,h),r=new s(r,h),a){case">":f=c,m=d,y=u,g=">",v=">=";break;case"<":f=u,m=p,y=c,g="<",v="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(l(t,r,h))return!1;for(let a=0;a<r.set.length;++a){let o=r.set[a],s=null,l=null;if(o.forEach(t=>{t.semver===n&&(t=new i(">=0.0.0")),s=s||t,l=l||t,f(t.semver,s.semver,h)?s=t:y(t.semver,l.semver,h)&&(l=t)}),s.operator===g||s.operator===v||(!l.operator||l.operator===g)&&m(t,l.semver)||l.operator===v&&y(t,l.semver))return!1}return!0}},4039(t,r,a){"use strict";let o=a(4056),i=a(6958);t.exports=(t,r,a)=>{let n=[],s=null,l=null,c=t.sort((t,r)=>i(t,r,a));for(let t of c)o(t,r,a)?(l=t,s||(s=t)):(l&&n.push([s,l]),l=null,s=null);s&&n.push([s,null]);let u=[];for(let[t,r]of n)t===r?u.push(t):r||t!==c[0]?r?t===c[0]?u.push(`<=${r}`):u.push(`${t} - ${r}`):u.push(`>=${t}`):u.push("*");let d=u.join(" || "),p="string"==typeof r.raw?r.raw:String(r);return d.length<p.length?d:r}},22(t,r,a){"use strict";let o=a(2069),i=a(8610),{ANY:n}=i,s=a(4056),l=a(6958),c=[new i(">=0.0.0-0")],u=[new i(">=0.0.0")],d=(t,r,a)=>{let o,i,d,f,m,y,g;if(t===r)return!0;if(1===t.length&&t[0].semver===n)if(1===r.length&&r[0].semver===n)return!0;else t=a.includePrerelease?c:u;if(1===r.length&&r[0].semver===n)if(a.includePrerelease)return!0;else r=u;let v=new Set;for(let r of t)">"===r.operator||">="===r.operator?o=p(o,r,a):"<"===r.operator||"<="===r.operator?i=h(i,r,a):v.add(r.semver);if(v.size>1)return null;if(o&&i&&((d=l(o.semver,i.semver,a))>0||0===d&&(">="!==o.operator||"<="!==i.operator)))return null;for(let t of v){if(o&&!s(t,String(o),a)||i&&!s(t,String(i),a))return null;for(let o of r)if(!s(t,String(o),a))return!1;return!0}let b=!!i&&!a.includePrerelease&&!!i.semver.prerelease.length&&i.semver,S=!!o&&!a.includePrerelease&&!!o.semver.prerelease.length&&o.semver;for(let t of(b&&1===b.prerelease.length&&"<"===i.operator&&0===b.prerelease[0]&&(b=!1),r)){if(g=g||">"===t.operator||">="===t.operator,y=y||"<"===t.operator||"<="===t.operator,o){if(S&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===S.major&&t.semver.minor===S.minor&&t.semver.patch===S.patch&&(S=!1),">"===t.operator||">="===t.operator){if((f=p(o,t,a))===t&&f!==o)return!1}else if(">="===o.operator&&!s(o.semver,String(t),a))return!1}if(i){if(b&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===b.major&&t.semver.minor===b.minor&&t.semver.patch===b.patch&&(b=!1),"<"===t.operator||"<="===t.operator){if((m=h(i,t,a))===t&&m!==i)return!1}else if("<="===i.operator&&!s(i.semver,String(t),a))return!1}if(!t.operator&&(i||o)&&0!==d)return!1}return(!o||!y||!!i||0===d)&&(!i||!g||!!o||0===d)&&!S&&!b&&!0},p=(t,r,a)=>{if(!t)return r;let o=l(t.semver,r.semver,a);return o>0?t:o<0||">"===r.operator&&">="===t.operator?r:t},h=(t,r,a)=>{if(!t)return r;let o=l(t.semver,r.semver,a);return o<0?t:o>0||"<"===r.operator&&"<="===t.operator?r:t};t.exports=(t,r,a={})=>{if(t===r)return!0;t=new o(t,a),r=new o(r,a);let i=!1;e:for(let o of t.set){for(let t of r.set){let r=d(o,t,a);if(i=i||null!==r,r)continue e}if(i)return!1}return!0}},6613(t,r,a){"use strict";let o=a(2069);t.exports=(t,r)=>new o(t,r).set.map(t=>t.map(t=>t.value).join(" ").trim().split(" "))},5372(t,r,a){"use strict";let o=a(2069);t.exports=(t,r)=>{try{return new o(t,r).range||"*"}catch(t){return null}}},600(t,r,a){"use strict";let o=a(9638);t.exports=(t="")=>{let r=t.match(o);if(!r)return null;let[a,i]=r[0].replace(/#! ?/,"").split(" "),n=a.split("/").pop();return"env"===n?i:i?`${n} ${i}`:n}},9638(t){"use strict";t.exports=/^#!(.*)/},1905(t,r,a){let o="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,i=a(6928),n=o?";":":",s=a(9344),l=t=>Object.assign(Error(`not found: ${t}`),{code:"ENOENT"}),c=(t,r)=>{let a=r.colon||n,i=t.match(/\//)||o&&t.match(/\\/)?[""]:[...o?[process.cwd()]:[],...(r.path||process.env.PATH||"").split(a)],s=o?r.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",l=o?s.split(a):[""];return o&&-1!==t.indexOf(".")&&""!==l[0]&&l.unshift(""),{pathEnv:i,pathExt:l,pathExtExe:s}},u=(t,r,a)=>{"function"==typeof r&&(a=r,r={}),r||(r={});let{pathEnv:o,pathExt:n,pathExtExe:u}=c(t,r),d=[],p=a=>new Promise((n,s)=>{if(a===o.length)return r.all&&d.length?n(d):s(l(t));let c=o[a],u=/^".*"$/.test(c)?c.slice(1,-1):c,p=i.join(u,t);n(h(!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p,a,0))}),h=(t,a,o)=>new Promise((i,l)=>{if(o===n.length)return i(p(a+1));let c=n[o];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,a,o+1))})});return a?p(0).then(t=>a(null,t),a):p(0)};t.exports=u,u.sync=(t,r)=>{let{pathEnv:a,pathExt:o,pathExtExe:n}=c(t,r=r||{}),u=[];for(let l=0;l<a.length;l++){let c=a[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<o.length;t++){let a=h+o[t];try{if(s.sync(a,{pathExt:n}))if(!r.all)return a;else u.push(a)}catch(t){}}}if(r.all&&u.length)return u;if(r.nothrow)return null;throw l(t)}},181(t){"use strict";t.exports=require("buffer")},5317(t){"use strict";t.exports=require("child_process")},6982(t){"use strict";t.exports=require("crypto")},9896(t){"use strict";t.exports=require("fs")},7598(t){"use strict";t.exports=require("node:crypto")},857(t){"use strict";t.exports=require("os")},6928(t){"use strict";t.exports=require("path")},2203(t){"use strict";t.exports=require("stream")},9023(t){"use strict";t.exports=require("util")},4953(r){"use strict";r.exports=t},8775(t,r,a){"use strict";let o,i;a.r(r),a.d(r,{jwksCache:()=>tH,FlattenedEncrypt:()=>tu,decodeProtectedHeader:()=>tJ,generateSecret:()=>tZ,flattenedDecrypt:()=>ts,exportSPKI:()=>e0,flattenedVerify:()=>th,jwtDecrypt:()=>tE,customFetch:()=>tL,importSPKI:()=>eG,CompactEncrypt:()=>tP,importPKCS8:()=>eX,decodeJwt:()=>tW,errors:()=>s,generalVerify:()=>tm,compactDecrypt:()=>tl,compactVerify:()=>tf,EmbeddedJWK:()=>tN,exportPKCS8:()=>e1,CompactSign:()=>tk,cryptoRuntime:()=>tX,generalDecrypt:()=>tc,createLocalJWKSet:()=>tD,FlattenedSign:()=>tR,jwtVerify:()=>t$,GeneralEncrypt:()=>tp,EncryptJWT:()=>tC,calculateJwkThumbprintUri:()=>tI,SignJWT:()=>tx,exportJWK:()=>e2,importX509:()=>eZ,importJWK:()=>eY,GeneralSign:()=>tO,createRemoteJWKSet:()=>tK,generateKeyPair:()=>tG,calculateJwkThumbprint:()=>tA,base64url:()=>n,UnsecuredJWT:()=>tF});var n={};a.r(n),a.d(n,{decode:()=>g,encode:()=>v});var s={};a.r(s),a.d(s,{JOSEAlgNotAllowed:()=>O,JOSEError:()=>R,JOSENotSupported:()=>x,JWEDecryptionFailed:()=>C,JWEInvalid:()=>j,JWKInvalid:()=>N,JWKSInvalid:()=>M,JWKSMultipleMatchingKeys:()=>z,JWKSNoMatchingKey:()=>q,JWKSTimeout:()=>D,JWSInvalid:()=>A,JWSSignatureVerificationFailed:()=>L,JWTClaimValidationFailed:()=>k,JWTExpired:()=>T,JWTInvalid:()=>I});let l=new TextEncoder,c=new TextDecoder;function u(...t){let r=new Uint8Array(t.reduce((t,{length:r})=>t+r,0)),a=0;for(let o of t)r.set(o,a),a+=o.length;return r}function d(t,r,a){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],a)}function p(t){let r=Math.floor(t/0x100000000),a=new Uint8Array(8);return d(a,r,0),d(a,t%0x100000000,4),a}function h(t){let r=new Uint8Array(4);return d(r,t),r}function f(t){let r=new Uint8Array(t.length);for(let a=0;a<t.length;a++){let o=t.charCodeAt(a);if(o>127)throw TypeError("non-ASCII string encountered in encode()");r[a]=o}return r}function m(t){if(Uint8Array.prototype.toBase64)return t.toBase64();let r=[];for(let a=0;a<t.length;a+=32768)r.push(String.fromCharCode.apply(null,t.subarray(a,a+32768)));return btoa(r.join(""))}function y(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t);let r=atob(t),a=new Uint8Array(r.length);for(let t=0;t<r.length;t++)a[t]=r.charCodeAt(t);return a}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 b=(t,r="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${r} must be ${t}`);function S(t,r){if(parseInt(t.hash.name.slice(4),10)!==r)throw b(`SHA-${r}`,"algorithm.hash")}function _(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,a){switch(r){case"A128GCM":case"A192GCM":case"A256GCM":{if("AES-GCM"!==t.algorithm.name)throw b("AES-GCM");let a=parseInt(r.slice(1,4),10);if(t.algorithm.length!==a)throw b(a,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if("AES-KW"!==t.algorithm.name)throw b("AES-KW");let a=parseInt(r.slice(1,4),10);if(t.algorithm.length!==a)throw b(a,"algorithm.length");break}case"ECDH":switch(t.algorithm.name){case"ECDH":case"X25519":break;default:throw b("ECDH or X25519")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if("PBKDF2"!==t.algorithm.name)throw b("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if("RSA-OAEP"!==t.algorithm.name)throw b("RSA-OAEP");S(t.algorithm,parseInt(r.slice(9),10)||1);break;default:throw TypeError("CryptoKey does not support this operation")}_(t,a)}function $(t,r,...a){if((a=a.filter(Boolean)).length>2){let r=a.pop();t+=`one of type ${a.join(", ")}, or ${r}.`}else 2===a.length?t+=`one of type ${a[0]} or ${a[1]}.`:t+=`of type ${a[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,...a)=>$(`Key for the ${t} algorithm must be `,r,...a);class R 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 k extends R{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(t,r,a="unspecified",o="unspecified"){super(t,{cause:{claim:a,reason:o,payload:r}}),this.claim=a,this.reason=o,this.payload=r}}class T extends R{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(t,r,a="unspecified",o="unspecified"){super(t,{cause:{claim:a,reason:o,payload:r}}),this.claim=a,this.reason=o,this.payload=r}}class O extends R{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class x extends R{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class C extends R{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(t="decryption operation failed",r){super(t,r)}}class j extends R{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class A extends R{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class I extends R{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class N extends R{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class M extends R{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class q extends R{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 z extends R{[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 D extends R{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(t="request timed out",r){super(t,r)}}class L extends R{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(t="signature verification failed",r){super(t,r)}}function U(t){if(!H(t))throw Error("CryptoKey instance expected")}let H=t=>{if(t?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return t instanceof CryptoKey}catch{return!1}},V=t=>t?.[Symbol.toStringTag]==="KeyObject",K=t=>H(t)||V(t);function F(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 x(`Unsupported JWE Algorithm: ${t}`)}}let J=t=>crypto.getRandomValues(new Uint8Array(F(t)>>3));function W(t,r){let a=t.byteLength<<3;if(a!==r)throw new j(`Invalid Content Encryption Key length. Expected ${r} bits, got ${a} 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 x(`Unsupported JWE Algorithm: ${t}`)}}function G(t,r){if(r.length<<3!==B(t))throw new j("Invalid Initialization Vector length")}async function Z(t,r,a){if(!(r instanceof Uint8Array))throw TypeError(E(r,"Uint8Array"));let o=parseInt(t.slice(1,4),10);return{encKey:await crypto.subtle.importKey("raw",r.subarray(o>>3),"AES-CBC",!1,[a]),macKey:await crypto.subtle.importKey("raw",r.subarray(0,o>>3),{hash:`SHA-${o<<1}`,name:"HMAC"},!1,["sign"]),keySize:o}}async function X(t,r,a){return new Uint8Array((await crypto.subtle.sign("HMAC",t,r)).slice(0,a>>3))}async function Y(t,r,a,o,i){let{encKey:n,macKey:s,keySize:l}=await Z(t,a,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:o,name:"AES-CBC"},n,r)),d=u(i,o,c,p(i.length<<3));return{ciphertext:c,tag:await X(s,d,l),iv:o}}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 a={name:"HMAC",hash:"SHA-256"},o=await crypto.subtle.generateKey(a,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(a,o,t)),n=new Uint8Array(await crypto.subtle.sign(a,o,r)),s=0,l=-1;for(;++l<32;)s|=i[l]^n[l];return 0===s}async function ee(t,r,a,o,i,n){let s,l,{encKey:c,macKey:d,keySize:h}=await Z(t,r,"decrypt"),f=u(n,o,a,p(n.length<<3)),m=await X(d,f,h);try{s=await Q(i,m)}catch{}if(!s)throw new C;try{l=new Uint8Array(await crypto.subtle.decrypt({iv:o,name:"AES-CBC"},c,a))}catch{}if(!l)throw new C;return l}async function et(t,r,a,o,i){let n;a instanceof Uint8Array?n=await crypto.subtle.importKey("raw",a,"AES-GCM",!1,["encrypt"]):(w(a,t,"encrypt"),n=a);let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:o,name:"AES-GCM",tagLength:128},n,r)),l=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:l,iv:o}}async function er(t,r,a,o,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:o,name:"AES-GCM",tagLength:128},s,u(a,i)))}catch{throw new C}}let ea="Unsupported JWE Content Encryption Algorithm";async function eo(t,r,a,o,i){if(!H(a)&&!(a instanceof Uint8Array))throw TypeError(E(a,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(o)G(t,o);else o=crypto.getRandomValues(new Uint8Array(B(t)>>3));switch(t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return a instanceof Uint8Array&&W(a,parseInt(t.slice(-3),10)),Y(t,r,a,o,i);case"A128GCM":case"A192GCM":case"A256GCM":return a instanceof Uint8Array&&W(a,parseInt(t.slice(1,4),10)),et(t,r,a,o,i);default:throw new x(ea)}}async function ei(t,r,a,o,i,n){if(!H(r)&&!(r instanceof Uint8Array))throw TypeError(E(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!o)throw new j("JWE Initialization Vector missing");if(!i)throw new j("JWE Authentication Tag missing");switch(G(t,o),t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&W(r,parseInt(t.slice(-3),10)),ee(t,r,a,o,i,n);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&W(r,parseInt(t.slice(1,4),10)),er(t,r,a,o,i,n);default:throw new x(ea)}}let en=Symbol();function es(t,r){if(t)throw TypeError(`${r} can only be called once`)}function el(t,r,a){try{return g(t)}catch{throw new a(`Failed to base64url decode the ${r}`)}}async function ec(t,r){let a=`SHA-${t.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(a,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,a=t.filter(Boolean);if(0===a.length||1===a.length)return!0;for(let t of a){let a=Object.keys(t);if(!r||0===r.size){r=new Set(a);continue}for(let t of a){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,a){return t instanceof Uint8Array?crypto.subtle.importKey("raw",t,"AES-KW",!0,[a]):(w(t,r,a),t)}async function em(t,r,a){let o=await ef(r,t,"wrapKey");eh(o,t);let i=await crypto.subtle.importKey("raw",a,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,o,"AES-KW"))}async function ey(t,r,a){let o=await ef(r,t,"unwrapKey");eh(o,t);let i=await crypto.subtle.unwrapKey("raw",a,o,"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,a){let o=r>>3,i=Math.ceil(o/32),n=new Uint8Array(32*i);for(let r=1;r<=i;r++){let o=new Uint8Array(4+t.length+a.length);o.set(h(r),0),o.set(t,4),o.set(a,4+t.length);let i=await ec("sha256",o);n.set(i,(r-1)*32)}return n.slice(0,o)}async function eb(t,r,a,o,i=new Uint8Array,n=new Uint8Array){var s;w(t,"ECDH"),w(r,"ECDH","deriveBits");let l=u(eg(f(a)),eg(i),eg(n),h(o),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)),o,l)}function eS(t){switch(t.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return"X25519"===t.algorithm.name}}async function e_(t,r,a,o){if(!(t instanceof Uint8Array)||t.length<8)throw new j("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(a)||1!==Math.sign(a))throw new j("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:a,name:"PBKDF2",salt:i},l=await (o instanceof Uint8Array?crypto.subtle.importKey("raw",o,"PBKDF2",!1,["deriveBits"]):(w(o,r,"deriveBits"),o));return new Uint8Array(await crypto.subtle.deriveBits(s,l,n))}async function ew(t,r,a,o=2048,i=crypto.getRandomValues(new Uint8Array(16))){let n=await e_(i,t,o,r);return{encryptedKey:await em(t.slice(-6),n,a),p2c:o,p2s:v(i)}}async function e$(t,r,a,o,i){let n=await e_(i,t,o,r);return ey(t.slice(-6),n,a)}function eE(t,r){if(t.startsWith("RS")||t.startsWith("PS")){let{modulusLength:a}=r.algorithm;if("number"!=typeof a||a<2048)throw TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}function eP(t,r){let a=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:a,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:a,name:"RSA-PSS",saltLength:parseInt(t.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:a,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:a,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 x(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function eR(t,r,a){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,[a])}switch(t){case"HS256":case"HS384":case"HS512":if("HMAC"!==r.algorithm.name)throw b("HMAC");S(r.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if("RSASSA-PKCS1-v1_5"!==r.algorithm.name)throw b("RSASSA-PKCS1-v1_5");S(r.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if("RSA-PSS"!==r.algorithm.name)throw b("RSA-PSS");S(r.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if("Ed25519"!==r.algorithm.name)throw b("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":let o;if(o=r.algorithm,o.name!==t)throw b(t);break;case"ES256":case"ES384":case"ES512":{if("ECDSA"!==r.algorithm.name)throw b("ECDSA");let a=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!==a)throw b(a,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}return _(r,a),r}async function ek(t,r,a){let o=await eR(t,r,"sign");return eE(t,o),new Uint8Array(await crypto.subtle.sign(eP(t,o.algorithm),o,a))}async function eT(t,r,a,o){let i=await eR(t,r,"verify");eE(t,i);let n=eP(t,i.algorithm);try{return await crypto.subtle.verify(n,i,a,o)}catch{return!1}}let eO=t=>{switch(t){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new x(`alg ${t} is not supported either by JOSE or your javascript runtime`)}};async function ex(t,r,a){return w(r,t,"encrypt"),eE(t,r),new Uint8Array(await crypto.subtle.encrypt(eO(t),r,a))}async function eC(t,r,a){return w(r,t,"decrypt"),eE(t,r),new Uint8Array(await crypto.subtle.decrypt(eO(t),r,a))}let ej='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function eA(t){if(!t.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:r,keyUsages:a}=function(t){let r,a;switch(t.kty){case"AKP":switch(t.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":r={name:t.alg},a=t.priv?["sign"]:["verify"];break;default:throw new x(ej)}break;case"RSA":switch(t.alg){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},a=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},a=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}`},a=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new x(ej)}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]},a=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},a=t.d?["deriveBits"]:[];break;default:throw new x(ej)}break;case"OKP":switch(t.alg){case"Ed25519":case"EdDSA":r={name:"Ed25519"},a=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":r={name:t.crv},a=t.d?["deriveBits"]:[];break;default:throw new x(ej)}break;default:throw new x('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:r,keyUsages:a}}(t),o={...t};return"AKP"!==o.kty&&delete o.alg,delete o.use,crypto.subtle.importKey("jwk",o,r,t.ext??(!t.d&&!t.priv),t.key_ops??a)}let eI="given KeyObject instance cannot be used for this algorithm",eN=async(t,r,a,i=!1)=>{let n=(o||=new WeakMap).get(t);if(n?.[a])return n[a];let s=await eA({...r,alg:a});return i&&Object.freeze(t),n?n[a]=s:o.set(t,{[a]:s}),s};async function eM(t,r){if(t instanceof Uint8Array||H(t))return t;if(V(t)){if("secret"===t.type)return t.export();if("toCryptoKey"in t&&"function"==typeof t.toCryptoKey)try{return((t,r)=>{let a,i=(o||=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)}a=t.toCryptoKey(t.asymmetricKeyType,s,n?[]:["deriveBits"])}if("ed25519"===t.asymmetricKeyType){if("EdDSA"!==r&&"Ed25519"!==r)throw TypeError(eI);a=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);a=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}if("rsa"===t.asymmetricKeyType){let o;switch(r){case"RSA-OAEP":o="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":o="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":o="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":o="SHA-512";break;default:throw TypeError(eI)}if(r.startsWith("RSA-OAEP"))return t.toCryptoKey({name:"RSA-OAEP",hash:o},s,n?["encrypt"]:["decrypt"]);a=t.toCryptoKey({name:r.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:o},s,[n?"verify":"sign"])}if("ec"===t.asymmetricKeyType){let o=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(t.asymmetricKeyDetails?.namedCurve);if(!o)throw TypeError(eI);let i={ES256:"P-256",ES384:"P-384",ES512:"P-521"};i[r]&&o===i[r]&&(a=t.toCryptoKey({name:"ECDSA",namedCurve:o},s,[n?"verify":"sign"])),r.startsWith("ECDH-ES")&&(a=t.toCryptoKey({name:"ECDH",namedCurve:o},s,n?[]:["deriveBits"]))}if(!a)throw TypeError(eI);return i?i[r]=a:o.set(t,{[r]:a}),a})(t,r)}catch(t){if(t instanceof TypeError)throw t}let a=t.export({format:"jwk"});return eN(t,a,r)}if(ep(t))return t.k?g(t.k):eN(t,t,r,!0);throw Error("unreachable")}let eq=(t,r)=>{let a=(t.match(/.{1,64}/g)||[]).join("\n");return`-----BEGIN ${r}-----
2
2
  ${a}
3
- -----END ${r}-----`},ez=async(t,r,a)=>{if(V(a)){if(a.type!==t)throw TypeError(`key is not a ${t} key`);return a.export({format:"pem",type:r})}if(!H(a))throw TypeError(E(a,"CryptoKey","KeyObject"));if(!a.extractable)throw TypeError("CryptoKey is not extractable");if(a.type!==t)throw TypeError(`key is not a ${t} key`);return eq(m(new Uint8Array(await crypto.subtle.exportKey(r,a))),`${t.toUpperCase()} KEY`)},eD=(t,r)=>{if(t.byteLength!==r.length)return!1;for(let a=0;a<t.byteLength;a++)if(t[a]!==r[a])return!1;return!0},eL=t=>({data:t,pos:0}),eU=t=>{let r=t.data[t.pos++];if(128&r){let a=127&r,o=0;for(let r=0;r<a;r++)o=o<<8|t.data[t.pos++];return o}return r},eH=(t,r=1)=>{if(r<=0)return;t.pos++;let a=eU(t);t.pos+=a,r>1&&eH(t,r-1)},eV=(t,r,a)=>{if(t.data[t.pos++]!==r)throw Error(a)},eK=(t,r)=>{let a=t.data.subarray(t.pos,t.pos+r);return t.pos+=r,a},eF=t=>{let r,a=(eV(t,6,"Expected algorithm OID"),r=eU(t),eK(t,r));if(eD(a,[43,101,110]))return"X25519";if(!eD(a,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");eV(t,6,"Expected curve OID");let o=eU(t),i=eK(t,o);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(eD(i,r))return t;throw Error("Unsupported named curve")},eJ=async(t,r,a,o)=>{let i,n,s="spki"===t,l=()=>s?["verify"]:["sign"];switch(a){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${a.slice(-3)}`},n=l();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${a.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(a.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"})[a]},n=l();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{let t=o.getNamedCurve(r);i="X25519"===t?{name:"X25519"}:{name:"ECDH",namedCurve:t}}catch(t){throw new x("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:a},n=l();break;default:throw new x('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(t,r,i,o?.extractable??!!s,n)},eW=(t,r)=>y(t.replace(r,"")),eB=(t,r,a)=>{let o=eW(t,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g),i=a;return r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r=eL(t);return eV(r,48,"Invalid SPKI structure"),eU(r),eV(r,48,"Expected algorithm identifier"),eU(r),r.pos,eF(r)}),eJ("spki",o,r,i)};async function eG(t,r,a){if("string"!=typeof t||0!==t.indexOf("-----BEGIN PUBLIC KEY-----"))throw TypeError('"spki" must be SPKI formatted string');return eB(t,r,a)}async function eZ(t,r,a){if("string"!=typeof t||0!==t.indexOf("-----BEGIN CERTIFICATE-----"))throw TypeError('"x509" must be X.509 formatted string');return((t,r,a)=>{let o;try{var i;let r,a,n;r=eL(i=eW(t,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g)),eV(r,48,"Invalid certificate structure"),eU(r),eV(r,48,"Invalid tbsCertificate structure"),eU(r),160===i[r.pos]?eH(r,6):eH(r,5),a=r.pos,eV(r,48,"Invalid SPKI structure"),n=eU(r),o=i.subarray(a,a+n+(r.pos-a))}catch(t){throw TypeError("Failed to parse the X.509 certificate",{cause:t})}return eB(eq(m(o),"PUBLIC KEY"),r,a)})(t,r,a)}async function eX(t,r,a){let o,i;if("string"!=typeof t||0!==t.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return o=eW(t,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),i=a,r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r,a=eL(t);return eV(a,48,"Invalid PKCS#8 structure"),eU(a),eV(a,2,"Expected version field"),r=eU(a),a.pos+=r,eV(a,48,"Expected algorithm identifier"),eU(a),a.pos,eF(a)}),eJ("pkcs8",o,r,i)}async function eY(t,r,a){let o;if(!eu(t))throw TypeError("JWK must be an object");switch(r??=t.alg,o??=a?.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 x('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return eA({...t,alg:r,ext:o});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 eA({...t,ext:o});case"EC":case"OKP":return eA({...t,alg:r,ext:o});default:throw new x('Unsupported "kty" (Key Type) Parameter value')}}async function eQ(t){if(V(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(!H(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:a,alg:o,use:i,...n}=await crypto.subtle.exportKey("jwk",t);return"AKP"===n.kty&&(n.alg=o),n}async function e0(t){return ez("public","spki",t)}async function e1(t){return ez("private","pkcs8",t)}async function e2(t){return eQ(t)}async function e9(t,r,a,o){let i=t.slice(0,7),n=await eo(i,a,r,o,new Uint8Array);return{encryptedKey:n.ciphertext,iv:v(n.iv),tag:v(n.tag)}}async function e4(t,r,a,o,i){return ei(t.slice(0,7),r,a,o,i,new Uint8Array)}let e5='Invalid or unsupported "alg" (JWE Algorithm) header value';function e6(t){if(void 0===t)throw new j("JWE Encrypted Key missing")}async function e3(t,r,a,o,i){switch(t){case"dir":if(void 0!==a)throw new j("Encountered unexpected JWE Encrypted Key");return r;case"ECDH-ES":if(void 0!==a)throw new j("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let i,n;if(!eu(o.epk))throw new j('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(U(r),!eS(r))throw new x("ECDH with the provided key is not allowed or not supported by your javascript runtime");let s=await eY(o.epk,t);if(U(s),void 0!==o.apu){if("string"!=typeof o.apu)throw new j('JOSE Header "apu" (Agreement PartyUInfo) invalid');i=el(o.apu,"apu",j)}if(void 0!==o.apv){if("string"!=typeof o.apv)throw new j('JOSE Header "apv" (Agreement PartyVInfo) invalid');n=el(o.apv,"apv",j)}let l=await eb(s,r,"ECDH-ES"===t?o.enc:t,"ECDH-ES"===t?F(o.enc):parseInt(t.slice(-5,-2),10),i,n);if("ECDH-ES"===t)return l;return e6(a),ey(t.slice(-6),l,a)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return e6(a),U(r),eC(t,r,a);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let n;if(e6(a),"number"!=typeof o.p2c)throw new j('JOSE Header "p2c" (PBES2 Count) missing or invalid');let s=i?.maxPBES2Count||1e4;if(o.p2c>s)throw new j('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof o.p2s)throw new j('JOSE Header "p2s" (PBES2 Salt) missing or invalid');return n=el(o.p2s,"p2s",j),e$(t,r,a,o.p2c,n)}case"A128KW":case"A192KW":case"A256KW":return e6(a),ey(t,r,a);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":if(e6(a),"string"!=typeof o.iv)throw new j('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof o.tag)throw new j('JOSE Header "tag" (Authentication Tag) missing or invalid');return e4(t,r,a,el(o.iv,"iv",j),el(o.tag,"tag",j));default:throw new x(e5)}}async function e8(t,r,a,o,i={}){let n,s,l;switch(t){case"dir":l=a;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let c;if(U(a),!eS(a))throw new x("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(a.algorithm,!0,["deriveBits"])).privateKey;let{x:p,y:h,crv:f,kty:m}=await e2(c),y=await eb(a,c,"ECDH-ES"===t?r:t,"ECDH-ES"===t?F(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=o||J(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=o||J(r),U(a),n=await ex(t,a,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=o||J(r);let{p2c:c,p2s:u}=i;({encryptedKey:n,...s}=await ew(t,a,l,c,u));break}case"A128KW":case"A192KW":case"A256KW":l=o||J(r),n=await em(t,a,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=o||J(r);let{iv:c}=i;({encryptedKey:n,...s}=await e9(t,a,l,c));break}default:throw new x(e5)}return{cek:l,encryptedKey:n,parameters:s}}function e7(t,r,a,o,i){let n;if(void 0!==i.crit&&o?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return new Set;if(!Array.isArray(o.crit)||0===o.crit.length||o.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!==a?new Map([...Object.entries(a),...r.entries()]):r,o.crit)){if(!n.has(s))throw new x(`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===o[s])throw new t(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(o.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,a)=>{if(void 0!==r.use){let t;switch(a){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 o;switch(!0){case"sign"===a||"verify"===a:case"dir"===t:case t.includes("CBC-HS"):o=a;break;case t.startsWith("PBES2"):o="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(t):o=!t.includes("GCM")&&t.endsWith("KW")?"encrypt"===a?"wrapKey":"unwrapKey":a;break;case"encrypt"===a&&t.startsWith("RSA"):o="wrapKey";break;case"decrypt"===a:o=t.startsWith("RSA")?"unwrapKey":"deriveBits"}if(o&&r.key_ops?.includes?.(o)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}return!0};function ta(t,r,a){switch(t.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((t,r,a)=>{if(!(r instanceof Uint8Array)){if(ep(r)){if("oct"===r.kty&&"string"==typeof r.k&&tr(t,r,a))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(!K(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,a);break;default:((t,r,a)=>{if(ep(r))switch(a){case"decrypt":case"sign":if("oct"!==r.kty&&("AKP"===r.kty&&"string"==typeof r.priv||"string"==typeof r.d)&&tr(t,r,a))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,a))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!K(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(a){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(a){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,a)}}function to(t){if(void 0===globalThis[t])throw new x(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${t} API.`)}async function ti(t){to("CompressionStream");let r=new CompressionStream("deflate-raw"),a=r.writable.getWriter();a.write(t).catch(()=>{}),a.close().catch(()=>{});let o=[],i=r.readable.getReader();for(;;){let{value:t,done:r}=await i.read();if(r)break;o.push(t)}return u(...o)}async function tn(t,r){to("DecompressionStream");let a=new DecompressionStream("deflate-raw"),o=a.writable.getWriter();o.write(t).catch(()=>{}),o.close().catch(()=>{});let i=[],n=0,s=a.readable.getReader();for(;;){let{value:t,done:a}=await s.read();if(a)break;if(i.push(t),n+=t.byteLength,r!==1/0&&n>r)throw new j("Decompressed plaintext exceeded the configured limit")}return u(...i)}async function ts(t,r,a){let o,i,n,s,l,d;if(!eu(t))throw new j("Flattened JWE must be an object");if(void 0===t.protected&&void 0===t.header&&void 0===t.unprotected)throw new j("JOSE Header missing");if(void 0!==t.iv&&"string"!=typeof t.iv)throw new j("JWE Initialization Vector incorrect type");if("string"!=typeof t.ciphertext)throw new j("JWE Ciphertext missing or incorrect type");if(void 0!==t.tag&&"string"!=typeof t.tag)throw new j("JWE Authentication Tag incorrect type");if(void 0!==t.protected&&"string"!=typeof t.protected)throw new j("JWE Protected Header incorrect type");if(void 0!==t.encrypted_key&&"string"!=typeof t.encrypted_key)throw new j("JWE Encrypted Key incorrect type");if(void 0!==t.aad&&"string"!=typeof t.aad)throw new j("JWE AAD incorrect type");if(void 0!==t.header&&!eu(t.header))throw new j("JWE Shared Unprotected Header incorrect type");if(void 0!==t.unprotected&&!eu(t.unprotected))throw new j("JWE Per-Recipient Unprotected Header incorrect type");if(t.protected)try{let r=g(t.protected);o=JSON.parse(c.decode(r))}catch{throw new j("JWE Protected Header is invalid")}if(!ed(o,t.header,t.unprotected))throw new j("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let p={...o,...t.header,...t.unprotected};if(e7(j,new Map,a?.crit,o,p),void 0!==p.zip&&"DEF"!==p.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==p.zip&&!o?.zip)throw new j('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 j("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof m||!m)throw new j("missing JWE Encryption Algorithm (enc) in JWE Header");let y=a&&te("keyManagementAlgorithms",a.keyManagementAlgorithms),v=a&&te("contentEncryptionAlgorithms",a.contentEncryptionAlgorithms);if(y&&!y.has(h)||!y&&h.startsWith("PBES2"))throw new O('"alg" (Algorithm) Header Parameter value not allowed');if(v&&!v.has(m))throw new O('"enc" (Encryption Algorithm) Header Parameter value not allowed');void 0!==t.encrypted_key&&(i=el(t.encrypted_key,"encrypted_key",j));let b=!1;"function"==typeof r&&(r=await r(o,t),b=!0),ta("dir"===h?m:h,r,"decrypt");let S=await eM(r,h);try{n=await e3(h,S,i,p,a)}catch(t){if(t instanceof TypeError||t instanceof j||t instanceof x)throw t;n=J(m)}void 0!==t.iv&&(s=el(t.iv,"iv",j)),void 0!==t.tag&&(l=el(t.tag,"tag",j));let _=void 0!==t.protected?f(t.protected):new Uint8Array;d=void 0!==t.aad?u(_,f("."),f(t.aad)):_;let w=el(t.ciphertext,"ciphertext",j),$=await ei(m,n,w,s,l,d),E={plaintext:$};if("DEF"===p.zip){let t=a?.maxDecompressedLength??25e4;if(0===t)throw new x('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 j)throw t;throw new j("Failed to decompress plaintext",{cause:t})})}return(void 0!==t.protected&&(E.protectedHeader=o),void 0!==t.aad&&(E.additionalAuthenticatedData=el(t.aad,"aad",j)),void 0!==t.unprotected&&(E.sharedUnprotectedHeader=t.unprotected),void 0!==t.header&&(E.unprotectedHeader=t.header),b)?{...E,key:S}:E}async function tl(t,r,a){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new j("Compact JWE must be a string or Uint8Array");let{0:o,1:i,2:n,3:s,4:l,length:u}=t.split(".");if(5!==u)throw new j("Invalid Compact JWE");let d=await ts({ciphertext:s,iv:n||void 0,protected:o,tag:l||void 0,encrypted_key:i||void 0},r,a),p={plaintext:d.plaintext,protectedHeader:d.protectedHeader};return"function"==typeof r?{...p,key:d.key}:p}async function tc(t,r,a){if(!eu(t))throw new j("General JWE must be an object");if(!Array.isArray(t.recipients)||!t.recipients.every(eu))throw new j("JWE Recipients missing or incorrect type");if(!t.recipients.length)throw new j("JWE Recipients has no members");for(let o of t.recipients)try{return await ts({aad:t.aad,ciphertext:t.ciphertext,encrypted_key:o.encrypted_key,header:o.header,iv:t.iv,protected:t.protected,tag:t.tag,unprotected:t.unprotected},r,a)}catch{}throw new C}class tu{#e;#t;#r;#a;#o;#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.#a,"setUnprotectedHeader"),this.#a=t,this}setAdditionalAuthenticatedData(t){return this.#o=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 a,o,i,n,s,l;if(!this.#t&&!this.#a&&!this.#r)throw new j("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ed(this.#t,this.#a,this.#r))throw new j("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let c={...this.#t,...this.#a,...this.#r};if(e7(j,new Map,r?.crit,this.#t,c),void 0!==c.zip&&"DEF"!==c.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==c.zip&&!this.#t?.zip)throw new j('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 j('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof p||!p)throw new j('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}`);ta("dir"===d?p:d,t,"encrypt");{let i,n=await eM(t,d);({cek:o,encryptedKey:a,parameters:i}=await e8(d,p,n,this.#i,this.#s)),i&&(r&&en in r?this.#a?this.#a={...this.#a,...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.#o){let t=f(l=v(this.#o));i=u(s,f("."),t)}else i=s;let h=this.#e;"DEF"===c.zip&&(h=await ti(h).catch(t=>{throw new j("Failed to compress plaintext",{cause:t})}));let{ciphertext:m,tag:y,iv:g}=await eo(p,h,o,this.#n,i),b={ciphertext:v(m)};return g&&(b.iv=v(g)),y&&(b.tag=v(y)),a&&(b.encrypted_key=v(a)),l&&(b.aad=l),this.#t&&(b.protected=n),this.#r&&(b.unprotected=this.#r),this.#a&&(b.header=this.#a),b}}class td{#l;unprotectedHeader;keyManagementParameters;key;options;constructor(t,r,a){this.#l=t,this.key=r,this.options=a}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;#a;#o;constructor(t){this.#e=t}addRecipient(t,r){let a=new td(this,t,{crit:r?.crit});return this.#c.push(a),a}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setSharedUnprotectedHeader(t){return es(this.#a,"setSharedUnprotectedHeader"),this.#a=t,this}setAdditionalAuthenticatedData(t){return this.#o=t,this}async encrypt(){let t;if(!this.#c.length)throw new j("at least one recipient must be added");if(1===this.#c.length){let[t]=this.#c,r=await new tu(this.#e).setAdditionalAuthenticatedData(this.#o).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#a).setUnprotectedHeader(t.unprotectedHeader).encrypt(t.key,{...t.options}),a={ciphertext:r.ciphertext,iv:r.iv,recipients:[{}],tag:r.tag};return r.aad&&(a.aad=r.aad),r.protected&&(a.protected=r.protected),r.unprotected&&(a.unprotected=r.unprotected),r.encrypted_key&&(a.recipients[0].encrypted_key=r.encrypted_key),r.header&&(a.recipients[0].header=r.header),a}for(let r=0;r<this.#c.length;r++){let a=this.#c[r];if(!ed(this.#t,this.#a,a.unprotectedHeader))throw new j("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let o={...this.#t,...this.#a,...a.unprotectedHeader},{alg:i}=o;if("string"!=typeof i||!i)throw new j('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===i||"ECDH-ES"===i)throw new j('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof o.enc||!o.enc)throw new j('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(t){if(t!==o.enc)throw new j('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else t=o.enc;if(e7(j,new Map,a.options.crit,this.#t,o),void 0!==o.zip&&"DEF"!==o.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==o.zip&&!this.#t?.zip)throw new j('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}let r=J(t),a={ciphertext:"",recipients:[]};for(let o=0;o<this.#c.length;o++){let i=this.#c[o],n={};if(a.recipients.push(n),0===o){let t=await new tu(this.#e).setAdditionalAuthenticatedData(this.#o).setContentEncryptionKey(r).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#a).setUnprotectedHeader(i.unprotectedHeader).setKeyManagementParameters(i.keyManagementParameters).encrypt(i.key,{...i.options,[en]:!0});a.ciphertext=t.ciphertext,a.iv=t.iv,a.tag=t.tag,t.aad&&(a.aad=t.aad),t.protected&&(a.protected=t.protected),t.unprotected&&(a.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.#a?.alg;ta("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 a}}async function th(t,r,a){if(!eu(t))throw new A("Flattened JWS must be an object");if(void 0===t.protected&&void 0===t.header)throw new A('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==t.protected&&"string"!=typeof t.protected)throw new A("JWS Protected Header incorrect type");if(void 0===t.payload)throw new A("JWS Payload missing");if("string"!=typeof t.signature)throw new A("JWS Signature missing or incorrect type");if(void 0!==t.header&&!eu(t.header))throw new A("JWS Unprotected Header incorrect type");let o={};if(t.protected)try{let r=g(t.protected);o=JSON.parse(c.decode(r))}catch{throw new A("JWS Protected Header is invalid")}if(!ed(o,t.header))throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...o,...t.header},n=e7(A,new Map([["b64",!0]]),a?.crit,o,i),s=!0;if(n.has("b64")&&"boolean"!=typeof(s=o.b64))throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=i;if("string"!=typeof d||!d)throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');let p=a&&te("algorithms",a.algorithms);if(p&&!p.has(d))throw new O('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof t.payload)throw new A("JWS Payload must be a string")}else if("string"!=typeof t.payload&&!(t.payload instanceof Uint8Array))throw new A("JWS Payload must be a string or an Uint8Array instance");let h=!1;"function"==typeof r&&(r=await r(o,t),h=!0),ta(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",A),v=await eM(r,d);if(!await eT(d,v,y,m))throw new L;let b={payload:s?el(t.payload,"payload",A):"string"==typeof t.payload?l.encode(t.payload):t.payload};return(void 0!==t.protected&&(b.protectedHeader=o),void 0!==t.header&&(b.unprotectedHeader=t.header),h)?{...b,key:v}:b}async function tf(t,r,a){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new A("Compact JWS must be a string or Uint8Array");let{0:o,1:i,2:n,length:s}=t.split(".");if(3!==s)throw new A("Invalid Compact JWS");let l=await th({payload:i,protected:o,signature:n},r,a),u={payload:l.payload,protectedHeader:l.protectedHeader};return"function"==typeof r?{...u,key:l.key}:u}async function tm(t,r,a){if(!eu(t))throw new A("General JWS must be an object");if(!Array.isArray(t.signatures)||!t.signatures.every(eu))throw new A("JWS Signatures missing or incorrect type");for(let o of t.signatures)try{return await th({header:o.header,payload:t.payload,protected:o.protected,signature:o.signature},r,a)}catch{}throw new L}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,a=tg.exec(t);if(!a||a[4]&&a[1])throw TypeError("Invalid time period format");let o=parseFloat(a[2]);switch(a[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":r=Math.round(o);break;case"minute":case"minutes":case"min":case"mins":case"m":r=Math.round(60*o);break;case"hour":case"hours":case"hr":case"hrs":case"h":r=Math.round(3600*o);break;case"day":case"days":case"d":r=Math.round(86400*o);break;case"week":case"weeks":case"w":r=Math.round(604800*o);break;default:r=Math.round(0x1e187e0*o)}return"-"===a[1]||"ago"===a[4]?-r:r}function tb(t,r){if(!Number.isFinite(r))throw TypeError(`Invalid ${t} input`);return r}let tS=t=>t.includes("/")?t.toLowerCase():`application/${t.toLowerCase()}`;function t_(t,r,a={}){var o,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}=a;if(l&&("string"!=typeof t.typ||tS(t.typ)!==tS(l)))throw new k('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:u=[],issuer:d,subject:p,audience:h,maxTokenAge:f}=a,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 k(`missing required "${t}" claim`,n,t,"missing");if(d&&!(Array.isArray(d)?d:[d]).includes(n.iss))throw new k('unexpected "iss" claim value',n,"iss","check_failed");if(p&&n.sub!==p)throw new k('unexpected "sub" claim value',n,"sub","check_failed");if(h&&(o=n.aud,i="string"==typeof h?[h]:h,"string"==typeof o?!i.includes(o):!(Array.isArray(o)&&i.some(Set.prototype.has.bind(new Set(o))))))throw new k('unexpected "aud" claim value',n,"aud","check_failed");switch(typeof a.clockTolerance){case"string":s=tv(a.clockTolerance);break;case"number":s=a.clockTolerance;break;case"undefined":s=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:y}=a,g=ty(y||new Date);if((void 0!==n.iat||f)&&"number"!=typeof n.iat)throw new k('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new k('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>g+s)throw new k('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new k('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=g-s)throw new T('"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 T('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(t<0-s)throw new k('"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=tb("setNotBefore",t):t instanceof Date?this.#u.nbf=tb("setNotBefore",ty(t)):this.#u.nbf=ty(new Date)+tv(t)}set exp(t){"number"==typeof t?this.#u.exp=tb("setExpirationTime",t):t instanceof Date?this.#u.exp=tb("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=tb("setIssuedAt",ty(t)):"string"==typeof t?this.#u.iat=tb("setIssuedAt",ty(new Date)+tv(t)):this.#u.iat=tb("setIssuedAt",t)}}async function t$(t,r,a){let o=await tf(t,r,a);if(o.protectedHeader.crit?.includes("b64")&&!1===o.protectedHeader.b64)throw new I("JWTs MUST NOT use unencoded payload");let i={payload:t_(o.protectedHeader,o.payload,a),protectedHeader:o.protectedHeader};return"function"==typeof r?{...i,key:o.key}:i}async function tE(t,r,a){let o=await tl(t,r,a),i=t_(o.protectedHeader,o.plaintext,a),{protectedHeader:n}=o;if(void 0!==n.iss&&n.iss!==i.iss)throw new k('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==n.sub&&n.sub!==i.sub)throw new k('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==n.aud&&JSON.stringify(n.aud)!==JSON.stringify(i.aud))throw new k('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let s={payload:i,protectedHeader:n};return"function"==typeof r?{...s,key:o.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 a=await this.#d.encrypt(t,r);return[a.protected,a.encrypted_key,a.iv,a.ciphertext,a.tag].join(".")}}class tR{#u;#t;#a;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.#a,"setUnprotectedHeader"),this.#a=t,this}async sign(t,r){let a,o,i,n;if(!this.#t&&!this.#a)throw new A("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ed(this.#t,this.#a))throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let s={...this.#t,...this.#a},l=e7(A,new Map([["b64",!0]]),r?.crit,this.#t,s),c=!0;if(l.has("b64")&&"boolean"!=typeof(c=this.#t.b64))throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=s;if("string"!=typeof d||!d)throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');ta(d,t,"sign"),c?o=f(a=v(this.#u)):(o=this.#u,a=""),this.#t?n=f(i=v(JSON.stringify(this.#t))):(i="",n=new Uint8Array);let p=u(n,f("."),o),h=await eM(t,d),m={signature:v(await ek(d,h,p)),payload:a};return this.#a&&(m.header=this.#a),this.#t&&(m.protected=i),m}}class tk{#d;constructor(t){this.#d=new tR(t)}setProtectedHeader(t){return this.#d.setProtectedHeader(t),this}async sign(t,r){let a=await this.#d.sign(t,r);if(void 0===a.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${a.protected}.${a.payload}.${a.signature}`}}class tT{#l;protectedHeader;unprotectedHeader;options;key;constructor(t,r,a){this.#l=t,this.key=r,this.options=a}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 tO{#u;#p=[];constructor(t){this.#u=t}addSignature(t,r){let a=new tT(this,t,r);return this.#p.push(a),a}async sign(){if(!this.#p.length)throw new A("at least one signature must be added");let t={signatures:[],payload:""};for(let r=0;r<this.#p.length;r++){let a=this.#p[r],o=new tR(this.#u);o.setProtectedHeader(a.protectedHeader),o.setUnprotectedHeader(a.unprotectedHeader);let{payload:i,...n}=await o.sign(a.key,a.options);if(0===r)t.payload=i;else if(t.payload!==i)throw new A("inconsistent use of JWS Unencoded Payload (RFC7797)");t.signatures.push(n)}return t}}class tx{#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 a=new tk(this.#h.data());if(a.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 a.sign(t,r)}}class tC{#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 a=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}),a.setProtectedHeader(this.#t),this.#n&&a.setInitializationVector(this.#n),this.#i&&a.setContentEncryptionKey(this.#i),this.#s&&a.setKeyManagementParameters(this.#s),a.encrypt(t,r)}}let tj=(t,r)=>{if("string"!=typeof t||!t)throw new N(`${r} missing or invalid`)};async function tA(t,r){let a,o;if(ep(t))a=t;else if(K(t))a=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(a.kty){case"AKP":tj(a.alg,'"alg" (Algorithm) Parameter'),tj(a.pub,'"pub" (Public key) Parameter'),o={alg:a.alg,kty:a.kty,pub:a.pub};break;case"EC":tj(a.crv,'"crv" (Curve) Parameter'),tj(a.x,'"x" (X Coordinate) Parameter'),tj(a.y,'"y" (Y Coordinate) Parameter'),o={crv:a.crv,kty:a.kty,x:a.x,y:a.y};break;case"OKP":tj(a.crv,'"crv" (Subtype of Key Pair) Parameter'),tj(a.x,'"x" (Public Key) Parameter'),o={crv:a.crv,kty:a.kty,x:a.x};break;case"RSA":tj(a.e,'"e" (Exponent) Parameter'),tj(a.n,'"n" (Modulus) Parameter'),o={e:a.e,kty:a.kty,n:a.n};break;case"oct":tj(a.k,'"k" (Key Value) Parameter'),o={k:a.k,kty:a.kty};break;default:throw new x('"kty" (Key Type) Parameter missing or unsupported')}let i=f(JSON.stringify(o));return v(await ec(r,i))}async function tI(t,r){r??="sha256";let a=await tA(t,r);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${r.slice(-3)}:${a}`}async function tN(t,r){let a={...t,...r?.header};if(!eu(a.jwk))throw new A('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let o=await eY({...a.jwk,ext:!0},a.alg);if(o instanceof Uint8Array||"public"!==o.type)throw new A('"jwk" (JSON Web Key) Header Parameter must be a public key');return o}function tM(t){return eu(t)}class tq{#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:a,kid:o}={...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 x('Unsupported "alg" value for a JSON Web Key Set')}}(a),n=this.#g.keys.filter(t=>{let r=i===t.kty;if(r&&"string"==typeof o&&(r=o===t.kid),r&&("string"==typeof t.alg||"AKP"===i)&&(r=a===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(a){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 q;if(1!==l){let t=new z,r=this.#v;throw t[Symbol.asyncIterator]=async function*(){for(let t of n)try{yield await tz(r,t,a)}catch{}},t}return tz(this.#v,s,a)}}async function tz(t,r,a){let o=t.get(r)||t.set(r,{}).get(r);if(void 0===o[a]){let t=await eY({...r,ext:!0},a);if(t instanceof Uint8Array||"public"!==t.type)throw new M("JSON Web Key Set members must be public keys");o[a]=t}return o[a]}function tD(t){let r=new tq(t),a=async(t,a)=>r.getKey(t,a);return Object.defineProperties(a,{jwks:{value:()=>structuredClone(r.jwks()),enumerable:!1,configurable:!1,writable:!1}}),a}"undefined"!=typeof navigator&&navigator.userAgent?.startsWith?.("Mozilla/5.0 ")||(i="jose/v6.2.3");let tL=Symbol();async function tU(t,r,a,o=fetch){let i=await o(t,{method:"GET",signal:a,redirect:"manual",headers:r}).catch(t=>{if("TimeoutError"===t.name)throw new D;throw t});if(200!==i.status)throw new R("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new R("Failed to parse the JSON Web Key Set HTTP response as JSON")}}let tH=Symbol();class tV{#b;#S;#_;#w;#$;#E;#P;#R;#k;#T;constructor(t,r){if(!(t instanceof URL))throw TypeError("url must be an instance of URL");this.#b=new URL(t.href),this.#S="number"==typeof r?.timeoutDuration?r?.timeoutDuration:5e3,this.#_="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.#R=r?.[tL],r?.[tH]!==void 0&&(this.#T=r?.[tH],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?.[tH],this.#w)&&(this.#$=this.#T.uat,this.#k=tD(this.#T.jwks)))}pendingFetch(){return!!this.#E}coolingDown(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#_}fresh(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#w}jwks(){return this.#k?.jwks()}async getKey(t,r){this.#k&&this.fresh()||await this.reload();try{return await this.#k(t,r)}catch(a){if(a instanceof q&&!1===this.coolingDown())return await this.reload(),this.#k(t,r);throw a}}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||=tU(this.#b.href,this.#P,AbortSignal.timeout(this.#S),this.#R).then(t=>{this.#k=tD(t),this.#T&&(this.#T.uat=Date.now(),this.#T.jwks=t),this.#$=Date.now(),this.#E=void 0}).catch(t=>{throw this.#E=void 0,t}),await this.#E}}function tK(t,r){let a=new tV(t,r),o=async(t,r)=>a.getKey(t,r);return Object.defineProperties(o,{coolingDown:{get:()=>a.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>a.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>a.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>a.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>a.jwks(),enumerable:!0,configurable:!1,writable:!1}}),o}class tF{#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 a;if("string"!=typeof t)throw new I("Unsecured JWT must be a string");let{0:o,1:i,2:n,length:s}=t.split(".");if(3!==s||""!==n)throw new I("Invalid Unsecured JWT");try{if(a=JSON.parse(c.decode(g(o))),"none"!==a.alg)throw Error()}catch{throw new I("Invalid Unsecured JWT")}return{payload:t_(a,g(i),r),header:a}}}function tJ(t){let r;if("string"==typeof t){let a=t.split(".");(3===a.length||5===a.length)&&([r]=a)}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 tW(t){let r,a;if("string"!=typeof t)throw new I("JWTs must use Compact JWS serialization, JWT must be a string");let{1:o,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(!o)throw new I("JWTs must contain a payload");try{r=g(o)}catch{throw new I("Failed to base64url decode the payload")}try{a=JSON.parse(c.decode(r))}catch{throw new I("Failed to parse the decoded payload as JSON")}if(!eu(a))throw new I("Invalid JWT Claims Set");return a}function tB(t){let r=t?.modulusLength??2048;if("number"!=typeof r||r<2048)throw new x("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return r}async function tG(t,r){let a,o;switch(t){case"PS256":case"PS384":case"PS512":a={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["sign","verify"];break;case"RS256":case"RS384":case"RS512":a={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":a={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":a={name:"ECDSA",namedCurve:"P-256"},o=["sign","verify"];break;case"ES384":a={name:"ECDSA",namedCurve:"P-384"},o=["sign","verify"];break;case"ES512":a={name:"ECDSA",namedCurve:"P-521"},o=["sign","verify"];break;case"Ed25519":case"EdDSA":o=["sign","verify"],a={name:"Ed25519"};break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":o=["sign","verify"],a={name:t};break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{o=["deriveBits"];let t=r?.crv??"P-256";switch(t){case"P-256":case"P-384":case"P-521":a={name:"ECDH",namedCurve:t};break;case"X25519":a={name:"X25519"};break;default:throw new x("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}break}default:throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(a,r?.extractable??!1,o)}async function tZ(t,r){let a,o,i;switch(t){case"HS256":case"HS384":case"HS512":a=parseInt(t.slice(-3),10),o={name:"HMAC",hash:`SHA-${a}`,length:a},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return a=parseInt(t.slice(-3),10),crypto.getRandomValues(new Uint8Array(a>>3));case"A128KW":case"A192KW":case"A256KW":o={name:"AES-KW",length:a=parseInt(t.slice(1,4),10)},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":o={name:"AES-GCM",length:a=parseInt(t.slice(1,4),10)},i=["encrypt","decrypt"];break;default:throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(o,r?.extractable??!1,i)}let tX="WebCryptoAPI"},4519(t){"use strict";t.exports=JSON.parse('{"name":"dotenv","version":"16.6.1","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}')},8330(t){"use strict";t.exports=JSON.parse('{"name":"xmcp","description":"The MCP framework","version":"1.8.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.5","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}}}')}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var a=i[t]={exports:{}};return o[t](a,a.exports,n),a.exports}n.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return n.d(r,{a:r}),r},a=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o||"object"==typeof t&&t&&(4&o&&t.__esModule||16&o&&"function"==typeof t.then))return t;var i=Object.create(null);n.r(i);var s={};r=r||[null,a({}),a([]),a(a)];for(var l=2&o&&t;("object"==typeof l||"function"==typeof l)&&!~r.indexOf(l);l=a(l))Object.getOwnPropertyNames(l).forEach(r=>{s[r]=()=>t[r]});return s.default=()=>t,n.d(i,s),i},n.d=(t,r)=>{for(var a in r)n.o(r,a)&&!n.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},n.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{"use strict";let t,r,a,o,i,l,c,u,d,p,h,f,m,y,g,v,b,S,_;n.r(s),n.d(s,{HOST_CONTEXT_CHANGED_METHOD:()=>yg,isEnvHeader:()=>m3,createSTDIOClient:()=>ya,INITIALIZE_METHOD:()=>yc,LOG_MESSAGE_METHOD:()=>ym,OPEN_LINK_METHOD:()=>yp,REQUEST_DISPLAY_MODE_METHOD:()=>yd,inputResponse:()=>ch,disconnectSTDIOClient:()=>yn,embeddedResource:()=>B,isInputRequiredResult:()=>l7,callSTDIOClientTool:()=>yi,headersToRecord:()=>m8,MCP_APPS_PROTOCOL_VERSION:()=>yl,extractToolNamesFromRequest:()=>ys,UI_MESSAGE_METHOD:()=>yf,completable:()=>u3,acceptedContent:()=>cp,listSTDIOClientTools:()=>yo,UPDATE_MODEL_CONTEXT_METHOD:()=>yh,UrlElicitationRequiredError:()=>l9,createRequestStateCodec:()=>de,audio:()=>W,createMcpHostBridge:()=>y_,SIZE_CHANGED_METHOD:()=>yv,image:()=>J,INITIALIZED_METHOD:()=>yu,inputRequired:()=>cd,RESOURCES_READ_METHOD:()=>yy,createContext:()=>K,getRequestContext:()=>X,jwtAuthMiddleware:()=>L,createHTTPClient:()=>yr,apiKeyAuthMiddleware:()=>q});var w,$,E,P,R,k,T,O,x,C,j=n(8583),A=n.n(j),I=n(4953);let N=I.z.object({apiKey:I.z.string().optional(),headerName:I.z.string().optional(),validateApiKey:I.z.function().args(I.z.string()).returns(I.z.promise(I.z.boolean())).optional()}).strict().refine(t=>void 0!==t.apiKey||void 0!==t.validateApiKey,{message:"Either 'apiKey' or 'validateApiKey' must be provided"}).refine(t=>void 0===t.apiKey||void 0===t.validateApiKey,{message:"'apiKey' and 'validateApiKey' are mutually exclusive - provide only one"}),M="Unauthorized: Missing or invalid API key";function q(t){let r=N.safeParse(t);if(!r.success){let a="apiKey"in t,o="validateApiKey"in t;if(a&&o)throw Error("'apiKey' and 'validateApiKey' are mutually exclusive - provide only one");if(a||o)throw Error(`Invalid configuration: ${r.error.message}`);throw Error("Either 'apiKey' or 'validateApiKey' must be provided")}let a=t.headerName??"x-api-key",o="apiKey"in t?t.apiKey:void 0,i="validateApiKey"in t?t.validateApiKey:void 0;return async(r,n,s)=>{let l=r.header(a);!l||"apiKey"in t&&l!==o||i&&!await i(l)?n.status(401).json({error:M}):s()}}var z=n(8400),D=n.n(z);function L(t){return(r,a,o)=>{let i=r.header("Authorization");if(!i||!i.startsWith("Bearer "))return void a.status(401).json({error:"Unauthorized: Missing or malformed Authorization header"});let n=i.slice(7).trim();if(!n)return void a.status(401).json({error:"Unauthorized: Missing access token"});try{let{secret:a,...i}=t;r.user=D().verify(n,a,i),o()}catch(t){a.status(401).json({error:"Unauthorized: Invalid or expired token"})}}}let U=require("async_hooks"),H=(t,r)=>{globalThis[t]=r},V=t=>globalThis[t];function K({name:t,fallback:r=!0}){let a=Symbol.for(`xmcp-context-${t}`),o=Symbol.for(`xmcp-context-${t}-fallback-store`);if(V(a))return V(a);let i=new U.AsyncLocalStorage,n=globalThis[o]??{current:null};H(o,n);let s={provider:(t,a)=>(r&&(n.current=t),i.run(t,a)),getContext:()=>{let a=i.getStore();if(a)return a;if(r&&n.current)return n.current;throw Error(`getContext() can only be used within the ${t} context.`)},setContext:a=>{let o=i.getStore()??(r?n.current:null);if(!o)throw Error(`setContext() can only be used within the ${t} context.`);Object.assign(o,a)}};return H(a,s),s}function F(t){let r;if(t instanceof Uint8Array)r=t;else if(t instanceof ArrayBuffer)r=new Uint8Array(t);else throw TypeError("Expected bytes as a Uint8Array or ArrayBuffer");let a="";for(let t=0;t<r.length;t+=32768)a+=String.fromCharCode(...r.subarray(t,t+32768));return btoa(a)}function J(t,r){return{type:"image",data:F(t),mimeType:r}}function W(t,r){return{type:"audio",data:F(t),mimeType:r}}function B(t,r,a){return{type:"resource",resource:{uri:t,...void 0===a?{}:{mimeType:a},..."string"==typeof r?{text:r}:{blob:F(r)}}}}let G=K({name:"http-request-context"});G.setContext,G.getContext,G.provider;let Z=K({name:"request-context",fallback:!1});function X(){try{return Z.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}var Y=Object.create,Q=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,er=Object.getPrototypeOf,ea=Object.prototype.hasOwnProperty,eo=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);function ei(t){let r=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,a])=>-1===r.indexOf(+t)).map(([t,r])=>r)}function en(t,r="|"){return t.map(t=>eT(t)).join(r)}function es(t,r){return"bigint"==typeof r?r.toString():r}class el{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 ec(t){return new el(t)}function eu(t){let r=+!!t.startsWith("^"),a=t.endsWith("$")?t.length-1:t.length;return t.slice(r,a)}let ed=Symbol("evaluating");function ep(t,r,a){Object.defineProperty(t,r,{value:a,writable:!0,enumerable:!0,configurable:!0})}function eh(t){let r=Object.getOwnPropertyDescriptor(t,"shape");return r?.get?r.get.raw:r?.value}function ef(t){return eh(t._zod.def)??t._zod.def.shape}function em(t,r,a){Object.defineProperty(t,r,{get(){let t=a();return ep(this,r,t),t},enumerable:!0,configurable:!0})}function ey(t,r,a){r in t?ep(t,r,a):t[r]=a}function eg(t,r,a,o){let i=ef(r);for(let n of a){let a=Object.getOwnPropertyDescriptor(i,n);a.enumerable&&(a.get?em(t,n,()=>{let t=r._zod.def.shape[n];return o?o(t,n):t}):ey(t,n,o?o(a.value,n):a.value))}}function ev(...t){let r={};for(let a of t)Object.assign(r,Object.getOwnPropertyDescriptors(a));return Object.defineProperties({},r)}let eb="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function eS(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let e_=ec(()=>{if(e0.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(t){return!1}});function ew(t){if(!1===eS(t))return!1;let r=t.constructor;if(void 0===r||"function"!=typeof r)return!0;let a=r.prototype;return!1!==eS(a)&&!1!==Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")}function e$(t){return ew(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}let eE=new Set(["string","number","symbol"]);function eP(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eR(t,r,a){let o=new t._zod.constr(r??t._zod.def);return(!r||a?.parent)&&(o._zod.parent=t),o}function ek(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 eT(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}let eO={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]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eC(t,r){let a=ef(t),o=[];for(let t of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(a,t)?.enumerable)throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&o.push(t)}return o}function ej(t,r){let a={};eg(a,t,Reflect.ownKeys(ef(t)));for(let t of Reflect.ownKeys(r)){let o=Object.getOwnPropertyDescriptor(r,t);o.enumerable&&(o.get?em(a,t,()=>r[t]):ey(a,t,o.value))}return a}function eA(t,r,a,o="partial"){let i=r._zod.def.checks;if(i&&i.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let n=a?new Set(eC(r,a)):void 0,s={};return eg(s,r,Reflect.ownKeys(ef(r)),t&&((r,a)=>n&&!n.has(a)?r:new t({type:"optional",innerType:r}))),eR(r,ev(r._zod.def,{shape:s,checks:[]}))}function eI(t,r=0){if(!0===t.aborted)return!0;for(let a=r;a<t.issues.length;a++)if(t.issues[a]?.continue!==!0)return!0;return!1}function eN(t,r){return r.map(r=>(r.path??(r.path=[]),r.path.unshift(t),r))}function eM(t){return"string"==typeof t?t:t?.message}function eq(t,r,a){var o;for(let i=r;i<t.length;i++)(o=t[i]).schema??(o.schema=a)}function ez(t,r,a){let o=t.inst?._zod?.traits;o?.has("$ZodType")&&(o.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:eM(t.inst?._zod.def?.error?.(t))??eM(i?.(t))??eM(r?.error?.(t))??eM(a.customError?.(t))??eM(a.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 eD=/[\uD800-\uDBFF]/;function eL(t){let r=t.length;if(!eD.test(t))return r;let a=r;for(let o=0;o<r-1;o++)(64512&t.charCodeAt(o))==55296&&(64512&t.charCodeAt(o+1))==56320&&(a--,o++);return a}function eU(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function eH(...t){let[r,a,o]=t;return"string"==typeof r?{message:r,code:"custom",input:a,inst:o}:{...r}}function eV(t,r,a,o=!0){return Object.defineProperty(t,r,{configurable:!0,writable:!0,enumerable:o,value:a}),a}function eK(t,r){for(let a in t){let o=t[a];Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get(){return eV(this,a,o(this))},set(t){eV(this,a,t)}})}return r}let eF=!1,eJ={configurable:!0,get(){eF=!0}};function eW(r,a,o){let i=Object.getPrototypeOf(r._zod);if(a in i&&t!==r._zod){t=void 0;return}t=r._zod,Object.defineProperty(i,a,{configurable:!0,get(){Object.defineProperty(this,a,eJ);let t=eF;eF=!1;try{let r=o(this);return eF?delete this[a]:Object.defineProperty(this,a,{configurable:!0,writable:!0,value:r}),eF=eF||t,r}catch(r){throw delete this[a],eF=eF||t,r}},set(t){Object.defineProperty(this,a,{configurable:!0,writable:!0,value:t})}})}let eB=Object.freeze({status:"aborted"}),eG={value:void 0,enumerable:!1},eZ="captureStackTrace"in Error?Error:null;function eX(t,r,a,o){function i(t){this.def=t,this.constr=u,this.traits=new Set}i.prototype={};let n=a&&new WeakSet;function s(o,s){if(o._zod){if(o._zod.traits.has(t))return}else{eG.value=new i(s);try{Object.defineProperty(o,"_zod",eG)}finally{eG.value=void 0}}if(o._zod.traits.add(t),r(o,s),n){let t=Object.getPrototypeOf(o),r=o._zod.constr.prototype,i=t;for(;i&&i!==r;)i=Object.getPrototypeOf(i);let s=i??t;if(!n.has(s)){n.add(s);for(let t in a){let r=Object.getOwnPropertyDescriptor(a,t);r.get?Object.defineProperty(s,t,{...r,enumerable:!1}):function(t,r,a){Object.defineProperty(t,r,{configurable:!0,get(){return this==null?a:eV(this,r,a.bind(this))},set(t){eV(this,r,t)}})}(s,t,r.value)}}}let l=u.prototype;for(let t in l)Object.prototype.hasOwnProperty.call(l,t)&&(t in o||(o[t]=l[t].bind(o)))}let l=o?.Parent??Object;class c extends l{}function u(t){let r=o?.Parent?function(t){let r=eZ;if(r){let a=r.stackTraceLimit;if("number"==typeof a){try{r.stackTraceLimit=0}catch{return eZ=null,new t}try{return new t}finally{r.stackTraceLimit=a}}}return new t}(c):this;s(r,t);let a=r._zod.deferred;if(a){for(let t of a)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=>!!o?.Parent&&r instanceof o.Parent||r?._zod?.traits?.has(t)}),Object.defineProperty(u,"name",{value:t}),u}class eY extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eQ extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(O=globalThis).__zod_globalConfig??(O.__zod_globalConfig={});let e0=globalThis.__zod_globalConfig;function e1(t){return t&&Object.assign(e0,t),e0}class e2 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let e9="~memo",e4=[];function e5(t){return null!==t&&"object"==typeof t}function e6(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}let e3=new WeakMap,e8=[],e7={alloc(t,a,o){let i=r;if(!i)return o;r=void 0;let n={value:o,issues:null};return i.set(a.value,n),e8.push(n),o},guard(t){var r;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,a=(t,a)=>{var o,i;let n;if("backward"!==a.direction&&(o=a,i=t.value,void 0!==(n=o[e9]?.backEdges)&&e5(i)&&n.has(i)))throw new e2;return r(t,a)};t._zod.parse=a,t._zod.run===r&&(t._zod.run=a)})},attach(t){var a;let o,i,n,s=!1;(a=t._zod).deferred??(a.deferred=[]),t._zod.deferred.push(()=>{let a=t._zod.parse,l=(c,u)=>{let d;if(void 0===o){let r=function t(r,a,o){var i,n;let s=e3.get(r);if(void 0!==s)return 2*!!s;if(a.has(r))return 2;a.add(r);let l=0,c=r=>{if(2!==l&&r?._zod){let i=t(r,a,o);i>l&&(l=i)}},u=t=>{t>l&&(l=t)},d=r._zod.def;switch(d.type){case"object":{let r=eh(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,a,o):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??(o?r._zod.innerType:void 0);u(i?t(i,a,!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 a=r.value;if(a&&"object"==typeof a){if(a._zod)c(a);else if(Array.isArray(a))for(let t of a)c(t)}}}return a.delete(r),i=r,1!==(n=l)&&e3.set(i,2===n),n}(t,new Set,!1);if(0===r)return t._zod.parse=a,t._zod.run===l&&(t._zod.run=a),a(c,u);2===r||s?o=!0:s=!0}let p=c.value;if(!e5(p))return a(c,u);let h=u[e9];if(h||(h={buckets:new WeakMap,backEdges:void 0},u[e9]=h),i===u)d=n;else{var f;let r;(r=(f=h).buckets.get(t))||(r=new WeakMap,f.buckets.set(t,r)),d=r,i=u,n=d}let m=d.get(p);if(m)return c.value=m.value,m.issues?m.issues.length&&c.issues.push(...e6(m.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(m.value)),c;r=d;let y=e8.length,g=a(c,u);r=void 0;let v=e8.length>y?e8.pop():void 0;return g instanceof Promise?g.then(t=>(v&&(v.issues=t.issues.length?e6(t.issues):e4),t)):(v&&(v.issues=g.issues.length?e6(g.issues):e4),g)};t._zod.parse=l,t._zod.run===a&&(t._zod.run=l)})}},te=/^[cC][0-9a-z]{6,}$/,tt=/^[0-9a-z]+$/,tr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ta=/^[0-9a-vA-V]{20}$/,to=/^[A-Za-z0-9]{27}$/,ti=/^[a-zA-Z0-9_-]{21}$/,tn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ts=/^([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})$/,tl=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)$/,tc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tu=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,td=/^(?:(?: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])$/,tp=/^(([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}|:))$/,th=/^((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])$/,tf=/^(([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])$/,tm=/^https?$/,ty=/^\+[1-9]\d{6,14}$/,tg="(?:(?:\\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])))",tv=RegExp(`^${tg}$`);function tb(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 tS=/^[\s\S]{0,}$/,t_=/^-?\d+$/,tw=/^-?\d+(?:\.\d+)?$/,t$=/^(?:true|false)$/i,tE=/^null$/i,tP=/^[^A-Z]*$/,tR=/^[^a-z]*$/,tk=eX("$ZodCheck",(t,r)=>{var a;t._zod??(t._zod={}),t._zod.def=r,(a=t._zod).onattach??(a.onattach=[])}),tT=t=>{let r=t.value;return null!=r&&void 0!==r.length},tO={number:"number",bigint:"bigint",object:"date"},tx=eX("$ZodCheckLessThan",(t,r)=>{tk.init(t,r);let a=tO[typeof r.value];t._zod.check=o=>{(r.inclusive?o.value<=r.value:o.value<r.value)||o.issues.push({origin:tO[typeof o.value]??a,code:"too_big",maximum:"object"==typeof r.value?r.value.getTime():r.value,input:o.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tC=eX("$ZodCheckGreaterThan",(t,r)=>{tk.init(t,r);let a=tO[typeof r.value];t._zod.check=o=>{(r.inclusive?o.value>=r.value:o.value>r.value)||o.issues.push({origin:tO[typeof o.value]??a,code:"too_small",minimum:"object"==typeof r.value?r.value.getTime():r.value,input:o.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tj=eX("$ZodCheckMultipleOf",(t,r)=>{tk.init(t,r),t._zod.check=a=>{let o,i,n;if(typeof a.value!=typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof a.value?r.value!==BigInt(0)&&a.value%r.value===BigInt(0):0==(i=Math.round(o=a.value/r.value),n=4*Number.EPSILON*Math.max(Math.abs(o),1),Math.abs(o-i)<n?0:o-i))||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:r.value,input:a.value,inst:t,continue:!r.abort})}}),tA=eX("$ZodCheckNumberFormat",(t,r)=>{tk.init(t,r),r.format=r.format||"float64";let a=r.format?.includes("int"),o=a?"int":"number",[i,n]=eO[r.format];t._zod.check=s=>{let l=s.value;if(a){if(!Number.isInteger(l))return void s.issues.push({expected:o,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:o,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:o,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})}}),tI=eX("$ZodCheckMaxLength",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length;if(("string"==typeof o&&i>r.maximum?eL(o):i)<=r.maximum)return;let n=eU(o);a.issues.push({origin:n,code:"too_big",maximum:r.maximum,inclusive:!0,input:o,inst:t,continue:!r.abort})}}),tN=eX("$ZodCheckMinLength",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length;if(("string"==typeof o&&i>=r.minimum&&i<2*r.minimum?eL(o):i)>=r.minimum)return;let n=eU(o);a.issues.push({origin:n,code:"too_small",minimum:r.minimum,inclusive:!0,input:o,inst:t,continue:!r.abort})}}),tM=eX("$ZodCheckLengthEquals",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length,n="string"==typeof o&&i>=r.length&&i<=2*r.length?eL(o):i;if(n===r.length)return;let s=eU(o),l=n>r.length;a.issues.push({origin:s,...l?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:a.value,inst:t,continue:!r.abort})}}),tq=eX("$ZodCheckStringFormat",(t,r)=>{var a,o;tk.init(t,r),r.pattern?(a=t._zod).check??(a.check=a=>{r.pattern.lastIndex=0,r.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:r.format,input:a.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(o=t._zod).check??(o.check=()=>{})}),tz=eX("$ZodCheckRegex",(t,r)=>{tq.init(t,r),t._zod.check=a=>{r.pattern.lastIndex=0,r.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),tD=eX("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=tP),tq.init(t,r)}),tL=eX("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=tR),tq.init(t,r)}),tU=eX("$ZodCheckIncludes",(t,r)=>{tk.init(t,r);let a=eP(r.includes),o=new RegExp("number"==typeof r.position?`^.{${r.position},}${a}`:a);r.pattern=o,t._zod.check=a=>{a.value.includes(r.includes,r.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:a.value,inst:t,continue:!r.abort})}}),tH=eX("$ZodCheckStartsWith",(t,r)=>{tk.init(t,r);let a=RegExp(`^${eP(r.prefix)}.*`);r.pattern??(r.pattern=a),t._zod.check=a=>{a.value.startsWith(r.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:a.value,inst:t,continue:!r.abort})}}),tV=eX("$ZodCheckEndsWith",(t,r)=>{tk.init(t,r);let a=RegExp(`.*${eP(r.suffix)}$`);r.pattern??(r.pattern=a),t._zod.check=a=>{a.value.endsWith(r.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:a.value,inst:t,continue:!r.abort})}}),tK=eX("$ZodCheckOverwrite",(t,r)=>{tk.init(t,r),t._zod.check=t=>{t.value=r.tx(t.value)}});class tF{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),a=Math.min(...r.map(t=>t.length-t.trimStart().length));for(let t of r.map(t=>t.slice(a)).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(", ")}) {
3
+ -----END ${r}-----`},ez=async(t,r,a)=>{if(V(a)){if(a.type!==t)throw TypeError(`key is not a ${t} key`);return a.export({format:"pem",type:r})}if(!H(a))throw TypeError(E(a,"CryptoKey","KeyObject"));if(!a.extractable)throw TypeError("CryptoKey is not extractable");if(a.type!==t)throw TypeError(`key is not a ${t} key`);return eq(m(new Uint8Array(await crypto.subtle.exportKey(r,a))),`${t.toUpperCase()} KEY`)},eD=(t,r)=>{if(t.byteLength!==r.length)return!1;for(let a=0;a<t.byteLength;a++)if(t[a]!==r[a])return!1;return!0},eL=t=>({data:t,pos:0}),eU=t=>{let r=t.data[t.pos++];if(128&r){let a=127&r,o=0;for(let r=0;r<a;r++)o=o<<8|t.data[t.pos++];return o}return r},eH=(t,r=1)=>{if(r<=0)return;t.pos++;let a=eU(t);t.pos+=a,r>1&&eH(t,r-1)},eV=(t,r,a)=>{if(t.data[t.pos++]!==r)throw Error(a)},eK=(t,r)=>{let a=t.data.subarray(t.pos,t.pos+r);return t.pos+=r,a},eF=t=>{let r,a=(eV(t,6,"Expected algorithm OID"),r=eU(t),eK(t,r));if(eD(a,[43,101,110]))return"X25519";if(!eD(a,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");eV(t,6,"Expected curve OID");let o=eU(t),i=eK(t,o);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(eD(i,r))return t;throw Error("Unsupported named curve")},eJ=async(t,r,a,o)=>{let i,n,s="spki"===t,l=()=>s?["verify"]:["sign"];switch(a){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${a.slice(-3)}`},n=l();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${a.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(a.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"})[a]},n=l();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{let t=o.getNamedCurve(r);i="X25519"===t?{name:"X25519"}:{name:"ECDH",namedCurve:t}}catch(t){throw new x("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:a},n=l();break;default:throw new x('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(t,r,i,o?.extractable??!!s,n)},eW=(t,r)=>y(t.replace(r,"")),eB=(t,r,a)=>{let o=eW(t,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g),i=a;return r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r=eL(t);return eV(r,48,"Invalid SPKI structure"),eU(r),eV(r,48,"Expected algorithm identifier"),eU(r),r.pos,eF(r)}),eJ("spki",o,r,i)};async function eG(t,r,a){if("string"!=typeof t||0!==t.indexOf("-----BEGIN PUBLIC KEY-----"))throw TypeError('"spki" must be SPKI formatted string');return eB(t,r,a)}async function eZ(t,r,a){if("string"!=typeof t||0!==t.indexOf("-----BEGIN CERTIFICATE-----"))throw TypeError('"x509" must be X.509 formatted string');return((t,r,a)=>{let o;try{var i;let r,a,n;r=eL(i=eW(t,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g)),eV(r,48,"Invalid certificate structure"),eU(r),eV(r,48,"Invalid tbsCertificate structure"),eU(r),160===i[r.pos]?eH(r,6):eH(r,5),a=r.pos,eV(r,48,"Invalid SPKI structure"),n=eU(r),o=i.subarray(a,a+n+(r.pos-a))}catch(t){throw TypeError("Failed to parse the X.509 certificate",{cause:t})}return eB(eq(m(o),"PUBLIC KEY"),r,a)})(t,r,a)}async function eX(t,r,a){let o,i;if("string"!=typeof t||0!==t.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return o=eW(t,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),i=a,r?.startsWith?.("ECDH-ES")&&((i||={}).getNamedCurve=t=>{let r,a=eL(t);return eV(a,48,"Invalid PKCS#8 structure"),eU(a),eV(a,2,"Expected version field"),r=eU(a),a.pos+=r,eV(a,48,"Expected algorithm identifier"),eU(a),a.pos,eF(a)}),eJ("pkcs8",o,r,i)}async function eY(t,r,a){let o;if(!eu(t))throw TypeError("JWK must be an object");switch(r??=t.alg,o??=a?.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 x('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return eA({...t,alg:r,ext:o});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 eA({...t,ext:o});case"EC":case"OKP":return eA({...t,alg:r,ext:o});default:throw new x('Unsupported "kty" (Key Type) Parameter value')}}async function eQ(t){if(V(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(!H(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:a,alg:o,use:i,...n}=await crypto.subtle.exportKey("jwk",t);return"AKP"===n.kty&&(n.alg=o),n}async function e0(t){return ez("public","spki",t)}async function e1(t){return ez("private","pkcs8",t)}async function e2(t){return eQ(t)}async function e9(t,r,a,o){let i=t.slice(0,7),n=await eo(i,a,r,o,new Uint8Array);return{encryptedKey:n.ciphertext,iv:v(n.iv),tag:v(n.tag)}}async function e4(t,r,a,o,i){return ei(t.slice(0,7),r,a,o,i,new Uint8Array)}let e5='Invalid or unsupported "alg" (JWE Algorithm) header value';function e6(t){if(void 0===t)throw new j("JWE Encrypted Key missing")}async function e3(t,r,a,o,i){switch(t){case"dir":if(void 0!==a)throw new j("Encountered unexpected JWE Encrypted Key");return r;case"ECDH-ES":if(void 0!==a)throw new j("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let i,n;if(!eu(o.epk))throw new j('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(U(r),!eS(r))throw new x("ECDH with the provided key is not allowed or not supported by your javascript runtime");let s=await eY(o.epk,t);if(U(s),void 0!==o.apu){if("string"!=typeof o.apu)throw new j('JOSE Header "apu" (Agreement PartyUInfo) invalid');i=el(o.apu,"apu",j)}if(void 0!==o.apv){if("string"!=typeof o.apv)throw new j('JOSE Header "apv" (Agreement PartyVInfo) invalid');n=el(o.apv,"apv",j)}let l=await eb(s,r,"ECDH-ES"===t?o.enc:t,"ECDH-ES"===t?F(o.enc):parseInt(t.slice(-5,-2),10),i,n);if("ECDH-ES"===t)return l;return e6(a),ey(t.slice(-6),l,a)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return e6(a),U(r),eC(t,r,a);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let n;if(e6(a),"number"!=typeof o.p2c)throw new j('JOSE Header "p2c" (PBES2 Count) missing or invalid');let s=i?.maxPBES2Count||1e4;if(o.p2c>s)throw new j('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof o.p2s)throw new j('JOSE Header "p2s" (PBES2 Salt) missing or invalid');return n=el(o.p2s,"p2s",j),e$(t,r,a,o.p2c,n)}case"A128KW":case"A192KW":case"A256KW":return e6(a),ey(t,r,a);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":if(e6(a),"string"!=typeof o.iv)throw new j('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof o.tag)throw new j('JOSE Header "tag" (Authentication Tag) missing or invalid');return e4(t,r,a,el(o.iv,"iv",j),el(o.tag,"tag",j));default:throw new x(e5)}}async function e8(t,r,a,o,i={}){let n,s,l;switch(t){case"dir":l=a;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let c;if(U(a),!eS(a))throw new x("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(a.algorithm,!0,["deriveBits"])).privateKey;let{x:p,y:h,crv:f,kty:m}=await e2(c),y=await eb(a,c,"ECDH-ES"===t?r:t,"ECDH-ES"===t?F(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=o||J(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=o||J(r),U(a),n=await ex(t,a,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=o||J(r);let{p2c:c,p2s:u}=i;({encryptedKey:n,...s}=await ew(t,a,l,c,u));break}case"A128KW":case"A192KW":case"A256KW":l=o||J(r),n=await em(t,a,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=o||J(r);let{iv:c}=i;({encryptedKey:n,...s}=await e9(t,a,l,c));break}default:throw new x(e5)}return{cek:l,encryptedKey:n,parameters:s}}function e7(t,r,a,o,i){let n;if(void 0!==i.crit&&o?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return new Set;if(!Array.isArray(o.crit)||0===o.crit.length||o.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!==a?new Map([...Object.entries(a),...r.entries()]):r,o.crit)){if(!n.has(s))throw new x(`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===o[s])throw new t(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(o.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,a)=>{if(void 0!==r.use){let t;switch(a){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 o;switch(!0){case"sign"===a||"verify"===a:case"dir"===t:case t.includes("CBC-HS"):o=a;break;case t.startsWith("PBES2"):o="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(t):o=!t.includes("GCM")&&t.endsWith("KW")?"encrypt"===a?"wrapKey":"unwrapKey":a;break;case"encrypt"===a&&t.startsWith("RSA"):o="wrapKey";break;case"decrypt"===a:o=t.startsWith("RSA")?"unwrapKey":"deriveBits"}if(o&&r.key_ops?.includes?.(o)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}return!0};function ta(t,r,a){switch(t.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((t,r,a)=>{if(!(r instanceof Uint8Array)){if(ep(r)){if("oct"===r.kty&&"string"==typeof r.k&&tr(t,r,a))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(!K(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,a);break;default:((t,r,a)=>{if(ep(r))switch(a){case"decrypt":case"sign":if("oct"!==r.kty&&("AKP"===r.kty&&"string"==typeof r.priv||"string"==typeof r.d)&&tr(t,r,a))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,a))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!K(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(a){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(a){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,a)}}function to(t){if(void 0===globalThis[t])throw new x(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${t} API.`)}async function ti(t){to("CompressionStream");let r=new CompressionStream("deflate-raw"),a=r.writable.getWriter();a.write(t).catch(()=>{}),a.close().catch(()=>{});let o=[],i=r.readable.getReader();for(;;){let{value:t,done:r}=await i.read();if(r)break;o.push(t)}return u(...o)}async function tn(t,r){to("DecompressionStream");let a=new DecompressionStream("deflate-raw"),o=a.writable.getWriter();o.write(t).catch(()=>{}),o.close().catch(()=>{});let i=[],n=0,s=a.readable.getReader();for(;;){let{value:t,done:a}=await s.read();if(a)break;if(i.push(t),n+=t.byteLength,r!==1/0&&n>r)throw new j("Decompressed plaintext exceeded the configured limit")}return u(...i)}async function ts(t,r,a){let o,i,n,s,l,d;if(!eu(t))throw new j("Flattened JWE must be an object");if(void 0===t.protected&&void 0===t.header&&void 0===t.unprotected)throw new j("JOSE Header missing");if(void 0!==t.iv&&"string"!=typeof t.iv)throw new j("JWE Initialization Vector incorrect type");if("string"!=typeof t.ciphertext)throw new j("JWE Ciphertext missing or incorrect type");if(void 0!==t.tag&&"string"!=typeof t.tag)throw new j("JWE Authentication Tag incorrect type");if(void 0!==t.protected&&"string"!=typeof t.protected)throw new j("JWE Protected Header incorrect type");if(void 0!==t.encrypted_key&&"string"!=typeof t.encrypted_key)throw new j("JWE Encrypted Key incorrect type");if(void 0!==t.aad&&"string"!=typeof t.aad)throw new j("JWE AAD incorrect type");if(void 0!==t.header&&!eu(t.header))throw new j("JWE Shared Unprotected Header incorrect type");if(void 0!==t.unprotected&&!eu(t.unprotected))throw new j("JWE Per-Recipient Unprotected Header incorrect type");if(t.protected)try{let r=g(t.protected);o=JSON.parse(c.decode(r))}catch{throw new j("JWE Protected Header is invalid")}if(!ed(o,t.header,t.unprotected))throw new j("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let p={...o,...t.header,...t.unprotected};if(e7(j,new Map,a?.crit,o,p),void 0!==p.zip&&"DEF"!==p.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==p.zip&&!o?.zip)throw new j('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 j("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof m||!m)throw new j("missing JWE Encryption Algorithm (enc) in JWE Header");let y=a&&te("keyManagementAlgorithms",a.keyManagementAlgorithms),v=a&&te("contentEncryptionAlgorithms",a.contentEncryptionAlgorithms);if(y&&!y.has(h)||!y&&h.startsWith("PBES2"))throw new O('"alg" (Algorithm) Header Parameter value not allowed');if(v&&!v.has(m))throw new O('"enc" (Encryption Algorithm) Header Parameter value not allowed');void 0!==t.encrypted_key&&(i=el(t.encrypted_key,"encrypted_key",j));let b=!1;"function"==typeof r&&(r=await r(o,t),b=!0),ta("dir"===h?m:h,r,"decrypt");let S=await eM(r,h);try{n=await e3(h,S,i,p,a)}catch(t){if(t instanceof TypeError||t instanceof j||t instanceof x)throw t;n=J(m)}void 0!==t.iv&&(s=el(t.iv,"iv",j)),void 0!==t.tag&&(l=el(t.tag,"tag",j));let _=void 0!==t.protected?f(t.protected):new Uint8Array;d=void 0!==t.aad?u(_,f("."),f(t.aad)):_;let w=el(t.ciphertext,"ciphertext",j),$=await ei(m,n,w,s,l,d),E={plaintext:$};if("DEF"===p.zip){let t=a?.maxDecompressedLength??25e4;if(0===t)throw new x('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 j)throw t;throw new j("Failed to decompress plaintext",{cause:t})})}return(void 0!==t.protected&&(E.protectedHeader=o),void 0!==t.aad&&(E.additionalAuthenticatedData=el(t.aad,"aad",j)),void 0!==t.unprotected&&(E.sharedUnprotectedHeader=t.unprotected),void 0!==t.header&&(E.unprotectedHeader=t.header),b)?{...E,key:S}:E}async function tl(t,r,a){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new j("Compact JWE must be a string or Uint8Array");let{0:o,1:i,2:n,3:s,4:l,length:u}=t.split(".");if(5!==u)throw new j("Invalid Compact JWE");let d=await ts({ciphertext:s,iv:n||void 0,protected:o,tag:l||void 0,encrypted_key:i||void 0},r,a),p={plaintext:d.plaintext,protectedHeader:d.protectedHeader};return"function"==typeof r?{...p,key:d.key}:p}async function tc(t,r,a){if(!eu(t))throw new j("General JWE must be an object");if(!Array.isArray(t.recipients)||!t.recipients.every(eu))throw new j("JWE Recipients missing or incorrect type");if(!t.recipients.length)throw new j("JWE Recipients has no members");for(let o of t.recipients)try{return await ts({aad:t.aad,ciphertext:t.ciphertext,encrypted_key:o.encrypted_key,header:o.header,iv:t.iv,protected:t.protected,tag:t.tag,unprotected:t.unprotected},r,a)}catch{}throw new C}class tu{#e;#t;#r;#a;#o;#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.#a,"setUnprotectedHeader"),this.#a=t,this}setAdditionalAuthenticatedData(t){return this.#o=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 a,o,i,n,s,l;if(!this.#t&&!this.#a&&!this.#r)throw new j("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ed(this.#t,this.#a,this.#r))throw new j("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let c={...this.#t,...this.#a,...this.#r};if(e7(j,new Map,r?.crit,this.#t,c),void 0!==c.zip&&"DEF"!==c.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==c.zip&&!this.#t?.zip)throw new j('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 j('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof p||!p)throw new j('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}`);ta("dir"===d?p:d,t,"encrypt");{let i,n=await eM(t,d);({cek:o,encryptedKey:a,parameters:i}=await e8(d,p,n,this.#i,this.#s)),i&&(r&&en in r?this.#a?this.#a={...this.#a,...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.#o){let t=f(l=v(this.#o));i=u(s,f("."),t)}else i=s;let h=this.#e;"DEF"===c.zip&&(h=await ti(h).catch(t=>{throw new j("Failed to compress plaintext",{cause:t})}));let{ciphertext:m,tag:y,iv:g}=await eo(p,h,o,this.#n,i),b={ciphertext:v(m)};return g&&(b.iv=v(g)),y&&(b.tag=v(y)),a&&(b.encrypted_key=v(a)),l&&(b.aad=l),this.#t&&(b.protected=n),this.#r&&(b.unprotected=this.#r),this.#a&&(b.header=this.#a),b}}class td{#l;unprotectedHeader;keyManagementParameters;key;options;constructor(t,r,a){this.#l=t,this.key=r,this.options=a}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;#a;#o;constructor(t){this.#e=t}addRecipient(t,r){let a=new td(this,t,{crit:r?.crit});return this.#c.push(a),a}setProtectedHeader(t){return es(this.#t,"setProtectedHeader"),this.#t=t,this}setSharedUnprotectedHeader(t){return es(this.#a,"setSharedUnprotectedHeader"),this.#a=t,this}setAdditionalAuthenticatedData(t){return this.#o=t,this}async encrypt(){let t;if(!this.#c.length)throw new j("at least one recipient must be added");if(1===this.#c.length){let[t]=this.#c,r=await new tu(this.#e).setAdditionalAuthenticatedData(this.#o).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#a).setUnprotectedHeader(t.unprotectedHeader).encrypt(t.key,{...t.options}),a={ciphertext:r.ciphertext,iv:r.iv,recipients:[{}],tag:r.tag};return r.aad&&(a.aad=r.aad),r.protected&&(a.protected=r.protected),r.unprotected&&(a.unprotected=r.unprotected),r.encrypted_key&&(a.recipients[0].encrypted_key=r.encrypted_key),r.header&&(a.recipients[0].header=r.header),a}for(let r=0;r<this.#c.length;r++){let a=this.#c[r];if(!ed(this.#t,this.#a,a.unprotectedHeader))throw new j("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let o={...this.#t,...this.#a,...a.unprotectedHeader},{alg:i}=o;if("string"!=typeof i||!i)throw new j('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===i||"ECDH-ES"===i)throw new j('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof o.enc||!o.enc)throw new j('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(t){if(t!==o.enc)throw new j('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else t=o.enc;if(e7(j,new Map,a.options.crit,this.#t,o),void 0!==o.zip&&"DEF"!==o.zip)throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==o.zip&&!this.#t?.zip)throw new j('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}let r=J(t),a={ciphertext:"",recipients:[]};for(let o=0;o<this.#c.length;o++){let i=this.#c[o],n={};if(a.recipients.push(n),0===o){let t=await new tu(this.#e).setAdditionalAuthenticatedData(this.#o).setContentEncryptionKey(r).setProtectedHeader(this.#t).setSharedUnprotectedHeader(this.#a).setUnprotectedHeader(i.unprotectedHeader).setKeyManagementParameters(i.keyManagementParameters).encrypt(i.key,{...i.options,[en]:!0});a.ciphertext=t.ciphertext,a.iv=t.iv,a.tag=t.tag,t.aad&&(a.aad=t.aad),t.protected&&(a.protected=t.protected),t.unprotected&&(a.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.#a?.alg;ta("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 a}}async function th(t,r,a){if(!eu(t))throw new A("Flattened JWS must be an object");if(void 0===t.protected&&void 0===t.header)throw new A('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==t.protected&&"string"!=typeof t.protected)throw new A("JWS Protected Header incorrect type");if(void 0===t.payload)throw new A("JWS Payload missing");if("string"!=typeof t.signature)throw new A("JWS Signature missing or incorrect type");if(void 0!==t.header&&!eu(t.header))throw new A("JWS Unprotected Header incorrect type");let o={};if(t.protected)try{let r=g(t.protected);o=JSON.parse(c.decode(r))}catch{throw new A("JWS Protected Header is invalid")}if(!ed(o,t.header))throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...o,...t.header},n=e7(A,new Map([["b64",!0]]),a?.crit,o,i),s=!0;if(n.has("b64")&&"boolean"!=typeof(s=o.b64))throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=i;if("string"!=typeof d||!d)throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');let p=a&&te("algorithms",a.algorithms);if(p&&!p.has(d))throw new O('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof t.payload)throw new A("JWS Payload must be a string")}else if("string"!=typeof t.payload&&!(t.payload instanceof Uint8Array))throw new A("JWS Payload must be a string or an Uint8Array instance");let h=!1;"function"==typeof r&&(r=await r(o,t),h=!0),ta(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",A),v=await eM(r,d);if(!await eT(d,v,y,m))throw new L;let b={payload:s?el(t.payload,"payload",A):"string"==typeof t.payload?l.encode(t.payload):t.payload};return(void 0!==t.protected&&(b.protectedHeader=o),void 0!==t.header&&(b.unprotectedHeader=t.header),h)?{...b,key:v}:b}async function tf(t,r,a){if(t instanceof Uint8Array&&(t=c.decode(t)),"string"!=typeof t)throw new A("Compact JWS must be a string or Uint8Array");let{0:o,1:i,2:n,length:s}=t.split(".");if(3!==s)throw new A("Invalid Compact JWS");let l=await th({payload:i,protected:o,signature:n},r,a),u={payload:l.payload,protectedHeader:l.protectedHeader};return"function"==typeof r?{...u,key:l.key}:u}async function tm(t,r,a){if(!eu(t))throw new A("General JWS must be an object");if(!Array.isArray(t.signatures)||!t.signatures.every(eu))throw new A("JWS Signatures missing or incorrect type");for(let o of t.signatures)try{return await th({header:o.header,payload:t.payload,protected:o.protected,signature:o.signature},r,a)}catch{}throw new L}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,a=tg.exec(t);if(!a||a[4]&&a[1])throw TypeError("Invalid time period format");let o=parseFloat(a[2]);switch(a[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":r=Math.round(o);break;case"minute":case"minutes":case"min":case"mins":case"m":r=Math.round(60*o);break;case"hour":case"hours":case"hr":case"hrs":case"h":r=Math.round(3600*o);break;case"day":case"days":case"d":r=Math.round(86400*o);break;case"week":case"weeks":case"w":r=Math.round(604800*o);break;default:r=Math.round(0x1e187e0*o)}return"-"===a[1]||"ago"===a[4]?-r:r}function tb(t,r){if(!Number.isFinite(r))throw TypeError(`Invalid ${t} input`);return r}let tS=t=>t.includes("/")?t.toLowerCase():`application/${t.toLowerCase()}`;function t_(t,r,a={}){var o,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}=a;if(l&&("string"!=typeof t.typ||tS(t.typ)!==tS(l)))throw new k('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:u=[],issuer:d,subject:p,audience:h,maxTokenAge:f}=a,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 k(`missing required "${t}" claim`,n,t,"missing");if(d&&!(Array.isArray(d)?d:[d]).includes(n.iss))throw new k('unexpected "iss" claim value',n,"iss","check_failed");if(p&&n.sub!==p)throw new k('unexpected "sub" claim value',n,"sub","check_failed");if(h&&(o=n.aud,i="string"==typeof h?[h]:h,"string"==typeof o?!i.includes(o):!(Array.isArray(o)&&i.some(Set.prototype.has.bind(new Set(o))))))throw new k('unexpected "aud" claim value',n,"aud","check_failed");switch(typeof a.clockTolerance){case"string":s=tv(a.clockTolerance);break;case"number":s=a.clockTolerance;break;case"undefined":s=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:y}=a,g=ty(y||new Date);if((void 0!==n.iat||f)&&"number"!=typeof n.iat)throw new k('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new k('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>g+s)throw new k('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new k('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=g-s)throw new T('"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 T('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(t<0-s)throw new k('"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=tb("setNotBefore",t):t instanceof Date?this.#u.nbf=tb("setNotBefore",ty(t)):this.#u.nbf=ty(new Date)+tv(t)}set exp(t){"number"==typeof t?this.#u.exp=tb("setExpirationTime",t):t instanceof Date?this.#u.exp=tb("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=tb("setIssuedAt",ty(t)):"string"==typeof t?this.#u.iat=tb("setIssuedAt",ty(new Date)+tv(t)):this.#u.iat=tb("setIssuedAt",t)}}async function t$(t,r,a){let o=await tf(t,r,a);if(o.protectedHeader.crit?.includes("b64")&&!1===o.protectedHeader.b64)throw new I("JWTs MUST NOT use unencoded payload");let i={payload:t_(o.protectedHeader,o.payload,a),protectedHeader:o.protectedHeader};return"function"==typeof r?{...i,key:o.key}:i}async function tE(t,r,a){let o=await tl(t,r,a),i=t_(o.protectedHeader,o.plaintext,a),{protectedHeader:n}=o;if(void 0!==n.iss&&n.iss!==i.iss)throw new k('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==n.sub&&n.sub!==i.sub)throw new k('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==n.aud&&JSON.stringify(n.aud)!==JSON.stringify(i.aud))throw new k('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let s={payload:i,protectedHeader:n};return"function"==typeof r?{...s,key:o.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 a=await this.#d.encrypt(t,r);return[a.protected,a.encrypted_key,a.iv,a.ciphertext,a.tag].join(".")}}class tR{#u;#t;#a;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.#a,"setUnprotectedHeader"),this.#a=t,this}async sign(t,r){let a,o,i,n;if(!this.#t&&!this.#a)throw new A("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ed(this.#t,this.#a))throw new A("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let s={...this.#t,...this.#a},l=e7(A,new Map([["b64",!0]]),r?.crit,this.#t,s),c=!0;if(l.has("b64")&&"boolean"!=typeof(c=this.#t.b64))throw new A('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:d}=s;if("string"!=typeof d||!d)throw new A('JWS "alg" (Algorithm) Header Parameter missing or invalid');ta(d,t,"sign"),c?o=f(a=v(this.#u)):(o=this.#u,a=""),this.#t?n=f(i=v(JSON.stringify(this.#t))):(i="",n=new Uint8Array);let p=u(n,f("."),o),h=await eM(t,d),m={signature:v(await ek(d,h,p)),payload:a};return this.#a&&(m.header=this.#a),this.#t&&(m.protected=i),m}}class tk{#d;constructor(t){this.#d=new tR(t)}setProtectedHeader(t){return this.#d.setProtectedHeader(t),this}async sign(t,r){let a=await this.#d.sign(t,r);if(void 0===a.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${a.protected}.${a.payload}.${a.signature}`}}class tT{#l;protectedHeader;unprotectedHeader;options;key;constructor(t,r,a){this.#l=t,this.key=r,this.options=a}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 tO{#u;#p=[];constructor(t){this.#u=t}addSignature(t,r){let a=new tT(this,t,r);return this.#p.push(a),a}async sign(){if(!this.#p.length)throw new A("at least one signature must be added");let t={signatures:[],payload:""};for(let r=0;r<this.#p.length;r++){let a=this.#p[r],o=new tR(this.#u);o.setProtectedHeader(a.protectedHeader),o.setUnprotectedHeader(a.unprotectedHeader);let{payload:i,...n}=await o.sign(a.key,a.options);if(0===r)t.payload=i;else if(t.payload!==i)throw new A("inconsistent use of JWS Unencoded Payload (RFC7797)");t.signatures.push(n)}return t}}class tx{#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 a=new tk(this.#h.data());if(a.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 a.sign(t,r)}}class tC{#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 a=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}),a.setProtectedHeader(this.#t),this.#n&&a.setInitializationVector(this.#n),this.#i&&a.setContentEncryptionKey(this.#i),this.#s&&a.setKeyManagementParameters(this.#s),a.encrypt(t,r)}}let tj=(t,r)=>{if("string"!=typeof t||!t)throw new N(`${r} missing or invalid`)};async function tA(t,r){let a,o;if(ep(t))a=t;else if(K(t))a=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(a.kty){case"AKP":tj(a.alg,'"alg" (Algorithm) Parameter'),tj(a.pub,'"pub" (Public key) Parameter'),o={alg:a.alg,kty:a.kty,pub:a.pub};break;case"EC":tj(a.crv,'"crv" (Curve) Parameter'),tj(a.x,'"x" (X Coordinate) Parameter'),tj(a.y,'"y" (Y Coordinate) Parameter'),o={crv:a.crv,kty:a.kty,x:a.x,y:a.y};break;case"OKP":tj(a.crv,'"crv" (Subtype of Key Pair) Parameter'),tj(a.x,'"x" (Public Key) Parameter'),o={crv:a.crv,kty:a.kty,x:a.x};break;case"RSA":tj(a.e,'"e" (Exponent) Parameter'),tj(a.n,'"n" (Modulus) Parameter'),o={e:a.e,kty:a.kty,n:a.n};break;case"oct":tj(a.k,'"k" (Key Value) Parameter'),o={k:a.k,kty:a.kty};break;default:throw new x('"kty" (Key Type) Parameter missing or unsupported')}let i=f(JSON.stringify(o));return v(await ec(r,i))}async function tI(t,r){r??="sha256";let a=await tA(t,r);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${r.slice(-3)}:${a}`}async function tN(t,r){let a={...t,...r?.header};if(!eu(a.jwk))throw new A('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let o=await eY({...a.jwk,ext:!0},a.alg);if(o instanceof Uint8Array||"public"!==o.type)throw new A('"jwk" (JSON Web Key) Header Parameter must be a public key');return o}function tM(t){return eu(t)}class tq{#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:a,kid:o}={...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 x('Unsupported "alg" value for a JSON Web Key Set')}}(a),n=this.#g.keys.filter(t=>{let r=i===t.kty;if(r&&"string"==typeof o&&(r=o===t.kid),r&&("string"==typeof t.alg||"AKP"===i)&&(r=a===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(a){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 q;if(1!==l){let t=new z,r=this.#v;throw t[Symbol.asyncIterator]=async function*(){for(let t of n)try{yield await tz(r,t,a)}catch{}},t}return tz(this.#v,s,a)}}async function tz(t,r,a){let o=t.get(r)||t.set(r,{}).get(r);if(void 0===o[a]){let t=await eY({...r,ext:!0},a);if(t instanceof Uint8Array||"public"!==t.type)throw new M("JSON Web Key Set members must be public keys");o[a]=t}return o[a]}function tD(t){let r=new tq(t),a=async(t,a)=>r.getKey(t,a);return Object.defineProperties(a,{jwks:{value:()=>structuredClone(r.jwks()),enumerable:!1,configurable:!1,writable:!1}}),a}"undefined"!=typeof navigator&&navigator.userAgent?.startsWith?.("Mozilla/5.0 ")||(i="jose/v6.2.3");let tL=Symbol();async function tU(t,r,a,o=fetch){let i=await o(t,{method:"GET",signal:a,redirect:"manual",headers:r}).catch(t=>{if("TimeoutError"===t.name)throw new D;throw t});if(200!==i.status)throw new R("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new R("Failed to parse the JSON Web Key Set HTTP response as JSON")}}let tH=Symbol();class tV{#b;#S;#_;#w;#$;#E;#P;#R;#k;#T;constructor(t,r){if(!(t instanceof URL))throw TypeError("url must be an instance of URL");this.#b=new URL(t.href),this.#S="number"==typeof r?.timeoutDuration?r?.timeoutDuration:5e3,this.#_="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.#R=r?.[tL],r?.[tH]!==void 0&&(this.#T=r?.[tH],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?.[tH],this.#w)&&(this.#$=this.#T.uat,this.#k=tD(this.#T.jwks)))}pendingFetch(){return!!this.#E}coolingDown(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#_}fresh(){return"number"==typeof this.#$&&Date.now()<this.#$+this.#w}jwks(){return this.#k?.jwks()}async getKey(t,r){this.#k&&this.fresh()||await this.reload();try{return await this.#k(t,r)}catch(a){if(a instanceof q&&!1===this.coolingDown())return await this.reload(),this.#k(t,r);throw a}}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||=tU(this.#b.href,this.#P,AbortSignal.timeout(this.#S),this.#R).then(t=>{this.#k=tD(t),this.#T&&(this.#T.uat=Date.now(),this.#T.jwks=t),this.#$=Date.now(),this.#E=void 0}).catch(t=>{throw this.#E=void 0,t}),await this.#E}}function tK(t,r){let a=new tV(t,r),o=async(t,r)=>a.getKey(t,r);return Object.defineProperties(o,{coolingDown:{get:()=>a.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>a.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>a.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>a.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>a.jwks(),enumerable:!0,configurable:!1,writable:!1}}),o}class tF{#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 a;if("string"!=typeof t)throw new I("Unsecured JWT must be a string");let{0:o,1:i,2:n,length:s}=t.split(".");if(3!==s||""!==n)throw new I("Invalid Unsecured JWT");try{if(a=JSON.parse(c.decode(g(o))),"none"!==a.alg)throw Error()}catch{throw new I("Invalid Unsecured JWT")}return{payload:t_(a,g(i),r),header:a}}}function tJ(t){let r;if("string"==typeof t){let a=t.split(".");(3===a.length||5===a.length)&&([r]=a)}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 tW(t){let r,a;if("string"!=typeof t)throw new I("JWTs must use Compact JWS serialization, JWT must be a string");let{1:o,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(!o)throw new I("JWTs must contain a payload");try{r=g(o)}catch{throw new I("Failed to base64url decode the payload")}try{a=JSON.parse(c.decode(r))}catch{throw new I("Failed to parse the decoded payload as JSON")}if(!eu(a))throw new I("Invalid JWT Claims Set");return a}function tB(t){let r=t?.modulusLength??2048;if("number"!=typeof r||r<2048)throw new x("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return r}async function tG(t,r){let a,o;switch(t){case"PS256":case"PS384":case"PS512":a={name:"RSA-PSS",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["sign","verify"];break;case"RS256":case"RS384":case"RS512":a={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":a={name:"RSA-OAEP",hash:`SHA-${parseInt(t.slice(-3),10)||1}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:tB(r)},o=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":a={name:"ECDSA",namedCurve:"P-256"},o=["sign","verify"];break;case"ES384":a={name:"ECDSA",namedCurve:"P-384"},o=["sign","verify"];break;case"ES512":a={name:"ECDSA",namedCurve:"P-521"},o=["sign","verify"];break;case"Ed25519":case"EdDSA":o=["sign","verify"],a={name:"Ed25519"};break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":o=["sign","verify"],a={name:t};break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{o=["deriveBits"];let t=r?.crv??"P-256";switch(t){case"P-256":case"P-384":case"P-521":a={name:"ECDH",namedCurve:t};break;case"X25519":a={name:"X25519"};break;default:throw new x("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}break}default:throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(a,r?.extractable??!1,o)}async function tZ(t,r){let a,o,i;switch(t){case"HS256":case"HS384":case"HS512":a=parseInt(t.slice(-3),10),o={name:"HMAC",hash:`SHA-${a}`,length:a},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return a=parseInt(t.slice(-3),10),crypto.getRandomValues(new Uint8Array(a>>3));case"A128KW":case"A192KW":case"A256KW":o={name:"AES-KW",length:a=parseInt(t.slice(1,4),10)},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":o={name:"AES-GCM",length:a=parseInt(t.slice(1,4),10)},i=["encrypt","decrypt"];break;default:throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(o,r?.extractable??!1,i)}let tX="WebCryptoAPI"},4519(t){"use strict";t.exports=JSON.parse('{"name":"dotenv","version":"16.6.1","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}')},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}}}')}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var a=i[t]={exports:{}};return o[t](a,a.exports,n),a.exports}n.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return n.d(r,{a:r}),r},a=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o||"object"==typeof t&&t&&(4&o&&t.__esModule||16&o&&"function"==typeof t.then))return t;var i=Object.create(null);n.r(i);var s={};r=r||[null,a({}),a([]),a(a)];for(var l=2&o&&t;("object"==typeof l||"function"==typeof l)&&!~r.indexOf(l);l=a(l))Object.getOwnPropertyNames(l).forEach(r=>{s[r]=()=>t[r]});return s.default=()=>t,n.d(i,s),i},n.d=(t,r)=>{for(var a in r)n.o(r,a)&&!n.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},n.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{"use strict";let t,r,a,o,i,l,c,u,d,p,h,f,m,y,g,v,b,S,_;n.r(s),n.d(s,{HOST_CONTEXT_CHANGED_METHOD:()=>yg,isEnvHeader:()=>m3,createSTDIOClient:()=>ya,INITIALIZE_METHOD:()=>yc,LOG_MESSAGE_METHOD:()=>ym,OPEN_LINK_METHOD:()=>yp,REQUEST_DISPLAY_MODE_METHOD:()=>yd,inputResponse:()=>ch,disconnectSTDIOClient:()=>yn,embeddedResource:()=>B,isInputRequiredResult:()=>l7,callSTDIOClientTool:()=>yi,headersToRecord:()=>m8,MCP_APPS_PROTOCOL_VERSION:()=>yl,extractToolNamesFromRequest:()=>ys,UI_MESSAGE_METHOD:()=>yf,completable:()=>u3,acceptedContent:()=>cp,listSTDIOClientTools:()=>yo,UPDATE_MODEL_CONTEXT_METHOD:()=>yh,UrlElicitationRequiredError:()=>l9,createRequestStateCodec:()=>de,audio:()=>W,createMcpHostBridge:()=>y_,SIZE_CHANGED_METHOD:()=>yv,image:()=>J,INITIALIZED_METHOD:()=>yu,inputRequired:()=>cd,RESOURCES_READ_METHOD:()=>yy,createContext:()=>K,getRequestContext:()=>X,jwtAuthMiddleware:()=>L,createHTTPClient:()=>yr,apiKeyAuthMiddleware:()=>q});var w,$,E,P,R,k,T,O,x,C,j=n(8583),A=n.n(j),I=n(4953);let N=I.z.object({apiKey:I.z.string().optional(),headerName:I.z.string().optional(),validateApiKey:I.z.function().args(I.z.string()).returns(I.z.promise(I.z.boolean())).optional()}).strict().refine(t=>void 0!==t.apiKey||void 0!==t.validateApiKey,{message:"Either 'apiKey' or 'validateApiKey' must be provided"}).refine(t=>void 0===t.apiKey||void 0===t.validateApiKey,{message:"'apiKey' and 'validateApiKey' are mutually exclusive - provide only one"}),M="Unauthorized: Missing or invalid API key";function q(t){let r=N.safeParse(t);if(!r.success){let a="apiKey"in t,o="validateApiKey"in t;if(a&&o)throw Error("'apiKey' and 'validateApiKey' are mutually exclusive - provide only one");if(a||o)throw Error(`Invalid configuration: ${r.error.message}`);throw Error("Either 'apiKey' or 'validateApiKey' must be provided")}let a=t.headerName??"x-api-key",o="apiKey"in t?t.apiKey:void 0,i="validateApiKey"in t?t.validateApiKey:void 0;return async(r,n,s)=>{let l=r.header(a);!l||"apiKey"in t&&l!==o||i&&!await i(l)?n.status(401).json({error:M}):s()}}var z=n(8400),D=n.n(z);function L(t){return(r,a,o)=>{let i=r.header("Authorization");if(!i||!i.startsWith("Bearer "))return void a.status(401).json({error:"Unauthorized: Missing or malformed Authorization header"});let n=i.slice(7).trim();if(!n)return void a.status(401).json({error:"Unauthorized: Missing access token"});try{let{secret:a,...i}=t;r.user=D().verify(n,a,i),o()}catch(t){a.status(401).json({error:"Unauthorized: Invalid or expired token"})}}}let U=require("async_hooks"),H=(t,r)=>{globalThis[t]=r},V=t=>globalThis[t];function K({name:t,fallback:r=!0}){let a=Symbol.for(`xmcp-context-${t}`),o=Symbol.for(`xmcp-context-${t}-fallback-store`);if(V(a))return V(a);let i=new U.AsyncLocalStorage,n=globalThis[o]??{current:null};H(o,n);let s={provider:(t,a)=>(r&&(n.current=t),i.run(t,a)),getContext:()=>{let a=i.getStore();if(a)return a;if(r&&n.current)return n.current;throw Error(`getContext() can only be used within the ${t} context.`)},setContext:a=>{let o=i.getStore()??(r?n.current:null);if(!o)throw Error(`setContext() can only be used within the ${t} context.`);Object.assign(o,a)}};return H(a,s),s}function F(t){let r;if(t instanceof Uint8Array)r=t;else if(t instanceof ArrayBuffer)r=new Uint8Array(t);else throw TypeError("Expected bytes as a Uint8Array or ArrayBuffer");let a="";for(let t=0;t<r.length;t+=32768)a+=String.fromCharCode(...r.subarray(t,t+32768));return btoa(a)}function J(t,r){return{type:"image",data:F(t),mimeType:r}}function W(t,r){return{type:"audio",data:F(t),mimeType:r}}function B(t,r,a){return{type:"resource",resource:{uri:t,...void 0===a?{}:{mimeType:a},..."string"==typeof r?{text:r}:{blob:F(r)}}}}let G=K({name:"http-request-context"});G.setContext,G.getContext,G.provider;let Z=K({name:"request-context",fallback:!1});function X(){try{return Z.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}var Y=Object.create,Q=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,er=Object.getPrototypeOf,ea=Object.prototype.hasOwnProperty,eo=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);function ei(t){let r=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,a])=>-1===r.indexOf(+t)).map(([t,r])=>r)}function en(t,r="|"){return t.map(t=>eT(t)).join(r)}function es(t,r){return"bigint"==typeof r?r.toString():r}class el{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 ec(t){return new el(t)}function eu(t){let r=+!!t.startsWith("^"),a=t.endsWith("$")?t.length-1:t.length;return t.slice(r,a)}let ed=Symbol("evaluating");function ep(t,r,a){Object.defineProperty(t,r,{value:a,writable:!0,enumerable:!0,configurable:!0})}function eh(t){let r=Object.getOwnPropertyDescriptor(t,"shape");return r?.get?r.get.raw:r?.value}function ef(t){return eh(t._zod.def)??t._zod.def.shape}function em(t,r,a){Object.defineProperty(t,r,{get(){let t=a();return ep(this,r,t),t},enumerable:!0,configurable:!0})}function ey(t,r,a){r in t?ep(t,r,a):t[r]=a}function eg(t,r,a,o){let i=ef(r);for(let n of a){let a=Object.getOwnPropertyDescriptor(i,n);a.enumerable&&(a.get?em(t,n,()=>{let t=r._zod.def.shape[n];return o?o(t,n):t}):ey(t,n,o?o(a.value,n):a.value))}}function ev(...t){let r={};for(let a of t)Object.assign(r,Object.getOwnPropertyDescriptors(a));return Object.defineProperties({},r)}let eb="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function eS(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let e_=ec(()=>{if(e0.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(t){return!1}});function ew(t){if(!1===eS(t))return!1;let r=t.constructor;if(void 0===r||"function"!=typeof r)return!0;let a=r.prototype;return!1!==eS(a)&&!1!==Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")}function e$(t){return ew(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}let eE=new Set(["string","number","symbol"]);function eP(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eR(t,r,a){let o=new t._zod.constr(r??t._zod.def);return(!r||a?.parent)&&(o._zod.parent=t),o}function ek(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 eT(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}let eO={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]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eC(t,r){let a=ef(t),o=[];for(let t of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(a,t)?.enumerable)throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&o.push(t)}return o}function ej(t,r){let a={};eg(a,t,Reflect.ownKeys(ef(t)));for(let t of Reflect.ownKeys(r)){let o=Object.getOwnPropertyDescriptor(r,t);o.enumerable&&(o.get?em(a,t,()=>r[t]):ey(a,t,o.value))}return a}function eA(t,r,a,o="partial"){let i=r._zod.def.checks;if(i&&i.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let n=a?new Set(eC(r,a)):void 0,s={};return eg(s,r,Reflect.ownKeys(ef(r)),t&&((r,a)=>n&&!n.has(a)?r:new t({type:"optional",innerType:r}))),eR(r,ev(r._zod.def,{shape:s,checks:[]}))}function eI(t,r=0){if(!0===t.aborted)return!0;for(let a=r;a<t.issues.length;a++)if(t.issues[a]?.continue!==!0)return!0;return!1}function eN(t,r){return r.map(r=>(r.path??(r.path=[]),r.path.unshift(t),r))}function eM(t){return"string"==typeof t?t:t?.message}function eq(t,r,a){var o;for(let i=r;i<t.length;i++)(o=t[i]).schema??(o.schema=a)}function ez(t,r,a){let o=t.inst?._zod?.traits;o?.has("$ZodType")&&(o.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:eM(t.inst?._zod.def?.error?.(t))??eM(i?.(t))??eM(r?.error?.(t))??eM(a.customError?.(t))??eM(a.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 eD=/[\uD800-\uDBFF]/;function eL(t){let r=t.length;if(!eD.test(t))return r;let a=r;for(let o=0;o<r-1;o++)(64512&t.charCodeAt(o))==55296&&(64512&t.charCodeAt(o+1))==56320&&(a--,o++);return a}function eU(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function eH(...t){let[r,a,o]=t;return"string"==typeof r?{message:r,code:"custom",input:a,inst:o}:{...r}}function eV(t,r,a,o=!0){return Object.defineProperty(t,r,{configurable:!0,writable:!0,enumerable:o,value:a}),a}function eK(t,r){for(let a in t){let o=t[a];Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get(){return eV(this,a,o(this))},set(t){eV(this,a,t)}})}return r}let eF=!1,eJ={configurable:!0,get(){eF=!0}};function eW(r,a,o){let i=Object.getPrototypeOf(r._zod);if(a in i&&t!==r._zod){t=void 0;return}t=r._zod,Object.defineProperty(i,a,{configurable:!0,get(){Object.defineProperty(this,a,eJ);let t=eF;eF=!1;try{let r=o(this);return eF?delete this[a]:Object.defineProperty(this,a,{configurable:!0,writable:!0,value:r}),eF=eF||t,r}catch(r){throw delete this[a],eF=eF||t,r}},set(t){Object.defineProperty(this,a,{configurable:!0,writable:!0,value:t})}})}let eB=Object.freeze({status:"aborted"}),eG={value:void 0,enumerable:!1},eZ="captureStackTrace"in Error?Error:null;function eX(t,r,a,o){function i(t){this.def=t,this.constr=u,this.traits=new Set}i.prototype={};let n=a&&new WeakSet;function s(o,s){if(o._zod){if(o._zod.traits.has(t))return}else{eG.value=new i(s);try{Object.defineProperty(o,"_zod",eG)}finally{eG.value=void 0}}if(o._zod.traits.add(t),r(o,s),n){let t=Object.getPrototypeOf(o),r=o._zod.constr.prototype,i=t;for(;i&&i!==r;)i=Object.getPrototypeOf(i);let s=i??t;if(!n.has(s)){n.add(s);for(let t in a){let r=Object.getOwnPropertyDescriptor(a,t);r.get?Object.defineProperty(s,t,{...r,enumerable:!1}):function(t,r,a){Object.defineProperty(t,r,{configurable:!0,get(){return this==null?a:eV(this,r,a.bind(this))},set(t){eV(this,r,t)}})}(s,t,r.value)}}}let l=u.prototype;for(let t in l)Object.prototype.hasOwnProperty.call(l,t)&&(t in o||(o[t]=l[t].bind(o)))}let l=o?.Parent??Object;class c extends l{}function u(t){let r=o?.Parent?function(t){let r=eZ;if(r){let a=r.stackTraceLimit;if("number"==typeof a){try{r.stackTraceLimit=0}catch{return eZ=null,new t}try{return new t}finally{r.stackTraceLimit=a}}}return new t}(c):this;s(r,t);let a=r._zod.deferred;if(a){for(let t of a)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=>!!o?.Parent&&r instanceof o.Parent||r?._zod?.traits?.has(t)}),Object.defineProperty(u,"name",{value:t}),u}class eY extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eQ extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(O=globalThis).__zod_globalConfig??(O.__zod_globalConfig={});let e0=globalThis.__zod_globalConfig;function e1(t){return t&&Object.assign(e0,t),e0}class e2 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let e9="~memo",e4=[];function e5(t){return null!==t&&"object"==typeof t}function e6(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}let e3=new WeakMap,e8=[],e7={alloc(t,a,o){let i=r;if(!i)return o;r=void 0;let n={value:o,issues:null};return i.set(a.value,n),e8.push(n),o},guard(t){var r;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,a=(t,a)=>{var o,i;let n;if("backward"!==a.direction&&(o=a,i=t.value,void 0!==(n=o[e9]?.backEdges)&&e5(i)&&n.has(i)))throw new e2;return r(t,a)};t._zod.parse=a,t._zod.run===r&&(t._zod.run=a)})},attach(t){var a;let o,i,n,s=!1;(a=t._zod).deferred??(a.deferred=[]),t._zod.deferred.push(()=>{let a=t._zod.parse,l=(c,u)=>{let d;if(void 0===o){let r=function t(r,a,o){var i,n;let s=e3.get(r);if(void 0!==s)return 2*!!s;if(a.has(r))return 2;a.add(r);let l=0,c=r=>{if(2!==l&&r?._zod){let i=t(r,a,o);i>l&&(l=i)}},u=t=>{t>l&&(l=t)},d=r._zod.def;switch(d.type){case"object":{let r=eh(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,a,o):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??(o?r._zod.innerType:void 0);u(i?t(i,a,!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 a=r.value;if(a&&"object"==typeof a){if(a._zod)c(a);else if(Array.isArray(a))for(let t of a)c(t)}}}return a.delete(r),i=r,1!==(n=l)&&e3.set(i,2===n),n}(t,new Set,!1);if(0===r)return t._zod.parse=a,t._zod.run===l&&(t._zod.run=a),a(c,u);2===r||s?o=!0:s=!0}let p=c.value;if(!e5(p))return a(c,u);let h=u[e9];if(h||(h={buckets:new WeakMap,backEdges:void 0},u[e9]=h),i===u)d=n;else{var f;let r;(r=(f=h).buckets.get(t))||(r=new WeakMap,f.buckets.set(t,r)),d=r,i=u,n=d}let m=d.get(p);if(m)return c.value=m.value,m.issues?m.issues.length&&c.issues.push(...e6(m.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new WeakSet),h.backEdges.add(m.value)),c;r=d;let y=e8.length,g=a(c,u);r=void 0;let v=e8.length>y?e8.pop():void 0;return g instanceof Promise?g.then(t=>(v&&(v.issues=t.issues.length?e6(t.issues):e4),t)):(v&&(v.issues=g.issues.length?e6(g.issues):e4),g)};t._zod.parse=l,t._zod.run===a&&(t._zod.run=l)})}},te=/^[cC][0-9a-z]{6,}$/,tt=/^[0-9a-z]+$/,tr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ta=/^[0-9a-vA-V]{20}$/,to=/^[A-Za-z0-9]{27}$/,ti=/^[a-zA-Z0-9_-]{21}$/,tn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ts=/^([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})$/,tl=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)$/,tc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tu=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,td=/^(?:(?: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])$/,tp=/^(([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}|:))$/,th=/^((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])$/,tf=/^(([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])$/,tm=/^https?$/,ty=/^\+[1-9]\d{6,14}$/,tg="(?:(?:\\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])))",tv=RegExp(`^${tg}$`);function tb(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 tS=/^[\s\S]{0,}$/,t_=/^-?\d+$/,tw=/^-?\d+(?:\.\d+)?$/,t$=/^(?:true|false)$/i,tE=/^null$/i,tP=/^[^A-Z]*$/,tR=/^[^a-z]*$/,tk=eX("$ZodCheck",(t,r)=>{var a;t._zod??(t._zod={}),t._zod.def=r,(a=t._zod).onattach??(a.onattach=[])}),tT=t=>{let r=t.value;return null!=r&&void 0!==r.length},tO={number:"number",bigint:"bigint",object:"date"},tx=eX("$ZodCheckLessThan",(t,r)=>{tk.init(t,r);let a=tO[typeof r.value];t._zod.check=o=>{(r.inclusive?o.value<=r.value:o.value<r.value)||o.issues.push({origin:tO[typeof o.value]??a,code:"too_big",maximum:"object"==typeof r.value?r.value.getTime():r.value,input:o.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tC=eX("$ZodCheckGreaterThan",(t,r)=>{tk.init(t,r);let a=tO[typeof r.value];t._zod.check=o=>{(r.inclusive?o.value>=r.value:o.value>r.value)||o.issues.push({origin:tO[typeof o.value]??a,code:"too_small",minimum:"object"==typeof r.value?r.value.getTime():r.value,input:o.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tj=eX("$ZodCheckMultipleOf",(t,r)=>{tk.init(t,r),t._zod.check=a=>{let o,i,n;if(typeof a.value!=typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof a.value?r.value!==BigInt(0)&&a.value%r.value===BigInt(0):0==(i=Math.round(o=a.value/r.value),n=4*Number.EPSILON*Math.max(Math.abs(o),1),Math.abs(o-i)<n?0:o-i))||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:r.value,input:a.value,inst:t,continue:!r.abort})}}),tA=eX("$ZodCheckNumberFormat",(t,r)=>{tk.init(t,r),r.format=r.format||"float64";let a=r.format?.includes("int"),o=a?"int":"number",[i,n]=eO[r.format];t._zod.check=s=>{let l=s.value;if(a){if(!Number.isInteger(l))return void s.issues.push({expected:o,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:o,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:o,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})}}),tI=eX("$ZodCheckMaxLength",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length;if(("string"==typeof o&&i>r.maximum?eL(o):i)<=r.maximum)return;let n=eU(o);a.issues.push({origin:n,code:"too_big",maximum:r.maximum,inclusive:!0,input:o,inst:t,continue:!r.abort})}}),tN=eX("$ZodCheckMinLength",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length;if(("string"==typeof o&&i>=r.minimum&&i<2*r.minimum?eL(o):i)>=r.minimum)return;let n=eU(o);a.issues.push({origin:n,code:"too_small",minimum:r.minimum,inclusive:!0,input:o,inst:t,continue:!r.abort})}}),tM=eX("$ZodCheckLengthEquals",(t,r)=>{var a;tk.init(t,r),(a=t._zod.def).when??(a.when=tT),t._zod.check=a=>{let o=a.value,i=o.length,n="string"==typeof o&&i>=r.length&&i<=2*r.length?eL(o):i;if(n===r.length)return;let s=eU(o),l=n>r.length;a.issues.push({origin:s,...l?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:a.value,inst:t,continue:!r.abort})}}),tq=eX("$ZodCheckStringFormat",(t,r)=>{var a,o;tk.init(t,r),r.pattern?(a=t._zod).check??(a.check=a=>{r.pattern.lastIndex=0,r.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:r.format,input:a.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(o=t._zod).check??(o.check=()=>{})}),tz=eX("$ZodCheckRegex",(t,r)=>{tq.init(t,r),t._zod.check=a=>{r.pattern.lastIndex=0,r.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),tD=eX("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=tP),tq.init(t,r)}),tL=eX("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=tR),tq.init(t,r)}),tU=eX("$ZodCheckIncludes",(t,r)=>{tk.init(t,r);let a=eP(r.includes),o=new RegExp("number"==typeof r.position?`^.{${r.position},}${a}`:a);r.pattern=o,t._zod.check=a=>{a.value.includes(r.includes,r.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:a.value,inst:t,continue:!r.abort})}}),tH=eX("$ZodCheckStartsWith",(t,r)=>{tk.init(t,r);let a=RegExp(`^${eP(r.prefix)}.*`);r.pattern??(r.pattern=a),t._zod.check=a=>{a.value.startsWith(r.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:a.value,inst:t,continue:!r.abort})}}),tV=eX("$ZodCheckEndsWith",(t,r)=>{tk.init(t,r);let a=RegExp(`.*${eP(r.suffix)}$`);r.pattern??(r.pattern=a),t._zod.check=a=>{a.value.endsWith(r.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:a.value,inst:t,continue:!r.abort})}}),tK=eX("$ZodCheckOverwrite",(t,r)=>{tk.init(t,r),t._zod.check=t=>{t.value=r.tx(t.value)}});class tF{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),a=Math.min(...r.map(t=>t.length-t.trimStart().length));for(let t of r.map(t=>t.slice(a)).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(", ")}) {
4
4
  ${r.join("\n")}
5
5
  };`)(...Object.values(this.closed))}}let tJ={major:4,minor:6,patch:5},tW=eX("$ZodType",(t,r)=>{var a;t??(t={}),t._zod.def=r,t._zod.bag=t._zod.bag||{},t._zod.version=tJ;let o=t._zod.def.checks,i=t._zod.traits.has("$ZodCheck")?[t,...o??[]]:o?.length?[...o]:[];for(let r of i)for(let a of r._zod.onattach)a(t);if(0===i.length)(a=t._zod).deferred??(a.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(r,a,o)=>{let i;if(r.memo)return r;let n=eI(r);for(let s of a){if(s._zod.def.when){if(function(t,r=0){if(!0===t.aborted)return!0;for(let a=r;a<t.issues.length;a++)if(t.issues[a]?.continue===!1)return!0;return!1}(r)||!s._zod.def.when(r))continue}else if(n)continue;let a=r.issues.length,l=s._zod.check(r);if(l instanceof Promise&&o?.async===!1)throw new eY;if(i||l instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await l,r.issues.length!==a&&(eq(r.issues,a,t),n||(n=eI(r,a)))});else{if(r.issues.length===a)continue;eq(r.issues,a,t),n||(n=eI(r,a))}}return i?i.then(()=>r):r},a=(a,o,n)=>{if(eI(a))return a.aborted=!0,a;let s=r(o,i,n);if(s instanceof Promise){if(!1===n.async)throw new eY;return s.then(r=>t._zod.parse(r,n))}return t._zod.parse(s,n)};t._zod.run=(o,n)=>{if(n.skipChecks)return t._zod.parse(o,n);if("backward"===n.direction){let r=t._zod.parse({value:o.value,issues:[]},{...n,skipChecks:!0});return r instanceof Promise?r.then(t=>a(t,o,n)):a(r,o,n)}let s=t._zod.parse(o,n);if(s instanceof Promise){if(!1===n.async)throw new eY;return s.then(t=>r(t,i,n))}return r(s,i,n)}}},{get"~standard"(){return eV(this,"~standard",tZ(this),!1)},set"~standard"(value){eV(this,"~standard",value)}}),tB=(t,r)=>t.issues.length?{issues:t.issues.map(t=>ez(t,r,e1()))}:{value:t.value};async function tG(t,r){let a={async:!0};return tB(await t._zod.run({value:r,issues:[]},a),a)}function tZ(t){return{validate:r=>{let a={async:!1};try{let o=t._zod.run({value:r,issues:[]},a);if(!(o instanceof Promise))return tB(o,a)}catch(t){}return tG(t,r)},vendor:"zod",version:1}}let tX=eX("$ZodString",(t,r)=>{tW.init(t,r),t._zod.pattern=r.pattern??tS,t._zod.parse=(a,o)=>{if(r.coerce)try{a.value=String(a.value)}catch(t){}return"string"==typeof a.value||a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:t}),a}}),tY=eX("$ZodStringFormat",(t,r)=>{tq.init(t,r),tX.init(t,r)}),tQ=eX("$ZodGUID",(t,r)=>{r.pattern??(r.pattern=ts),tY.init(t,r)}),t0=eX("$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=tl(t))}else r.pattern??(r.pattern=tl());tY.init(t,r)}),t1=eX("$ZodEmail",(t,r)=>{r.pattern??(r.pattern=tc),tY.init(t,r)});function t2(t){try{if("undefined"!=typeof URL&&"function"==typeof URL.canParse)return URL.canParse(t);return new URL(t),!0}catch{return!1}}let t9=/[\t\n\r]/g;function t4(t){return t.replace(t9,"")}let t5=eX("$ZodURL",(t,r)=>{tY.init(t,r),t._zod.check=a=>{try{var o,i;let n=a.value.trim(),s="normalize"in r||"hostname"in r||"protocol"in r?function(t,r){if(!r.normalize&&r.protocol?.source===tm.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}}(n,r):t2(n)||2;if(1===s)return void a.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:a.value,inst:t,continue:!r.abort});if(2===s)return void a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:t,continue:!r.abort});if(!0===s){a.value=t4(n);return}r.hostname&&((o=r.hostname).lastIndex=0,!o.test(s.hostname))&&a.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:a.value,inst:t,continue:!r.abort}),r.protocol&&((i=r.protocol).lastIndex=0,!i.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol))&&a.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:a.value,inst:t,continue:!r.abort}),a.value=r.normalize?s.href:t4(n);return}catch(o){a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:t,continue:!r.abort})}}}),t6=eX("$ZodEmoji",(t,r)=>{r.pattern??(r.pattern=RegExp(tu,"u")),tY.init(t,r)}),t3=eX("$ZodNanoID",(t,r)=>{var a;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?ti:(a=r.length,RegExp(`^[a-zA-Z0-9_-]{${a}}$`))),tY.init(t,r)}),t8=eX("$ZodCUID",(t,r)=>{r.pattern??(r.pattern=te),tY.init(t,r)}),t7=eX("$ZodCUID2",(t,r)=>{r.pattern??(r.pattern=tt),tY.init(t,r)}),re=eX("$ZodULID",(t,r)=>{r.pattern??(r.pattern=tr),tY.init(t,r)}),rt=eX("$ZodXID",(t,r)=>{r.pattern??(r.pattern=ta),tY.init(t,r)}),rr=eX("$ZodKSUID",(t,r)=>{r.pattern??(r.pattern=to),tY.init(t,r)}),ra=eX("$ZodISODateTime",(t,r)=>{let a,o,i;r.pattern??(a=["Z"],r.offset&&a.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),o=`${tb({precision:r.precision,seconds:!0})}(?:${a.join("|")})`,i=r.local?`${o}|${tb({precision:r.precision})}`:o,r.pattern=RegExp(`^${tg}T(?:${i})$`)),tY.init(t,r)}),ro=eX("$ZodISODate",(t,r)=>{r.pattern??(r.pattern=tv),tY.init(t,r)}),ri=eX("$ZodISOTime",(t,r)=>{r.pattern??(r.pattern=RegExp(`^${tb(r)}$`)),tY.init(t,r)}),rn=eX("$ZodISODuration",(t,r)=>{r.pattern??(r.pattern=tn),tY.init(t,r)}),rs=eX("$ZodIPv4",(t,r)=>{r.pattern??(r.pattern=td),tY.init(t,r)}),rl=/^[0-9a-fA-F:.]+$/;function rc(t){return!!rl.test(t)&&t2(`http://[${t}]`)}let ru=eX("$ZodIPv6",(t,r)=>{r.pattern??(r.pattern=tp),tY.init(t,r),t._zod.check=a=>{rc(a.value)||a.issues.push({code:"invalid_format",format:"ipv6",input:a.value,inst:t,continue:!r.abort})}}),rd=eX("$ZodCIDRv4",(t,r)=>{r.pattern??(r.pattern=th),tY.init(t,r)}),rp=eX("$ZodCIDRv6",(t,r)=>{r.pattern??(r.pattern=tf),tY.init(t,r),t._zod.check=a=>{!function(t){let r=t.split("/");if(2!==r.length)return!1;let[a,o]=r;if(!o)return!1;let i=Number(o);return`${i}`===o&&!(i<0)&&!(i>128)&&rc(a)}(a.value)&&a.issues.push({code:"invalid_format",format:"cidrv6",input:a.value,inst:t,continue:!r.abort})}});function rh(t){if(""===t)return!0;if(/\s/.test(t)||t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}let rf=/^[0-9a-zA-Z+/]*={0,2}$/,rm=eX("$ZodBase64",(t,r)=>{r.pattern??(r.pattern=rf),tY.init(t,r),t._zod.check=a=>{rh(a.value)||a.issues.push({code:"invalid_format",format:"base64",input:a.value,inst:t,continue:!r.abort})}}),ry=/^[A-Za-z0-9_-]*$/,rg=eX("$ZodBase64URL",(t,r)=>{r.pattern??(r.pattern=ry),tY.init(t,r),t._zod.check=a=>{!function(t){if(!ry.test(t))return!1;let r=t.replace(/[-_]/g,t=>"-"===t?"+":"/");return rh(r.padEnd(4*Math.ceil(r.length/4),"="))}(a.value)&&a.issues.push({code:"invalid_format",format:"base64url",input:a.value,inst:t,continue:!r.abort})}}),rv=eX("$ZodE164",(t,r)=>{r.pattern??(r.pattern=ty),tY.init(t,r)}),rb=eX("$ZodJWT",(t,r)=>{tY.init(t,r),t._zod.check=a=>{!function(t,r=null){try{let a=t.split(".");if(3!==a.length)return!1;let[o]=a;if(!o)return!1;let i=JSON.parse(atob(o));if("typ"in i&&i?.typ!=="JWT"||!i.alg||r&&(!("alg"in i)||i.alg!==r))return!1;return!0}catch{return!1}}(a.value,r.alg)&&a.issues.push({code:"invalid_format",format:"jwt",input:a.value,inst:t,continue:!r.abort})}}),rS=eX("$ZodNumber",(t,r)=>{tW.init(t,r),t._zod.pattern=tw,t._zod.parse=(a,o)=>{if(r.coerce)try{a.value=Number(a.value)}catch(t){}let i=a.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return a;let n="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return a.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...n?{received:n}:{}}),a}}),r_=eX("$ZodNumberFormat",(t,r)=>{tA.init(t,r),rS.init(t,r)}),rw=eX("$ZodBoolean",(t,r)=>{tW.init(t,r),t._zod.pattern=t$,t._zod.parse=(a,o)=>{if(r.coerce)try{a.value=!!a.value}catch(t){}let i=a.value;return"boolean"==typeof i||a.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),a}}),r$=eX("$ZodNull",(t,r)=>{tW.init(t,r),t._zod.pattern=tE,t._zod.values=new Set([null]),t._zod.parse=(r,a)=>{let o=r.value;return null===o||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}}),rE=eX("$ZodAny",(t,r)=>{tW.init(t,r),t._zod.parse=t=>t}),rP=eX("$ZodUnknown",(t,r)=>{tW.init(t,r),t._zod.parse=t=>t}),rR=eX("$ZodNever",(t,r)=>{tW.init(t,r),t._zod.parse=(r,a)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function rk(t,r,a){t.issues.length&&r.issues.push(...eN(a,t.issues)),r.value[a]=t.value}let rT=eX("$ZodArray",(t,r)=>{tW.init(t,r);let a=e0.memoizer;a?.attach(t),t._zod.parse=(o,i)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:"array",code:"invalid_type",input:n,inst:t}),o;o.value=a?a.alloc(t,o,Array(n.length),i):Array(n.length);let s=[],l=i?.abortEarly;for(let t=0;t<n.length;t++){let a=n[t],c=r.element._zod.run({value:a,issues:[]},i);if(c instanceof Promise)s.push(c.then(r=>rk(r,o,t)));else if(rk(c,o,t),l&&0!==c.issues.length&&eI(c))break}return s.length?Promise.all(s).then(()=>o):o}});function rO(t,r,a,o,i,n){let s=a in o,l="optional"===n;if(s||!l||"optional"!==i){if(t.issues.length){if(void 0!==i&&l&&!s)return;r.issues.push(...eN(a,t.issues))}if(!s&&void 0===i){t.issues.length||r.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[a]});return}void 0===t.value?(s||"defaulted"===i&&!l)&&(r.value[a]=void 0):r.value[a]=t.value}}let rx=[];function rC(t){var r;let a=Object.keys(t.shape),o=Object.getOwnPropertySymbols(t.shape),i=o.length?o:rx,n=i.length?[...a,...i]:a;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(a),numKeys:a.length,optionalKeys:new Set(s)}}function rj(t,r,a,o,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&&a.issues.length!==f){if(eI(a,f))break;f=a.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:[]},o);n instanceof Promise?t.push(n.then(t=>rO(t,a,i,r,p,h))):rO(n,a,i,r,p,h)}return(l.length&&a.issues.push({code:"unrecognized_keys",keys:l,input:r,inst:n,continue:!0}),t.length)?Promise.all(t).then(()=>a):a}let rA=eX("$ZodObject",(t,r)=>{let a;tW.init(t,r);let o=Object.getOwnPropertyDescriptor(r,"shape"),i=o?.get?o.get.raw:r.shape??{};if(i){let t=()=>{let a={...i};return Object.defineProperty(r,"shape",{value:a}),t.raw=a,a};t.raw=i,Object.defineProperty(r,"shape",{get:t})}let n=ec(()=>rC(r));eW(t,"propValues",t=>{let r=t.def.shape,a={};for(let t in r){let o=r[t]._zod;if(o.values){for(let r of(Object.prototype.hasOwnProperty.call(a,t)||ep(a,t,new Set),o.values))a[t].add(r);void 0!==o.optin&&a[t].add(void 0)}}return a});let s=r.catchall,l=e0.memoizer;l?.attach(t),t._zod.parse=(r,o)=>{a??(a=n.value);let i=r.value;if(!eS(i))return r.issues.push({expected:"object",code:"invalid_type",input:i,inst:t}),r;r.value=l?l.alloc(t,r,{},o):{};let c=[],u=a.shape,d=o?.abortEarly,p=r.issues.length;for(let t of a.allKeys){if(d&&r.issues.length!==p){if(eI(r,p))break;p=r.issues.length}if("__proto__"===t)continue;let a=u[t],n=a._zod.optin,s=a._zod.optout,l=a._zod.run({value:i[t],issues:[]},o);l instanceof Promise?c.push(l.then(a=>rO(a,r,t,i,n,s))):rO(l,r,t,i,n,s)}return s?rj(c,i,r,o,n.value,t,!0===d):c.length?Promise.all(c).then(()=>r):r}}),rI=eX("$ZodObjectJIT",(t,r)=>{let a,o;rA.init(t,r);let i=t._zod.parse,n=ec(()=>rC(r)),s=e0.memoizer,l=!e0.jitless,c=l&&e_.value,u=r.catchall;t._zod.parse=(d,p)=>{o??(o=n.value);let h=d.value;return eS(h)?l&&c&&p?.async===!1&&!0!==p.jitless?(a||(a=(r=>{let a=n.value,o=a.symbolKeys,i=new tF(["payload","ctx"],{shape:r,inst:t,memo:s,syms:o}),l=t=>`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`,c=(t,r)=>`
6
6
  let ${t}_ab = false;