veloce-ts 1.0.0 → 1.2.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/CHANGELOG.md +115 -19
- package/README.md +30 -9
- package/dist/cjs/src/auth/index.js +2 -2
- package/dist/cjs/src/auth/index.js.map +3 -3
- package/dist/cjs/src/cli/index.js +257 -95
- package/dist/cjs/src/cli/index.js.map +4 -4
- package/dist/cjs/src/docs/index.js +3 -3
- package/dist/cjs/src/docs/index.js.map +4 -4
- package/dist/cjs/src/errors/index.js +24 -24
- package/dist/cjs/src/errors/index.js.map +6 -5
- package/dist/cjs/src/graphql/index.js +16 -16
- package/dist/cjs/src/graphql/index.js.map +4 -4
- package/dist/cjs/src/index.js +64 -62
- package/dist/cjs/src/index.js.map +18 -12
- package/dist/cjs/src/plugins/index.js +23 -23
- package/dist/cjs/src/plugins/index.js.map +6 -6
- package/dist/cjs/src/testing/index.js +34 -32
- package/dist/cjs/src/testing/index.js.map +11 -6
- package/dist/esm/src/auth/index.js +2 -2
- package/dist/esm/src/auth/index.js.map +3 -3
- package/dist/esm/src/cli/index.js +257 -95
- package/dist/esm/src/cli/index.js.map +4 -4
- package/dist/esm/src/docs/index.js +3 -3
- package/dist/esm/src/docs/index.js.map +4 -4
- package/dist/esm/src/errors/index.js +24 -24
- package/dist/esm/src/errors/index.js.map +6 -5
- package/dist/esm/src/graphql/index.js +15 -15
- package/dist/esm/src/graphql/index.js.map +4 -4
- package/dist/esm/src/index.js +64 -62
- package/dist/esm/src/index.js.map +18 -12
- package/dist/esm/src/plugins/index.js +23 -23
- package/dist/esm/src/plugins/index.js.map +6 -6
- package/dist/esm/src/testing/index.js +34 -32
- package/dist/esm/src/testing/index.js.map +11 -6
- package/dist/types/cli/commands/generate.d.ts.map +1 -1
- package/dist/types/core/application.d.ts +15 -0
- package/dist/types/core/application.d.ts.map +1 -1
- package/dist/types/core/interceptor-manager.d.ts +16 -0
- package/dist/types/core/interceptor-manager.d.ts.map +1 -0
- package/dist/types/core/router-compiler.d.ts +5 -1
- package/dist/types/core/router-compiler.d.ts.map +1 -1
- package/dist/types/decorators/extras.d.ts +20 -0
- package/dist/types/decorators/extras.d.ts.map +1 -0
- package/dist/types/decorators/stream.d.ts +5 -0
- package/dist/types/decorators/stream.d.ts.map +1 -0
- package/dist/types/docs/openapi-generator.d.ts +2 -2
- package/dist/types/docs/openapi-generator.d.ts.map +1 -1
- package/dist/types/docs/zod-to-json-schema.d.ts.map +1 -1
- package/dist/types/errors/exception-filter.d.ts +12 -0
- package/dist/types/errors/exception-filter.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +2 -0
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/events/event-bus.d.ts +14 -0
- package/dist/types/events/event-bus.d.ts.map +1 -0
- package/dist/types/events/index.d.ts +2 -0
- package/dist/types/events/index.d.ts.map +1 -0
- package/dist/types/graphql/plugin.d.ts +12 -0
- package/dist/types/graphql/plugin.d.ts.map +1 -1
- package/dist/types/graphql/schema-builder.d.ts +4 -5
- package/dist/types/graphql/schema-builder.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/testing/index.d.ts +1 -0
- package/dist/types/testing/index.d.ts.map +1 -1
- package/dist/types/testing/isolate.d.ts +12 -0
- package/dist/types/testing/isolate.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var sq=Object.create;var{getPrototypeOf:tq,defineProperty:Q6,getOwnPropertyNames:g8,getOwnPropertyDescriptor:eq}=Object,y8=Object.prototype.hasOwnProperty;function m8($){return this[$]}var $Q,qQ,QQ=($,q,Q)=>{var J=$!=null&&typeof $==="object";if(J){var W=q?$Q??=new WeakMap:qQ??=new WeakMap,X=W.get($);if(X)return X}Q=$!=null?sq(tq($)):{};let H=q||!$||!$.__esModule?Q6(Q,"default",{value:$,enumerable:!0}):Q;for(let Y of g8($))if(!y8.call(H,Y))Q6(H,Y,{get:m8.bind($,Y),enumerable:!0});if(J)W.set($,H);return H},JQ=($)=>{var q=(h8??=new WeakMap).get($),Q;if(q)return q;if(q=Q6({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var J of g8($))if(!y8.call(q,J))Q6(q,J,{get:m8.bind($,J),enumerable:!(Q=eq($,J))||Q.enumerable})}return h8.set($,q),q},h8,z=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);var WQ=($)=>$;function XQ($,q){this[$]=WQ.bind(null,q)}var M0=($,q)=>{for(var Q in q)Q6($,Q,{get:q[Q],enumerable:!0,configurable:!0,set:XQ.bind(q,Q)})};var E0=($,q)=>()=>($&&(q=$($=0)),q);var P$=z((A0,u8)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var f6=require("buffer"),Q$=f6.Buffer;function l8($,q){for(var Q in $)q[Q]=$[Q]}if(Q$.from&&Q$.alloc&&Q$.allocUnsafe&&Q$.allocUnsafeSlow)u8.exports=f6;else l8(f6,A0),A0.Buffer=N$;function N$($,q,Q){return Q$($,q,Q)}N$.prototype=Object.create(Q$.prototype);l8(Q$,N$);N$.from=function($,q,Q){if(typeof $==="number")throw TypeError("Argument must not be a number");return Q$($,q,Q)};N$.alloc=function($,q,Q){if(typeof $!=="number")throw TypeError("Argument must be a number");var J=Q$($);if(q!==void 0)if(typeof Q==="string")J.fill(q,Q);else J.fill(q);else J.fill(0);return J};N$.allocUnsafe=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return Q$($)};N$.allocUnsafeSlow=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return f6.SlowBuffer($)}});var C0=z((xH,c8)=>{var T6=P$().Buffer,HQ=require("stream"),YQ=require("util");function x6($){if(this.buffer=null,this.writable=!0,this.readable=!0,!$)return this.buffer=T6.alloc(0),this;if(typeof $.pipe==="function")return this.buffer=T6.alloc(0),$.pipe(this),this;if($.length||typeof $==="object")return this.buffer=$,this.writable=!1,process.nextTick(function(){this.emit("end",$),this.readable=!1,this.emit("close")}.bind(this)),this;throw TypeError("Unexpected data type ("+typeof $+")")}YQ.inherits(x6,HQ);x6.prototype.write=function(q){this.buffer=T6.concat([this.buffer,T6.from(q)]),this.emit("data",q)};x6.prototype.end=function(q){if(q)this.write(q);this.emit("end",q),this.emit("close"),this.writable=!1,this.readable=!1};c8.exports=x6});var p8=z((vH,d8)=>{function K0($){var q=($/8|0)+($%8===0?0:1);return q}var GQ={ES256:K0(256),ES384:K0(384),ES512:K0(521)};function BQ($){var q=GQ[$];if(q)return q;throw Error('Unknown algorithm "'+$+'"')}d8.exports=BQ});var t8=z((hH,s8)=>{var v6=P$().Buffer,i8=p8(),h6=128,r8=0,wQ=32,VQ=16,FQ=2,o8=VQ|wQ|r8<<6,g6=FQ|r8<<6;function UQ($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function a8($){if(v6.isBuffer($))return $;else if(typeof $==="string")return v6.from($,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function _Q($,q){$=a8($);var Q=i8(q),J=Q+1,W=$.length,X=0;if($[X++]!==o8)throw Error('Could not find expected "seq"');var H=$[X++];if(H===(h6|1))H=$[X++];if(W-X<H)throw Error('"seq" specified length of "'+H+'", only "'+(W-X)+'" remaining');if($[X++]!==g6)throw Error('Could not find expected "int" for "r"');var Y=$[X++];if(W-X-2<Y)throw Error('"r" specified length of "'+Y+'", only "'+(W-X-2)+'" available');if(J<Y)throw Error('"r" specified length of "'+Y+'", max of "'+J+'" is acceptable');var G=X;if(X+=Y,$[X++]!==g6)throw Error('Could not find expected "int" for "s"');var w=$[X++];if(W-X!==w)throw Error('"s" specified length of "'+w+'", expected "'+(W-X)+'"');if(J<w)throw Error('"s" specified length of "'+w+'", max of "'+J+'" is acceptable');var V=X;if(X+=w,X!==W)throw Error('Expected to consume entire buffer, but "'+(W-X)+'" bytes remain');var U=Q-Y,M=Q-w,O=v6.allocUnsafe(U+Y+M+w);for(X=0;X<U;++X)O[X]=0;$.copy(O,X,G+Math.max(-U,0),G+Y),X=Q;for(var P=X;X<P+M;++X)O[X]=0;return $.copy(O,X,V+Math.max(-M,0),V+w),O=O.toString("base64"),O=UQ(O),O}function n8($,q,Q){var J=0;while(q+J<Q&&$[q+J]===0)++J;var W=$[q+J]>=h6;if(W)--J;return J}function DQ($,q){$=a8($);var Q=i8(q),J=$.length;if(J!==Q*2)throw TypeError('"'+q+'" signatures must be "'+Q*2+'" bytes, saw "'+J+'"');var W=n8($,0,Q),X=n8($,Q,$.length),H=Q-W,Y=Q-X,G=2+H+1+1+Y,w=G<h6,V=v6.allocUnsafe((w?2:3)+G),U=0;if(V[U++]=o8,w)V[U++]=G;else V[U++]=h6|1,V[U++]=G&255;if(V[U++]=g6,V[U++]=H,W<0)V[U++]=0,U+=$.copy(V,U,0,Q);else U+=$.copy(V,U,W,Q);if(V[U++]=g6,V[U++]=Y,X<0)V[U++]=0,$.copy(V,U,Q);else $.copy(V,U,Q+X);return V}s8.exports={derToJose:_Q,joseToDer:DQ}});var $1=z((gH,e8)=>{var J6=require("buffer").Buffer,I0=require("buffer").SlowBuffer;e8.exports=y6;function y6($,q){if(!J6.isBuffer($)||!J6.isBuffer(q))return!1;if($.length!==q.length)return!1;var Q=0;for(var J=0;J<$.length;J++)Q|=$[J]^q[J];return Q===0}y6.install=function(){J6.prototype.equal=I0.prototype.equal=function(q){return y6(this,q)}};var zQ=J6.prototype.equal,LQ=I0.prototype.equal;y6.restore=function(){J6.prototype.equal=zQ,I0.prototype.equal=LQ}});var Z0=z((yH,B1)=>{var b$=P$().Buffer,p=require("crypto"),Q1=t8(),q1=require("util"),jQ=`"%s" is not a valid algorithm.
|
|
2
2
|
Supported algorithms are:
|
|
3
|
-
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,W6="secret must be a string or buffer",k$="key must be a string or a buffer",OQ="key must be a string, a buffer or an object",k0=typeof p.createPublicKey==="function";if(k0)k$+=" or a KeyObject",W6+="or a KeyObject";function J1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(!k0)throw r(k$);if(typeof $!=="object")throw r(k$);if(typeof $.type!=="string")throw r(k$);if(typeof $.asymmetricKeyType!=="string")throw r(k$);if(typeof $.export!=="function")throw r(k$)}function W1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(typeof $==="object")return;throw r(OQ)}function NQ($){if(b$.isBuffer($))return;if(typeof $==="string")return $;if(!k0)throw r(W6);if(typeof $!=="object")throw r(W6);if($.type!=="secret")throw r(W6);if(typeof $.export!=="function")throw r(W6)}function b0($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function X1($){$=$.toString();var q=4-$.length%4;if(q!==4)for(var Q=0;Q<q;++Q)$+="=";return $.replace(/\-/g,"+").replace(/_/g,"/")}function r($){var q=[].slice.call(arguments,1),Q=q1.format.bind(q1,$).apply(null,q);return TypeError(Q)}function RQ($){return b$.isBuffer($)||typeof $==="string"}function X6($){if(!RQ($))$=JSON.stringify($);return $}function H1($){return function(Q,J){NQ(J),Q=X6(Q);var W=p.createHmac("sha"+$,J),X=(W.update(Q),W.digest("base64"));return b0(X)}}var P0,SQ="timingSafeEqual"in p?function(q,Q){if(q.byteLength!==Q.byteLength)return!1;return p.timingSafeEqual(q,Q)}:function(q,Q){if(!P0)P0=$1();return P0(q,Q)};function MQ($){return function(Q,J,W){var X=H1($)(Q,W);return SQ(b$.from(J),b$.from(X))}}function Y1($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign(J,"base64"));return b0(X)}}function G1($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify(W,J,"base64")}}function EQ($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign({key:J,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return b0(X)}}function AQ($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify({key:W,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},J,"base64")}}function CQ($){var q=Y1($);return function(){var J=q.apply(null,arguments);return J=Q1.derToJose(J,"ES"+$),J}}function KQ($){var q=G1($);return function(J,W,X){W=Q1.joseToDer(W,"ES"+$).toString("base64");var H=q(J,W,X);return H}}function IQ(){return function(){return""}}function PQ(){return function(q,Q){return Q===""}}B1.exports=function(q){var Q={hs:H1,rs:Y1,ps:EQ,es:CQ,none:IQ},J={hs:MQ,rs:G1,ps:AQ,es:KQ,none:PQ},W=q.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!W)throw r(jQ,q);var X=(W[1]||W[3]).toLowerCase(),H=W[2];return{sign:Q[X](H),verify:J[X](H)}}});var f0=z((mH,w1)=>{var kQ=require("buffer").Buffer;w1.exports=function(q){if(typeof q==="string")return q;if(typeof q==="number"||kQ.isBuffer(q))return q.toString();return JSON.stringify(q)}});var z1=z((lH,D1)=>{var bQ=P$().Buffer,V1=C0(),ZQ=Z0(),fQ=require("stream"),F1=f0(),T0=require("util");function U1($,q){return bQ.from($,q).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function TQ($,q,Q){Q=Q||"utf8";var J=U1(F1($),"binary"),W=U1(F1(q),Q);return T0.format("%s.%s",J,W)}function _1($){var{header:q,payload:Q}=$,J=$.secret||$.privateKey,W=$.encoding,X=ZQ(q.alg),H=TQ(q,Q,W),Y=X.sign(H,J);return T0.format("%s.%s",H,Y)}function m6($){var q=$.secret;if(q=q==null?$.privateKey:q,q=q==null?$.key:q,/^hs/i.test($.header.alg)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new V1(q);this.readable=!0,this.header=$.header,this.encoding=$.encoding,this.secret=this.privateKey=this.key=Q,this.payload=new V1($.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}T0.inherits(m6,fQ);m6.prototype.sign=function(){try{var q=_1({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(Q){this.readable=!1,this.emit("error",Q),this.emit("close")}};m6.sign=_1;D1.exports=m6});var C1=z((uH,A1)=>{var j1=P$().Buffer,L1=C0(),xQ=Z0(),vQ=require("stream"),O1=f0(),hQ=require("util"),gQ=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function yQ($){return Object.prototype.toString.call($)==="[object Object]"}function mQ($){if(yQ($))return $;try{return JSON.parse($)}catch(q){return}}function N1($){var q=$.split(".",1)[0];return mQ(j1.from(q,"base64").toString("binary"))}function lQ($){return $.split(".",2).join(".")}function R1($){return $.split(".")[2]}function uQ($,q){q=q||"utf8";var Q=$.split(".")[1];return j1.from(Q,"base64").toString(q)}function S1($){return gQ.test($)&&!!N1($)}function M1($,q,Q){if(!q){var J=Error("Missing algorithm parameter for jws.verify");throw J.code="MISSING_ALGORITHM",J}$=O1($);var W=R1($),X=lQ($),H=xQ(q);return H.verify(X,W,Q)}function E1($,q){if(q=q||{},$=O1($),!S1($))return null;var Q=N1($);if(!Q)return null;var J=uQ($);if(Q.typ==="JWT"||q.json)J=JSON.parse(J,q.encoding);return{header:Q,payload:J,signature:R1($)}}function Z$($){$=$||{};var q=$.secret;if(q=q==null?$.publicKey:q,q=q==null?$.key:q,/^hs/i.test($.algorithm)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new L1(q);this.readable=!0,this.algorithm=$.algorithm,this.encoding=$.encoding,this.secret=this.publicKey=this.key=Q,this.signature=new L1($.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}hQ.inherits(Z$,vQ);Z$.prototype.verify=function(){try{var q=M1(this.signature.buffer,this.algorithm,this.key.buffer),Q=E1(this.signature.buffer,this.encoding);return this.emit("done",q,Q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(J){this.readable=!1,this.emit("error",J),this.emit("close")}};Z$.decode=E1;Z$.isValid=S1;Z$.verify=M1;A1.exports=Z$});var u6=z((V$)=>{var K1=z1(),l6=C1(),cQ=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];V$.ALGORITHMS=cQ;V$.sign=K1.sign;V$.verify=l6.verify;V$.decode=l6.decode;V$.isValid=l6.isValid;V$.createSign=function(q){return new K1(q)};V$.createVerify=function(q){return new l6(q)}});var x0=z((dH,I1)=>{var dQ=u6();I1.exports=function($,q){q=q||{};var Q=dQ.decode($,q);if(!Q)return null;var J=Q.payload;if(typeof J==="string")try{var W=JSON.parse(J);if(W!==null&&typeof W==="object")J=W}catch(X){}if(q.complete===!0)return{header:Q.header,payload:J,signature:Q.signature};return J}});var H6=z((pH,P1)=>{var c6=function($,q){if(Error.call(this,$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);if(this.name="JsonWebTokenError",this.message=$,q)this.inner=q};c6.prototype=Object.create(Error.prototype);c6.prototype.constructor=c6;P1.exports=c6});var v0=z((nH,b1)=>{var k1=H6(),d6=function($,q){k1.call(this,$),this.name="NotBeforeError",this.date=q};d6.prototype=Object.create(k1.prototype);d6.prototype.constructor=d6;b1.exports=d6});var h0=z((iH,f1)=>{var Z1=H6(),p6=function($,q){Z1.call(this,$),this.name="TokenExpiredError",this.expiredAt=q};p6.prototype=Object.create(Z1.prototype);p6.prototype.constructor=p6;f1.exports=p6});var x1=z((rH,T1)=>{var f$=1000,T$=f$*60,x$=T$*60,R$=x$*24,pQ=R$*7,nQ=R$*365.25;T1.exports=function($,q){q=q||{};var Q=typeof $;if(Q==="string"&&$.length>0)return iQ($);else if(Q==="number"&&isFinite($))return q.long?oQ($):rQ($);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify($))};function iQ($){if($=String($),$.length>100)return;var q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec($);if(!q)return;var Q=parseFloat(q[1]),J=(q[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return Q*nQ;case"weeks":case"week":case"w":return Q*pQ;case"days":case"day":case"d":return Q*R$;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*x$;case"minutes":case"minute":case"mins":case"min":case"m":return Q*T$;case"seconds":case"second":case"secs":case"sec":case"s":return Q*f$;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function rQ($){var q=Math.abs($);if(q>=R$)return Math.round($/R$)+"d";if(q>=x$)return Math.round($/x$)+"h";if(q>=T$)return Math.round($/T$)+"m";if(q>=f$)return Math.round($/f$)+"s";return $+"ms"}function oQ($){var q=Math.abs($);if(q>=R$)return n6($,q,R$,"day");if(q>=x$)return n6($,q,x$,"hour");if(q>=T$)return n6($,q,T$,"minute");if(q>=f$)return n6($,q,f$,"second");return $+" ms"}function n6($,q,Q,J){var W=q>=Q*1.5;return Math.round($/Q)+" "+J+(W?"s":"")}});var g0=z((oH,v1)=>{var aQ=x1();v1.exports=function($,q){var Q=q||Math.floor(Date.now()/1000);if(typeof $==="string"){var J=aQ($);if(typeof J>"u")return;return Math.floor(Q+J/1000)}else if(typeof $==="number")return Q+$;else return}});var Y6=z((aH,h1)=>{var sQ=Number.MAX_SAFE_INTEGER||9007199254740991,tQ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];h1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:sQ,RELEASE_TYPES:tQ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var G6=z((sH,g1)=>{var eQ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};g1.exports=eQ});var v$=z((J$,y1)=>{var{MAX_SAFE_COMPONENT_LENGTH:y0,MAX_SAFE_BUILD_LENGTH:$J,MAX_LENGTH:qJ}=Y6(),QJ=G6();J$=y1.exports={};var JJ=J$.re=[],WJ=J$.safeRe=[],L=J$.src=[],XJ=J$.safeSrc=[],j=J$.t={},HJ=0,m0="[a-zA-Z0-9-]",YJ=[["\\s",1],["\\d",qJ],[m0,$J]],GJ=($)=>{for(let[q,Q]of YJ)$=$.split(`${q}*`).join(`${q}{0,${Q}}`).split(`${q}+`).join(`${q}{1,${Q}}`);return $},E=($,q,Q)=>{let J=GJ(q),W=HJ++;QJ($,W,q),j[$]=W,L[W]=q,XJ[W]=J,JJ[W]=new RegExp(q,Q?"g":void 0),WJ[W]=new RegExp(J,Q?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m0}*`);E("MAINVERSION",`(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${L[j.PRERELEASEIDENTIFIER]}(?:\\.${L[j.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${L[j.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${L[j.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${m0}+`);E("BUILD",`(?:\\+(${L[j.BUILDIDENTIFIER]}(?:\\.${L[j.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${L[j.MAINVERSION]}${L[j.PRERELEASE]}?${L[j.BUILD]}?`);E("FULL",`^${L[j.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${L[j.MAINVERSIONLOOSE]}${L[j.PRERELEASELOOSE]}?${L[j.BUILD]}?`);E("LOOSE",`^${L[j.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${L[j.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${L[j.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:${L[j.PRERELEASE]})?${L[j.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:${L[j.PRERELEASELOOSE]})?${L[j.BUILD]}?)?)?`);E("XRANGE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${y0}})(?:\\.(\\d{1,${y0}}))?(?:\\.(\\d{1,${y0}}))?`);E("COERCE",`${L[j.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",L[j.COERCEPLAIN]+`(?:${L[j.PRERELEASE]})?(?:${L[j.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",L[j.COERCE],!0);E("COERCERTLFULL",L[j.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${L[j.LONETILDE]}\\s+`,!0);J$.tildeTrimReplace="$1~";E("TILDE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${L[j.LONECARET]}\\s+`,!0);J$.caretTrimReplace="$1^";E("CARET",`^${L[j.LONECARET]}${L[j.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${L[j.LONECARET]}${L[j.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${L[j.GTLT]}\\s*(${L[j.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]}|${L[j.XRANGEPLAIN]})`,!0);J$.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${L[j.XRANGEPLAIN]})\\s+-\\s+(${L[j.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${L[j.XRANGEPLAINLOOSE]})\\s+-\\s+(${L[j.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var i6=z((tH,m1)=>{var BJ=Object.freeze({loose:!0}),wJ=Object.freeze({}),VJ=($)=>{if(!$)return wJ;if(typeof $!=="object")return BJ;return $};m1.exports=VJ});var l0=z((eH,c1)=>{var l1=/^[0-9]+$/,u1=($,q)=>{if(typeof $==="number"&&typeof q==="number")return $===q?0:$<q?-1:1;let Q=l1.test($),J=l1.test(q);if(Q&&J)$=+$,q=+q;return $===q?0:Q&&!J?-1:J&&!Q?1:$<q?-1:1},FJ=($,q)=>u1(q,$);c1.exports={compareIdentifiers:u1,rcompareIdentifiers:FJ}});var h=z(($Y,p1)=>{var r6=G6(),{MAX_LENGTH:d1,MAX_SAFE_INTEGER:o6}=Y6(),{safeRe:a6,t:s6}=v$(),UJ=i6(),{compareIdentifiers:u0}=l0();class o{constructor($,q){if(q=UJ(q),$ instanceof o)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>d1)throw TypeError(`version is longer than ${d1} characters`);r6("SemVer",$,q),this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease;let Q=$.trim().match(q.loose?a6[s6.LOOSE]:a6[s6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>o6||this.major<0)throw TypeError("Invalid major version");if(this.minor>o6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>o6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let W=+J;if(W>=0&&W<o6)return W}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(r6("SemVer.compare",this.version,this.options,$),!($ instanceof o)){if(typeof $==="string"&&$===this.version)return 0;$=new o($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof o))$=new o($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof o))$=new o($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let q=0;do{let Q=this.prerelease[q],J=$.prerelease[q];if(r6("prerelease compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}compareBuild($){if(!($ instanceof o))$=new o($,this.options);let q=0;do{let Q=this.build[q],J=$.build[q];if(r6("build compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}inc($,q,Q){if($.startsWith("pre")){if(!q&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(q){let J=`-${q}`.match(this.options.loose?a6[s6.PRERELEASELOOSE]:a6[s6.PRERELEASE]);if(!J||J[1]!==q)throw Error(`invalid identifier: ${q}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",q,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",q,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",q,Q),this.inc("pre",q,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",q,Q);this.inc("pre",q,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let W=this.prerelease.length;while(--W>=0)if(typeof this.prerelease[W]==="number")this.prerelease[W]++,W=-2;if(W===-1){if(q===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(q){let W=[q,J];if(Q===!1)W=[q];if(u0(this.prerelease[0],q)===0){if(isNaN(this.prerelease[1]))this.prerelease=W}else this.prerelease=W}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}p1.exports=o});var S$=z((qY,i1)=>{var n1=h(),_J=($,q,Q=!1)=>{if($ instanceof n1)return $;try{return new n1($,q)}catch(J){if(!Q)return null;throw J}};i1.exports=_J});var o1=z((QY,r1)=>{var DJ=S$(),zJ=($,q)=>{let Q=DJ($,q);return Q?Q.version:null};r1.exports=zJ});var s1=z((JY,a1)=>{var LJ=S$(),jJ=($,q)=>{let Q=LJ($.trim().replace(/^[=v]+/,""),q);return Q?Q.version:null};a1.exports=jJ});var $4=z((WY,e1)=>{var t1=h(),OJ=($,q,Q,J,W)=>{if(typeof Q==="string")W=J,J=Q,Q=void 0;try{return new t1($ instanceof t1?$.version:$,Q).inc(q,J,W).version}catch(X){return null}};e1.exports=OJ});var J4=z((XY,Q4)=>{var q4=S$(),NJ=($,q)=>{let Q=q4($,null,!0),J=q4(q,null,!0),W=Q.compare(J);if(W===0)return null;let X=W>0,H=X?Q:J,Y=X?J:Q,G=!!H.prerelease.length;if(!!Y.prerelease.length&&!G){if(!Y.patch&&!Y.minor)return"major";if(Y.compareMain(H)===0){if(Y.minor&&!Y.patch)return"minor";return"patch"}}let V=G?"pre":"";if(Q.major!==J.major)return V+"major";if(Q.minor!==J.minor)return V+"minor";if(Q.patch!==J.patch)return V+"patch";return"prerelease"};Q4.exports=NJ});var X4=z((HY,W4)=>{var RJ=h(),SJ=($,q)=>new RJ($,q).major;W4.exports=SJ});var Y4=z((YY,H4)=>{var MJ=h(),EJ=($,q)=>new MJ($,q).minor;H4.exports=EJ});var B4=z((GY,G4)=>{var AJ=h(),CJ=($,q)=>new AJ($,q).patch;G4.exports=CJ});var V4=z((BY,w4)=>{var KJ=S$(),IJ=($,q)=>{let Q=KJ($,q);return Q&&Q.prerelease.length?Q.prerelease:null};w4.exports=IJ});var n=z((wY,U4)=>{var F4=h(),PJ=($,q,Q)=>new F4($,Q).compare(new F4(q,Q));U4.exports=PJ});var D4=z((VY,_4)=>{var kJ=n(),bJ=($,q,Q)=>kJ(q,$,Q);_4.exports=bJ});var L4=z((FY,z4)=>{var ZJ=n(),fJ=($,q)=>ZJ($,q,!0);z4.exports=fJ});var t6=z((UY,O4)=>{var j4=h(),TJ=($,q,Q)=>{let J=new j4($,Q),W=new j4(q,Q);return J.compare(W)||J.compareBuild(W)};O4.exports=TJ});var R4=z((_Y,N4)=>{var xJ=t6(),vJ=($,q)=>$.sort((Q,J)=>xJ(Q,J,q));N4.exports=vJ});var M4=z((DY,S4)=>{var hJ=t6(),gJ=($,q)=>$.sort((Q,J)=>hJ(J,Q,q));S4.exports=gJ});var B6=z((zY,E4)=>{var yJ=n(),mJ=($,q,Q)=>yJ($,q,Q)>0;E4.exports=mJ});var e6=z((LY,A4)=>{var lJ=n(),uJ=($,q,Q)=>lJ($,q,Q)<0;A4.exports=uJ});var c0=z((jY,C4)=>{var cJ=n(),dJ=($,q,Q)=>cJ($,q,Q)===0;C4.exports=dJ});var d0=z((OY,K4)=>{var pJ=n(),nJ=($,q,Q)=>pJ($,q,Q)!==0;K4.exports=nJ});var $0=z((NY,I4)=>{var iJ=n(),rJ=($,q,Q)=>iJ($,q,Q)>=0;I4.exports=rJ});var q0=z((RY,P4)=>{var oJ=n(),aJ=($,q,Q)=>oJ($,q,Q)<=0;P4.exports=aJ});var p0=z((SY,k4)=>{var sJ=c0(),tJ=d0(),eJ=B6(),$5=$0(),q5=e6(),Q5=q0(),J5=($,q,Q,J)=>{switch(q){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return sJ($,Q,J);case"!=":return tJ($,Q,J);case">":return eJ($,Q,J);case">=":return $5($,Q,J);case"<":return q5($,Q,J);case"<=":return Q5($,Q,J);default:throw TypeError(`Invalid operator: ${q}`)}};k4.exports=J5});var Z4=z((MY,b4)=>{var W5=h(),X5=S$(),{safeRe:Q0,t:J0}=v$(),H5=($,q)=>{if($ instanceof W5)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;q=q||{};let Q=null;if(!q.rtl)Q=$.match(q.includePrerelease?Q0[J0.COERCEFULL]:Q0[J0.COERCE]);else{let G=q.includePrerelease?Q0[J0.COERCERTLFULL]:Q0[J0.COERCERTL],w;while((w=G.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||w.index+w[0].length!==Q.index+Q[0].length)Q=w;G.lastIndex=w.index+w[1].length+w[2].length}G.lastIndex=-1}if(Q===null)return null;let J=Q[2],W=Q[3]||"0",X=Q[4]||"0",H=q.includePrerelease&&Q[5]?`-${Q[5]}`:"",Y=q.includePrerelease&&Q[6]?`+${Q[6]}`:"";return X5(`${J}.${W}.${X}${H}${Y}`,q)};b4.exports=H5});var x4=z((EY,T4)=>{class f4{constructor(){this.max=1000,this.map=new Map}get($){let q=this.map.get($);if(q===void 0)return;else return this.map.delete($),this.map.set($,q),q}delete($){return this.map.delete($)}set($,q){if(!this.delete($)&&q!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,q)}return this}}T4.exports=f4});var i=z((AY,y4)=>{var Y5=/\s+/g;class w6{constructor($,q){if(q=B5(q),$ instanceof w6)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else return new w6($.raw,q);if($ instanceof n0)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease,this.raw=$.trim().replace(Y5," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!h4(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&z5(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let q=this.set[$];for(let Q=0;Q<q.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=q[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&_5)|(this.options.loose&&D5))+":"+$,J=v4.get(Q);if(J)return J;let W=this.options.loose,X=W?m[g.HYPHENRANGELOOSE]:m[g.HYPHENRANGE];$=$.replace(X,C5(this.options.includePrerelease)),k("hyphen replace",$),$=$.replace(m[g.COMPARATORTRIM],V5),k("comparator trim",$),$=$.replace(m[g.TILDETRIM],F5),k("tilde trim",$),$=$.replace(m[g.CARETTRIM],U5),k("caret trim",$);let H=$.split(" ").map((V)=>L5(V,this.options)).join(" ").split(/\s+/).map((V)=>A5(V,this.options));if(W)H=H.filter((V)=>{return k("loose invalid filter",V,this.options),!!V.match(m[g.COMPARATORLOOSE])});k("range list",H);let Y=new Map,G=H.map((V)=>new n0(V,this.options));for(let V of G){if(h4(V))return[V];Y.set(V.value,V)}if(Y.size>1&&Y.has(""))Y.delete("");let w=[...Y.values()];return v4.set(Q,w),w}intersects($,q){if(!($ instanceof w6))throw TypeError("a Range is required");return this.set.some((Q)=>{return g4(Q,q)&&$.set.some((J)=>{return g4(J,q)&&Q.every((W)=>{return J.every((X)=>{return W.intersects(X,q)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new w5($,this.options)}catch(q){return!1}for(let q=0;q<this.set.length;q++)if(K5(this.set[q],$,this.options))return!0;return!1}}y4.exports=w6;var G5=x4(),v4=new G5,B5=i6(),n0=V6(),k=G6(),w5=h(),{safeRe:m,t:g,comparatorTrimReplace:V5,tildeTrimReplace:F5,caretTrimReplace:U5}=v$(),{FLAG_INCLUDE_PRERELEASE:_5,FLAG_LOOSE:D5}=Y6(),h4=($)=>$.value==="<0.0.0-0",z5=($)=>$.value==="",g4=($,q)=>{let Q=!0,J=$.slice(),W=J.pop();while(Q&&J.length)Q=J.every((X)=>{return W.intersects(X,q)}),W=J.pop();return Q},L5=($,q)=>{return $=$.replace(m[g.BUILD],""),k("comp",$,q),$=N5($,q),k("caret",$),$=j5($,q),k("tildes",$),$=S5($,q),k("xrange",$),$=E5($,q),k("stars",$),$},l=($)=>!$||$.toLowerCase()==="x"||$==="*",j5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>O5(Q,q)).join(" ")},O5=($,q)=>{let Q=q.loose?m[g.TILDELOOSE]:m[g.TILDE];return $.replace(Q,(J,W,X,H,Y)=>{k("tilde",$,J,W,X,H,Y);let G;if(l(W))G="";else if(l(X))G=`>=${W}.0.0 <${+W+1}.0.0-0`;else if(l(H))G=`>=${W}.${X}.0 <${W}.${+X+1}.0-0`;else if(Y)k("replaceTilde pr",Y),G=`>=${W}.${X}.${H}-${Y} <${W}.${+X+1}.0-0`;else G=`>=${W}.${X}.${H} <${W}.${+X+1}.0-0`;return k("tilde return",G),G})},N5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>R5(Q,q)).join(" ")},R5=($,q)=>{k("caret",$,q);let Q=q.loose?m[g.CARETLOOSE]:m[g.CARET],J=q.includePrerelease?"-0":"";return $.replace(Q,(W,X,H,Y,G)=>{k("caret",$,W,X,H,Y,G);let w;if(l(X))w="";else if(l(H))w=`>=${X}.0.0${J} <${+X+1}.0.0-0`;else if(l(Y))if(X==="0")w=`>=${X}.${H}.0${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.0${J} <${+X+1}.0.0-0`;else if(G)if(k("replaceCaret pr",G),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}-${G} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}-${G} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y}-${G} <${+X+1}.0.0-0`;else if(k("no pr"),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}${J} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y} <${+X+1}.0.0-0`;return k("caret return",w),w})},S5=($,q)=>{return k("replaceXRanges",$,q),$.split(/\s+/).map((Q)=>M5(Q,q)).join(" ")},M5=($,q)=>{$=$.trim();let Q=q.loose?m[g.XRANGELOOSE]:m[g.XRANGE];return $.replace(Q,(J,W,X,H,Y,G)=>{k("xRange",$,J,W,X,H,Y,G);let w=l(X),V=w||l(H),U=V||l(Y),M=U;if(W==="="&&M)W="";if(G=q.includePrerelease?"-0":"",w)if(W===">"||W==="<")J="<0.0.0-0";else J="*";else if(W&&M){if(V)H=0;if(Y=0,W===">")if(W=">=",V)X=+X+1,H=0,Y=0;else H=+H+1,Y=0;else if(W==="<=")if(W="<",V)X=+X+1;else H=+H+1;if(W==="<")G="-0";J=`${W+X}.${H}.${Y}${G}`}else if(V)J=`>=${X}.0.0${G} <${+X+1}.0.0-0`;else if(U)J=`>=${X}.${H}.0${G} <${X}.${+H+1}.0-0`;return k("xRange return",J),J})},E5=($,q)=>{return k("replaceStars",$,q),$.trim().replace(m[g.STAR],"")},A5=($,q)=>{return k("replaceGTE0",$,q),$.trim().replace(m[q.includePrerelease?g.GTE0PRE:g.GTE0],"")},C5=($)=>(q,Q,J,W,X,H,Y,G,w,V,U,M)=>{if(l(J))Q="";else if(l(W))Q=`>=${J}.0.0${$?"-0":""}`;else if(l(X))Q=`>=${J}.${W}.0${$?"-0":""}`;else if(H)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(l(w))G="";else if(l(V))G=`<${+w+1}.0.0-0`;else if(l(U))G=`<${w}.${+V+1}.0-0`;else if(M)G=`<=${w}.${V}.${U}-${M}`;else if($)G=`<${w}.${V}.${+U+1}-0`;else G=`<=${G}`;return`${Q} ${G}`.trim()},K5=($,q,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(q))return!1;if(q.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(k($[J].semver),$[J].semver===n0.ANY)continue;if($[J].semver.prerelease.length>0){let W=$[J].semver;if(W.major===q.major&&W.minor===q.minor&&W.patch===q.patch)return!0}}return!1}return!0}});var V6=z((CY,p4)=>{var F6=Symbol("SemVer ANY");class W0{static get ANY(){return F6}constructor($,q){if(q=m4(q),$ instanceof W0)if($.loose===!!q.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),r0("comparator",$,q),this.options=q,this.loose=!!q.loose,this.parse($),this.semver===F6)this.value="";else this.value=this.operator+this.semver.version;r0("comp",this)}parse($){let q=this.options.loose?l4[u4.COMPARATORLOOSE]:l4[u4.COMPARATOR],Q=$.match(q);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=F6;else this.semver=new c4(Q[2],this.options.loose)}toString(){return this.value}test($){if(r0("Comparator.test",$,this.options.loose),this.semver===F6||$===F6)return!0;if(typeof $==="string")try{$=new c4($,this.options)}catch(q){return!1}return i0($,this.operator,this.semver,this.options)}intersects($,q){if(!($ instanceof W0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new d4($.value,q).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new d4(this.value,q).test($.semver)}if(q=m4(q),q.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!q.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(i0(this.semver,"<",$.semver,q)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(i0(this.semver,">",$.semver,q)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}p4.exports=W0;var m4=i6(),{safeRe:l4,t:u4}=v$(),i0=p0(),r0=G6(),c4=h(),d4=i()});var U6=z((KY,n4)=>{var I5=i(),P5=($,q,Q)=>{try{q=new I5(q,Q)}catch(J){return!1}return q.test($)};n4.exports=P5});var r4=z((IY,i4)=>{var k5=i(),b5=($,q)=>new k5($,q).set.map((Q)=>Q.map((J)=>J.value).join(" ").trim().split(" "));i4.exports=b5});var a4=z((PY,o4)=>{var Z5=h(),f5=i(),T5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new f5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===-1)J=H,W=new Z5(J,Q)}}),J};o4.exports=T5});var t4=z((kY,s4)=>{var x5=h(),v5=i(),h5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new v5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===1)J=H,W=new x5(J,Q)}}),J};s4.exports=h5});var q9=z((bY,$9)=>{var o0=h(),g5=i(),e4=B6(),y5=($,q)=>{$=new g5($,q);let Q=new o0("0.0.0");if($.test(Q))return Q;if(Q=new o0("0.0.0-0"),$.test(Q))return Q;Q=null;for(let J=0;J<$.set.length;++J){let W=$.set[J],X=null;if(W.forEach((H)=>{let Y=new o0(H.semver.version);switch(H.operator){case">":if(Y.prerelease.length===0)Y.patch++;else Y.prerelease.push(0);Y.raw=Y.format();case"":case">=":if(!X||e4(Y,X))X=Y;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${H.operator}`)}}),X&&(!Q||e4(Q,X)))Q=X}if(Q&&$.test(Q))return Q;return null};$9.exports=y5});var J9=z((ZY,Q9)=>{var m5=i(),l5=($,q)=>{try{return new m5($,q).range||"*"}catch(Q){return null}};Q9.exports=l5});var X0=z((fY,Y9)=>{var u5=h(),H9=V6(),{ANY:c5}=H9,d5=i(),p5=U6(),W9=B6(),X9=e6(),n5=q0(),i5=$0(),r5=($,q,Q,J)=>{$=new u5($,J),q=new d5(q,J);let W,X,H,Y,G;switch(Q){case">":W=W9,X=n5,H=X9,Y=">",G=">=";break;case"<":W=X9,X=i5,H=W9,Y="<",G="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(p5($,q,J))return!1;for(let w=0;w<q.set.length;++w){let V=q.set[w],U=null,M=null;if(V.forEach((O)=>{if(O.semver===c5)O=new H9(">=0.0.0");if(U=U||O,M=M||O,W(O.semver,U.semver,J))U=O;else if(H(O.semver,M.semver,J))M=O}),U.operator===Y||U.operator===G)return!1;if((!M.operator||M.operator===Y)&&X($,M.semver))return!1;else if(M.operator===G&&H($,M.semver))return!1}return!0};Y9.exports=r5});var B9=z((TY,G9)=>{var o5=X0(),a5=($,q,Q)=>o5($,q,">",Q);G9.exports=a5});var V9=z((xY,w9)=>{var s5=X0(),t5=($,q,Q)=>s5($,q,"<",Q);w9.exports=t5});var _9=z((vY,U9)=>{var F9=i(),e5=($,q,Q)=>{return $=new F9($,Q),q=new F9(q,Q),$.intersects(q,Q)};U9.exports=e5});var z9=z((hY,D9)=>{var $2=U6(),q2=n();D9.exports=($,q,Q)=>{let J=[],W=null,X=null,H=$.sort((V,U)=>q2(V,U,Q));for(let V of H)if($2(V,q,Q)){if(X=V,!W)W=V}else{if(X)J.push([W,X]);X=null,W=null}if(W)J.push([W,null]);let Y=[];for(let[V,U]of J)if(V===U)Y.push(V);else if(!U&&V===H[0])Y.push("*");else if(!U)Y.push(`>=${V}`);else if(V===H[0])Y.push(`<=${U}`);else Y.push(`${V} - ${U}`);let G=Y.join(" || "),w=typeof q.raw==="string"?q.raw:String(q);return G.length<w.length?G:q}});var S9=z((gY,R9)=>{var L9=i(),s0=V6(),{ANY:a0}=s0,_6=U6(),t0=n(),Q2=($,q,Q={})=>{if($===q)return!0;$=new L9($,Q),q=new L9(q,Q);let J=!1;$:for(let W of $.set){for(let X of q.set){let H=W2(W,X,Q);if(J=J||H!==null,H)continue $}if(J)return!1}return!0},J2=[new s0(">=0.0.0-0")],j9=[new s0(">=0.0.0")],W2=($,q,Q)=>{if($===q)return!0;if($.length===1&&$[0].semver===a0)if(q.length===1&&q[0].semver===a0)return!0;else if(Q.includePrerelease)$=J2;else $=j9;if(q.length===1&&q[0].semver===a0)if(Q.includePrerelease)return!0;else q=j9;let J=new Set,W,X;for(let O of $)if(O.operator===">"||O.operator===">=")W=O9(W,O,Q);else if(O.operator==="<"||O.operator==="<=")X=N9(X,O,Q);else J.add(O.semver);if(J.size>1)return null;let H;if(W&&X){if(H=t0(W.semver,X.semver,Q),H>0)return null;else if(H===0&&(W.operator!==">="||X.operator!=="<="))return null}for(let O of J){if(W&&!_6(O,String(W),Q))return null;if(X&&!_6(O,String(X),Q))return null;for(let P of q)if(!_6(O,String(P),Q))return!1;return!0}let Y,G,w,V,U=X&&!Q.includePrerelease&&X.semver.prerelease.length?X.semver:!1,M=W&&!Q.includePrerelease&&W.semver.prerelease.length?W.semver:!1;if(U&&U.prerelease.length===1&&X.operator==="<"&&U.prerelease[0]===0)U=!1;for(let O of q){if(V=V||O.operator===">"||O.operator===">=",w=w||O.operator==="<"||O.operator==="<=",W){if(M){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===M.major&&O.semver.minor===M.minor&&O.semver.patch===M.patch)M=!1}if(O.operator===">"||O.operator===">="){if(Y=O9(W,O,Q),Y===O&&Y!==W)return!1}else if(W.operator===">="&&!_6(W.semver,String(O),Q))return!1}if(X){if(U){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===U.major&&O.semver.minor===U.minor&&O.semver.patch===U.patch)U=!1}if(O.operator==="<"||O.operator==="<="){if(G=N9(X,O,Q),G===O&&G!==X)return!1}else if(X.operator==="<="&&!_6(X.semver,String(O),Q))return!1}if(!O.operator&&(X||W)&&H!==0)return!1}if(W&&w&&!X&&H!==0)return!1;if(X&&V&&!W&&H!==0)return!1;if(M||U)return!1;return!0},O9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J>0?$:J<0?q:q.operator===">"&&$.operator===">="?q:$},N9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J<0?$:J>0?q:q.operator==="<"&&$.operator==="<="?q:$};R9.exports=Q2});var H0=z((yY,A9)=>{var e0=v$(),M9=Y6(),X2=h(),E9=l0(),H2=S$(),Y2=o1(),G2=s1(),B2=$4(),w2=J4(),V2=X4(),F2=Y4(),U2=B4(),_2=V4(),D2=n(),z2=D4(),L2=L4(),j2=t6(),O2=R4(),N2=M4(),R2=B6(),S2=e6(),M2=c0(),E2=d0(),A2=$0(),C2=q0(),K2=p0(),I2=Z4(),P2=V6(),k2=i(),b2=U6(),Z2=r4(),f2=a4(),T2=t4(),x2=q9(),v2=J9(),h2=X0(),g2=B9(),y2=V9(),m2=_9(),l2=z9(),u2=S9();A9.exports={parse:H2,valid:Y2,clean:G2,inc:B2,diff:w2,major:V2,minor:F2,patch:U2,prerelease:_2,compare:D2,rcompare:z2,compareLoose:L2,compareBuild:j2,sort:O2,rsort:N2,gt:R2,lt:S2,eq:M2,neq:E2,gte:A2,lte:C2,cmp:K2,coerce:I2,Comparator:P2,Range:k2,satisfies:b2,toComparators:Z2,maxSatisfying:f2,minSatisfying:T2,minVersion:x2,validRange:v2,outside:h2,gtr:g2,ltr:y2,intersects:m2,simplifyRange:l2,subset:u2,SemVer:X2,re:e0.re,src:e0.src,tokens:e0.t,SEMVER_SPEC_VERSION:M9.SEMVER_SPEC_VERSION,RELEASE_TYPES:M9.RELEASE_TYPES,compareIdentifiers:E9.compareIdentifiers,rcompareIdentifiers:E9.rcompareIdentifiers}});var K9=z((mY,C9)=>{var c2=H0();C9.exports=c2.satisfies(process.version,">=15.7.0")});var P9=z((lY,I9)=>{var d2=H0();I9.exports=d2.satisfies(process.version,">=16.9.0")});var $8=z((uY,k9)=>{var p2=K9(),n2=P9(),i2={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},r2={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};k9.exports=function($,q){if(!$||!q)return;let Q=q.asymmetricKeyType;if(!Q)return;let J=i2[Q];if(!J)throw Error(`Unknown key type "${Q}".`);if(!J.includes($))throw Error(`"alg" parameter for "${Q}" key type must be one of: ${J.join(", ")}.`);if(p2)switch(Q){case"ec":let W=q.asymmetricKeyDetails.namedCurve,X=r2[$];if(W!==X)throw Error(`"alg" parameter "${$}" requires curve "${X}".`);break;case"rsa-pss":if(n2){let H=parseInt($.slice(-3),10),{hashAlgorithm:Y,mgf1HashAlgorithm:G,saltLength:w}=q.asymmetricKeyDetails;if(Y!==`sha${H}`||G!==Y)throw Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${$}.`);if(w!==void 0&&w>H>>3)throw Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${$}.`)}break}}});var q8=z((cY,b9)=>{var o2=H0();b9.exports=o2.satisfies(process.version,"^6.12.0 || >=8.0.0")});var T9=z((dY,f9)=>{var I=H6(),a2=v0(),Z9=h0(),s2=x0(),t2=g0(),e2=$8(),$W=q8(),qW=u6(),{KeyObject:QW,createSecretKey:JW,createPublicKey:WW}=require("crypto"),Q8=["RS256","RS384","RS512"],XW=["ES256","ES384","ES512"],J8=["RS256","RS384","RS512"],HW=["HS256","HS384","HS512"];if($W)Q8.splice(Q8.length,0,"PS256","PS384","PS512"),J8.splice(J8.length,0,"PS256","PS384","PS512");f9.exports=function($,q,Q,J){if(typeof Q==="function"&&!J)J=Q,Q={};if(!Q)Q={};Q=Object.assign({},Q);let W;if(J)W=J;else W=function(V,U){if(V)throw V;return U};if(Q.clockTimestamp&&typeof Q.clockTimestamp!=="number")return W(new I("clockTimestamp must be a number"));if(Q.nonce!==void 0&&(typeof Q.nonce!=="string"||Q.nonce.trim()===""))return W(new I("nonce must be a non-empty string"));if(Q.allowInvalidAsymmetricKeyTypes!==void 0&&typeof Q.allowInvalidAsymmetricKeyTypes!=="boolean")return W(new I("allowInvalidAsymmetricKeyTypes must be a boolean"));let X=Q.clockTimestamp||Math.floor(Date.now()/1000);if(!$)return W(new I("jwt must be provided"));if(typeof $!=="string")return W(new I("jwt must be a string"));let H=$.split(".");if(H.length!==3)return W(new I("jwt malformed"));let Y;try{Y=s2($,{complete:!0})}catch(V){return W(V)}if(!Y)return W(new I("invalid token"));let G=Y.header,w;if(typeof q==="function"){if(!J)return W(new I("verify must be called asynchronous if secret or public key is provided as a callback"));w=q}else w=function(V,U){return U(null,q)};return w(G,function(V,U){if(V)return W(new I("error in secret or public key callback: "+V.message));let M=H[2].trim()!=="";if(!M&&U)return W(new I("jwt signature is required"));if(M&&!U)return W(new I("secret or public key must be provided"));if(!M&&!Q.algorithms)return W(new I('please specify "none" in "algorithms" to verify unsigned tokens'));if(U!=null&&!(U instanceof QW))try{U=WW(U)}catch(u){try{U=JW(typeof U==="string"?Buffer.from(U):U)}catch(aq){return W(new I("secretOrPublicKey is not valid key material"))}}if(!Q.algorithms)if(U.type==="secret")Q.algorithms=HW;else if(["rsa","rsa-pss"].includes(U.asymmetricKeyType))Q.algorithms=J8;else if(U.asymmetricKeyType==="ec")Q.algorithms=XW;else Q.algorithms=Q8;if(Q.algorithms.indexOf(Y.header.alg)===-1)return W(new I("invalid algorithm"));if(G.alg.startsWith("HS")&&U.type!=="secret")return W(new I(`secretOrPublicKey must be a symmetric key when using ${G.alg}`));else if(/^(?:RS|PS|ES)/.test(G.alg)&&U.type!=="public")return W(new I(`secretOrPublicKey must be an asymmetric key when using ${G.alg}`));if(!Q.allowInvalidAsymmetricKeyTypes)try{e2(G.alg,U)}catch(u){return W(u)}let O;try{O=qW.verify($,Y.header.alg,U)}catch(u){return W(u)}if(!O)return W(new I("invalid signature"));let P=Y.payload;if(typeof P.nbf<"u"&&!Q.ignoreNotBefore){if(typeof P.nbf!=="number")return W(new I("invalid nbf value"));if(P.nbf>X+(Q.clockTolerance||0))return W(new a2("jwt not active",new Date(P.nbf*1000)))}if(typeof P.exp<"u"&&!Q.ignoreExpiration){if(typeof P.exp!=="number")return W(new I("invalid exp value"));if(X>=P.exp+(Q.clockTolerance||0))return W(new Z9("jwt expired",new Date(P.exp*1000)))}if(Q.audience){let u=Array.isArray(Q.audience)?Q.audience:[Q.audience];if(!(Array.isArray(P.aud)?P.aud:[P.aud]).some(function(v8){return u.some(function(S0){return S0 instanceof RegExp?S0.test(v8):S0===v8})}))return W(new I("jwt audience invalid. expected: "+u.join(" or ")))}if(Q.issuer){if(typeof Q.issuer==="string"&&P.iss!==Q.issuer||Array.isArray(Q.issuer)&&Q.issuer.indexOf(P.iss)===-1)return W(new I("jwt issuer invalid. expected: "+Q.issuer))}if(Q.subject){if(P.sub!==Q.subject)return W(new I("jwt subject invalid. expected: "+Q.subject))}if(Q.jwtid){if(P.jti!==Q.jwtid)return W(new I("jwt jwtid invalid. expected: "+Q.jwtid))}if(Q.nonce){if(P.nonce!==Q.nonce)return W(new I("jwt nonce invalid. expected: "+Q.nonce))}if(Q.maxAge){if(typeof P.iat!=="number")return W(new I("iat required when maxAge is specified"));let u=t2(Q.maxAge,P.iat);if(typeof u>"u")return W(new I('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(X>=u+(Q.clockTolerance||0))return W(new Z9("maxAge exceeded",new Date(u*1000)))}if(Q.complete===!0){let u=Y.signature;return W(null,{header:G,payload:P,signature:u})}return W(null,P)})}});var m9=z((pY,y9)=>{var x9=1/0,h9=9007199254740991,YW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,v9=NaN,GW="[object Arguments]",BW="[object Function]",wW="[object GeneratorFunction]",VW="[object String]",FW="[object Symbol]",UW=/^\s+|\s+$/g,_W=/^[-+]0x[0-9a-f]+$/i,DW=/^0b[01]+$/i,zW=/^0o[0-7]+$/i,LW=/^(?:0|[1-9]\d*)$/,jW=parseInt;function OW($,q){var Q=-1,J=$?$.length:0,W=Array(J);while(++Q<J)W[Q]=q($[Q],Q,$);return W}function NW($,q,Q,J){var W=$.length,X=Q+(J?1:-1);while(J?X--:++X<W)if(q($[X],X,$))return X;return-1}function RW($,q,Q){if(q!==q)return NW($,SW,Q);var J=Q-1,W=$.length;while(++J<W)if($[J]===q)return J;return-1}function SW($){return $!==$}function MW($,q){var Q=-1,J=Array($);while(++Q<$)J[Q]=q(Q);return J}function EW($,q){return OW(q,function(Q){return $[Q]})}function AW($,q){return function(Q){return $(q(Q))}}var Y0=Object.prototype,X8=Y0.hasOwnProperty,G0=Y0.toString,CW=Y0.propertyIsEnumerable,KW=AW(Object.keys,Object),IW=Math.max;function PW($,q){var Q=g9($)||TW($)?MW($.length,String):[],J=Q.length,W=!!J;for(var X in $)if((q||X8.call($,X))&&!(W&&(X=="length"||bW(X,J))))Q.push(X);return Q}function kW($){if(!ZW($))return KW($);var q=[];for(var Q in Object($))if(X8.call($,Q)&&Q!="constructor")q.push(Q);return q}function bW($,q){return q=q==null?h9:q,!!q&&(typeof $=="number"||LW.test($))&&($>-1&&$%1==0&&$<q)}function ZW($){var q=$&&$.constructor,Q=typeof q=="function"&&q.prototype||Y0;return $===Q}function fW($,q,Q,J){$=H8($)?$:dW($),Q=Q&&!J?lW(Q):0;var W=$.length;if(Q<0)Q=IW(W+Q,0);return gW($)?Q<=W&&$.indexOf(q,Q)>-1:!!W&&RW($,q,Q)>-1}function TW($){return xW($)&&X8.call($,"callee")&&(!CW.call($,"callee")||G0.call($)==GW)}var g9=Array.isArray;function H8($){return $!=null&&hW($.length)&&!vW($)}function xW($){return Y8($)&&H8($)}function vW($){var q=W8($)?G0.call($):"";return q==BW||q==wW}function hW($){return typeof $=="number"&&$>-1&&$%1==0&&$<=h9}function W8($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function Y8($){return!!$&&typeof $=="object"}function gW($){return typeof $=="string"||!g9($)&&Y8($)&&G0.call($)==VW}function yW($){return typeof $=="symbol"||Y8($)&&G0.call($)==FW}function mW($){if(!$)return $===0?$:0;if($=uW($),$===x9||$===-x9){var q=$<0?-1:1;return q*YW}return $===$?$:0}function lW($){var q=mW($),Q=q%1;return q===q?Q?q-Q:q:0}function uW($){if(typeof $=="number")return $;if(yW($))return v9;if(W8($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=W8(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(UW,"");var Q=DW.test($);return Q||zW.test($)?jW($.slice(2),Q?2:8):_W.test($)?v9:+$}function cW($){return H8($)?PW($):kW($)}function dW($){return $?EW($,cW($)):[]}y9.exports=fW});var u9=z((nY,l9)=>{var pW="[object Boolean]",nW=Object.prototype,iW=nW.toString;function rW($){return $===!0||$===!1||oW($)&&iW.call($)==pW}function oW($){return!!$&&typeof $=="object"}l9.exports=rW});var i9=z((iY,n9)=>{var c9=1/0,aW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,d9=NaN,sW="[object Symbol]",tW=/^\s+|\s+$/g,eW=/^[-+]0x[0-9a-f]+$/i,$7=/^0b[01]+$/i,q7=/^0o[0-7]+$/i,Q7=parseInt,J7=Object.prototype,W7=J7.toString;function X7($){return typeof $=="number"&&$==B7($)}function p9($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function H7($){return!!$&&typeof $=="object"}function Y7($){return typeof $=="symbol"||H7($)&&W7.call($)==sW}function G7($){if(!$)return $===0?$:0;if($=w7($),$===c9||$===-c9){var q=$<0?-1:1;return q*aW}return $===$?$:0}function B7($){var q=G7($),Q=q%1;return q===q?Q?q-Q:q:0}function w7($){if(typeof $=="number")return $;if(Y7($))return d9;if(p9($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=p9(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(tW,"");var Q=$7.test($);return Q||q7.test($)?Q7($.slice(2),Q?2:8):eW.test($)?d9:+$}n9.exports=X7});var o9=z((rY,r9)=>{var V7="[object Number]",F7=Object.prototype,U7=F7.toString;function _7($){return!!$&&typeof $=="object"}function D7($){return typeof $=="number"||_7($)&&U7.call($)==V7}r9.exports=D7});var e9=z((oY,t9)=>{var z7="[object Object]";function L7($){var q=!1;if($!=null&&typeof $.toString!="function")try{q=!!($+"")}catch(Q){}return q}function j7($,q){return function(Q){return $(q(Q))}}var O7=Function.prototype,a9=Object.prototype,s9=O7.toString,N7=a9.hasOwnProperty,R7=s9.call(Object),S7=a9.toString,M7=j7(Object.getPrototypeOf,Object);function E7($){return!!$&&typeof $=="object"}function A7($){if(!E7($)||S7.call($)!=z7||L7($))return!1;var q=M7($);if(q===null)return!0;var Q=N7.call(q,"constructor")&&q.constructor;return typeof Q=="function"&&Q instanceof Q&&s9.call(Q)==R7}t9.exports=A7});var qq=z((aY,$q)=>{var C7="[object String]",K7=Object.prototype,I7=K7.toString,P7=Array.isArray;function k7($){return!!$&&typeof $=="object"}function b7($){return typeof $=="string"||!P7($)&&k7($)&&I7.call($)==C7}$q.exports=b7});var Hq=z((sY,Xq)=>{var Z7="Expected a function",Qq=1/0,f7=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,Jq=NaN,T7="[object Symbol]",x7=/^\s+|\s+$/g,v7=/^[-+]0x[0-9a-f]+$/i,h7=/^0b[01]+$/i,g7=/^0o[0-7]+$/i,y7=parseInt,m7=Object.prototype,l7=m7.toString;function u7($,q){var Q;if(typeof q!="function")throw TypeError(Z7);return $=i7($),function(){if(--$>0)Q=q.apply(this,arguments);if($<=1)q=void 0;return Q}}function c7($){return u7(2,$)}function Wq($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function d7($){return!!$&&typeof $=="object"}function p7($){return typeof $=="symbol"||d7($)&&l7.call($)==T7}function n7($){if(!$)return $===0?$:0;if($=r7($),$===Qq||$===-Qq){var q=$<0?-1:1;return q*f7}return $===$?$:0}function i7($){var q=n7($),Q=q%1;return q===q?Q?q-Q:q:0}function r7($){if(typeof $=="number")return $;if(p7($))return Jq;if(Wq($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=Wq(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(x7,"");var Q=h7.test($);return Q||g7.test($)?y7($.slice(2),Q?2:8):v7.test($)?Jq:+$}Xq.exports=c7});var Dq=z((tY,_q)=>{var Yq=g0(),o7=q8(),a7=$8(),Gq=u6(),s7=m9(),B0=u9(),Bq=i9(),G8=o9(),Vq=e9(),F$=qq(),t7=Hq(),{KeyObject:e7,createSecretKey:$3,createPrivateKey:q3}=require("crypto"),Fq=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];if(o7)Fq.splice(3,0,"PS256","PS384","PS512");var Q3={expiresIn:{isValid:function($){return Bq($)||F$($)&&$},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function($){return Bq($)||F$($)&&$},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function($){return F$($)||Array.isArray($)},message:'"audience" must be a string or array'},algorithm:{isValid:s7.bind(null,Fq),message:'"algorithm" must be a valid string enum value'},header:{isValid:Vq,message:'"header" must be an object'},encoding:{isValid:F$,message:'"encoding" must be a string'},issuer:{isValid:F$,message:'"issuer" must be a string'},subject:{isValid:F$,message:'"subject" must be a string'},jwtid:{isValid:F$,message:'"jwtid" must be a string'},noTimestamp:{isValid:B0,message:'"noTimestamp" must be a boolean'},keyid:{isValid:F$,message:'"keyid" must be a string'},mutatePayload:{isValid:B0,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:B0,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:B0,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},J3={iat:{isValid:G8,message:'"iat" should be a number of seconds'},exp:{isValid:G8,message:'"exp" should be a number of seconds'},nbf:{isValid:G8,message:'"nbf" should be a number of seconds'}};function Uq($,q,Q,J){if(!Vq(Q))throw Error('Expected "'+J+'" to be a plain object.');Object.keys(Q).forEach(function(W){let X=$[W];if(!X){if(!q)throw Error('"'+W+'" is not allowed in "'+J+'"');return}if(!X.isValid(Q[W]))throw Error(X.message)})}function W3($){return Uq(Q3,!1,$,"options")}function X3($){return Uq(J3,!0,$,"payload")}var wq={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},H3=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];_q.exports=function($,q,Q,J){if(typeof Q==="function")J=Q,Q={};else Q=Q||{};let W=typeof $==="object"&&!Buffer.isBuffer($),X=Object.assign({alg:Q.algorithm||"HS256",typ:W?"JWT":void 0,kid:Q.keyid},Q.header);function H(w){if(J)return J(w);throw w}if(!q&&Q.algorithm!=="none")return H(Error("secretOrPrivateKey must have a value"));if(q!=null&&!(q instanceof e7))try{q=q3(q)}catch(w){try{q=$3(typeof q==="string"?Buffer.from(q):q)}catch(V){return H(Error("secretOrPrivateKey is not valid key material"))}}if(X.alg.startsWith("HS")&&q.type!=="secret")return H(Error(`secretOrPrivateKey must be a symmetric key when using ${X.alg}`));else if(/^(?:RS|PS|ES)/.test(X.alg)){if(q.type!=="private")return H(Error(`secretOrPrivateKey must be an asymmetric key when using ${X.alg}`));if(!Q.allowInsecureKeySizes&&!X.alg.startsWith("ES")&&q.asymmetricKeyDetails!==void 0&&q.asymmetricKeyDetails.modulusLength<2048)return H(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`))}if(typeof $>"u")return H(Error("payload is required"));else if(W){try{X3($)}catch(w){return H(w)}if(!Q.mutatePayload)$=Object.assign({},$)}else{let w=H3.filter(function(V){return typeof Q[V]<"u"});if(w.length>0)return H(Error("invalid "+w.join(",")+" option for "+typeof $+" payload"))}if(typeof $.exp<"u"&&typeof Q.expiresIn<"u")return H(Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(typeof $.nbf<"u"&&typeof Q.notBefore<"u")return H(Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{W3(Q)}catch(w){return H(w)}if(!Q.allowInvalidAsymmetricKeyTypes)try{a7(X.alg,q)}catch(w){return H(w)}let Y=$.iat||Math.floor(Date.now()/1000);if(Q.noTimestamp)delete $.iat;else if(W)$.iat=Y;if(typeof Q.notBefore<"u"){try{$.nbf=Yq(Q.notBefore,Y)}catch(w){return H(w)}if(typeof $.nbf>"u")return H(Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(typeof Q.expiresIn<"u"&&typeof $==="object"){try{$.exp=Yq(Q.expiresIn,Y)}catch(w){return H(w)}if(typeof $.exp>"u")return H(Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(wq).forEach(function(w){let V=wq[w];if(typeof Q[w]<"u"){if(typeof $[V]<"u")return H(Error('Bad "options.'+w+'" option. The payload already has an "'+V+'" property.'));$[V]=Q[w]}});let G=Q.encoding||"utf8";if(typeof J==="function")J=J&&t7(J),Gq.createSign({header:X,privateKey:q,payload:$,encoding:G}).once("error",J).once("done",function(w){if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)return J(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`));J(null,w)});else{let w=Gq.sign({header:X,payload:$,secret:q,encoding:G});if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)throw Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`);return w}}});var Lq=z((eY,zq)=>{zq.exports={decode:x0(),verify:T9(),sign:Dq(),JsonWebTokenError:H6(),NotBeforeError:v0(),TokenExpiredError:h0()}});function D0($){return`https://veloce-ts.com/problems/${$}`}function Pq($,q){if(q)return q;let Q=NX[$]??"unknown-error";return D0(Q)}function kq($,q,Q){if(Q)return Q;return RX[$]??q}function SX($){try{return new URL($.req.url).href}catch{return $.req.path}}function MX($){let q=$.statusCode??$.status,J={error:(typeof $.error==="string"?$.error:null)??(typeof $.detail==="string"?$.detail:"Error"),statusCode:q};if($.details!==void 0)J.details=$.details;else if($.violations!==void 0)J.details=$.violations;return J}function kG($,q,Q,J){let W=SX($),X={...q,instance:W};if(J==="legacy")return $.json(MX(X),Q);return new Response(JSON.stringify(X),{status:Q,headers:{"Content-Type":"application/problem+json"}})}var IG="application/problem+json",PG="https://veloce-ts.com/problems",NX,RX;var F8=E0(()=>{NX={400:"bad-request",401:"unauthorized",403:"forbidden",404:"not-found",409:"conflict",410:"gone",413:"payload-too-large",422:"unprocessable-entity",429:"too-many-requests",500:"internal-server-error",503:"service-unavailable"},RX={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",409:"Conflict",410:"Gone",413:"Payload Too Large",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",503:"Service Unavailable"}});var d,EX,AX,CX,KX,IX,PX,kX,bX,ZX,fX;var bq=E0(()=>{F8();d=class d extends Error{statusCode;details;problemType;title;constructor($,q,Q,J){super(q);this.statusCode=$;this.details=Q;if(this.name="HTTPException",this.problemType=J?.problemType,this.title=J?.title,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){let $=this.statusCode,q=Pq($,this.problemType),Q=kq($,this.message,this.title);return{type:q,title:Q,status:$,detail:this.message,...this.details!==void 0?{details:this.details}:{},error:this.message,statusCode:$}}};EX=class EX extends d{constructor($="Not Found",q){super(404,$,q,{title:"Not Found"});this.name="NotFoundException"}};AX=class AX extends d{constructor($="Unauthorized",q){super(401,$,q,{title:"Unauthorized"});this.name="UnauthorizedException"}};CX=class CX extends d{constructor($="Forbidden",q){super(403,$,q,{title:"Forbidden"});this.name="ForbiddenException"}};KX=class KX extends d{constructor($="Bad Request",q){super(400,$,q,{title:"Bad Request"});this.name="BadRequestException"}};IX=class IX extends d{constructor($="Conflict",q){super(409,$,q,{title:"Conflict"});this.name="ConflictException"}};PX=class PX extends d{constructor($="Gone",q){super(410,$,q,{title:"Gone"});this.name="GoneException"}};kX=class kX extends d{constructor($="Payload Too Large",q){super(413,$,q,{title:"Payload Too Large"});this.name="PayloadTooLargeException"}};bX=class bX extends d{constructor($="Unprocessable Entity",q){super(422,$,q,{title:"Unprocessable Entity"});this.name="UnprocessableEntityException"}};ZX=class ZX extends d{constructor($="Too Many Requests",q){super(429,$,q,{title:"Too Many Requests"});this.name="TooManyRequestsException"}};fX=class fX extends d{constructor($="Service Unavailable",q){super(503,$,q,{title:"Service Unavailable"});this.name="ServiceUnavailableException"}}});var TX={};M0(TX,{TokenRevokedException:()=>U8,TokenExpiredException:()=>S6,InvalidTokenException:()=>I$,AuthorizationException:()=>x,AuthenticationException:()=>f});var f,x,S6,I$,U8;var w$=E0(()=>{bq();F8();f=class f extends d{constructor($="Authentication required"){super(401,$,void 0,{title:"Authentication Error",problemType:D0("authentication-error")});this.name="AuthenticationException"}};x=class x extends d{constructor($="Insufficient permissions"){super(403,$,void 0,{title:"Authorization Error",problemType:D0("authorization-error")});this.name="AuthorizationException"}};S6=class S6 extends f{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};I$=class I$ extends f{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};U8=class U8 extends f{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var ZH={};M0(ZH,{setSessionData:()=>kH,removeSessionData:()=>bH,isSessionAuthenticated:()=>IH,isOAuthAuthenticated:()=>iX,isAuthenticated:()=>gX,getUserRoles:()=>Z8,getUserResourcePermissions:()=>DH,getUserPermissions:()=>dq,getToken:()=>K8,getSessionUserId:()=>PH,getSessionManager:()=>b6,getSessionData:()=>KH,getRBACManager:()=>cq,getPermissionManager:()=>T8,getOAuthUser:()=>pX,getOAuthToken:()=>nX,getOAuthProvider:()=>rX,getCurrentUser:()=>T,getCurrentSession:()=>q$,getCSRFProtection:()=>CH,getAuthError:()=>yX,createSessionMiddleware:()=>x8,createRBACMiddleware:()=>b8,createPermissionMiddleware:()=>f8,createDefaultRBAC:()=>P8,createAuthMiddleware:()=>C8,checkUserRole:()=>QH,checkUserPermission:()=>JH,checkResourceAccess:()=>iq,canUserAccess:()=>zH,UpdateSessionSchema:()=>NH,TokenRevokedException:()=>U8,TokenPayloadSchema:()=>LX,TokenExpiredException:()=>S6,Token:()=>hX,TeamOnly:()=>VH,TeamMembershipPolicy:()=>O0,SuperAdminOnly:()=>$H,SessionPlugin:()=>oq,SessionManager:()=>P6,SessionGuard:()=>Z6,SessionDataSchema:()=>LH,SessionData:()=>MH,SessionConfigSchema:()=>jH,Session:()=>RH,Roles:()=>lq,RoleSchema:()=>oX,RoleAssignmentSchema:()=>aX,ResourcePermissionSchema:()=>WH,ResourcePermissionCheckSchema:()=>XH,RequireRole:()=>k8,RequirePermission:()=>tX,RequireCSRF:()=>AH,RefreshRequestSchema:()=>OX,RedisSessionStore:()=>R0,RBACPlugin:()=>pq,RBACManager:()=>t$,RBACGuard:()=>C6,PublicResourcePolicy:()=>N0,PublicRead:()=>FH,Permissions:()=>uq,PermissionSchema:()=>nq,PermissionPlugin:()=>rq,PermissionMatcher:()=>e$,PermissionManager:()=>K6,PermissionGuard:()=>I6,PermissionCheckSchema:()=>sX,PKCEUtils:()=>z0,OwnershipPolicy:()=>j0,OwnerOnly:()=>wH,OAuthUserSchema:()=>lX,OAuthUser:()=>cX,OAuthTokensSchema:()=>mX,OAuthToken:()=>dX,OAuthStateManager:()=>L0,OAuthPlugin:()=>mq,OAuthCallbackSchema:()=>I8,OAuth:()=>uX,MinimumRole:()=>qH,MicrosoftOAuthProvider:()=>yq,MemorySessionStore:()=>$6,LoginRequestSchema:()=>jX,JWTProvider:()=>_0,InvalidTokenException:()=>I$,InMemoryUserProvider:()=>Zq,GoogleOAuthProvider:()=>hq,GitHubOAuthProvider:()=>gq,FilteredResource:()=>UH,FilteredAttributes:()=>_H,CurrentUser:()=>vX,CurrentSession:()=>SH,CreateSessionSchema:()=>OH,CanWrite:()=>YH,CanUpdate:()=>GH,CanRead:()=>HH,CanDelete:()=>BH,CanAccess:()=>O$,CSRFToken:()=>EH,CSRFProtection:()=>k6,BaseOAuthProvider:()=>A6,AuthorizationException:()=>x,AuthenticationException:()=>f,AuthService:()=>M6,AuthPlugin:()=>vq,Auth:()=>xX,AdminOnly:()=>eX});module.exports=JQ(ZH);var j$=QQ(Lq(),1);var B={};M0(B,{void:()=>d3,util:()=>K,unknown:()=>u3,union:()=>r3,undefined:()=>y3,tuple:()=>s3,transformer:()=>YX,symbol:()=>g3,string:()=>Cq,strictObject:()=>i3,setErrorMap:()=>B3,set:()=>$X,record:()=>t3,quotelessJson:()=>Y3,promise:()=>HX,preprocess:()=>wX,pipeline:()=>VX,ostring:()=>FX,optional:()=>GX,onumber:()=>UX,oboolean:()=>_X,objectUtil:()=>B8,object:()=>n3,number:()=>Kq,nullable:()=>BX,null:()=>m3,never:()=>c3,nativeEnum:()=>XX,nan:()=>x3,map:()=>e3,makeIssue:()=>D6,literal:()=>JX,lazy:()=>QX,late:()=>f3,isValid:()=>U$,isDirty:()=>V0,isAsync:()=>g$,isAborted:()=>w0,intersection:()=>a3,instanceof:()=>T3,getParsedType:()=>W$,getErrorMap:()=>h$,function:()=>qX,enum:()=>WX,effect:()=>YX,discriminatedUnion:()=>o3,defaultErrorMap:()=>Y$,datetimeRegex:()=>Mq,date:()=>h3,custom:()=>Aq,coerce:()=>DX,boolean:()=>Iq,bigint:()=>v3,array:()=>p3,any:()=>l3,addIssueToContext:()=>D,ZodVoid:()=>L6,ZodUnknown:()=>_$,ZodUnion:()=>d$,ZodUndefined:()=>u$,ZodType:()=>C,ZodTuple:()=>H$,ZodTransformer:()=>$$,ZodSymbol:()=>z6,ZodString:()=>a,ZodSet:()=>C$,ZodSchema:()=>C,ZodRecord:()=>j6,ZodReadonly:()=>s$,ZodPromise:()=>K$,ZodPipeline:()=>R6,ZodParsedType:()=>_,ZodOptional:()=>t,ZodObject:()=>Z,ZodNumber:()=>D$,ZodNullable:()=>B$,ZodNull:()=>c$,ZodNever:()=>X$,ZodNativeEnum:()=>r$,ZodNaN:()=>N6,ZodMap:()=>O6,ZodLiteral:()=>i$,ZodLazy:()=>n$,ZodIssueCode:()=>F,ZodIntersection:()=>p$,ZodFunction:()=>m$,ZodFirstPartyTypeKind:()=>S,ZodError:()=>c,ZodEnum:()=>L$,ZodEffects:()=>$$,ZodDiscriminatedUnion:()=>F0,ZodDefault:()=>o$,ZodDate:()=>E$,ZodCatch:()=>a$,ZodBranded:()=>U0,ZodBoolean:()=>l$,ZodBigInt:()=>z$,ZodArray:()=>s,ZodAny:()=>A$,Schema:()=>C,ParseStatus:()=>v,OK:()=>y,NEVER:()=>zX,INVALID:()=>R,EMPTY_PATH:()=>w3,DIRTY:()=>M$,BRAND:()=>Z3});var K;(function($){$.assertEqual=(W)=>{};function q(W){}$.assertIs=q;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let X={};for(let H of W)X[H]=H;return X},$.getValidEnumValues=(W)=>{let X=$.objectKeys(W).filter((Y)=>typeof W[W[Y]]!=="number"),H={};for(let Y of X)H[Y]=W[Y];return $.objectValues(H)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(X){return W[X]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let X=[];for(let H in W)if(Object.prototype.hasOwnProperty.call(W,H))X.push(H);return X},$.find=(W,X)=>{for(let H of W)if(X(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function J(W,X=" | "){return W.map((H)=>typeof H==="string"?`'${H}'`:H).join(X)}$.joinValues=J,$.jsonStringifyReplacer=(W,X)=>{if(typeof X==="bigint")return X.toString();return X}})(K||(K={}));var B8;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(B8||(B8={}));var _=K.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W$=($)=>{switch(typeof $){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN($)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":if(Array.isArray($))return _.array;if($===null)return _.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return _.promise;if(typeof Map<"u"&&$ instanceof Map)return _.map;if(typeof Set<"u"&&$ instanceof Set)return _.set;if(typeof Date<"u"&&$ instanceof Date)return _.date;return _.object;default:return _.unknown}};var F=K.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Y3=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class c extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(W){return W.message},Q={_errors:[]},J=(W)=>{for(let X of W.issues)if(X.code==="invalid_union")X.unionErrors.map(J);else if(X.code==="invalid_return_type")J(X.returnTypeError);else if(X.code==="invalid_arguments")J(X.argumentsError);else if(X.path.length===0)Q._errors.push(q(X));else{let H=Q,Y=0;while(Y<X.path.length){let G=X.path[Y];if(Y!==X.path.length-1)H[G]=H[G]||{_errors:[]};else H[G]=H[G]||{_errors:[]},H[G]._errors.push(q(X));H=H[G],Y++}}};return J(this),Q}static assert($){if(!($ instanceof c))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,K.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let J of this.issues)if(J.path.length>0){let W=J.path[0];q[W]=q[W]||[],q[W].push($(J))}else Q.push($(J));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}c.create=($)=>{return new c($)};var G3=($,q)=>{let Q;switch($.code){case F.invalid_type:if($.received===_.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case F.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,K.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:Q=`Unrecognized key(s) in object: ${K.joinValues($.keys,", ")}`;break;case F.invalid_union:Q="Invalid input";break;case F.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${K.joinValues($.options)}`;break;case F.invalid_enum_value:Q=`Invalid enum value. Expected ${K.joinValues($.options)}, received '${$.received}'`;break;case F.invalid_arguments:Q="Invalid function arguments";break;case F.invalid_return_type:Q="Invalid function return type";break;case F.invalid_date:Q="Invalid date";break;case F.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else K.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case F.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case F.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case F.custom:Q="Invalid input";break;case F.invalid_intersection_types:Q="Intersection results could not be merged";break;case F.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case F.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,K.assertNever($)}return{message:Q}},Y$=G3;var jq=Y$;function B3($){jq=$}function h$(){return jq}var D6=($)=>{let{data:q,path:Q,errorMaps:J,issueData:W}=$,X=[...Q,...W.path||[]],H={...W,path:X};if(W.message!==void 0)return{...W,path:X,message:W.message};let Y="",G=J.filter((w)=>!!w).slice().reverse();for(let w of G)Y=w(H,{data:q,defaultError:Y}).message;return{...W,path:X,message:Y}},w3=[];function D($,q){let Q=h$(),J=D6({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===Y$?void 0:Y$].filter((W)=>!!W)});$.common.issues.push(J)}class v{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let J of q){if(J.status==="aborted")return R;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let J of q){let W=await J.key,X=await J.value;Q.push({key:W,value:X})}return v.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let J of q){let{key:W,value:X}=J;if(W.status==="aborted")return R;if(X.status==="aborted")return R;if(W.status==="dirty")$.dirty();if(X.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof X.value<"u"||J.alwaysSet))Q[W.value]=X.value}return{status:$.value,value:Q}}}var R=Object.freeze({status:"aborted"}),M$=($)=>({status:"dirty",value:$}),y=($)=>({status:"valid",value:$}),w0=($)=>$.status==="aborted",V0=($)=>$.status==="dirty",U$=($)=>$.status==="valid",g$=($)=>typeof Promise<"u"&&$ instanceof Promise;var N;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(N||(N={}));class e{constructor($,q,Q,J){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=J}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Oq=($,q)=>{if(U$(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new c($.common.issues);return this._error=Q,this._error}}}};function A($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:J,description:W}=$;if(q&&(Q||J))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:W};return{errorMap:(H,Y)=>{let{message:G}=$;if(H.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??J??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:G??Q??Y.defaultError}},description:W}}class C{get description(){return this._def.description}_getType($){return W$($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new v,ctx:{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(g$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return Oq(Q,J)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return U$(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>U$(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parse({data:$,path:Q.path,parent:Q}),W=await(g$(J)?J:Promise.resolve(J));return Oq(Q,W)}refine($,q){let Q=(J)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(J);else return q};return this._refinement((J,W)=>{let X=$(J),H=()=>W.addIssue({code:F.custom,...Q(J)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!X)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof q==="function"?q(Q,J):q),!1;else return!0})}_refinement($){return new $$({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return t.create(this,this._def)}nullable(){return B$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return s.create(this)}promise(){return K$.create(this,this._def)}or($){return d$.create([this,$],this._def)}and($){return p$.create(this,$,this._def)}transform($){return new $$({...A(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new o$({...A(this._def),innerType:this,defaultValue:q,typeName:S.ZodDefault})}brand(){return new U0({typeName:S.ZodBranded,type:this,...A(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new a$({...A(this._def),innerType:this,catchValue:q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return R6.create(this,$)}readonly(){return s$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var V3=/^c[^\s-]{8,}$/i,F3=/^[0-9a-z]+$/,U3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,D3=/^[a-z0-9_-]{21}$/i,z3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,O3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",w8,N3=/^(?:(?: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])$/,R3=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,S3=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M3=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,E3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,A3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rq="((\\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])))",C3=new RegExp(`^${Rq}$`);function Sq($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function K3($){return new RegExp(`^${Sq($)}$`)}function Mq($){let q=`${Rq}T${Sq($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function I3($,q){if((q==="v4"||!q)&&N3.test($))return!0;if((q==="v6"||!q)&&S3.test($))return!0;return!1}function P3($,q){if(!z3.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(J));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(q&&W.alg!==q)return!1;return!0}catch{return!1}}function k3($,q){if((q==="v4"||!q)&&R3.test($))return!0;if((q==="v6"||!q)&&M3.test($))return!0;return!1}class a extends C{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==_.string){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.string,received:W.parsedType}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let X=$.data.length>W.value,H=$.data.length<W.value;if(X||H){if(J=this._getOrReturnCtx($,J),X)D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(H)D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!j3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"email",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!w8)w8=new RegExp(O3,"u");if(!w8.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"emoji",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!_3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"uuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!D3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"nanoid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!V3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!F3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid2",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!U3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"ulid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),D(J,{validation:"url",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"regex",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!Mq(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!C3.test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!K3(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!L3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"duration",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!I3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"ip",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!P3($.data,W.alg))J=this._getOrReturnCtx($,J),D(J,{validation:"jwt",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!k3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"cidr",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!E3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!A3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64url",code:F.invalid_string,message:W.message}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((J)=>$.test(J),{validation:q,code:F.invalid_string,...N.errToObj(Q)})}_addCheck($){return new a({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...N.errToObj($)})}url($){return this._addCheck({kind:"url",...N.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...N.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...N.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...N.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...N.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...N.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...N.errToObj($)})}base64($){return this._addCheck({kind:"base64",...N.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...N.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...N.errToObj($)})}ip($){return this._addCheck({kind:"ip",...N.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...N.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...N.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...N.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...N.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...N.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...N.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...N.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...N.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...N.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...N.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...N.errToObj(q)})}nonempty($){return this.min(1,N.errToObj($))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}a.create=($)=>{return new a({checks:[],typeName:S.ZodString,coerce:$?.coerce??!1,...A($)})};function b3($,q){let Q=($.toString().split(".")[1]||"").length,J=(q.toString().split(".")[1]||"").length,W=Q>J?Q:J,X=Number.parseInt($.toFixed(W).replace(".","")),H=Number.parseInt(q.toFixed(W).replace(".",""));return X%H/10**W}class D$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==_.number){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.number,received:W.parsedType}),R}let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="int"){if(!K.isInteger($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.invalid_type,expected:"integer",received:"float",message:W.message}),J.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if(b3($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_finite,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new D$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new D$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:N.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}finite($){return this._addCheck({kind:"finite",message:N.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&K.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}D$.create=($)=>{return new D$({checks:[],typeName:S.ZodNumber,coerce:$?.coerce||!1,...A($)})};class z$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==_.bigint)return this._getInvalidInput($);let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.bigint,received:q.parsedType}),R}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new z$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new z$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}z$.create=($)=>{return new z$({checks:[],typeName:S.ZodBigInt,coerce:$?.coerce??!1,...A($)})};class l$ extends C{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==_.boolean){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.boolean,received:Q.parsedType}),R}return y($.data)}}l$.create=($)=>{return new l$({typeName:S.ZodBoolean,coerce:$?.coerce||!1,...A($)})};class E$ extends C{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==_.date){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.date,received:W.parsedType}),R}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_date}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:N.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:N.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}E$.create=($)=>{return new E$({checks:[],coerce:$?.coerce||!1,typeName:S.ZodDate,...A($)})};class z6 extends C{_parse($){if(this._getType($)!==_.symbol){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.symbol,received:Q.parsedType}),R}return y($.data)}}z6.create=($)=>{return new z6({typeName:S.ZodSymbol,...A($)})};class u$ extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.undefined,received:Q.parsedType}),R}return y($.data)}}u$.create=($)=>{return new u$({typeName:S.ZodUndefined,...A($)})};class c$ extends C{_parse($){if(this._getType($)!==_.null){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.null,received:Q.parsedType}),R}return y($.data)}}c$.create=($)=>{return new c$({typeName:S.ZodNull,...A($)})};class A$ extends C{constructor(){super(...arguments);this._any=!0}_parse($){return y($.data)}}A$.create=($)=>{return new A$({typeName:S.ZodAny,...A($)})};class _$ extends C{constructor(){super(...arguments);this._unknown=!0}_parse($){return y($.data)}}_$.create=($)=>{return new _$({typeName:S.ZodUnknown,...A($)})};class X$ extends C{_parse($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.never,received:q.parsedType}),R}}X$.create=($)=>{return new X$({typeName:S.ZodNever,...A($)})};class L6 extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.void,received:Q.parsedType}),R}return y($.data)}}L6.create=($)=>{return new L6({typeName:S.ZodVoid,...A($)})};class s extends C{_parse($){let{ctx:q,status:Q}=this._processInputParams($),J=this._def;if(q.parsedType!==_.array)return D(q,{code:F.invalid_type,expected:_.array,received:q.parsedType}),R;if(J.exactLength!==null){let X=q.data.length>J.exactLength.value,H=q.data.length<J.exactLength.value;if(X||H)D(q,{code:X?F.too_big:F.too_small,minimum:H?J.exactLength.value:void 0,maximum:X?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(q.data.length<J.minLength.value)D(q,{code:F.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(q.data.length>J.maxLength.value)D(q,{code:F.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((X,H)=>{return J.type._parseAsync(new e(q,X,q.path,H))})).then((X)=>{return v.mergeArray(Q,X)});let W=[...q.data].map((X,H)=>{return J.type._parseSync(new e(q,X,q.path,H))});return v.mergeArray(Q,W)}get element(){return this._def.type}min($,q){return new s({...this._def,minLength:{value:$,message:N.toString(q)}})}max($,q){return new s({...this._def,maxLength:{value:$,message:N.toString(q)}})}length($,q){return new s({...this._def,exactLength:{value:$,message:N.toString(q)}})}nonempty($){return this.min(1,$)}}s.create=($,q)=>{return new s({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...A(q)})};function y$($){if($ instanceof Z){let q={};for(let Q in $.shape){let J=$.shape[Q];q[Q]=t.create(y$(J))}return new Z({...$._def,shape:()=>q})}else if($ instanceof s)return new s({...$._def,type:y$($.element)});else if($ instanceof t)return t.create(y$($.unwrap()));else if($ instanceof B$)return B$.create(y$($.unwrap()));else if($ instanceof H$)return H$.create($.items.map((q)=>y$(q)));else return $}class Z extends C{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=K.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==_.object){let G=this._getOrReturnCtx($);return D(G,{code:F.invalid_type,expected:_.object,received:G.parsedType}),R}let{status:Q,ctx:J}=this._processInputParams($),{shape:W,keys:X}=this._getCached(),H=[];if(!(this._def.catchall instanceof X$&&this._def.unknownKeys==="strip")){for(let G in J.data)if(!X.includes(G))H.push(G)}let Y=[];for(let G of X){let w=W[G],V=J.data[G];Y.push({key:{status:"valid",value:G},value:w._parse(new e(J,V,J.path,G)),alwaysSet:G in J.data})}if(this._def.catchall instanceof X$){let G=this._def.unknownKeys;if(G==="passthrough")for(let w of H)Y.push({key:{status:"valid",value:w},value:{status:"valid",value:J.data[w]}});else if(G==="strict"){if(H.length>0)D(J,{code:F.unrecognized_keys,keys:H}),Q.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let w of H){let V=J.data[w];Y.push({key:{status:"valid",value:w},value:G._parse(new e(J,V,J.path,w)),alwaysSet:w in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let G=[];for(let w of Y){let V=await w.key,U=await w.value;G.push({key:V,value:U,alwaysSet:w.alwaysSet})}return G}).then((G)=>{return v.mergeObjectSync(Q,G)});else return v.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return N.errToObj,new Z({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let J=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:N.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new Z({...this._def,unknownKeys:"strip"})}passthrough(){return new Z({...this._def,unknownKeys:"passthrough"})}extend($){return new Z({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new Z({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new Z({...this._def,catchall:$})}pick($){let q={};for(let Q of K.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}omit($){let q={};for(let Q of K.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}deepPartial(){return y$(this)}partial($){let q={};for(let Q of K.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])q[Q]=J;else q[Q]=J.optional()}return new Z({...this._def,shape:()=>q})}required($){let q={};for(let Q of K.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof t)W=W._def.innerType;q[Q]=W}return new Z({...this._def,shape:()=>q})}keyof(){return Eq(K.objectKeys(this.shape))}}Z.create=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.strictCreate=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strict",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.lazycreate=($,q)=>{return new Z({shape:$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};class d$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function J(W){for(let H of W)if(H.result.status==="valid")return H.result;for(let H of W)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let X=W.map((H)=>new c(H.ctx.common.issues));return D(q,{code:F.invalid_union,unionErrors:X}),R}if(q.common.async)return Promise.all(Q.map(async(W)=>{let X={...q,common:{...q.common,issues:[]},parent:null};return{result:await W._parseAsync({data:q.data,path:q.path,parent:X}),ctx:X}})).then(J);else{let W=void 0,X=[];for(let Y of Q){let G={...q,common:{...q.common,issues:[]},parent:null},w=Y._parseSync({data:q.data,path:q.path,parent:G});if(w.status==="valid")return w;else if(w.status==="dirty"&&!W)W={result:w,ctx:G};if(G.common.issues.length)X.push(G.common.issues)}if(W)return q.common.issues.push(...W.ctx.common.issues),W.result;let H=X.map((Y)=>new c(Y));return D(q,{code:F.invalid_union,unionErrors:H}),R}}get options(){return this._def.options}}d$.create=($,q)=>{return new d$({options:$,typeName:S.ZodUnion,...A(q)})};var G$=($)=>{if($ instanceof n$)return G$($.schema);else if($ instanceof $$)return G$($.innerType());else if($ instanceof i$)return[$.value];else if($ instanceof L$)return $.options;else if($ instanceof r$)return K.objectValues($.enum);else if($ instanceof o$)return G$($._def.innerType);else if($ instanceof u$)return[void 0];else if($ instanceof c$)return[null];else if($ instanceof t)return[void 0,...G$($.unwrap())];else if($ instanceof B$)return[null,...G$($.unwrap())];else if($ instanceof U0)return G$($.unwrap());else if($ instanceof s$)return G$($.unwrap());else if($ instanceof a$)return G$($._def.innerType);else return[]};class F0 extends C{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.object)return D(q,{code:F.invalid_type,expected:_.object,received:q.parsedType}),R;let Q=this.discriminator,J=q.data[Q],W=this.optionsMap.get(J);if(!W)return D(q,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),R;if(q.common.async)return W._parseAsync({data:q.data,path:q.path,parent:q});else return W._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let J=new Map;for(let W of q){let X=G$(W.shape[$]);if(!X.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of X){if(J.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);J.set(H,W)}}return new F0({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:J,...A(Q)})}}function V8($,q){let Q=W$($),J=W$(q);if($===q)return{valid:!0,data:$};else if(Q===_.object&&J===_.object){let W=K.objectKeys(q),X=K.objectKeys($).filter((Y)=>W.indexOf(Y)!==-1),H={...$,...q};for(let Y of X){let G=V8($[Y],q[Y]);if(!G.valid)return{valid:!1};H[Y]=G.data}return{valid:!0,data:H}}else if(Q===_.array&&J===_.array){if($.length!==q.length)return{valid:!1};let W=[];for(let X=0;X<$.length;X++){let H=$[X],Y=q[X],G=V8(H,Y);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(Q===_.date&&J===_.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class p$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=(W,X)=>{if(w0(W)||w0(X))return R;let H=V8(W.value,X.value);if(!H.valid)return D(Q,{code:F.invalid_intersection_types}),R;if(V0(W)||V0(X))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,X])=>J(W,X));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}p$.create=($,q,Q)=>{return new p$({left:$,right:q,typeName:S.ZodIntersection,...A(Q)})};class H$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.array)return D(Q,{code:F.invalid_type,expected:_.array,received:Q.parsedType}),R;if(Q.data.length<this._def.items.length)return D(Q,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;if(!this._def.rest&&Q.data.length>this._def.items.length)D(Q,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let W=[...Q.data].map((X,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new e(Q,X,Q.path,H))}).filter((X)=>!!X);if(Q.common.async)return Promise.all(W).then((X)=>{return v.mergeArray(q,X)});else return v.mergeArray(q,W)}get items(){return this._def.items}rest($){return new H$({...this._def,rest:$})}}H$.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new H$({items:$,typeName:S.ZodTuple,rest:null,...A(q)})};class j6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.object)return D(Q,{code:F.invalid_type,expected:_.object,received:Q.parsedType}),R;let J=[],W=this._def.keyType,X=this._def.valueType;for(let H in Q.data)J.push({key:W._parse(new e(Q,H,Q.path,H)),value:X._parse(new e(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return v.mergeObjectAsync(q,J);else return v.mergeObjectSync(q,J)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof C)return new j6({keyType:$,valueType:q,typeName:S.ZodRecord,...A(Q)});return new j6({keyType:a.create(),valueType:$,typeName:S.ZodRecord,...A(q)})}}class O6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.map)return D(Q,{code:F.invalid_type,expected:_.map,received:Q.parsedType}),R;let J=this._def.keyType,W=this._def.valueType,X=[...Q.data.entries()].map(([H,Y],G)=>{return{key:J._parse(new e(Q,H,Q.path,[G,"key"])),value:W._parse(new e(Q,Y,Q.path,[G,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of X){let G=await Y.key,w=await Y.value;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of X){let{key:G,value:w}=Y;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}}}}O6.create=($,q,Q)=>{return new O6({valueType:q,keyType:$,typeName:S.ZodMap,...A(Q)})};class C$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.set)return D(Q,{code:F.invalid_type,expected:_.set,received:Q.parsedType}),R;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)D(Q,{code:F.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),q.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)D(Q,{code:F.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),q.dirty()}let W=this._def.valueType;function X(Y){let G=new Set;for(let w of Y){if(w.status==="aborted")return R;if(w.status==="dirty")q.dirty();G.add(w.value)}return{status:q.value,value:G}}let H=[...Q.data.values()].map((Y,G)=>W._parse(new e(Q,Y,Q.path,G)));if(Q.common.async)return Promise.all(H).then((Y)=>X(Y));else return X(H)}min($,q){return new C$({...this._def,minSize:{value:$,message:N.toString(q)}})}max($,q){return new C$({...this._def,maxSize:{value:$,message:N.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}C$.create=($,q)=>{return new C$({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...A(q)})};class m$ extends C{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.function)return D(q,{code:F.invalid_type,expected:_.function,received:q.parsedType}),R;function Q(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_arguments,argumentsError:Y}})}function J(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_return_type,returnTypeError:Y}})}let W={errorMap:q.common.contextualErrorMap},X=q.data;if(this._def.returns instanceof K$){let H=this;return y(async function(...Y){let G=new c([]),w=await H._def.args.parseAsync(Y,W).catch((M)=>{throw G.addIssue(Q(Y,M)),G}),V=await Reflect.apply(X,this,w);return await H._def.returns._def.type.parseAsync(V,W).catch((M)=>{throw G.addIssue(J(V,M)),G})})}else{let H=this;return y(function(...Y){let G=H._def.args.safeParse(Y,W);if(!G.success)throw new c([Q(Y,G.error)]);let w=Reflect.apply(X,this,G.data),V=H._def.returns.safeParse(w,W);if(!V.success)throw new c([J(w,V.error)]);return V.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new m$({...this._def,args:H$.create($).rest(_$.create())})}returns($){return new m$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new m$({args:$?$:H$.create([]).rest(_$.create()),returns:q||_$.create(),typeName:S.ZodFunction,...A(Q)})}}class n$ extends C{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}n$.create=($,q)=>{return new n$({getter:$,typeName:S.ZodLazy,...A(q)})};class i$ extends C{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return D(q,{received:q.data,code:F.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:$.data}}get value(){return this._def.value}}i$.create=($,q)=>{return new i$({value:$,typeName:S.ZodLiteral,...A(q)})};function Eq($,q){return new L$({values:$,typeName:S.ZodEnum,...A(q)})}class L$ extends C{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{expected:K.joinValues(Q),received:q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{received:q.data,code:F.invalid_enum_value,options:Q}),R}return y($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return L$.create($,{...this._def,...q})}exclude($,q=this._def){return L$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}L$.create=Eq;class r$ extends C{_parse($){let q=K.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==_.string&&Q.parsedType!==_.number){let J=K.objectValues(q);return D(Q,{expected:K.joinValues(J),received:Q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(K.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let J=K.objectValues(q);return D(Q,{received:Q.data,code:F.invalid_enum_value,options:J}),R}return y($.data)}get enum(){return this._def.values}}r$.create=($,q)=>{return new r$({values:$,typeName:S.ZodNativeEnum,...A(q)})};class K$ extends C{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.promise&&q.common.async===!1)return D(q,{code:F.invalid_type,expected:_.promise,received:q.parsedType}),R;let Q=q.parsedType===_.promise?q.data:Promise.resolve(q.data);return y(Q.then((J)=>{return this._def.type.parseAsync(J,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}K$.create=($,q)=>{return new K$({type:$,typeName:S.ZodPromise,...A(q)})};class $$ extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=this._def.effect||null,W={addIssue:(X)=>{if(D(Q,X),X.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),J.type==="preprocess"){let X=J.transform(Q.data,W);if(Q.common.async)return Promise.resolve(X).then(async(H)=>{if(q.value==="aborted")return R;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return R;if(Y.status==="dirty")return M$(Y.value);if(q.value==="dirty")return M$(Y.value);return Y});else{if(q.value==="aborted")return R;let H=this._def.schema._parseSync({data:X,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")return M$(H.value);if(q.value==="dirty")return M$(H.value);return H}}if(J.type==="refinement"){let X=(H)=>{let Y=J.refinement(H,W);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(J.type==="transform")if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!U$(X))return R;let H=J.transform(X.value,W);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(!U$(X))return R;return Promise.resolve(J.transform(X.value,W)).then((H)=>({status:q.value,value:H}))});K.assertNever(J)}}$$.create=($,q,Q)=>{return new $$({schema:$,typeName:S.ZodEffects,effect:q,...A(Q)})};$$.createWithPreprocess=($,q,Q)=>{return new $$({schema:q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...A(Q)})};class t extends C{_parse($){if(this._getType($)===_.undefined)return y(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}t.create=($,q)=>{return new t({innerType:$,typeName:S.ZodOptional,...A(q)})};class B$ extends C{_parse($){if(this._getType($)===_.null)return y(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}B$.create=($,q)=>{return new B$({innerType:$,typeName:S.ZodNullable,...A(q)})};class o$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===_.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}o$.create=($,q)=>{return new o$({innerType:$,typeName:S.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...A(q)})};class a$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(g$(J))return J.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}a$.create=($,q)=>{return new a$({innerType:$,typeName:S.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...A(q)})};class N6 extends C{_parse($){if(this._getType($)!==_.nan){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.nan,received:Q.parsedType}),R}return{status:"valid",value:$.data}}}N6.create=($)=>{return new N6({typeName:S.ZodNaN,...A($)})};var Z3=Symbol("zod_brand");class U0 extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class R6 extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return R;if(W.status==="dirty")return q.dirty(),M$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return R;if(J.status==="dirty")return q.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,q){return new R6({in:$,out:q,typeName:S.ZodPipeline})}}class s$ extends C{_parse($){let q=this._def.innerType._parse($),Q=(J)=>{if(U$(J))J.value=Object.freeze(J.value);return J};return g$(q)?q.then((J)=>Q(J)):Q(q)}unwrap(){return this._def.innerType}}s$.create=($,q)=>{return new s$({innerType:$,typeName:S.ZodReadonly,...A(q)})};function Nq($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Aq($,q={},Q){if($)return A$.create().superRefine((J,W)=>{let X=$(J);if(X instanceof Promise)return X.then((H)=>{if(!H){let Y=Nq(q,J),G=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:G})}});if(!X){let H=Nq(q,J),Y=H.fatal??Q??!0;W.addIssue({code:"custom",...H,fatal:Y})}return});return A$.create()}var f3={object:Z.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var T3=($,q={message:`Input not instance of ${$.name}`})=>Aq((Q)=>Q instanceof $,q),Cq=a.create,Kq=D$.create,x3=N6.create,v3=z$.create,Iq=l$.create,h3=E$.create,g3=z6.create,y3=u$.create,m3=c$.create,l3=A$.create,u3=_$.create,c3=X$.create,d3=L6.create,p3=s.create,n3=Z.create,i3=Z.strictCreate,r3=d$.create,o3=F0.create,a3=p$.create,s3=H$.create,t3=j6.create,e3=O6.create,$X=C$.create,qX=m$.create,QX=n$.create,JX=i$.create,WX=L$.create,XX=r$.create,HX=K$.create,YX=$$.create,GX=t.create,BX=B$.create,wX=$$.createWithPreprocess,VX=R6.create,FX=()=>Cq().optional(),UX=()=>Kq().optional(),_X=()=>Iq().optional(),DX={string:($)=>a.create({...$,coerce:!0}),number:($)=>D$.create({...$,coerce:!0}),boolean:($)=>l$.create({...$,coerce:!0}),bigint:($)=>z$.create({...$,coerce:!0}),date:($)=>E$.create({...$,coerce:!0})};var zX=R;class _0{config;blacklistedTokens=new Map;constructor($){this.config=$;if(!$.secret)throw Error("JWT secret is required")}generateTokens($){let q=Math.floor(Date.now()/1000),Q=this.parseExpiration(this.config.expiresIn||"1h"),J={sub:$.sub,...$,iat:q,exp:q+Q,iss:this.config.issuer,aud:this.config.audience},W=j$.sign(J,this.config.secret,{algorithm:this.config.algorithm||"HS256"}),X={sub:$.sub,type:"refresh",iat:q,exp:q+this.parseExpiration(this.config.refreshExpiresIn||"7d"),iss:this.config.issuer,aud:this.config.audience},H=j$.sign(X,this.config.refreshSecret||this.config.secret,{algorithm:this.config.algorithm||"HS256"});return{accessToken:W,refreshToken:H,expiresIn:Q}}verifyAccessToken($){if(this.isBlacklisted($))throw Error("Token has been revoked");try{return j$.verify($,this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience})}catch(q){if(q instanceof Error)throw Error(`Invalid token: ${q.message}`);throw Error("Invalid token")}}verifyRefreshToken($){if(this.isBlacklisted($))throw Error("Refresh token has been revoked");try{let q=j$.verify($,this.config.refreshSecret||this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience});if(q.type!=="refresh")throw Error("Invalid refresh token type");return q}catch(q){if(q instanceof Error)throw Error(`Invalid refresh token: ${q.message}`);throw Error("Invalid refresh token")}}refreshAccessToken($){let q=this.verifyRefreshToken($);return this.blacklistToken($),this.generateTokens({sub:q.sub,...Object.fromEntries(Object.entries(q).filter(([Q])=>!["iat","exp","iss","aud","type"].includes(Q)))})}decodeToken($){try{return j$.decode($)}catch{return null}}blacklistToken($){let Q=this.decodeToken($)?.exp??Math.floor(Date.now()/1000)+3600;this.blacklistedTokens.set($,Q)}isBlacklisted($){let q=this.blacklistedTokens.get($);if(q===void 0)return!1;if(q<Math.floor(Date.now()/1000))return this.blacklistedTokens.delete($),!1;return!0}cleanupBlacklist(){let $=Math.floor(Date.now()/1000);for(let[q,Q]of this.blacklistedTokens)if(Q<$)this.blacklistedTokens.delete(q)}parseExpiration($){if(typeof $==="number")return $;let q={s:1,m:60,h:3600,d:86400,w:604800},Q=$.match(/^(\d+)([smhdw])$/);if(!Q)throw Error(`Invalid expiration format: ${$}`);let[,J,W]=Q;return parseInt(J)*q[W]}}var LX=B.object({sub:B.string(),iat:B.number().optional(),exp:B.number().optional(),iss:B.string().optional(),aud:B.string().optional()}).passthrough(),jX=B.object({username:B.string().min(1),password:B.string().min(1)}),OX=B.object({refreshToken:B.string().min(1)});w$();class M6{config;userProvider;jwtProvider;constructor($,q){this.config=$;this.userProvider=q;this.jwtProvider=new _0($)}async login($,q){let Q=await this.userProvider.findByCredentials($,q);if(!Q)throw new f("Invalid credentials");let J=this.jwtProvider.generateTokens({sub:Q.id,username:Q.username,email:Q.email,roles:Q.roles||[],permissions:Q.permissions||[]});return{user:Q,tokens:J}}async refresh($){try{return this.jwtProvider.refreshAccessToken($)}catch(q){throw new I$(q instanceof Error?q.message:"Invalid refresh token")}}async logout($,q){if(this.jwtProvider.blacklistToken($),q)this.jwtProvider.blacklistToken(q)}async verifyToken($){try{let q=this.jwtProvider.verifyAccessToken($),Q=await this.userProvider.findById(q.sub);if(!Q)throw new f("User not found");return Q}catch(q){if(q instanceof Error){if(q.message.includes("expired"))throw new S6;throw new I$(q.message)}throw new I$("Token verification failed")}}getUserFromToken($){return this.jwtProvider.verifyAccessToken($)}hasRoles($,q){let Q=$.roles||[];return q.every((J)=>Q.includes(J))}hasPermissions($,q){let Q=$.permissions||[];return q.every((J)=>Q.includes(J))}async register($){if(!this.userProvider.createUser)throw Error("UserProvider does not support user creation");let q=await this.userProvider.createUser($),Q=this.jwtProvider.generateTokens({sub:q.id,username:q.username,email:q.email,roles:q.roles||[],permissions:q.permissions||[]});return{user:q,tokens:Q}}cleanup(){this.jwtProvider.cleanupBlacklist()}getJWTProvider(){return this.jwtProvider}}class Zq{users=new Map;async findByCredentials($,q){for(let[Q,J]of this.users)if(J.username===$){if(await this.verifyPassword(q,J.passwordHash)){let{passwordHash:X,...H}=J;return H}}return null}async findById($){let q=this.users.get($);if(q){let{passwordHash:Q,...J}=q;return J}return null}async hashPassword($){return Buffer.from($).toString("base64")}async verifyPassword($,q){return await this.hashPassword($)===q}async createUser($){let q=crypto.randomUUID(),Q=await this.hashPassword($.password),J={id:q,username:$.username,email:$.email,roles:$.roles||["user"],passwordHash:Q};this.users.set(q,J);let{passwordHash:W,...X}=J;return X}}var uG=require("reflect-metadata"),_8=Symbol("route:metadata"),D8=Symbol("controller:metadata"),fq=Symbol("parameter:metadata"),Tq=Symbol("dependency:metadata"),z8=Symbol("websocket:metadata"),xq=Symbol("websocket:handler:metadata"),L8=Symbol("graphql:resolver"),E6=Symbol("graphql:field"),j8=Symbol("auth:metadata"),O8=Symbol("oauth:metadata"),N8=Symbol("roles:metadata"),R8=Symbol("permissions:metadata"),S8=Symbol("minimum-role:metadata"),M8=Symbol("resource-permission:metadata"),E8=Symbol("session:metadata"),A8=Symbol("csrf:metadata");class b{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let q=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(q,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,q){this.controllers.set($,q)}getRoutes(){return Array.from(this.routes.values())}getRoute($,q){let Q=this.getRouteKey($,q);return this.routes.get(Q)}getRoutesByController($){return this.routesByController.get($)||[]}getController($){return this.controllers.get($)}getControllers(){return new Map(this.controllers)}registerWebSocket($){this.websockets.set($.target,$)}getWebSockets(){return Array.from(this.websockets.values())}getWebSocket($){return this.websockets.get($)}registerGraphQLResolver($){this.graphqlResolvers.set($.target,$)}registerGraphQLField($){let q=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(q,$)}getGraphQLResolvers(){return Array.from(this.graphqlResolvers.values())}getGraphQLResolver($){return this.graphqlResolvers.get($)}getGraphQLFields(){return Array.from(this.graphqlFields.values())}getGraphQLFieldsByResolver($){return Array.from(this.graphqlFields.values()).filter((q)=>q.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,q){return`${$.name}:${q}`}static defineRoute($,q,Q){let J=this.getRouteMetadata($,q),W={...J,...Q,target:$.constructor,propertyKey:q,middleware:[...J?.middleware||[],...Q.middleware||[]],parameters:Q.parameters||J?.parameters||[],dependencies:Q.dependencies||J?.dependencies||[],responses:Q.responses||J?.responses||[],auth:Q.auth||J?.auth,oauth:Q.oauth||J?.oauth,roles:Q.roles||J?.roles,permissions:Q.permissions||J?.permissions,minimumRole:Q.minimumRole||J?.minimumRole,resourcePermission:Q.resourcePermission||J?.resourcePermission,session:Q.session||J?.session,csrf:Q.csrf||J?.csrf};Reflect.defineMetadata(_8,W,$,q)}static defineParameter($,q,Q,J){let W=this.getParameterMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(fq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,parameters:W})}static defineDependency($,q,Q,J){let W=this.getDependencyMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(Tq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,dependencies:W})}static defineController($,q){Reflect.defineMetadata(D8,q,$)}static getRouteMetadata($,q){return Reflect.getMetadata(_8,$,q)}static getParameterMetadata($,q){return Reflect.getMetadata(fq,$,q)}static getDependencyMetadata($,q){return Reflect.getMetadata(Tq,$,q)}static getControllerMetadata($){return Reflect.getMetadata(D8,$)}static hasControllerMetadata($){return Reflect.hasMetadata(D8,$)}static hasRouteMetadata($,q){return Reflect.hasMetadata(_8,$,q)}static getRouteMethods($){let q=new Set,Q=[],J=$.prototype;while(J&&J!==Object.prototype){for(let W of Object.getOwnPropertyNames(J)){if(W==="constructor"||q.has(W))continue;if(q.add(W),this.hasRouteMetadata(J,W))Q.push(W)}J=Object.getPrototypeOf(J)}return Q}static defineWebSocket($,q){let J={...this.getWebSocketMetadata($),...q,target:$};Reflect.defineMetadata(z8,J,$)}static defineWebSocketHandler($,q,Q){let J=this.getWebSocketMetadata($.constructor)||{};switch(Q.type){case"connect":J.onConnect=q;break;case"message":J.onMessage=q,J.messageSchema=Q.schema;break;case"disconnect":J.onDisconnect=q;break}this.defineWebSocket($.constructor,J),Reflect.defineMetadata(xq,Q,$,q)}static getWebSocketMetadata($){return Reflect.getMetadata(z8,$)}static getWebSocketHandlerMetadata($,q){return Reflect.getMetadata(xq,$,q)}static hasWebSocketMetadata($){return Reflect.hasMetadata(z8,$)}static defineGraphQLResolver($,q){Reflect.defineMetadata(L8,q,$)}static defineGraphQLField($,q,Q){Reflect.defineMetadata(E6,Q,$,q);let J=this.getGraphQLFieldsMetadata($.constructor)||[];J.push(Q),Reflect.defineMetadata(E6,J,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(L8,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(E6,$)||[]}static getGraphQLFieldMetadata($,q){return Reflect.getMetadata(E6,$,q)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(L8,$)}static hasGraphQLFieldMetadata($,q){return Reflect.hasMetadata(E6,$,q)}static defineAuth($,q,Q){Reflect.defineMetadata(j8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,auth:Q})}static getAuthMetadata($,q){return Reflect.getMetadata(j8,$,q)}static hasAuthMetadata($,q){return Reflect.hasMetadata(j8,$,q)}static defineOAuth($,q,Q){Reflect.defineMetadata(O8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,oauth:Q})}static getOAuthMetadata($,q){return Reflect.getMetadata(O8,$,q)}static hasOAuthMetadata($,q){return Reflect.hasMetadata(O8,$,q)}static defineRoles($,q,Q){Reflect.defineMetadata(N8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,roles:Q})}static definePermissions($,q,Q){Reflect.defineMetadata(R8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,permissions:Q})}static defineMinimumRole($,q,Q){Reflect.defineMetadata(S8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,minimumRole:Q})}static getRolesMetadata($,q){return Reflect.getMetadata(N8,$,q)}static getPermissionsMetadata($,q){return Reflect.getMetadata(R8,$,q)}static getMinimumRoleMetadata($,q){return Reflect.getMetadata(S8,$,q)}static hasRolesMetadata($,q){return Reflect.hasMetadata(N8,$,q)}static hasPermissionsMetadata($,q){return Reflect.hasMetadata(R8,$,q)}static hasMinimumRoleMetadata($,q){return Reflect.hasMetadata(S8,$,q)}static defineResourcePermission($,q,Q){Reflect.defineMetadata(M8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,resourcePermission:Q})}static getResourcePermissionMetadata($,q){return Reflect.getMetadata(M8,$,q)}static hasResourcePermissionMetadata($,q){return Reflect.hasMetadata(M8,$,q)}static defineSession($,q,Q){Reflect.defineMetadata(E8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,session:Q})}static defineCSRF($,q,Q){Reflect.defineMetadata(A8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,csrf:Q})}static getSessionMetadata($,q){return Reflect.getMetadata(E8,$,q)}static getCSRFMetadata($,q){return Reflect.getMetadata(A8,$,q)}static hasSessionMetadata($,q){return Reflect.hasMetadata(E8,$,q)}static hasCSRFMetadata($,q){return Reflect.hasMetadata(A8,$,q)}}function xX($){return(q,Q)=>{let J={required:!$?.optional,config:$};b.defineAuth(q,Q,J)}}function vX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-user",required:!1})}}function hX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"token",required:!1})}}function C8($){return async(q,Q)=>{let J=q.req.header("Authorization");if(!J||!J.startsWith("Bearer "))q.set("auth.error","Missing or invalid Authorization header"),q.set("auth.authenticated",!1);else{let W=J.substring(7);try{let X=$.verifyAccessToken(W);q.set("auth.user",X),q.set("auth.token",W),q.set("auth.authenticated",!0)}catch(X){q.set("auth.error",X instanceof Error?X.message:"Authentication failed"),q.set("auth.authenticated",!1)}}await Q()}}function T($){return $.get("auth.user")||null}function K8($){return $.get("auth.token")||null}function gX($){return $.get("auth.authenticated")===!0}function yX($){return $.get("auth.error")||null}w$();w$();class vq{config;name="auth";version="1.0.0";authService;compileExtended=!1;constructor($){this.config=$;this.authService=new M6($.jwt,$.userProvider)}async install($){let q=C8(this.authService.getJWTProvider());if($.use(q),$.getContainer().register(M6,{factory:()=>this.authService,scope:"singleton"}),this.config.enableDefaultRoutes!==!1)this.addDefaultRoutes($);this.extendRouterCompiler($)}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0,$.use(async(Q,J)=>{Q.set("authService",this.authService),await J()});let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getHono(),J=$.getMetadata().getRoutes();for(let W of J){let X=b.getAuthMetadata(W.target.prototype,W.propertyKey);if(W.auth?.required||X?.required){let Y=W.auth?.config||X?.config;Q.use(W.path,async(G,w)=>{if(G.req.method!==W.method)return w();let V=G.get("auth.user"),U=G.get("auth.error");if(!V)throw new f(U||"Authentication required");if(Y?.roles?.length){if(!this.authService.hasRoles(V,Y.roles))throw new x(`Required roles: ${Y.roles.join(", ")}`)}if(Y?.permissions?.length){if(!this.authService.hasPermissions(V,Y.permissions))throw new x(`Required permissions: ${Y.permissions.join(", ")}`)}await w()})}}}}buildPath($){return $.path}pathMatches($,q){let Q=$.replace(/:([^/]+)/g,"([^/]+)");return new RegExp(`^${Q}$`).test(q)}addDefaultRoutes($){let q=this.config.routes||{};if($.post(q.login||"/auth/login",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X}=J;try{let H=await this.authService.login(W,X);return{success:!0,user:H.user,tokens:H.tokens}}catch(H){throw new f(H instanceof Error?H.message:"Login failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(1)})}}),$.post(q.refresh||"/auth/refresh",{handler:async(Q)=>{let J=await Q.req.json(),{refreshToken:W}=J;try{return{success:!0,tokens:await this.authService.refresh(W)}}catch(X){throw new f(X instanceof Error?X.message:"Token refresh failed")}},schema:{body:B.object({refreshToken:B.string().min(1)})}}),$.post(q.logout||"/auth/logout",{handler:async(Q)=>{let J=K8(Q),W=await Q.req.json(),{refreshToken:X}=W;if(J)await this.authService.logout(J,X);return{success:!0,message:"Logged out successfully"}},schema:{body:B.object({refreshToken:B.string().optional()})}}),"createUser"in this.config.userProvider)$.post(q.register||"/auth/register",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X,email:H}=J;try{let Y=await this.authService.register({username:W,password:X,email:H});return{success:!0,user:Y.user,tokens:Y.tokens}}catch(Y){throw new f(Y instanceof Error?Y.message:"Registration failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(6),email:B.string().email().optional()})}});$.get("/auth/me",{handler:async(Q)=>{let J=T(Q);if(!J)throw new f("Not authenticated");return{success:!0,user:J}}})}getAuthService(){return this.authService}}class A6{name;config;constructor($,q){this.name=$;this.config=q}getAuthUrl($,q){let Q=new URLSearchParams({client_id:this.config.clientId,redirect_uri:this.config.redirectUri,response_type:"code",state:$,scope:this.config.scopes?.join(" ")||""});if(q&&this.config.pkce)Q.set("code_challenge",q),Q.set("code_challenge_method","S256");return`${this.config.authUrl}?${Q.toString()}`}async exchangeCodeForTokens($,q){let Q=new URLSearchParams({client_id:this.config.clientId,client_secret:this.config.clientSecret,code:$,grant_type:"authorization_code",redirect_uri:this.config.redirectUri});if(q&&this.config.pkce)Q.set("code_verifier",q);let J=await fetch(this.config.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!J.ok){let X=await J.text();throw Error(`Token exchange failed: ${X}`)}let W=await J.json();return{accessToken:W.access_token,refreshToken:W.refresh_token,expiresIn:W.expires_in,tokenType:W.token_type||"Bearer",scope:W.scope}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/json"}});if(!q.ok){let J=await q.text();throw Error(`Failed to get user info: ${J}`)}let Q=await q.json();return this.mapUserInfo(Q)}mapUserInfo($){return{id:$.id||$.sub,email:$.email,name:$.name,username:$.login||$.preferred_username,avatar:$.avatar_url||$.picture,provider:this.name,...$}}}class hq extends A6{constructor($,q,Q){super("google",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v2/userinfo",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.email,name:$.name,username:$.email,avatar:$.picture,provider:"google",verified:$.verified_email,locale:$.locale,raw:$}}}class gq extends A6{constructor($,q,Q){super("github",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["user:email"],authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",pkce:!1})}mapUserInfo($){return{id:$.id.toString(),email:$.email,name:$.name,username:$.login,avatar:$.avatar_url,provider:"github",company:$.company,location:$.location,bio:$.bio,raw:$}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(!q.ok)throw Error(`Failed to get user info: ${await q.text()}`);let Q=await q.json();if(!Q.email)try{let J=await fetch("https://api.github.com/user/emails",{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(J.ok){let X=(await J.json()).find((H)=>H.primary);if(X)Q.email=X.email}}catch(J){}return this.mapUserInfo(Q)}}class yq extends A6{constructor($,q,Q,J="common"){super("microsoft",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/token`,userInfoUrl:"https://graph.microsoft.com/v1.0/me",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.mail||$.userPrincipalName,name:$.displayName,username:$.userPrincipalName,avatar:void 0,provider:"microsoft",jobTitle:$.jobTitle,department:$.department,officeLocation:$.officeLocation,raw:$}}}class z0{static generateCodeVerifier(){let $=new Uint8Array(32);return crypto.getRandomValues($),this.base64URLEncode($)}static async generateCodeChallenge($){let Q=new TextEncoder().encode($),J=await crypto.subtle.digest("SHA-256",Q);return this.base64URLEncode(new Uint8Array(J))}static async generatePKCEChallenge(){let $=this.generateCodeVerifier(),q=await this.generateCodeChallenge($);return{codeVerifier:$,codeChallenge:q,codeChallengeMethod:"S256"}}static base64URLEncode($){return btoa(String.fromCharCode(...$)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}class L0{states=new Map;ttl=600000;generateState($){let q=crypto.randomUUID();return this.states.set(q,{timestamp:Date.now(),data:$}),this.cleanup(),q}validateState($){let q=this.states.get($);if(!q)return{valid:!1};if(Date.now()-q.timestamp>this.ttl)return this.states.delete($),{valid:!1};return this.states.delete($),{valid:!0,data:q.data}}cleanup(){let $=Date.now();for(let[q,Q]of this.states.entries())if($-Q.timestamp>this.ttl)this.states.delete(q)}}var I8=B.object({code:B.string(),state:B.string(),error:B.string().optional(),error_description:B.string().optional()}),mX=B.object({accessToken:B.string(),refreshToken:B.string().optional(),expiresIn:B.number().optional(),tokenType:B.string(),scope:B.string().optional()}),lX=B.object({id:B.string(),email:B.string().optional(),name:B.string().optional(),username:B.string().optional(),avatar:B.string().optional(),provider:B.string()}).passthrough();function uX($){return(q,Q)=>{let J={provider:$.provider,config:$};b.defineOAuth(q,Q,J)}}function cX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-user",required:!0})}}function dX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-token",required:!0})}}function pX($){return $.get("oauth.user")||null}function nX($){return $.get("oauth.token")||null}function iX($){return $.get("oauth.authenticated")===!0}function rX($){return $.get("oauth.provider")||null}class mq{config;name="oauth";version="1.0.0";dependencies=["auth"];stateManager=new L0;pkceStore=new Map;pkceStoreTTLMs=600000;constructor($){this.config=$}async install($){this.addOAuthRoutes($),this.extendRouterCompiler($)}addOAuthRoutes($){let q=this.config.routes||{};$.get(q.login||"/auth/oauth/:provider",{handler:async(Q)=>{let J=Q.req.param("provider"),W=this.config.providers[J];if(!W)return Q.json({error:"Unknown OAuth provider"},400);let X=this.stateManager.generateState({provider:J}),H;if(this.cleanupPkceStore(),W.config.pkce){let Y=await z0.generatePKCEChallenge();this.pkceStore.set(X,{challenge:Y,expiresAt:Date.now()+this.pkceStoreTTLMs}),H=W.getAuthUrl(X,Y.codeChallenge)}else H=W.getAuthUrl(X);return Q.json({authUrl:H,state:X,provider:J})}}),$.get(q.callback||"/auth/oauth/:provider/callback",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.query(),X=I8.parse(W);if(X.error)return Q.json({error:"OAuth error",description:X.error_description||X.error},400);let H=this.stateManager.validateState(X.state);if(!H.valid||H.data?.provider!==J)return Q.json({error:"Invalid state parameter"},400);let Y=this.config.providers[J];if(!Y)return Q.json({error:"Unknown OAuth provider"},400);try{let w=this.pkceStore.get(X.state)?.challenge.codeVerifier,V=await Y.exchangeCodeForTokens(X.code,w),U=await Y.getUserInfo(V.accessToken);this.pkceStore.delete(X.state);let M=null;if(this.config.userProvider)M=await this.findOrCreateUser(U);if(this.config.onUserLogin)await this.config.onUserLogin(U,M);let O=null;if(this.config.authService&&M)O=this.config.authService.getJWTProvider().generateTokens({sub:String(M.id??M.username??U.id),username:M.username,email:M.email});return Q.json({success:!0,user:M||U,oauthTokens:V,jwtTokens:O,provider:J})}catch(G){return console.error("OAuth callback error:",G),Q.json({error:"OAuth authentication failed",message:G instanceof Error?G.message:"Unknown error"},500)}}}),$.get("/auth/oauth/:provider/user",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.header("Authorization");if(!W||!W.startsWith("Bearer "))return Q.json({error:"Missing OAuth access token"},401);let X=W.substring(7),H=this.config.providers[J];if(!H)return Q.json({error:"Unknown OAuth provider"},400);try{let Y=await H.getUserInfo(X);return Q.json({user:Y})}catch(Y){return Q.json({error:"Failed to get user info",message:Y instanceof Error?Y.message:"Unknown error"},400)}}})}cleanupPkceStore(){let $=Date.now();for(let[q,Q]of this.pkceStore)if(Q.expiresAt<$)this.pkceStore.delete(q)}async findOrCreateUser($){if(!this.config.userProvider)return null;let q=await this.findUserByOAuthId($.id,$.provider);if(!q&&$.email)q=await this.findUserByEmail($.email);if(!q){if(q=await this.createUserFromOAuth($),this.config.onUserCreated)await this.config.onUserCreated($)}return q}async findUserByOAuthId($,q){return null}async findUserByEmail($){return null}async createUserFromOAuth($){if(!this.config.userProvider||!("createUser"in this.config.userProvider))throw Error("User provider does not support user creation");let q={username:$.username||$.email||`${$.provider}_${$.id}`,email:$.email,password:crypto.randomUUID(),roles:["user"],oauthId:$.id,oauthProvider:$.provider,name:$.name,avatar:$.avatar};return await this.config.userProvider.createUser(q)}extendRouterCompiler($){}getProvider($){return this.config.providers[$]}getProviders(){return{...this.config.providers}}}class t${roles=new Map;hierarchy=new Map;compiledPermissions=new Map;defineRole($){if(this.roles.set($.name,$),$.inherits&&$.inherits.length>0)this.hierarchy.set($.name,$.inherits);this.compiledPermissions.clear()}defineRoles($){for(let q of $)this.defineRole(q)}getRolePermissions($){if(this.compiledPermissions.has($))return Array.from(this.compiledPermissions.get($));let q=new Set;return this.collectPermissions($,q,new Set),this.compiledPermissions.set($,q),Array.from(q)}roleHasPermission($,q){return this.getRolePermissions($).includes(q)}userHasPermission($,q){for(let Q of $)if(this.roleHasPermission(Q,q))return!0;return!1}userHasRoles($,q){return q.every((Q)=>$.includes(Q))}userHasAnyRole($,q){return q.some((Q)=>$.includes(Q))}getRolesWithPermission($){let q=[];for(let Q of this.roles.keys())if(this.roleHasPermission(Q,$))q.push(Q);return q}getRoleHierarchy($){let q=[];return this.collectParentRoles($,q,new Set),q}roleInheritsFrom($,q){return this.getRoleHierarchy($).includes(q)}getAllRoles(){return Array.from(this.roles.values())}getRole($){return this.roles.get($)}roleExists($){return this.roles.has($)}validateRoles($){let q=[],Q=[];for(let J of $)if(this.roleExists(J))q.push(J);else Q.push(J);return{valid:q,invalid:Q}}getEffectiveRoles($){let q=new Set;for(let Q of $)q.add(Q),this.getRoleHierarchy(Q).forEach((W)=>q.add(W));return Array.from(q)}compareRoleLevels($,q){let Q=this.getRole($),J=this.getRole(q),W=Q?.level??0,X=J?.level??0;return W-X}getHighestRoleLevel($){let q=0;for(let Q of $){let J=this.getRole(Q);if(J&&J.level&&J.level>q)q=J.level}return q}collectPermissions($,q,Q){if(Q.has($))throw Error(`Circular role inheritance detected: ${$}`);Q.add($);let J=this.roles.get($);if(!J)throw Error(`Role not found: ${$}`);J.permissions.forEach((X)=>q.add(X));let W=this.hierarchy.get($)||[];for(let X of W)this.collectPermissions(X,q,new Set(Q))}collectParentRoles($,q,Q){if(Q.has($))return;Q.add($);let J=this.hierarchy.get($)||[];for(let W of J)q.push(W),this.collectParentRoles(W,q,Q)}}function P8(){let $=new t$;return $.defineRoles([{name:"guest",description:"Guest user with minimal permissions",permissions:["read:public"],level:1},{name:"user",description:"Regular authenticated user",permissions:["read:own","write:own","read:public"],inherits:["guest"],level:10},{name:"moderator",description:"Moderator with content management permissions",permissions:["read:all","write:all","moderate:content"],inherits:["user"],level:50},{name:"admin",description:"Administrator with full system access",permissions:["*"],inherits:["moderator"],level:100},{name:"super-admin",description:"Super administrator with unrestricted access",permissions:["*","system:*"],inherits:["admin"],level:1000}]),$}var oX=B.object({name:B.string().min(1),description:B.string().optional(),permissions:B.array(B.string()),inherits:B.array(B.string()).optional(),level:B.number().optional()}),aX=B.object({userId:B.string(),roles:B.array(B.string())}),sX=B.object({userId:B.string(),permission:B.string()});class e${static matches($,q){if(q==="*")return!0;if(q.endsWith("*")){let Q=q.slice(0,-1);return $.startsWith(Q)}return $===q}static hasPermission($,q){return $.some((Q)=>this.matches(q,Q))}static filterByPattern($,q){return $.filter((Q)=>this.matches(Q,q))}}w$();function lq($){return(q,Q)=>{let W={config:Array.isArray($)?{roles:$,requireAll:!1,allowInherited:!0}:{requireAll:!1,allowInherited:!0,...$}};b.defineRoles(q,Q,W)}}function uq($){return(q,Q)=>{let W={config:Array.isArray($)?{permissions:$,requireAll:!1}:{requireAll:!1,...$}};b.definePermissions(q,Q,W)}}function k8($){return lq([$])}function tX($){return uq([$])}function eX(){return k8("admin")}function $H(){return k8("super-admin")}function qH($){return(q,Q)=>{b.defineMinimumRole(q,Q,{roleName:$})}}function b8($){return async(q,Q)=>{q.set("rbac",$),await Q()}}class C6{rbac;constructor($){this.rbac=$}checkRoles($,q){let Q=T($);if(!Q)throw new x("Authentication required for role check");let J=Q.roles||[],W=q.allowInherited?this.rbac.getEffectiveRoles(J):J,X;if(q.requireAll)X=q.roles.every((H)=>W.includes(H));else X=q.roles.some((H)=>W.includes(H));if(!X){let H=q.requireAll?"all":"any";throw new x(`Access denied. Required ${H} of roles: ${q.roles.join(", ")}`)}}checkPermissions($,q){let Q=T($);if(!Q)throw new x("Authentication required for permission check");let J=Q.roles||[],W=new Set;for(let Y of J)this.rbac.getRolePermissions(Y).forEach((w)=>W.add(w));let X=Array.from(W),H;if(q.requireAll)H=q.permissions.every((Y)=>e$.hasPermission(X,Y));else H=q.permissions.some((Y)=>e$.hasPermission(X,Y));if(!H){let Y=q.requireAll?"all":"any";throw new x(`Access denied. Required ${Y} of permissions: ${q.permissions.join(", ")}`)}}checkMinimumRole($,q){let Q=T($);if(!Q)throw new x("Authentication required for role level check");let J=Q.roles||[],W=this.rbac.getHighestRoleLevel(J),X=this.rbac.getRole(q);if(!X)throw Error(`Required role not found: ${q}`);let H=X.level||0;if(W<H)throw new x(`Access denied. Minimum role level required: ${q} (level ${H})`)}}function cq($){return $.get("rbac")||null}function Z8($){return T($)?.roles||[]}function dq($){let q=cq($),Q=Z8($);if(!q)return[];let J=new Set;for(let W of Q)q.getRolePermissions(W).forEach((H)=>J.add(H));return Array.from(J)}function QH($,q){return Z8($).includes(q)}function JH($,q){let Q=dq($);return e$.hasPermission(Q,q)}w$();class pq{config;name="rbac";version="1.0.0";dependencies=["auth"];rbac;guard;constructor($={}){this.config=$;if($.rbac)this.rbac=$.rbac;else if($.useDefaults!==!1)this.rbac=P8();else this.rbac=new t$;if($.roles)this.rbac.defineRoles($.roles);this.guard=new C6(this.rbac)}async install($){let q=b8(this.rbac);if($.use(q),$.getContainer().register(t$,{factory:()=>this.rbac,scope:"singleton"}),$.getContainer().register(C6,{factory:()=>this.guard,scope:"singleton"}),this.injectRouteGuards($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}injectRouteGuards($){let q=$.getMetadata();for(let Q of q.getRoutes())if(Q.roles||Q.permissions||Q.minimumRole){let J=this.buildRBACMiddleware(Q);q.registerRoute({...Q,middleware:[J,...Q.middleware||[]]})}}buildRBACMiddleware($){let q=this.guard,Q=$.roles?.config,J=$.permissions?.config,W=$.minimumRole;return async(X,H)=>{if(!T(X))throw new f("Authentication required");if(Q)q.checkRoles(X,Q);if(J)q.checkPermissions(X,J);if(W)q.checkMinimumRole(X,W.roleName);await H()}}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.get(q.roles||"/rbac/roles",{middleware:[Q],handler:(J)=>{let W=this.rbac.getAllRoles();return J.json({success:!0,roles:W.map((X)=>({name:X.name,description:X.description,permissions:X.permissions,inherits:X.inherits,level:X.level}))})}}),$.get("/rbac/roles/:roleName",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName"),X=this.rbac.getRole(W);if(!X)return J.json({error:"Role not found"},404);let H=this.rbac.getRolePermissions(W),Y=this.rbac.getRoleHierarchy(W);return J.json({success:!0,role:{...X,effectivePermissions:H,hierarchy:Y}})}}),$.get("/rbac/roles/:roleName/permissions",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName");if(!this.rbac.roleExists(W))return J.json({error:"Role not found"},404);let X=this.rbac.getRolePermissions(W);return J.json({success:!0,role:W,permissions:X})}}),$.post("/rbac/check-permission",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X,permission:H}=W;if(!Array.isArray(X)||!H)return J.json({error:"Invalid request body"},400);let Y=this.rbac.userHasPermission(X,H);return J.json({success:!0,hasPermission:Y,roles:X,permission:H})}}),$.post("/rbac/check-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userRoles:X,requiredRoles:H,requireAll:Y=!1}=W;if(!Array.isArray(X)||!Array.isArray(H))return J.json({error:"Invalid request body"},400);let G=Y?this.rbac.userHasRoles(X,H):this.rbac.userHasAnyRole(X,H);return J.json({success:!0,hasRoles:G,userRoles:X,requiredRoles:H,requireAll:Y})}}),$.post("/rbac/effective-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=this.rbac.getEffectiveRoles(X);return J.json({success:!0,inputRoles:X,effectiveRoles:H})}}),$.post("/rbac/user-permissions",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=new Set;for(let Y of X)if(this.rbac.roleExists(Y))this.rbac.getRolePermissions(Y).forEach((w)=>H.add(w));return J.json({success:!0,roles:X,permissions:Array.from(H)})}})}getRBACManager(){return this.rbac}getGuard(){return this.guard}}class K6{resourcePermissions=new Map;permissionPolicies=new Map;grantPermission($){let q=this.getPermissionKey($.userId,$.resource);if(!this.resourcePermissions.has(q))this.resourcePermissions.set(q,[]);this.resourcePermissions.get(q).push($)}revokePermission($,q,Q){let J=this.getPermissionKey($,q),X=(this.resourcePermissions.get(J)||[]).filter((H)=>Q?H.resourceId!==Q:!0);if(X.length===0)this.resourcePermissions.delete(J);else this.resourcePermissions.set(J,X)}hasPermission($){let{user:q,resource:Q,action:J,attributes:W}=$;if(this.checkRoleBasedPermission(q,J,Q))return!0;let X=this.getPermissionKey(q.id,Q?.constructor?.name||"unknown"),H=this.resourcePermissions.get(X)||[];for(let Y of H){if(Y.expiresAt&&Y.expiresAt<new Date)continue;if(Y.resourceId&&Q?.id!==Y.resourceId)continue;for(let G of Y.permissions)if(this.matchesPermission(G,J,Q,W)){if(G.conditions&&!this.evaluateConditions(G.conditions,$))continue;return!0}}return this.checkPermissionPolicies($)}getUserPermissions($,q,Q){let J=this.getPermissionKey($,q),W=this.resourcePermissions.get(J)||[],X=[];for(let H of W){if(H.expiresAt&&H.expiresAt<new Date)continue;if(Q&&H.resourceId&&H.resourceId!==Q)continue;X.push(...H.permissions)}return X}getUserResources($){let q=new Set;for(let[Q,J]of this.resourcePermissions.entries())if(Q.startsWith(`${$}:`)){let W=Q.substring($.length+1);q.add(W)}return Array.from(q)}definePolicy($,q){this.permissionPolicies.set($,q)}filterResources($,q,Q,J=(W)=>W.constructor.name){return $.filter((W)=>{let X={user:q,resource:W,action:Q};return this.hasPermission(X)})}filterAttributes($,q,Q,J){let W={user:q,resource:$,action:Q,attributes:J};if(!this.hasPermission(W))return[];let X=$?.constructor?.name||"unknown",H=this.getUserPermissions(q.id,X,$?.id),Y=new Set;for(let G of H)if(G.action===Q||G.action==="*")if(G.attributes)G.attributes.forEach((w)=>Y.add(w));else J.forEach((w)=>Y.add(w));return Array.from(Y)}getPermissionKey($,q){return`${$}:${q}`}checkRoleBasedPermission($,q,Q){return!1}matchesPermission($,q,Q,J){if($.action!=="*"&&$.action!==q)return!1;let W=Q?.constructor?.name||"unknown";if($.resource!=="*"&&$.resource!==W)return!1;if(J&&$.attributes){if(!J.some((H)=>$.attributes.includes(H)||$.attributes.includes("*")))return!1}return!0}evaluateConditions($,q){return $.every((Q)=>this.evaluateCondition(Q,q))}evaluateCondition($,q){let Q=this.getFieldValue($.field,q);switch($.operator){case"eq":return Q===$.value;case"ne":return Q!==$.value;case"in":return Array.isArray($.value)&&$.value.includes(Q);case"nin":return Array.isArray($.value)&&!$.value.includes(Q);case"gt":return Q>$.value;case"gte":return Q>=$.value;case"lt":return Q<$.value;case"lte":return Q<=$.value;case"contains":return String(Q).includes(String($.value));case"startsWith":return String(Q).startsWith(String($.value));case"endsWith":return String(Q).endsWith(String($.value));default:return!1}}getFieldValue($,q){let Q=$.split("."),J=q;for(let W of Q)if(J&&typeof J==="object")J=J[W];else return;return J}checkPermissionPolicies($){for(let q of this.permissionPolicies.values())if(q.evaluate($))return!0;return!1}}class j0{name="ownership";description="User can access resources they own";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q)return!1;return Q.userId===q.id||Q.ownerId===q.id||Q.createdBy===q.id||Q.owner===q.id}}class O0{name="team-membership";description="User can access resources belonging to their team";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q||!q.teamId)return!1;return Q.teamId===q.teamId}}class N0{name="public-resource";description="Anyone can read public resources";evaluate($){let{resource:q,action:Q}=$;if(!q||Q!=="read")return!1;return q.isPublic===!0||q.visibility==="public"}}var nq=B.object({action:B.string(),resource:B.string(),conditions:B.array(B.object({field:B.string(),operator:B.enum(["eq","ne","in","nin","gt","gte","lt","lte","contains","startsWith","endsWith"]),value:B.any()})).optional(),attributes:B.array(B.string()).optional()}),WH=B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(nq),grantedBy:B.string().optional(),grantedAt:B.date().optional(),expiresAt:B.date().optional()}),XH=B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()});w$();function O$($){return(q,Q)=>{let J={config:$};b.defineResourcePermission(q,Q,J)}}function HH($,q){return O$({action:"read",resource:$,attributes:q})}function YH($,q){return O$({action:"write",resource:$,attributes:q})}function GH($,q){return O$({action:"update",resource:$,attributes:q})}function BH($){return O$({action:"delete",resource:$})}function wH($="access"){return O$({action:$,conditions:[{field:"resource.userId",operator:"eq",value:"{{user.id}}"}]})}function VH($="access"){return O$({action:$,conditions:[{field:"resource.teamId",operator:"eq",value:"{{user.teamId}}"}]})}function FH(){return O$({action:"read",conditions:[{field:"resource.isPublic",operator:"eq",value:!0}]})}function UH($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-resource",required:!0,metadata:{action:$}})}}function _H($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-attributes",required:!0,metadata:{action:$}})}}function f8($){return async(q,Q)=>{q.set("permissionManager",$),await Q()}}class I6{permissionManager;constructor($){this.permissionManager=$}checkResourcePermission($,q,Q){let J=T($);if(!J)throw new x("Authentication required for permission check");let W={user:J,resource:Q,action:q.action,attributes:q.attributes};if(q.conditions)W.conditions=q.conditions.map((H)=>({...H,value:this.resolveTemplateValue(H.value,W)}));if(!this.permissionManager.hasPermission(W))throw new x(`Access denied. Required permission: ${q.action} on ${q.resource||"resource"}`)}filterResource($,q,Q){let J=T($);if(!J)return null;let W={user:J,resource:q,action:Q};return this.permissionManager.hasPermission(W)?q:null}filterResources($,q,Q){let J=T($);if(!J)return[];return this.permissionManager.filterResources(q,J,Q)}filterAttributes($,q,Q,J){let W=T($);if(!W)return[];return this.permissionManager.filterAttributes(q,W,Q,J)}resolveTemplateValue($,q){if(typeof $==="string"&&$.startsWith("{{")&&$.endsWith("}}")){let Q=$.slice(2,-2);return this.getNestedValue(q,Q)}return $}getNestedValue($,q){return q.split(".").reduce((Q,J)=>Q?.[J],$)}}function T8($){return $.get("permissionManager")||null}function iq($,q,Q,J){let W=T8($),X=T($);if(!W||!X)return!1;let H={user:X,resource:q,action:Q,attributes:J};return W.hasPermission(H)}function DH($,q,Q){let J=T8($),W=T($);if(!J||!W)return[];return J.getUserPermissions(W.id,q,Q).map((H)=>H.action)}function zH($,q,Q){return iq($,q,Q)}w$();class rq{config;name="permissions";version="1.0.0";dependencies=["auth"];permissionManager;guard;constructor($={}){this.config=$;if(this.permissionManager=$.permissionManager||new K6,$.enableDefaultPolicies!==!1)this.permissionManager.definePolicy("ownership",new j0),this.permissionManager.definePolicy("team-membership",new O0),this.permissionManager.definePolicy("public-resource",new N0);this.guard=new I6(this.permissionManager)}async install($){let q=f8(this.permissionManager);if($.use(q),$.getContainer().register(K6,{factory:()=>this.permissionManager,scope:"singleton"}),$.getContainer().register(I6,{factory:()=>this.guard,scope:"singleton"}),this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}extendRouterCompiler($){let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.resourcePermission)this.addPermissionGuards($,J)}}addPermissionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.post(q.grant||"/permissions/grant",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y,permissions:G,expiresAt:w}=W,V={userId:X,resource:H,resourceId:Y,permissions:G,grantedBy:"system",grantedAt:new Date,expiresAt:w?new Date(w):void 0};return this.permissionManager.grantPermission(V),J.json({success:!0,message:"Permission granted successfully",permission:V})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(B.object({action:B.string(),resource:B.string(),conditions:B.array(B.any()).optional(),attributes:B.array(B.string()).optional()})),expiresAt:B.string().optional()})}}),$.delete(q.revoke||"/permissions/revoke",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y}=W;return this.permissionManager.revokePermission(X,H,Y),J.json({success:!0,message:"Permission revoked successfully"})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional()})}}),$.post(q.check||"/permissions/check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resource:Y,resourceId:G,attributes:w}=W,V={user:{id:X},resource:G?{id:G}:void 0,action:H,attributes:w},U=this.permissionManager.hasPermission(V);return J.json({success:!0,hasPermission:U,context:{userId:X,action:H,resource:Y,resourceId:G,attributes:w}})},schema:{body:B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()})}}),$.get("/permissions/user/:userId/resource/:resource",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=J.req.param("resource"),H=J.req.query("resourceId"),Y=this.permissionManager.getUserPermissions(W,X,H);return J.json({success:!0,userId:W,resource:X,resourceId:H,permissions:Y})}}),$.get("/permissions/user/:userId/resources",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=this.permissionManager.getUserResources(W);return J.json({success:!0,userId:W,resources:X})}}),$.post("/permissions/bulk-check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{checks:X}=W,H=X.map((Y)=>{let G={user:{id:Y.userId},resource:Y.resourceId?{id:Y.resourceId}:void 0,action:Y.action,attributes:Y.attributes},w=this.permissionManager.hasPermission(G);return{...Y,hasPermission:w}});return J.json({success:!0,results:H})},schema:{body:B.object({checks:B.array(B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()}))})}}),$.post("/permissions/filter-resources",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resources:Y}=W,G={id:X},w=this.permissionManager.filterResources(Y,G,H);return J.json({success:!0,userId:X,action:H,totalResources:Y.length,filteredResources:w.length,resources:w})},schema:{body:B.object({userId:B.string(),action:B.string(),resources:B.array(B.any())})}})}getPermissionManager(){return this.permissionManager}getGuard(){return this.guard}}class $6{sessions=new Map;cleanupTimer;constructor($=60000){if(this.cleanupTimer=setInterval(()=>this.cleanup(),$),typeof process<"u"&&process.on){let q=()=>clearInterval(this.cleanupTimer);process.on("exit",q),process.on("SIGTERM",q),process.on("SIGINT",q)}}async get($){let q=this.sessions.get($);if(!q)return null;if(q.expiresAt&&q.expiresAt<new Date)return this.sessions.delete($),null;return q}async set($,q){this.sessions.set($,q)}async destroy($){this.sessions.delete($)}async touch($){let q=this.sessions.get($);if(q)q.updatedAt=new Date,this.sessions.set($,q)}async clear(){this.sessions.clear()}async length(){return this.sessions.size}async all(){return Array.from(this.sessions.values())}cleanup(){let $=new Date;for(let[q,Q]of this.sessions.entries())if(Q.expiresAt&&Q.expiresAt<$)this.sessions.delete(q)}}class R0{redis;prefix="sess:";constructor($,q){this.redis=$;if(q)this.prefix=q}async get($){let q=this.prefix+$,Q=await this.redis.get(q);if(!Q)return null;try{let J=JSON.parse(Q);if(J.createdAt=new Date(J.createdAt),J.updatedAt=new Date(J.updatedAt),J.expiresAt)J.expiresAt=new Date(J.expiresAt);return J}catch(J){return null}}async set($,q){let Q=this.prefix+$,J=JSON.stringify(q);if(q.expiresAt){let W=Math.floor((q.expiresAt.getTime()-Date.now())/1000);if(W>0)await this.redis.setex(Q,W,J)}else await this.redis.set(Q,J)}async destroy($){let q=this.prefix+$;await this.redis.del(q)}async touch($){let q=await this.get($);if(q)q.updatedAt=new Date,await this.set($,q)}async clear(){let $=await this.redis.keys(this.prefix+"*");if($.length>0)await this.redis.del(...$)}async length(){return(await this.redis.keys(this.prefix+"*")).length}async all(){let $=await this.redis.keys(this.prefix+"*"),q=[];for(let Q of $){let J=await this.redis.get(Q);if(J)try{let W=JSON.parse(J);if(W.createdAt=new Date(W.createdAt),W.updatedAt=new Date(W.updatedAt),W.expiresAt)W.expiresAt=new Date(W.expiresAt);q.push(W)}catch(W){}}return q}}class P6{store;config;constructor($,q){this.store=$;this.config={name:"sessionId",maxAge:86400000,secure:!1,httpOnly:!0,sameSite:"lax",path:"/",rolling:!1,genid:()=>crypto.randomUUID(),...q,domain:q.domain}}async createSession($,q={},Q){let J=this.config.genid(),W=new Date,X=Q?.maxAge||this.config.maxAge,H={id:J,userId:$,data:q,createdAt:W,updatedAt:W,expiresAt:new Date(W.getTime()+X),ipAddress:Q?.ipAddress,userAgent:Q?.userAgent,csrfToken:this.generateCSRFToken()};return await this.store.set(J,H),H}async getSession($){return await this.store.get($)}async updateSession($,q){let Q=await this.store.get($);if(!Q)return null;if(Q.data={...Q.data,...q},Q.updatedAt=new Date,this.config.rolling)Q.expiresAt=new Date(Date.now()+this.config.maxAge);return await this.store.set($,Q),Q}async touchSession($){if(this.config.rolling){let q=await this.store.get($);if(q)q.updatedAt=new Date,q.expiresAt=new Date(Date.now()+this.config.maxAge),await this.store.set($,q)}else await this.store.touch($)}async destroySession($){await this.store.destroy($)}async regenerateSession($){let q=await this.store.get($);if(!q)return null;let Q=this.config.genid(),J={...q,id:Q,updatedAt:new Date,csrfToken:this.generateCSRFToken()};return await this.store.set(Q,J),await this.store.destroy($),J}async getUserSessions($){return(await this.store.all()).filter((Q)=>Q.userId===$)}async destroyUserSessions($){let q=await this.getUserSessions($);for(let Q of q)await this.store.destroy(Q.id)}validateCSRFToken($,q){return $.csrfToken===q}generateCSRFToken(){return crypto.randomUUID()}getCookieOptions(){let $={maxAge:this.config.maxAge,secure:this.config.secure,httpOnly:this.config.httpOnly,sameSite:this.config.sameSite,path:this.config.path};if(this.config.domain)$.domain=this.config.domain;return $}getConfig(){return{...this.config}}getStore(){return this.store}}class k6{tokenStore=new Map;tokenTTL=3600000;generateToken($){let q=crypto.randomUUID(),Q=new Date(Date.now()+this.tokenTTL);return this.tokenStore.set($,{token:q,expiresAt:Q}),this.cleanup(),q}validateToken($,q){let Q=this.tokenStore.get($);if(!Q)return!1;if(Q.expiresAt<new Date)return this.tokenStore.delete($),!1;return Q.token===q}removeToken($){this.tokenStore.delete($)}cleanup(){let $=new Date;for(let[q,Q]of this.tokenStore.entries())if(Q.expiresAt<$)this.tokenStore.delete(q)}}var LH=B.object({id:B.string(),userId:B.string(),data:B.record(B.any()),createdAt:B.date(),updatedAt:B.date(),expiresAt:B.date().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional(),csrfToken:B.string().optional()}),jH=B.object({name:B.string().optional(),secret:B.string(),maxAge:B.number().optional(),secure:B.boolean().optional(),httpOnly:B.boolean().optional(),sameSite:B.enum(["strict","lax","none"]).optional(),domain:B.string().optional(),path:B.string().optional(),rolling:B.boolean().optional()}),OH=B.object({userId:B.string(),data:B.record(B.any()).optional(),maxAge:B.number().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional()}),NH=B.object({data:B.record(B.any())});w$();var q6=require("hono/cookie");function RH($={}){return(q,Q)=>{let J={config:$};b.defineSession(q,Q,J)}}function SH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-session",required:!0})}}function MH($){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"session-data",required:!1,metadata:{key:$}})}}function EH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"csrf-token",required:!0})}}function AH(){return($,q)=>{b.defineCSRF($,q,{required:!0})}}function x8($,q){return async(Q,J)=>{let W=$.getConfig(),X=q6.getCookie(Q,W.name),H=null;if(X){if(H=await $.getSession(X),H)await $.touchSession(X)}Q.set("session",H),Q.set("sessionManager",$),Q.set("csrfProtection",q),await J()}}class Z6{sessionManager;csrfProtection;constructor($,q){this.sessionManager=$;this.csrfProtection=q}checkSession($,q){let Q=q$($);if(q.required&&!Q)throw new f("Session required");if(Q&&q.csrf)this.checkCSRF($,Q)}checkCSRF($,q){if(!this.csrfProtection)throw Error("CSRF protection not configured");let Q=$.req.header("X-CSRF-Token")||$.req.query("_csrf");if(!Q)throw new x("CSRF token required");if(!this.csrfProtection.validateToken(q.id,Q))throw new x("Invalid CSRF token")}async createSession($,q,Q={}){let J=b6($);if(!J)throw Error("Session manager not available");let W=$.req.header("X-Forwarded-For")||$.req.header("X-Real-IP")||"unknown",X=$.req.header("User-Agent")||"unknown",H=await J.createSession(q,Q,{ipAddress:W,userAgent:X}),Y=J.getCookieOptions();return q6.setCookie($,J.getConfig().name,H.id,Y),$.set("session",H),H}async updateSession($,q){let Q=q$($),J=b6($);if(!Q||!J)return null;let W=await J.updateSession(Q.id,q);if(W)$.set("session",W);return W}async destroySession($){let q=q$($),Q=b6($);if(!q||!Q)return;await Q.destroySession(q.id);let J=Q.getConfig();if(q6.setCookie($,J.name,"",{...Q.getCookieOptions(),maxAge:0}),$.set("session",null),this.csrfProtection)this.csrfProtection.removeToken(q.id)}async regenerateSession($){let q=q$($),Q=b6($);if(!q||!Q)return null;let J=await Q.regenerateSession(q.id);if(J){let W=Q.getCookieOptions();if(q6.setCookie($,Q.getConfig().name,J.id,W),$.set("session",J),this.csrfProtection)this.csrfProtection.removeToken(q.id),this.csrfProtection.generateToken(J.id)}return J}generateCSRFToken($){let q=q$($);if(!q||!this.csrfProtection)return null;return this.csrfProtection.generateToken(q.id)}}function q$($){return $.get("session")||null}function b6($){return $.get("sessionManager")||null}function CH($){return $.get("csrfProtection")||null}function KH($,q){let Q=q$($);if(!Q)return null;if(q)return Q.data[q];return Q.data}function IH($){return q$($)!==null}function PH($){return q$($)?.userId||null}function kH($,q,Q){let J=q$($);if(J)J.data[q]=Q,$.set("session",J)}function bH($,q){let Q=q$($);if(Q&&q in Q.data)delete Q.data[q],$.set("session",Q)}class oq{config;name="session";version="1.0.0";sessionManager;csrfProtection;guard;compileExtended=!1;cleanupIntervalId;constructor($){this.config=$;let q;if($.store)q=$.store;else if($.storeType==="redis"&&$.redis)q=new R0($.redis);else q=new $6;if(this.sessionManager=new P6(q,$.session),$.csrf?.enabled!==!1)this.csrfProtection=new k6;this.guard=new Z6(this.sessionManager,this.csrfProtection)}async install($){let q=x8(this.sessionManager,this.csrfProtection);if($.use(q),$.getContainer().register(P6,{factory:()=>this.sessionManager,scope:"singleton"}),$.getContainer().register(Z6,{factory:()=>this.guard,scope:"singleton"}),this.csrfProtection)$.getContainer().register(k6,{factory:()=>this.csrfProtection,scope:"singleton"});if(this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($);if(this.sessionManager.getStore()instanceof $6)this.setupCleanup()}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0;let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.session||J.csrf)this.addSessionGuards($,J)}}addSessionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{};if($.post(q.create||"/session/create",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,data:X}=J,H=await this.guard.createSession(Q,W,X);return Q.json({success:!0,message:"Session created successfully",session:{id:H.id,userId:H.userId,data:H.data,createdAt:H.createdAt,expiresAt:H.expiresAt}})},schema:{body:B.object({userId:B.string(),data:B.record(B.any()).optional()})}}),$.post(q.destroy||"/session/destroy",{handler:async(Q)=>{return await this.guard.destroySession(Q),Q.json({success:!0,message:"Session destroyed successfully"})}}),$.post(q.regenerate||"/session/regenerate",{handler:async(Q)=>{let J=await this.guard.regenerateSession(Q);if(!J)return Q.json({error:"No active session to regenerate"},400);return Q.json({success:!0,message:"Session regenerated successfully",session:{id:J.id,userId:J.userId,data:J.data,createdAt:J.createdAt,expiresAt:J.expiresAt}})}}),$.get(q.data||"/session/data",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return Q.json({success:!0,data:J.data})}}),$.put(q.data||"/session/data",{handler:async(Q)=>{let J=await Q.req.json(),{data:W}=J,X=await this.guard.updateSession(Q,W);if(!X)return Q.json({error:"No active session to update"},400);return Q.json({success:!0,message:"Session data updated successfully",data:X.data})},schema:{body:B.object({data:B.record(B.any())})}}),this.csrfProtection)$.get(q.csrf||"/session/csrf-token",{handler:(Q)=>{let J=this.guard.generateCSRFToken(Q);if(!J)return Q.json({error:"No active session or CSRF not enabled"},400);return Q.json({success:!0,csrfToken:J})}});$.get("/session/info",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({success:!0,authenticated:!1,session:null});return Q.json({success:!0,authenticated:!0,session:{id:J.id,userId:J.userId,createdAt:J.createdAt,updatedAt:J.updatedAt,expiresAt:J.expiresAt,ipAddress:J.ipAddress,userAgent:J.userAgent}})}}),$.get("/session/all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);let W=await this.sessionManager.getUserSessions(J.userId);return Q.json({success:!0,sessions:W.map((X)=>({id:X.id,createdAt:X.createdAt,updatedAt:X.updatedAt,expiresAt:X.expiresAt,ipAddress:X.ipAddress,userAgent:X.userAgent,current:X.id===J.id}))})}}),$.post("/session/destroy-all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return await this.sessionManager.destroyUserSessions(J.userId),Q.json({success:!0,message:"All sessions destroyed successfully"})}}),$.get("/session/stats",{handler:async(Q)=>{if(!Q.get("session"))return Q.json({error:"Authentication required"},401);let W=this.sessionManager.getStore(),X=await W.length(),H=await W.all(),Y={totalSessions:X,activeSessions:H.filter((G)=>!G.expiresAt||G.expiresAt>new Date).length,expiredSessions:H.filter((G)=>G.expiresAt&&G.expiresAt<=new Date).length,uniqueUsers:new Set(H.map((G)=>G.userId)).size};return Q.json({success:!0,stats:Y})}})}setupCleanup(){if(this.cleanupIntervalId)return;let $=900000;if(this.cleanupIntervalId=setInterval(()=>{let q=this.sessionManager.getStore();if(q instanceof $6)q.cleanup()},$),typeof process<"u"&&process.on)process.on("exit",()=>{if(this.cleanupIntervalId)clearInterval(this.cleanupIntervalId)})}getSessionManager(){return this.sessionManager}getCSRFProtection(){return this.csrfProtection}getGuard(){return this.guard}}
|
|
3
|
+
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,W6="secret must be a string or buffer",k$="key must be a string or a buffer",OQ="key must be a string, a buffer or an object",k0=typeof p.createPublicKey==="function";if(k0)k$+=" or a KeyObject",W6+="or a KeyObject";function J1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(!k0)throw r(k$);if(typeof $!=="object")throw r(k$);if(typeof $.type!=="string")throw r(k$);if(typeof $.asymmetricKeyType!=="string")throw r(k$);if(typeof $.export!=="function")throw r(k$)}function W1($){if(b$.isBuffer($))return;if(typeof $==="string")return;if(typeof $==="object")return;throw r(OQ)}function NQ($){if(b$.isBuffer($))return;if(typeof $==="string")return $;if(!k0)throw r(W6);if(typeof $!=="object")throw r(W6);if($.type!=="secret")throw r(W6);if(typeof $.export!=="function")throw r(W6)}function b0($){return $.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function X1($){$=$.toString();var q=4-$.length%4;if(q!==4)for(var Q=0;Q<q;++Q)$+="=";return $.replace(/\-/g,"+").replace(/_/g,"/")}function r($){var q=[].slice.call(arguments,1),Q=q1.format.bind(q1,$).apply(null,q);return TypeError(Q)}function RQ($){return b$.isBuffer($)||typeof $==="string"}function X6($){if(!RQ($))$=JSON.stringify($);return $}function H1($){return function(Q,J){NQ(J),Q=X6(Q);var W=p.createHmac("sha"+$,J),X=(W.update(Q),W.digest("base64"));return b0(X)}}var P0,SQ="timingSafeEqual"in p?function(q,Q){if(q.byteLength!==Q.byteLength)return!1;return p.timingSafeEqual(q,Q)}:function(q,Q){if(!P0)P0=$1();return P0(q,Q)};function MQ($){return function(Q,J,W){var X=H1($)(Q,W);return SQ(b$.from(J),b$.from(X))}}function Y1($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign(J,"base64"));return b0(X)}}function G1($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify(W,J,"base64")}}function EQ($){return function(Q,J){W1(J),Q=X6(Q);var W=p.createSign("RSA-SHA"+$),X=(W.update(Q),W.sign({key:J,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return b0(X)}}function AQ($){return function(Q,J,W){J1(W),Q=X6(Q),J=X1(J);var X=p.createVerify("RSA-SHA"+$);return X.update(Q),X.verify({key:W,padding:p.constants.RSA_PKCS1_PSS_PADDING,saltLength:p.constants.RSA_PSS_SALTLEN_DIGEST},J,"base64")}}function CQ($){var q=Y1($);return function(){var J=q.apply(null,arguments);return J=Q1.derToJose(J,"ES"+$),J}}function KQ($){var q=G1($);return function(J,W,X){W=Q1.joseToDer(W,"ES"+$).toString("base64");var H=q(J,W,X);return H}}function IQ(){return function(){return""}}function PQ(){return function(q,Q){return Q===""}}B1.exports=function(q){var Q={hs:H1,rs:Y1,ps:EQ,es:CQ,none:IQ},J={hs:MQ,rs:G1,ps:AQ,es:KQ,none:PQ},W=q.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!W)throw r(jQ,q);var X=(W[1]||W[3]).toLowerCase(),H=W[2];return{sign:Q[X](H),verify:J[X](H)}}});var f0=z((mH,w1)=>{var kQ=require("buffer").Buffer;w1.exports=function(q){if(typeof q==="string")return q;if(typeof q==="number"||kQ.isBuffer(q))return q.toString();return JSON.stringify(q)}});var z1=z((lH,D1)=>{var bQ=P$().Buffer,V1=C0(),ZQ=Z0(),fQ=require("stream"),F1=f0(),T0=require("util");function U1($,q){return bQ.from($,q).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function TQ($,q,Q){Q=Q||"utf8";var J=U1(F1($),"binary"),W=U1(F1(q),Q);return T0.format("%s.%s",J,W)}function _1($){var{header:q,payload:Q}=$,J=$.secret||$.privateKey,W=$.encoding,X=ZQ(q.alg),H=TQ(q,Q,W),Y=X.sign(H,J);return T0.format("%s.%s",H,Y)}function m6($){var q=$.secret;if(q=q==null?$.privateKey:q,q=q==null?$.key:q,/^hs/i.test($.header.alg)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new V1(q);this.readable=!0,this.header=$.header,this.encoding=$.encoding,this.secret=this.privateKey=this.key=Q,this.payload=new V1($.payload),this.secret.once("close",function(){if(!this.payload.writable&&this.readable)this.sign()}.bind(this)),this.payload.once("close",function(){if(!this.secret.writable&&this.readable)this.sign()}.bind(this))}T0.inherits(m6,fQ);m6.prototype.sign=function(){try{var q=_1({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(Q){this.readable=!1,this.emit("error",Q),this.emit("close")}};m6.sign=_1;D1.exports=m6});var C1=z((uH,A1)=>{var j1=P$().Buffer,L1=C0(),xQ=Z0(),vQ=require("stream"),O1=f0(),hQ=require("util"),gQ=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function yQ($){return Object.prototype.toString.call($)==="[object Object]"}function mQ($){if(yQ($))return $;try{return JSON.parse($)}catch(q){return}}function N1($){var q=$.split(".",1)[0];return mQ(j1.from(q,"base64").toString("binary"))}function lQ($){return $.split(".",2).join(".")}function R1($){return $.split(".")[2]}function uQ($,q){q=q||"utf8";var Q=$.split(".")[1];return j1.from(Q,"base64").toString(q)}function S1($){return gQ.test($)&&!!N1($)}function M1($,q,Q){if(!q){var J=Error("Missing algorithm parameter for jws.verify");throw J.code="MISSING_ALGORITHM",J}$=O1($);var W=R1($),X=lQ($),H=xQ(q);return H.verify(X,W,Q)}function E1($,q){if(q=q||{},$=O1($),!S1($))return null;var Q=N1($);if(!Q)return null;var J=uQ($);if(Q.typ==="JWT"||q.json)J=JSON.parse(J,q.encoding);return{header:Q,payload:J,signature:R1($)}}function Z$($){$=$||{};var q=$.secret;if(q=q==null?$.publicKey:q,q=q==null?$.key:q,/^hs/i.test($.algorithm)===!0&&q==null)throw TypeError("secret must be a string or buffer or a KeyObject");var Q=new L1(q);this.readable=!0,this.algorithm=$.algorithm,this.encoding=$.encoding,this.secret=this.publicKey=this.key=Q,this.signature=new L1($.signature),this.secret.once("close",function(){if(!this.signature.writable&&this.readable)this.verify()}.bind(this)),this.signature.once("close",function(){if(!this.secret.writable&&this.readable)this.verify()}.bind(this))}hQ.inherits(Z$,vQ);Z$.prototype.verify=function(){try{var q=M1(this.signature.buffer,this.algorithm,this.key.buffer),Q=E1(this.signature.buffer,this.encoding);return this.emit("done",q,Q),this.emit("data",q),this.emit("end"),this.readable=!1,q}catch(J){this.readable=!1,this.emit("error",J),this.emit("close")}};Z$.decode=E1;Z$.isValid=S1;Z$.verify=M1;A1.exports=Z$});var u6=z((V$)=>{var K1=z1(),l6=C1(),cQ=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];V$.ALGORITHMS=cQ;V$.sign=K1.sign;V$.verify=l6.verify;V$.decode=l6.decode;V$.isValid=l6.isValid;V$.createSign=function(q){return new K1(q)};V$.createVerify=function(q){return new l6(q)}});var x0=z((dH,I1)=>{var dQ=u6();I1.exports=function($,q){q=q||{};var Q=dQ.decode($,q);if(!Q)return null;var J=Q.payload;if(typeof J==="string")try{var W=JSON.parse(J);if(W!==null&&typeof W==="object")J=W}catch(X){}if(q.complete===!0)return{header:Q.header,payload:J,signature:Q.signature};return J}});var H6=z((pH,P1)=>{var c6=function($,q){if(Error.call(this,$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);if(this.name="JsonWebTokenError",this.message=$,q)this.inner=q};c6.prototype=Object.create(Error.prototype);c6.prototype.constructor=c6;P1.exports=c6});var v0=z((nH,b1)=>{var k1=H6(),d6=function($,q){k1.call(this,$),this.name="NotBeforeError",this.date=q};d6.prototype=Object.create(k1.prototype);d6.prototype.constructor=d6;b1.exports=d6});var h0=z((iH,f1)=>{var Z1=H6(),p6=function($,q){Z1.call(this,$),this.name="TokenExpiredError",this.expiredAt=q};p6.prototype=Object.create(Z1.prototype);p6.prototype.constructor=p6;f1.exports=p6});var x1=z((rH,T1)=>{var f$=1000,T$=f$*60,x$=T$*60,R$=x$*24,pQ=R$*7,nQ=R$*365.25;T1.exports=function($,q){q=q||{};var Q=typeof $;if(Q==="string"&&$.length>0)return iQ($);else if(Q==="number"&&isFinite($))return q.long?oQ($):rQ($);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify($))};function iQ($){if($=String($),$.length>100)return;var q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec($);if(!q)return;var Q=parseFloat(q[1]),J=(q[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return Q*nQ;case"weeks":case"week":case"w":return Q*pQ;case"days":case"day":case"d":return Q*R$;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*x$;case"minutes":case"minute":case"mins":case"min":case"m":return Q*T$;case"seconds":case"second":case"secs":case"sec":case"s":return Q*f$;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function rQ($){var q=Math.abs($);if(q>=R$)return Math.round($/R$)+"d";if(q>=x$)return Math.round($/x$)+"h";if(q>=T$)return Math.round($/T$)+"m";if(q>=f$)return Math.round($/f$)+"s";return $+"ms"}function oQ($){var q=Math.abs($);if(q>=R$)return n6($,q,R$,"day");if(q>=x$)return n6($,q,x$,"hour");if(q>=T$)return n6($,q,T$,"minute");if(q>=f$)return n6($,q,f$,"second");return $+" ms"}function n6($,q,Q,J){var W=q>=Q*1.5;return Math.round($/Q)+" "+J+(W?"s":"")}});var g0=z((oH,v1)=>{var aQ=x1();v1.exports=function($,q){var Q=q||Math.floor(Date.now()/1000);if(typeof $==="string"){var J=aQ($);if(typeof J>"u")return;return Math.floor(Q+J/1000)}else if(typeof $==="number")return Q+$;else return}});var Y6=z((aH,h1)=>{var sQ=Number.MAX_SAFE_INTEGER||9007199254740991,tQ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];h1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:sQ,RELEASE_TYPES:tQ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var G6=z((sH,g1)=>{var eQ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};g1.exports=eQ});var v$=z((J$,y1)=>{var{MAX_SAFE_COMPONENT_LENGTH:y0,MAX_SAFE_BUILD_LENGTH:$J,MAX_LENGTH:qJ}=Y6(),QJ=G6();J$=y1.exports={};var JJ=J$.re=[],WJ=J$.safeRe=[],L=J$.src=[],XJ=J$.safeSrc=[],j=J$.t={},HJ=0,m0="[a-zA-Z0-9-]",YJ=[["\\s",1],["\\d",qJ],[m0,$J]],GJ=($)=>{for(let[q,Q]of YJ)$=$.split(`${q}*`).join(`${q}{0,${Q}}`).split(`${q}+`).join(`${q}{1,${Q}}`);return $},E=($,q,Q)=>{let J=GJ(q),W=HJ++;QJ($,W,q),j[$]=W,L[W]=q,XJ[W]=J,JJ[W]=new RegExp(q,Q?"g":void 0),WJ[W]=new RegExp(J,Q?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m0}*`);E("MAINVERSION",`(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})\\.(${L[j.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})\\.(${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${L[j.NONNUMERICIDENTIFIER]}|${L[j.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${L[j.PRERELEASEIDENTIFIER]}(?:\\.${L[j.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${L[j.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${L[j.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${m0}+`);E("BUILD",`(?:\\+(${L[j.BUILDIDENTIFIER]}(?:\\.${L[j.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${L[j.MAINVERSION]}${L[j.PRERELEASE]}?${L[j.BUILD]}?`);E("FULL",`^${L[j.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${L[j.MAINVERSIONLOOSE]}${L[j.PRERELEASELOOSE]}?${L[j.BUILD]}?`);E("LOOSE",`^${L[j.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${L[j.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${L[j.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:\\.(${L[j.XRANGEIDENTIFIER]})(?:${L[j.PRERELEASE]})?${L[j.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:\\.(${L[j.XRANGEIDENTIFIERLOOSE]})(?:${L[j.PRERELEASELOOSE]})?${L[j.BUILD]}?)?)?`);E("XRANGE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${L[j.GTLT]}\\s*${L[j.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${y0}})(?:\\.(\\d{1,${y0}}))?(?:\\.(\\d{1,${y0}}))?`);E("COERCE",`${L[j.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",L[j.COERCEPLAIN]+`(?:${L[j.PRERELEASE]})?(?:${L[j.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",L[j.COERCE],!0);E("COERCERTLFULL",L[j.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${L[j.LONETILDE]}\\s+`,!0);J$.tildeTrimReplace="$1~";E("TILDE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${L[j.LONETILDE]}${L[j.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${L[j.LONECARET]}\\s+`,!0);J$.caretTrimReplace="$1^";E("CARET",`^${L[j.LONECARET]}${L[j.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${L[j.LONECARET]}${L[j.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${L[j.GTLT]}\\s*(${L[j.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${L[j.GTLT]}\\s*(${L[j.LOOSEPLAIN]}|${L[j.XRANGEPLAIN]})`,!0);J$.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${L[j.XRANGEPLAIN]})\\s+-\\s+(${L[j.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${L[j.XRANGEPLAINLOOSE]})\\s+-\\s+(${L[j.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var i6=z((tH,m1)=>{var BJ=Object.freeze({loose:!0}),wJ=Object.freeze({}),VJ=($)=>{if(!$)return wJ;if(typeof $!=="object")return BJ;return $};m1.exports=VJ});var l0=z((eH,c1)=>{var l1=/^[0-9]+$/,u1=($,q)=>{if(typeof $==="number"&&typeof q==="number")return $===q?0:$<q?-1:1;let Q=l1.test($),J=l1.test(q);if(Q&&J)$=+$,q=+q;return $===q?0:Q&&!J?-1:J&&!Q?1:$<q?-1:1},FJ=($,q)=>u1(q,$);c1.exports={compareIdentifiers:u1,rcompareIdentifiers:FJ}});var h=z(($Y,p1)=>{var r6=G6(),{MAX_LENGTH:d1,MAX_SAFE_INTEGER:o6}=Y6(),{safeRe:a6,t:s6}=v$(),UJ=i6(),{compareIdentifiers:u0}=l0();class o{constructor($,q){if(q=UJ(q),$ instanceof o)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>d1)throw TypeError(`version is longer than ${d1} characters`);r6("SemVer",$,q),this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease;let Q=$.trim().match(q.loose?a6[s6.LOOSE]:a6[s6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>o6||this.major<0)throw TypeError("Invalid major version");if(this.minor>o6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>o6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let W=+J;if(W>=0&&W<o6)return W}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(r6("SemVer.compare",this.version,this.options,$),!($ instanceof o)){if(typeof $==="string"&&$===this.version)return 0;$=new o($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof o))$=new o($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof o))$=new o($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let q=0;do{let Q=this.prerelease[q],J=$.prerelease[q];if(r6("prerelease compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}compareBuild($){if(!($ instanceof o))$=new o($,this.options);let q=0;do{let Q=this.build[q],J=$.build[q];if(r6("build compare",q,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return u0(Q,J)}while(++q)}inc($,q,Q){if($.startsWith("pre")){if(!q&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(q){let J=`-${q}`.match(this.options.loose?a6[s6.PRERELEASELOOSE]:a6[s6.PRERELEASE]);if(!J||J[1]!==q)throw Error(`invalid identifier: ${q}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",q,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",q,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",q,Q),this.inc("pre",q,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",q,Q);this.inc("pre",q,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let W=this.prerelease.length;while(--W>=0)if(typeof this.prerelease[W]==="number")this.prerelease[W]++,W=-2;if(W===-1){if(q===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(q){let W=[q,J];if(Q===!1)W=[q];if(u0(this.prerelease[0],q)===0){if(isNaN(this.prerelease[1]))this.prerelease=W}else this.prerelease=W}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}p1.exports=o});var S$=z((qY,i1)=>{var n1=h(),_J=($,q,Q=!1)=>{if($ instanceof n1)return $;try{return new n1($,q)}catch(J){if(!Q)return null;throw J}};i1.exports=_J});var o1=z((QY,r1)=>{var DJ=S$(),zJ=($,q)=>{let Q=DJ($,q);return Q?Q.version:null};r1.exports=zJ});var s1=z((JY,a1)=>{var LJ=S$(),jJ=($,q)=>{let Q=LJ($.trim().replace(/^[=v]+/,""),q);return Q?Q.version:null};a1.exports=jJ});var $4=z((WY,e1)=>{var t1=h(),OJ=($,q,Q,J,W)=>{if(typeof Q==="string")W=J,J=Q,Q=void 0;try{return new t1($ instanceof t1?$.version:$,Q).inc(q,J,W).version}catch(X){return null}};e1.exports=OJ});var J4=z((XY,Q4)=>{var q4=S$(),NJ=($,q)=>{let Q=q4($,null,!0),J=q4(q,null,!0),W=Q.compare(J);if(W===0)return null;let X=W>0,H=X?Q:J,Y=X?J:Q,G=!!H.prerelease.length;if(!!Y.prerelease.length&&!G){if(!Y.patch&&!Y.minor)return"major";if(Y.compareMain(H)===0){if(Y.minor&&!Y.patch)return"minor";return"patch"}}let V=G?"pre":"";if(Q.major!==J.major)return V+"major";if(Q.minor!==J.minor)return V+"minor";if(Q.patch!==J.patch)return V+"patch";return"prerelease"};Q4.exports=NJ});var X4=z((HY,W4)=>{var RJ=h(),SJ=($,q)=>new RJ($,q).major;W4.exports=SJ});var Y4=z((YY,H4)=>{var MJ=h(),EJ=($,q)=>new MJ($,q).minor;H4.exports=EJ});var B4=z((GY,G4)=>{var AJ=h(),CJ=($,q)=>new AJ($,q).patch;G4.exports=CJ});var V4=z((BY,w4)=>{var KJ=S$(),IJ=($,q)=>{let Q=KJ($,q);return Q&&Q.prerelease.length?Q.prerelease:null};w4.exports=IJ});var n=z((wY,U4)=>{var F4=h(),PJ=($,q,Q)=>new F4($,Q).compare(new F4(q,Q));U4.exports=PJ});var D4=z((VY,_4)=>{var kJ=n(),bJ=($,q,Q)=>kJ(q,$,Q);_4.exports=bJ});var L4=z((FY,z4)=>{var ZJ=n(),fJ=($,q)=>ZJ($,q,!0);z4.exports=fJ});var t6=z((UY,O4)=>{var j4=h(),TJ=($,q,Q)=>{let J=new j4($,Q),W=new j4(q,Q);return J.compare(W)||J.compareBuild(W)};O4.exports=TJ});var R4=z((_Y,N4)=>{var xJ=t6(),vJ=($,q)=>$.sort((Q,J)=>xJ(Q,J,q));N4.exports=vJ});var M4=z((DY,S4)=>{var hJ=t6(),gJ=($,q)=>$.sort((Q,J)=>hJ(J,Q,q));S4.exports=gJ});var B6=z((zY,E4)=>{var yJ=n(),mJ=($,q,Q)=>yJ($,q,Q)>0;E4.exports=mJ});var e6=z((LY,A4)=>{var lJ=n(),uJ=($,q,Q)=>lJ($,q,Q)<0;A4.exports=uJ});var c0=z((jY,C4)=>{var cJ=n(),dJ=($,q,Q)=>cJ($,q,Q)===0;C4.exports=dJ});var d0=z((OY,K4)=>{var pJ=n(),nJ=($,q,Q)=>pJ($,q,Q)!==0;K4.exports=nJ});var $0=z((NY,I4)=>{var iJ=n(),rJ=($,q,Q)=>iJ($,q,Q)>=0;I4.exports=rJ});var q0=z((RY,P4)=>{var oJ=n(),aJ=($,q,Q)=>oJ($,q,Q)<=0;P4.exports=aJ});var p0=z((SY,k4)=>{var sJ=c0(),tJ=d0(),eJ=B6(),$5=$0(),q5=e6(),Q5=q0(),J5=($,q,Q,J)=>{switch(q){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return sJ($,Q,J);case"!=":return tJ($,Q,J);case">":return eJ($,Q,J);case">=":return $5($,Q,J);case"<":return q5($,Q,J);case"<=":return Q5($,Q,J);default:throw TypeError(`Invalid operator: ${q}`)}};k4.exports=J5});var Z4=z((MY,b4)=>{var W5=h(),X5=S$(),{safeRe:Q0,t:J0}=v$(),H5=($,q)=>{if($ instanceof W5)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;q=q||{};let Q=null;if(!q.rtl)Q=$.match(q.includePrerelease?Q0[J0.COERCEFULL]:Q0[J0.COERCE]);else{let G=q.includePrerelease?Q0[J0.COERCERTLFULL]:Q0[J0.COERCERTL],w;while((w=G.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||w.index+w[0].length!==Q.index+Q[0].length)Q=w;G.lastIndex=w.index+w[1].length+w[2].length}G.lastIndex=-1}if(Q===null)return null;let J=Q[2],W=Q[3]||"0",X=Q[4]||"0",H=q.includePrerelease&&Q[5]?`-${Q[5]}`:"",Y=q.includePrerelease&&Q[6]?`+${Q[6]}`:"";return X5(`${J}.${W}.${X}${H}${Y}`,q)};b4.exports=H5});var x4=z((EY,T4)=>{class f4{constructor(){this.max=1000,this.map=new Map}get($){let q=this.map.get($);if(q===void 0)return;else return this.map.delete($),this.map.set($,q),q}delete($){return this.map.delete($)}set($,q){if(!this.delete($)&&q!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,q)}return this}}T4.exports=f4});var i=z((AY,y4)=>{var Y5=/\s+/g;class w6{constructor($,q){if(q=B5(q),$ instanceof w6)if($.loose===!!q.loose&&$.includePrerelease===!!q.includePrerelease)return $;else return new w6($.raw,q);if($ instanceof n0)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=q,this.loose=!!q.loose,this.includePrerelease=!!q.includePrerelease,this.raw=$.trim().replace(Y5," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!h4(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&z5(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let q=this.set[$];for(let Q=0;Q<q.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=q[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&_5)|(this.options.loose&&D5))+":"+$,J=v4.get(Q);if(J)return J;let W=this.options.loose,X=W?m[g.HYPHENRANGELOOSE]:m[g.HYPHENRANGE];$=$.replace(X,C5(this.options.includePrerelease)),k("hyphen replace",$),$=$.replace(m[g.COMPARATORTRIM],V5),k("comparator trim",$),$=$.replace(m[g.TILDETRIM],F5),k("tilde trim",$),$=$.replace(m[g.CARETTRIM],U5),k("caret trim",$);let H=$.split(" ").map((V)=>L5(V,this.options)).join(" ").split(/\s+/).map((V)=>A5(V,this.options));if(W)H=H.filter((V)=>{return k("loose invalid filter",V,this.options),!!V.match(m[g.COMPARATORLOOSE])});k("range list",H);let Y=new Map,G=H.map((V)=>new n0(V,this.options));for(let V of G){if(h4(V))return[V];Y.set(V.value,V)}if(Y.size>1&&Y.has(""))Y.delete("");let w=[...Y.values()];return v4.set(Q,w),w}intersects($,q){if(!($ instanceof w6))throw TypeError("a Range is required");return this.set.some((Q)=>{return g4(Q,q)&&$.set.some((J)=>{return g4(J,q)&&Q.every((W)=>{return J.every((X)=>{return W.intersects(X,q)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new w5($,this.options)}catch(q){return!1}for(let q=0;q<this.set.length;q++)if(K5(this.set[q],$,this.options))return!0;return!1}}y4.exports=w6;var G5=x4(),v4=new G5,B5=i6(),n0=V6(),k=G6(),w5=h(),{safeRe:m,t:g,comparatorTrimReplace:V5,tildeTrimReplace:F5,caretTrimReplace:U5}=v$(),{FLAG_INCLUDE_PRERELEASE:_5,FLAG_LOOSE:D5}=Y6(),h4=($)=>$.value==="<0.0.0-0",z5=($)=>$.value==="",g4=($,q)=>{let Q=!0,J=$.slice(),W=J.pop();while(Q&&J.length)Q=J.every((X)=>{return W.intersects(X,q)}),W=J.pop();return Q},L5=($,q)=>{return $=$.replace(m[g.BUILD],""),k("comp",$,q),$=N5($,q),k("caret",$),$=j5($,q),k("tildes",$),$=S5($,q),k("xrange",$),$=E5($,q),k("stars",$),$},l=($)=>!$||$.toLowerCase()==="x"||$==="*",j5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>O5(Q,q)).join(" ")},O5=($,q)=>{let Q=q.loose?m[g.TILDELOOSE]:m[g.TILDE];return $.replace(Q,(J,W,X,H,Y)=>{k("tilde",$,J,W,X,H,Y);let G;if(l(W))G="";else if(l(X))G=`>=${W}.0.0 <${+W+1}.0.0-0`;else if(l(H))G=`>=${W}.${X}.0 <${W}.${+X+1}.0-0`;else if(Y)k("replaceTilde pr",Y),G=`>=${W}.${X}.${H}-${Y} <${W}.${+X+1}.0-0`;else G=`>=${W}.${X}.${H} <${W}.${+X+1}.0-0`;return k("tilde return",G),G})},N5=($,q)=>{return $.trim().split(/\s+/).map((Q)=>R5(Q,q)).join(" ")},R5=($,q)=>{k("caret",$,q);let Q=q.loose?m[g.CARETLOOSE]:m[g.CARET],J=q.includePrerelease?"-0":"";return $.replace(Q,(W,X,H,Y,G)=>{k("caret",$,W,X,H,Y,G);let w;if(l(X))w="";else if(l(H))w=`>=${X}.0.0${J} <${+X+1}.0.0-0`;else if(l(Y))if(X==="0")w=`>=${X}.${H}.0${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.0${J} <${+X+1}.0.0-0`;else if(G)if(k("replaceCaret pr",G),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}-${G} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}-${G} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y}-${G} <${+X+1}.0.0-0`;else if(k("no pr"),X==="0")if(H==="0")w=`>=${X}.${H}.${Y}${J} <${X}.${H}.${+Y+1}-0`;else w=`>=${X}.${H}.${Y}${J} <${X}.${+H+1}.0-0`;else w=`>=${X}.${H}.${Y} <${+X+1}.0.0-0`;return k("caret return",w),w})},S5=($,q)=>{return k("replaceXRanges",$,q),$.split(/\s+/).map((Q)=>M5(Q,q)).join(" ")},M5=($,q)=>{$=$.trim();let Q=q.loose?m[g.XRANGELOOSE]:m[g.XRANGE];return $.replace(Q,(J,W,X,H,Y,G)=>{k("xRange",$,J,W,X,H,Y,G);let w=l(X),V=w||l(H),U=V||l(Y),M=U;if(W==="="&&M)W="";if(G=q.includePrerelease?"-0":"",w)if(W===">"||W==="<")J="<0.0.0-0";else J="*";else if(W&&M){if(V)H=0;if(Y=0,W===">")if(W=">=",V)X=+X+1,H=0,Y=0;else H=+H+1,Y=0;else if(W==="<=")if(W="<",V)X=+X+1;else H=+H+1;if(W==="<")G="-0";J=`${W+X}.${H}.${Y}${G}`}else if(V)J=`>=${X}.0.0${G} <${+X+1}.0.0-0`;else if(U)J=`>=${X}.${H}.0${G} <${X}.${+H+1}.0-0`;return k("xRange return",J),J})},E5=($,q)=>{return k("replaceStars",$,q),$.trim().replace(m[g.STAR],"")},A5=($,q)=>{return k("replaceGTE0",$,q),$.trim().replace(m[q.includePrerelease?g.GTE0PRE:g.GTE0],"")},C5=($)=>(q,Q,J,W,X,H,Y,G,w,V,U,M)=>{if(l(J))Q="";else if(l(W))Q=`>=${J}.0.0${$?"-0":""}`;else if(l(X))Q=`>=${J}.${W}.0${$?"-0":""}`;else if(H)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(l(w))G="";else if(l(V))G=`<${+w+1}.0.0-0`;else if(l(U))G=`<${w}.${+V+1}.0-0`;else if(M)G=`<=${w}.${V}.${U}-${M}`;else if($)G=`<${w}.${V}.${+U+1}-0`;else G=`<=${G}`;return`${Q} ${G}`.trim()},K5=($,q,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(q))return!1;if(q.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(k($[J].semver),$[J].semver===n0.ANY)continue;if($[J].semver.prerelease.length>0){let W=$[J].semver;if(W.major===q.major&&W.minor===q.minor&&W.patch===q.patch)return!0}}return!1}return!0}});var V6=z((CY,p4)=>{var F6=Symbol("SemVer ANY");class W0{static get ANY(){return F6}constructor($,q){if(q=m4(q),$ instanceof W0)if($.loose===!!q.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),r0("comparator",$,q),this.options=q,this.loose=!!q.loose,this.parse($),this.semver===F6)this.value="";else this.value=this.operator+this.semver.version;r0("comp",this)}parse($){let q=this.options.loose?l4[u4.COMPARATORLOOSE]:l4[u4.COMPARATOR],Q=$.match(q);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=F6;else this.semver=new c4(Q[2],this.options.loose)}toString(){return this.value}test($){if(r0("Comparator.test",$,this.options.loose),this.semver===F6||$===F6)return!0;if(typeof $==="string")try{$=new c4($,this.options)}catch(q){return!1}return i0($,this.operator,this.semver,this.options)}intersects($,q){if(!($ instanceof W0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new d4($.value,q).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new d4(this.value,q).test($.semver)}if(q=m4(q),q.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!q.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(i0(this.semver,"<",$.semver,q)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(i0(this.semver,">",$.semver,q)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}p4.exports=W0;var m4=i6(),{safeRe:l4,t:u4}=v$(),i0=p0(),r0=G6(),c4=h(),d4=i()});var U6=z((KY,n4)=>{var I5=i(),P5=($,q,Q)=>{try{q=new I5(q,Q)}catch(J){return!1}return q.test($)};n4.exports=P5});var r4=z((IY,i4)=>{var k5=i(),b5=($,q)=>new k5($,q).set.map((Q)=>Q.map((J)=>J.value).join(" ").trim().split(" "));i4.exports=b5});var a4=z((PY,o4)=>{var Z5=h(),f5=i(),T5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new f5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===-1)J=H,W=new Z5(J,Q)}}),J};o4.exports=T5});var t4=z((kY,s4)=>{var x5=h(),v5=i(),h5=($,q,Q)=>{let J=null,W=null,X=null;try{X=new v5(q,Q)}catch(H){return null}return $.forEach((H)=>{if(X.test(H)){if(!J||W.compare(H)===1)J=H,W=new x5(J,Q)}}),J};s4.exports=h5});var q9=z((bY,$9)=>{var o0=h(),g5=i(),e4=B6(),y5=($,q)=>{$=new g5($,q);let Q=new o0("0.0.0");if($.test(Q))return Q;if(Q=new o0("0.0.0-0"),$.test(Q))return Q;Q=null;for(let J=0;J<$.set.length;++J){let W=$.set[J],X=null;if(W.forEach((H)=>{let Y=new o0(H.semver.version);switch(H.operator){case">":if(Y.prerelease.length===0)Y.patch++;else Y.prerelease.push(0);Y.raw=Y.format();case"":case">=":if(!X||e4(Y,X))X=Y;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${H.operator}`)}}),X&&(!Q||e4(Q,X)))Q=X}if(Q&&$.test(Q))return Q;return null};$9.exports=y5});var J9=z((ZY,Q9)=>{var m5=i(),l5=($,q)=>{try{return new m5($,q).range||"*"}catch(Q){return null}};Q9.exports=l5});var X0=z((fY,Y9)=>{var u5=h(),H9=V6(),{ANY:c5}=H9,d5=i(),p5=U6(),W9=B6(),X9=e6(),n5=q0(),i5=$0(),r5=($,q,Q,J)=>{$=new u5($,J),q=new d5(q,J);let W,X,H,Y,G;switch(Q){case">":W=W9,X=n5,H=X9,Y=">",G=">=";break;case"<":W=X9,X=i5,H=W9,Y="<",G="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(p5($,q,J))return!1;for(let w=0;w<q.set.length;++w){let V=q.set[w],U=null,M=null;if(V.forEach((O)=>{if(O.semver===c5)O=new H9(">=0.0.0");if(U=U||O,M=M||O,W(O.semver,U.semver,J))U=O;else if(H(O.semver,M.semver,J))M=O}),U.operator===Y||U.operator===G)return!1;if((!M.operator||M.operator===Y)&&X($,M.semver))return!1;else if(M.operator===G&&H($,M.semver))return!1}return!0};Y9.exports=r5});var B9=z((TY,G9)=>{var o5=X0(),a5=($,q,Q)=>o5($,q,">",Q);G9.exports=a5});var V9=z((xY,w9)=>{var s5=X0(),t5=($,q,Q)=>s5($,q,"<",Q);w9.exports=t5});var _9=z((vY,U9)=>{var F9=i(),e5=($,q,Q)=>{return $=new F9($,Q),q=new F9(q,Q),$.intersects(q,Q)};U9.exports=e5});var z9=z((hY,D9)=>{var $2=U6(),q2=n();D9.exports=($,q,Q)=>{let J=[],W=null,X=null,H=$.sort((V,U)=>q2(V,U,Q));for(let V of H)if($2(V,q,Q)){if(X=V,!W)W=V}else{if(X)J.push([W,X]);X=null,W=null}if(W)J.push([W,null]);let Y=[];for(let[V,U]of J)if(V===U)Y.push(V);else if(!U&&V===H[0])Y.push("*");else if(!U)Y.push(`>=${V}`);else if(V===H[0])Y.push(`<=${U}`);else Y.push(`${V} - ${U}`);let G=Y.join(" || "),w=typeof q.raw==="string"?q.raw:String(q);return G.length<w.length?G:q}});var S9=z((gY,R9)=>{var L9=i(),s0=V6(),{ANY:a0}=s0,_6=U6(),t0=n(),Q2=($,q,Q={})=>{if($===q)return!0;$=new L9($,Q),q=new L9(q,Q);let J=!1;$:for(let W of $.set){for(let X of q.set){let H=W2(W,X,Q);if(J=J||H!==null,H)continue $}if(J)return!1}return!0},J2=[new s0(">=0.0.0-0")],j9=[new s0(">=0.0.0")],W2=($,q,Q)=>{if($===q)return!0;if($.length===1&&$[0].semver===a0)if(q.length===1&&q[0].semver===a0)return!0;else if(Q.includePrerelease)$=J2;else $=j9;if(q.length===1&&q[0].semver===a0)if(Q.includePrerelease)return!0;else q=j9;let J=new Set,W,X;for(let O of $)if(O.operator===">"||O.operator===">=")W=O9(W,O,Q);else if(O.operator==="<"||O.operator==="<=")X=N9(X,O,Q);else J.add(O.semver);if(J.size>1)return null;let H;if(W&&X){if(H=t0(W.semver,X.semver,Q),H>0)return null;else if(H===0&&(W.operator!==">="||X.operator!=="<="))return null}for(let O of J){if(W&&!_6(O,String(W),Q))return null;if(X&&!_6(O,String(X),Q))return null;for(let P of q)if(!_6(O,String(P),Q))return!1;return!0}let Y,G,w,V,U=X&&!Q.includePrerelease&&X.semver.prerelease.length?X.semver:!1,M=W&&!Q.includePrerelease&&W.semver.prerelease.length?W.semver:!1;if(U&&U.prerelease.length===1&&X.operator==="<"&&U.prerelease[0]===0)U=!1;for(let O of q){if(V=V||O.operator===">"||O.operator===">=",w=w||O.operator==="<"||O.operator==="<=",W){if(M){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===M.major&&O.semver.minor===M.minor&&O.semver.patch===M.patch)M=!1}if(O.operator===">"||O.operator===">="){if(Y=O9(W,O,Q),Y===O&&Y!==W)return!1}else if(W.operator===">="&&!_6(W.semver,String(O),Q))return!1}if(X){if(U){if(O.semver.prerelease&&O.semver.prerelease.length&&O.semver.major===U.major&&O.semver.minor===U.minor&&O.semver.patch===U.patch)U=!1}if(O.operator==="<"||O.operator==="<="){if(G=N9(X,O,Q),G===O&&G!==X)return!1}else if(X.operator==="<="&&!_6(X.semver,String(O),Q))return!1}if(!O.operator&&(X||W)&&H!==0)return!1}if(W&&w&&!X&&H!==0)return!1;if(X&&V&&!W&&H!==0)return!1;if(M||U)return!1;return!0},O9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J>0?$:J<0?q:q.operator===">"&&$.operator===">="?q:$},N9=($,q,Q)=>{if(!$)return q;let J=t0($.semver,q.semver,Q);return J<0?$:J>0?q:q.operator==="<"&&$.operator==="<="?q:$};R9.exports=Q2});var H0=z((yY,A9)=>{var e0=v$(),M9=Y6(),X2=h(),E9=l0(),H2=S$(),Y2=o1(),G2=s1(),B2=$4(),w2=J4(),V2=X4(),F2=Y4(),U2=B4(),_2=V4(),D2=n(),z2=D4(),L2=L4(),j2=t6(),O2=R4(),N2=M4(),R2=B6(),S2=e6(),M2=c0(),E2=d0(),A2=$0(),C2=q0(),K2=p0(),I2=Z4(),P2=V6(),k2=i(),b2=U6(),Z2=r4(),f2=a4(),T2=t4(),x2=q9(),v2=J9(),h2=X0(),g2=B9(),y2=V9(),m2=_9(),l2=z9(),u2=S9();A9.exports={parse:H2,valid:Y2,clean:G2,inc:B2,diff:w2,major:V2,minor:F2,patch:U2,prerelease:_2,compare:D2,rcompare:z2,compareLoose:L2,compareBuild:j2,sort:O2,rsort:N2,gt:R2,lt:S2,eq:M2,neq:E2,gte:A2,lte:C2,cmp:K2,coerce:I2,Comparator:P2,Range:k2,satisfies:b2,toComparators:Z2,maxSatisfying:f2,minSatisfying:T2,minVersion:x2,validRange:v2,outside:h2,gtr:g2,ltr:y2,intersects:m2,simplifyRange:l2,subset:u2,SemVer:X2,re:e0.re,src:e0.src,tokens:e0.t,SEMVER_SPEC_VERSION:M9.SEMVER_SPEC_VERSION,RELEASE_TYPES:M9.RELEASE_TYPES,compareIdentifiers:E9.compareIdentifiers,rcompareIdentifiers:E9.rcompareIdentifiers}});var K9=z((mY,C9)=>{var c2=H0();C9.exports=c2.satisfies(process.version,">=15.7.0")});var P9=z((lY,I9)=>{var d2=H0();I9.exports=d2.satisfies(process.version,">=16.9.0")});var $8=z((uY,k9)=>{var p2=K9(),n2=P9(),i2={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},r2={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};k9.exports=function($,q){if(!$||!q)return;let Q=q.asymmetricKeyType;if(!Q)return;let J=i2[Q];if(!J)throw Error(`Unknown key type "${Q}".`);if(!J.includes($))throw Error(`"alg" parameter for "${Q}" key type must be one of: ${J.join(", ")}.`);if(p2)switch(Q){case"ec":let W=q.asymmetricKeyDetails.namedCurve,X=r2[$];if(W!==X)throw Error(`"alg" parameter "${$}" requires curve "${X}".`);break;case"rsa-pss":if(n2){let H=parseInt($.slice(-3),10),{hashAlgorithm:Y,mgf1HashAlgorithm:G,saltLength:w}=q.asymmetricKeyDetails;if(Y!==`sha${H}`||G!==Y)throw Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${$}.`);if(w!==void 0&&w>H>>3)throw Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${$}.`)}break}}});var q8=z((cY,b9)=>{var o2=H0();b9.exports=o2.satisfies(process.version,"^6.12.0 || >=8.0.0")});var T9=z((dY,f9)=>{var I=H6(),a2=v0(),Z9=h0(),s2=x0(),t2=g0(),e2=$8(),$W=q8(),qW=u6(),{KeyObject:QW,createSecretKey:JW,createPublicKey:WW}=require("crypto"),Q8=["RS256","RS384","RS512"],XW=["ES256","ES384","ES512"],J8=["RS256","RS384","RS512"],HW=["HS256","HS384","HS512"];if($W)Q8.splice(Q8.length,0,"PS256","PS384","PS512"),J8.splice(J8.length,0,"PS256","PS384","PS512");f9.exports=function($,q,Q,J){if(typeof Q==="function"&&!J)J=Q,Q={};if(!Q)Q={};Q=Object.assign({},Q);let W;if(J)W=J;else W=function(V,U){if(V)throw V;return U};if(Q.clockTimestamp&&typeof Q.clockTimestamp!=="number")return W(new I("clockTimestamp must be a number"));if(Q.nonce!==void 0&&(typeof Q.nonce!=="string"||Q.nonce.trim()===""))return W(new I("nonce must be a non-empty string"));if(Q.allowInvalidAsymmetricKeyTypes!==void 0&&typeof Q.allowInvalidAsymmetricKeyTypes!=="boolean")return W(new I("allowInvalidAsymmetricKeyTypes must be a boolean"));let X=Q.clockTimestamp||Math.floor(Date.now()/1000);if(!$)return W(new I("jwt must be provided"));if(typeof $!=="string")return W(new I("jwt must be a string"));let H=$.split(".");if(H.length!==3)return W(new I("jwt malformed"));let Y;try{Y=s2($,{complete:!0})}catch(V){return W(V)}if(!Y)return W(new I("invalid token"));let G=Y.header,w;if(typeof q==="function"){if(!J)return W(new I("verify must be called asynchronous if secret or public key is provided as a callback"));w=q}else w=function(V,U){return U(null,q)};return w(G,function(V,U){if(V)return W(new I("error in secret or public key callback: "+V.message));let M=H[2].trim()!=="";if(!M&&U)return W(new I("jwt signature is required"));if(M&&!U)return W(new I("secret or public key must be provided"));if(!M&&!Q.algorithms)return W(new I('please specify "none" in "algorithms" to verify unsigned tokens'));if(U!=null&&!(U instanceof QW))try{U=WW(U)}catch(u){try{U=JW(typeof U==="string"?Buffer.from(U):U)}catch(aq){return W(new I("secretOrPublicKey is not valid key material"))}}if(!Q.algorithms)if(U.type==="secret")Q.algorithms=HW;else if(["rsa","rsa-pss"].includes(U.asymmetricKeyType))Q.algorithms=J8;else if(U.asymmetricKeyType==="ec")Q.algorithms=XW;else Q.algorithms=Q8;if(Q.algorithms.indexOf(Y.header.alg)===-1)return W(new I("invalid algorithm"));if(G.alg.startsWith("HS")&&U.type!=="secret")return W(new I(`secretOrPublicKey must be a symmetric key when using ${G.alg}`));else if(/^(?:RS|PS|ES)/.test(G.alg)&&U.type!=="public")return W(new I(`secretOrPublicKey must be an asymmetric key when using ${G.alg}`));if(!Q.allowInvalidAsymmetricKeyTypes)try{e2(G.alg,U)}catch(u){return W(u)}let O;try{O=qW.verify($,Y.header.alg,U)}catch(u){return W(u)}if(!O)return W(new I("invalid signature"));let P=Y.payload;if(typeof P.nbf<"u"&&!Q.ignoreNotBefore){if(typeof P.nbf!=="number")return W(new I("invalid nbf value"));if(P.nbf>X+(Q.clockTolerance||0))return W(new a2("jwt not active",new Date(P.nbf*1000)))}if(typeof P.exp<"u"&&!Q.ignoreExpiration){if(typeof P.exp!=="number")return W(new I("invalid exp value"));if(X>=P.exp+(Q.clockTolerance||0))return W(new Z9("jwt expired",new Date(P.exp*1000)))}if(Q.audience){let u=Array.isArray(Q.audience)?Q.audience:[Q.audience];if(!(Array.isArray(P.aud)?P.aud:[P.aud]).some(function(v8){return u.some(function(S0){return S0 instanceof RegExp?S0.test(v8):S0===v8})}))return W(new I("jwt audience invalid. expected: "+u.join(" or ")))}if(Q.issuer){if(typeof Q.issuer==="string"&&P.iss!==Q.issuer||Array.isArray(Q.issuer)&&Q.issuer.indexOf(P.iss)===-1)return W(new I("jwt issuer invalid. expected: "+Q.issuer))}if(Q.subject){if(P.sub!==Q.subject)return W(new I("jwt subject invalid. expected: "+Q.subject))}if(Q.jwtid){if(P.jti!==Q.jwtid)return W(new I("jwt jwtid invalid. expected: "+Q.jwtid))}if(Q.nonce){if(P.nonce!==Q.nonce)return W(new I("jwt nonce invalid. expected: "+Q.nonce))}if(Q.maxAge){if(typeof P.iat!=="number")return W(new I("iat required when maxAge is specified"));let u=t2(Q.maxAge,P.iat);if(typeof u>"u")return W(new I('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(X>=u+(Q.clockTolerance||0))return W(new Z9("maxAge exceeded",new Date(u*1000)))}if(Q.complete===!0){let u=Y.signature;return W(null,{header:G,payload:P,signature:u})}return W(null,P)})}});var m9=z((pY,y9)=>{var x9=1/0,h9=9007199254740991,YW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,v9=NaN,GW="[object Arguments]",BW="[object Function]",wW="[object GeneratorFunction]",VW="[object String]",FW="[object Symbol]",UW=/^\s+|\s+$/g,_W=/^[-+]0x[0-9a-f]+$/i,DW=/^0b[01]+$/i,zW=/^0o[0-7]+$/i,LW=/^(?:0|[1-9]\d*)$/,jW=parseInt;function OW($,q){var Q=-1,J=$?$.length:0,W=Array(J);while(++Q<J)W[Q]=q($[Q],Q,$);return W}function NW($,q,Q,J){var W=$.length,X=Q+(J?1:-1);while(J?X--:++X<W)if(q($[X],X,$))return X;return-1}function RW($,q,Q){if(q!==q)return NW($,SW,Q);var J=Q-1,W=$.length;while(++J<W)if($[J]===q)return J;return-1}function SW($){return $!==$}function MW($,q){var Q=-1,J=Array($);while(++Q<$)J[Q]=q(Q);return J}function EW($,q){return OW(q,function(Q){return $[Q]})}function AW($,q){return function(Q){return $(q(Q))}}var Y0=Object.prototype,X8=Y0.hasOwnProperty,G0=Y0.toString,CW=Y0.propertyIsEnumerable,KW=AW(Object.keys,Object),IW=Math.max;function PW($,q){var Q=g9($)||TW($)?MW($.length,String):[],J=Q.length,W=!!J;for(var X in $)if((q||X8.call($,X))&&!(W&&(X=="length"||bW(X,J))))Q.push(X);return Q}function kW($){if(!ZW($))return KW($);var q=[];for(var Q in Object($))if(X8.call($,Q)&&Q!="constructor")q.push(Q);return q}function bW($,q){return q=q==null?h9:q,!!q&&(typeof $=="number"||LW.test($))&&($>-1&&$%1==0&&$<q)}function ZW($){var q=$&&$.constructor,Q=typeof q=="function"&&q.prototype||Y0;return $===Q}function fW($,q,Q,J){$=H8($)?$:dW($),Q=Q&&!J?lW(Q):0;var W=$.length;if(Q<0)Q=IW(W+Q,0);return gW($)?Q<=W&&$.indexOf(q,Q)>-1:!!W&&RW($,q,Q)>-1}function TW($){return xW($)&&X8.call($,"callee")&&(!CW.call($,"callee")||G0.call($)==GW)}var g9=Array.isArray;function H8($){return $!=null&&hW($.length)&&!vW($)}function xW($){return Y8($)&&H8($)}function vW($){var q=W8($)?G0.call($):"";return q==BW||q==wW}function hW($){return typeof $=="number"&&$>-1&&$%1==0&&$<=h9}function W8($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function Y8($){return!!$&&typeof $=="object"}function gW($){return typeof $=="string"||!g9($)&&Y8($)&&G0.call($)==VW}function yW($){return typeof $=="symbol"||Y8($)&&G0.call($)==FW}function mW($){if(!$)return $===0?$:0;if($=uW($),$===x9||$===-x9){var q=$<0?-1:1;return q*YW}return $===$?$:0}function lW($){var q=mW($),Q=q%1;return q===q?Q?q-Q:q:0}function uW($){if(typeof $=="number")return $;if(yW($))return v9;if(W8($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=W8(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(UW,"");var Q=DW.test($);return Q||zW.test($)?jW($.slice(2),Q?2:8):_W.test($)?v9:+$}function cW($){return H8($)?PW($):kW($)}function dW($){return $?EW($,cW($)):[]}y9.exports=fW});var u9=z((nY,l9)=>{var pW="[object Boolean]",nW=Object.prototype,iW=nW.toString;function rW($){return $===!0||$===!1||oW($)&&iW.call($)==pW}function oW($){return!!$&&typeof $=="object"}l9.exports=rW});var i9=z((iY,n9)=>{var c9=1/0,aW=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,d9=NaN,sW="[object Symbol]",tW=/^\s+|\s+$/g,eW=/^[-+]0x[0-9a-f]+$/i,$7=/^0b[01]+$/i,q7=/^0o[0-7]+$/i,Q7=parseInt,J7=Object.prototype,W7=J7.toString;function X7($){return typeof $=="number"&&$==B7($)}function p9($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function H7($){return!!$&&typeof $=="object"}function Y7($){return typeof $=="symbol"||H7($)&&W7.call($)==sW}function G7($){if(!$)return $===0?$:0;if($=w7($),$===c9||$===-c9){var q=$<0?-1:1;return q*aW}return $===$?$:0}function B7($){var q=G7($),Q=q%1;return q===q?Q?q-Q:q:0}function w7($){if(typeof $=="number")return $;if(Y7($))return d9;if(p9($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=p9(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(tW,"");var Q=$7.test($);return Q||q7.test($)?Q7($.slice(2),Q?2:8):eW.test($)?d9:+$}n9.exports=X7});var o9=z((rY,r9)=>{var V7="[object Number]",F7=Object.prototype,U7=F7.toString;function _7($){return!!$&&typeof $=="object"}function D7($){return typeof $=="number"||_7($)&&U7.call($)==V7}r9.exports=D7});var e9=z((oY,t9)=>{var z7="[object Object]";function L7($){var q=!1;if($!=null&&typeof $.toString!="function")try{q=!!($+"")}catch(Q){}return q}function j7($,q){return function(Q){return $(q(Q))}}var O7=Function.prototype,a9=Object.prototype,s9=O7.toString,N7=a9.hasOwnProperty,R7=s9.call(Object),S7=a9.toString,M7=j7(Object.getPrototypeOf,Object);function E7($){return!!$&&typeof $=="object"}function A7($){if(!E7($)||S7.call($)!=z7||L7($))return!1;var q=M7($);if(q===null)return!0;var Q=N7.call(q,"constructor")&&q.constructor;return typeof Q=="function"&&Q instanceof Q&&s9.call(Q)==R7}t9.exports=A7});var qq=z((aY,$q)=>{var C7="[object String]",K7=Object.prototype,I7=K7.toString,P7=Array.isArray;function k7($){return!!$&&typeof $=="object"}function b7($){return typeof $=="string"||!P7($)&&k7($)&&I7.call($)==C7}$q.exports=b7});var Hq=z((sY,Xq)=>{var Z7="Expected a function",Qq=1/0,f7=179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,Jq=NaN,T7="[object Symbol]",x7=/^\s+|\s+$/g,v7=/^[-+]0x[0-9a-f]+$/i,h7=/^0b[01]+$/i,g7=/^0o[0-7]+$/i,y7=parseInt,m7=Object.prototype,l7=m7.toString;function u7($,q){var Q;if(typeof q!="function")throw TypeError(Z7);return $=i7($),function(){if(--$>0)Q=q.apply(this,arguments);if($<=1)q=void 0;return Q}}function c7($){return u7(2,$)}function Wq($){var q=typeof $;return!!$&&(q=="object"||q=="function")}function d7($){return!!$&&typeof $=="object"}function p7($){return typeof $=="symbol"||d7($)&&l7.call($)==T7}function n7($){if(!$)return $===0?$:0;if($=r7($),$===Qq||$===-Qq){var q=$<0?-1:1;return q*f7}return $===$?$:0}function i7($){var q=n7($),Q=q%1;return q===q?Q?q-Q:q:0}function r7($){if(typeof $=="number")return $;if(p7($))return Jq;if(Wq($)){var q=typeof $.valueOf=="function"?$.valueOf():$;$=Wq(q)?q+"":q}if(typeof $!="string")return $===0?$:+$;$=$.replace(x7,"");var Q=h7.test($);return Q||g7.test($)?y7($.slice(2),Q?2:8):v7.test($)?Jq:+$}Xq.exports=c7});var Dq=z((tY,_q)=>{var Yq=g0(),o7=q8(),a7=$8(),Gq=u6(),s7=m9(),B0=u9(),Bq=i9(),G8=o9(),Vq=e9(),F$=qq(),t7=Hq(),{KeyObject:e7,createSecretKey:$3,createPrivateKey:q3}=require("crypto"),Fq=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];if(o7)Fq.splice(3,0,"PS256","PS384","PS512");var Q3={expiresIn:{isValid:function($){return Bq($)||F$($)&&$},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function($){return Bq($)||F$($)&&$},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function($){return F$($)||Array.isArray($)},message:'"audience" must be a string or array'},algorithm:{isValid:s7.bind(null,Fq),message:'"algorithm" must be a valid string enum value'},header:{isValid:Vq,message:'"header" must be an object'},encoding:{isValid:F$,message:'"encoding" must be a string'},issuer:{isValid:F$,message:'"issuer" must be a string'},subject:{isValid:F$,message:'"subject" must be a string'},jwtid:{isValid:F$,message:'"jwtid" must be a string'},noTimestamp:{isValid:B0,message:'"noTimestamp" must be a boolean'},keyid:{isValid:F$,message:'"keyid" must be a string'},mutatePayload:{isValid:B0,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:B0,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:B0,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},J3={iat:{isValid:G8,message:'"iat" should be a number of seconds'},exp:{isValid:G8,message:'"exp" should be a number of seconds'},nbf:{isValid:G8,message:'"nbf" should be a number of seconds'}};function Uq($,q,Q,J){if(!Vq(Q))throw Error('Expected "'+J+'" to be a plain object.');Object.keys(Q).forEach(function(W){let X=$[W];if(!X){if(!q)throw Error('"'+W+'" is not allowed in "'+J+'"');return}if(!X.isValid(Q[W]))throw Error(X.message)})}function W3($){return Uq(Q3,!1,$,"options")}function X3($){return Uq(J3,!0,$,"payload")}var wq={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},H3=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];_q.exports=function($,q,Q,J){if(typeof Q==="function")J=Q,Q={};else Q=Q||{};let W=typeof $==="object"&&!Buffer.isBuffer($),X=Object.assign({alg:Q.algorithm||"HS256",typ:W?"JWT":void 0,kid:Q.keyid},Q.header);function H(w){if(J)return J(w);throw w}if(!q&&Q.algorithm!=="none")return H(Error("secretOrPrivateKey must have a value"));if(q!=null&&!(q instanceof e7))try{q=q3(q)}catch(w){try{q=$3(typeof q==="string"?Buffer.from(q):q)}catch(V){return H(Error("secretOrPrivateKey is not valid key material"))}}if(X.alg.startsWith("HS")&&q.type!=="secret")return H(Error(`secretOrPrivateKey must be a symmetric key when using ${X.alg}`));else if(/^(?:RS|PS|ES)/.test(X.alg)){if(q.type!=="private")return H(Error(`secretOrPrivateKey must be an asymmetric key when using ${X.alg}`));if(!Q.allowInsecureKeySizes&&!X.alg.startsWith("ES")&&q.asymmetricKeyDetails!==void 0&&q.asymmetricKeyDetails.modulusLength<2048)return H(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`))}if(typeof $>"u")return H(Error("payload is required"));else if(W){try{X3($)}catch(w){return H(w)}if(!Q.mutatePayload)$=Object.assign({},$)}else{let w=H3.filter(function(V){return typeof Q[V]<"u"});if(w.length>0)return H(Error("invalid "+w.join(",")+" option for "+typeof $+" payload"))}if(typeof $.exp<"u"&&typeof Q.expiresIn<"u")return H(Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(typeof $.nbf<"u"&&typeof Q.notBefore<"u")return H(Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{W3(Q)}catch(w){return H(w)}if(!Q.allowInvalidAsymmetricKeyTypes)try{a7(X.alg,q)}catch(w){return H(w)}let Y=$.iat||Math.floor(Date.now()/1000);if(Q.noTimestamp)delete $.iat;else if(W)$.iat=Y;if(typeof Q.notBefore<"u"){try{$.nbf=Yq(Q.notBefore,Y)}catch(w){return H(w)}if(typeof $.nbf>"u")return H(Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(typeof Q.expiresIn<"u"&&typeof $==="object"){try{$.exp=Yq(Q.expiresIn,Y)}catch(w){return H(w)}if(typeof $.exp>"u")return H(Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(wq).forEach(function(w){let V=wq[w];if(typeof Q[w]<"u"){if(typeof $[V]<"u")return H(Error('Bad "options.'+w+'" option. The payload already has an "'+V+'" property.'));$[V]=Q[w]}});let G=Q.encoding||"utf8";if(typeof J==="function")J=J&&t7(J),Gq.createSign({header:X,privateKey:q,payload:$,encoding:G}).once("error",J).once("done",function(w){if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)return J(Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`));J(null,w)});else{let w=Gq.sign({header:X,payload:$,secret:q,encoding:G});if(!Q.allowInsecureKeySizes&&/^(?:RS|PS)/.test(X.alg)&&w.length<256)throw Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${X.alg}`);return w}}});var Lq=z((eY,zq)=>{zq.exports={decode:x0(),verify:T9(),sign:Dq(),JsonWebTokenError:H6(),NotBeforeError:v0(),TokenExpiredError:h0()}});function D0($){return`https://veloce-ts.com/problems/${$}`}function Pq($,q){if(q)return q;let Q=NX[$]??"unknown-error";return D0(Q)}function kq($,q,Q){if(Q)return Q;return RX[$]??q}function SX($){try{return new URL($.req.url).href}catch{return $.req.path}}function MX($){let q=$.statusCode??$.status,J={error:(typeof $.error==="string"?$.error:null)??(typeof $.detail==="string"?$.detail:"Error"),statusCode:q};if($.details!==void 0)J.details=$.details;else if($.violations!==void 0)J.details=$.violations;return J}function kG($,q,Q,J){let W=SX($),X={...q,instance:W};if(J==="legacy")return $.json(MX(X),Q);return new Response(JSON.stringify(X),{status:Q,headers:{"Content-Type":"application/problem+json"}})}var IG="application/problem+json",PG="https://veloce-ts.com/problems",NX,RX;var F8=E0(()=>{NX={400:"bad-request",401:"unauthorized",403:"forbidden",404:"not-found",409:"conflict",410:"gone",413:"payload-too-large",422:"unprocessable-entity",429:"too-many-requests",500:"internal-server-error",503:"service-unavailable"},RX={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",409:"Conflict",410:"Gone",413:"Payload Too Large",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",503:"Service Unavailable"}});var d,EX,AX,CX,KX,IX,PX,kX,bX,ZX,fX;var bq=E0(()=>{F8();d=class d extends Error{statusCode;details;problemType;title;constructor($,q,Q,J){super(q);this.statusCode=$;this.details=Q;if(this.name="HTTPException",this.problemType=J?.problemType,this.title=J?.title,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){let $=this.statusCode,q=Pq($,this.problemType),Q=kq($,this.message,this.title);return{type:q,title:Q,status:$,detail:this.message,...this.details!==void 0?{details:this.details}:{},error:this.message,statusCode:$}}};EX=class EX extends d{constructor($="Not Found",q){super(404,$,q,{title:"Not Found"});this.name="NotFoundException"}};AX=class AX extends d{constructor($="Unauthorized",q){super(401,$,q,{title:"Unauthorized"});this.name="UnauthorizedException"}};CX=class CX extends d{constructor($="Forbidden",q){super(403,$,q,{title:"Forbidden"});this.name="ForbiddenException"}};KX=class KX extends d{constructor($="Bad Request",q){super(400,$,q,{title:"Bad Request"});this.name="BadRequestException"}};IX=class IX extends d{constructor($="Conflict",q){super(409,$,q,{title:"Conflict"});this.name="ConflictException"}};PX=class PX extends d{constructor($="Gone",q){super(410,$,q,{title:"Gone"});this.name="GoneException"}};kX=class kX extends d{constructor($="Payload Too Large",q){super(413,$,q,{title:"Payload Too Large"});this.name="PayloadTooLargeException"}};bX=class bX extends d{constructor($="Unprocessable Entity",q){super(422,$,q,{title:"Unprocessable Entity"});this.name="UnprocessableEntityException"}};ZX=class ZX extends d{constructor($="Too Many Requests",q){super(429,$,q,{title:"Too Many Requests"});this.name="TooManyRequestsException"}};fX=class fX extends d{constructor($="Service Unavailable",q){super(503,$,q,{title:"Service Unavailable"});this.name="ServiceUnavailableException"}}});var TX={};M0(TX,{TokenRevokedException:()=>U8,TokenExpiredException:()=>S6,InvalidTokenException:()=>I$,AuthorizationException:()=>x,AuthenticationException:()=>f});var f,x,S6,I$,U8;var w$=E0(()=>{bq();F8();f=class f extends d{constructor($="Authentication required"){super(401,$,void 0,{title:"Authentication Error",problemType:D0("authentication-error")});this.name="AuthenticationException"}};x=class x extends d{constructor($="Insufficient permissions"){super(403,$,void 0,{title:"Authorization Error",problemType:D0("authorization-error")});this.name="AuthorizationException"}};S6=class S6 extends f{constructor($="Token has expired"){super($);this.name="TokenExpiredException"}};I$=class I$ extends f{constructor($="Invalid token"){super($);this.name="InvalidTokenException"}};U8=class U8 extends f{constructor($="Token has been revoked"){super($);this.name="TokenRevokedException"}}});var ZH={};M0(ZH,{setSessionData:()=>kH,removeSessionData:()=>bH,isSessionAuthenticated:()=>IH,isOAuthAuthenticated:()=>iX,isAuthenticated:()=>gX,getUserRoles:()=>Z8,getUserResourcePermissions:()=>DH,getUserPermissions:()=>dq,getToken:()=>K8,getSessionUserId:()=>PH,getSessionManager:()=>b6,getSessionData:()=>KH,getRBACManager:()=>cq,getPermissionManager:()=>T8,getOAuthUser:()=>pX,getOAuthToken:()=>nX,getOAuthProvider:()=>rX,getCurrentUser:()=>T,getCurrentSession:()=>q$,getCSRFProtection:()=>CH,getAuthError:()=>yX,createSessionMiddleware:()=>x8,createRBACMiddleware:()=>b8,createPermissionMiddleware:()=>f8,createDefaultRBAC:()=>P8,createAuthMiddleware:()=>C8,checkUserRole:()=>QH,checkUserPermission:()=>JH,checkResourceAccess:()=>iq,canUserAccess:()=>zH,UpdateSessionSchema:()=>NH,TokenRevokedException:()=>U8,TokenPayloadSchema:()=>LX,TokenExpiredException:()=>S6,Token:()=>hX,TeamOnly:()=>VH,TeamMembershipPolicy:()=>O0,SuperAdminOnly:()=>$H,SessionPlugin:()=>oq,SessionManager:()=>P6,SessionGuard:()=>Z6,SessionDataSchema:()=>LH,SessionData:()=>MH,SessionConfigSchema:()=>jH,Session:()=>RH,Roles:()=>lq,RoleSchema:()=>oX,RoleAssignmentSchema:()=>aX,ResourcePermissionSchema:()=>WH,ResourcePermissionCheckSchema:()=>XH,RequireRole:()=>k8,RequirePermission:()=>tX,RequireCSRF:()=>AH,RefreshRequestSchema:()=>OX,RedisSessionStore:()=>R0,RBACPlugin:()=>pq,RBACManager:()=>t$,RBACGuard:()=>C6,PublicResourcePolicy:()=>N0,PublicRead:()=>FH,Permissions:()=>uq,PermissionSchema:()=>nq,PermissionPlugin:()=>rq,PermissionMatcher:()=>e$,PermissionManager:()=>K6,PermissionGuard:()=>I6,PermissionCheckSchema:()=>sX,PKCEUtils:()=>z0,OwnershipPolicy:()=>j0,OwnerOnly:()=>wH,OAuthUserSchema:()=>lX,OAuthUser:()=>cX,OAuthTokensSchema:()=>mX,OAuthToken:()=>dX,OAuthStateManager:()=>L0,OAuthPlugin:()=>mq,OAuthCallbackSchema:()=>I8,OAuth:()=>uX,MinimumRole:()=>qH,MicrosoftOAuthProvider:()=>yq,MemorySessionStore:()=>$6,LoginRequestSchema:()=>jX,JWTProvider:()=>_0,InvalidTokenException:()=>I$,InMemoryUserProvider:()=>Zq,GoogleOAuthProvider:()=>hq,GitHubOAuthProvider:()=>gq,FilteredResource:()=>UH,FilteredAttributes:()=>_H,CurrentUser:()=>vX,CurrentSession:()=>SH,CreateSessionSchema:()=>OH,CanWrite:()=>YH,CanUpdate:()=>GH,CanRead:()=>HH,CanDelete:()=>BH,CanAccess:()=>O$,CSRFToken:()=>EH,CSRFProtection:()=>k6,BaseOAuthProvider:()=>A6,AuthorizationException:()=>x,AuthenticationException:()=>f,AuthService:()=>M6,AuthPlugin:()=>vq,Auth:()=>xX,AdminOnly:()=>eX});module.exports=JQ(ZH);var j$=QQ(Lq(),1);var B={};M0(B,{void:()=>d3,util:()=>K,unknown:()=>u3,union:()=>r3,undefined:()=>y3,tuple:()=>s3,transformer:()=>YX,symbol:()=>g3,string:()=>Cq,strictObject:()=>i3,setErrorMap:()=>B3,set:()=>$X,record:()=>t3,quotelessJson:()=>Y3,promise:()=>HX,preprocess:()=>wX,pipeline:()=>VX,ostring:()=>FX,optional:()=>GX,onumber:()=>UX,oboolean:()=>_X,objectUtil:()=>B8,object:()=>n3,number:()=>Kq,nullable:()=>BX,null:()=>m3,never:()=>c3,nativeEnum:()=>XX,nan:()=>x3,map:()=>e3,makeIssue:()=>D6,literal:()=>JX,lazy:()=>QX,late:()=>f3,isValid:()=>U$,isDirty:()=>V0,isAsync:()=>g$,isAborted:()=>w0,intersection:()=>a3,instanceof:()=>T3,getParsedType:()=>W$,getErrorMap:()=>h$,function:()=>qX,enum:()=>WX,effect:()=>YX,discriminatedUnion:()=>o3,defaultErrorMap:()=>Y$,datetimeRegex:()=>Mq,date:()=>h3,custom:()=>Aq,coerce:()=>DX,boolean:()=>Iq,bigint:()=>v3,array:()=>p3,any:()=>l3,addIssueToContext:()=>D,ZodVoid:()=>L6,ZodUnknown:()=>_$,ZodUnion:()=>d$,ZodUndefined:()=>u$,ZodType:()=>C,ZodTuple:()=>H$,ZodTransformer:()=>$$,ZodSymbol:()=>z6,ZodString:()=>a,ZodSet:()=>C$,ZodSchema:()=>C,ZodRecord:()=>j6,ZodReadonly:()=>s$,ZodPromise:()=>K$,ZodPipeline:()=>R6,ZodParsedType:()=>_,ZodOptional:()=>t,ZodObject:()=>Z,ZodNumber:()=>D$,ZodNullable:()=>B$,ZodNull:()=>c$,ZodNever:()=>X$,ZodNativeEnum:()=>r$,ZodNaN:()=>N6,ZodMap:()=>O6,ZodLiteral:()=>i$,ZodLazy:()=>n$,ZodIssueCode:()=>F,ZodIntersection:()=>p$,ZodFunction:()=>m$,ZodFirstPartyTypeKind:()=>S,ZodError:()=>c,ZodEnum:()=>L$,ZodEffects:()=>$$,ZodDiscriminatedUnion:()=>F0,ZodDefault:()=>o$,ZodDate:()=>E$,ZodCatch:()=>a$,ZodBranded:()=>U0,ZodBoolean:()=>l$,ZodBigInt:()=>z$,ZodArray:()=>s,ZodAny:()=>A$,Schema:()=>C,ParseStatus:()=>v,OK:()=>y,NEVER:()=>zX,INVALID:()=>R,EMPTY_PATH:()=>w3,DIRTY:()=>M$,BRAND:()=>Z3});var K;(function($){$.assertEqual=(W)=>{};function q(W){}$.assertIs=q;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let X={};for(let H of W)X[H]=H;return X},$.getValidEnumValues=(W)=>{let X=$.objectKeys(W).filter((Y)=>typeof W[W[Y]]!=="number"),H={};for(let Y of X)H[Y]=W[Y];return $.objectValues(H)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(X){return W[X]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let X=[];for(let H in W)if(Object.prototype.hasOwnProperty.call(W,H))X.push(H);return X},$.find=(W,X)=>{for(let H of W)if(X(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function J(W,X=" | "){return W.map((H)=>typeof H==="string"?`'${H}'`:H).join(X)}$.joinValues=J,$.jsonStringifyReplacer=(W,X)=>{if(typeof X==="bigint")return X.toString();return X}})(K||(K={}));var B8;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(B8||(B8={}));var _=K.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W$=($)=>{switch(typeof $){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN($)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":if(Array.isArray($))return _.array;if($===null)return _.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return _.promise;if(typeof Map<"u"&&$ instanceof Map)return _.map;if(typeof Set<"u"&&$ instanceof Set)return _.set;if(typeof Date<"u"&&$ instanceof Date)return _.date;return _.object;default:return _.unknown}};var F=K.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Y3=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class c extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(W){return W.message},Q={_errors:[]},J=(W)=>{for(let X of W.issues)if(X.code==="invalid_union")X.unionErrors.map(J);else if(X.code==="invalid_return_type")J(X.returnTypeError);else if(X.code==="invalid_arguments")J(X.argumentsError);else if(X.path.length===0)Q._errors.push(q(X));else{let H=Q,Y=0;while(Y<X.path.length){let G=X.path[Y];if(Y!==X.path.length-1)H[G]=H[G]||{_errors:[]};else H[G]=H[G]||{_errors:[]},H[G]._errors.push(q(X));H=H[G],Y++}}};return J(this),Q}static assert($){if(!($ instanceof c))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,K.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let J of this.issues)if(J.path.length>0){let W=J.path[0];q[W]=q[W]||[],q[W].push($(J))}else Q.push($(J));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}c.create=($)=>{return new c($)};var G3=($,q)=>{let Q;switch($.code){case F.invalid_type:if($.received===_.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case F.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,K.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:Q=`Unrecognized key(s) in object: ${K.joinValues($.keys,", ")}`;break;case F.invalid_union:Q="Invalid input";break;case F.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${K.joinValues($.options)}`;break;case F.invalid_enum_value:Q=`Invalid enum value. Expected ${K.joinValues($.options)}, received '${$.received}'`;break;case F.invalid_arguments:Q="Invalid function arguments";break;case F.invalid_return_type:Q="Invalid function return type";break;case F.invalid_date:Q="Invalid date";break;case F.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else K.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case F.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case F.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case F.custom:Q="Invalid input";break;case F.invalid_intersection_types:Q="Intersection results could not be merged";break;case F.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case F.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,K.assertNever($)}return{message:Q}},Y$=G3;var jq=Y$;function B3($){jq=$}function h$(){return jq}var D6=($)=>{let{data:q,path:Q,errorMaps:J,issueData:W}=$,X=[...Q,...W.path||[]],H={...W,path:X};if(W.message!==void 0)return{...W,path:X,message:W.message};let Y="",G=J.filter((w)=>!!w).slice().reverse();for(let w of G)Y=w(H,{data:q,defaultError:Y}).message;return{...W,path:X,message:Y}},w3=[];function D($,q){let Q=h$(),J=D6({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===Y$?void 0:Y$].filter((W)=>!!W)});$.common.issues.push(J)}class v{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let J of q){if(J.status==="aborted")return R;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let J of q){let W=await J.key,X=await J.value;Q.push({key:W,value:X})}return v.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let J of q){let{key:W,value:X}=J;if(W.status==="aborted")return R;if(X.status==="aborted")return R;if(W.status==="dirty")$.dirty();if(X.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof X.value<"u"||J.alwaysSet))Q[W.value]=X.value}return{status:$.value,value:Q}}}var R=Object.freeze({status:"aborted"}),M$=($)=>({status:"dirty",value:$}),y=($)=>({status:"valid",value:$}),w0=($)=>$.status==="aborted",V0=($)=>$.status==="dirty",U$=($)=>$.status==="valid",g$=($)=>typeof Promise<"u"&&$ instanceof Promise;var N;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(N||(N={}));class e{constructor($,q,Q,J){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=J}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Oq=($,q)=>{if(U$(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new c($.common.issues);return this._error=Q,this._error}}}};function A($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:J,description:W}=$;if(q&&(Q||J))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:W};return{errorMap:(H,Y)=>{let{message:G}=$;if(H.code==="invalid_enum_value")return{message:G??Y.defaultError};if(typeof Y.data>"u")return{message:G??J??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:G??Q??Y.defaultError}},description:W}}class C{get description(){return this._def.description}_getType($){return W$($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new v,ctx:{common:$.parent.common,data:$.data,parsedType:W$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(g$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return Oq(Q,J)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return U$(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>U$(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:W$($)},J=this._parse({data:$,path:Q.path,parent:Q}),W=await(g$(J)?J:Promise.resolve(J));return Oq(Q,W)}refine($,q){let Q=(J)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(J);else return q};return this._refinement((J,W)=>{let X=$(J),H=()=>W.addIssue({code:F.custom,...Q(J)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!X)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof q==="function"?q(Q,J):q),!1;else return!0})}_refinement($){return new $$({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return t.create(this,this._def)}nullable(){return B$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return s.create(this)}promise(){return K$.create(this,this._def)}or($){return d$.create([this,$],this._def)}and($){return p$.create(this,$,this._def)}transform($){return new $$({...A(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new o$({...A(this._def),innerType:this,defaultValue:q,typeName:S.ZodDefault})}brand(){return new U0({typeName:S.ZodBranded,type:this,...A(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new a$({...A(this._def),innerType:this,catchValue:q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return R6.create(this,$)}readonly(){return s$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var V3=/^c[^\s-]{8,}$/i,F3=/^[0-9a-z]+$/,U3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,D3=/^[a-z0-9_-]{21}$/i,z3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,O3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",w8,N3=/^(?:(?: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])$/,R3=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,S3=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M3=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,E3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,A3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rq="((\\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])))",C3=new RegExp(`^${Rq}$`);function Sq($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function K3($){return new RegExp(`^${Sq($)}$`)}function Mq($){let q=`${Rq}T${Sq($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function I3($,q){if((q==="v4"||!q)&&N3.test($))return!0;if((q==="v6"||!q)&&S3.test($))return!0;return!1}function P3($,q){if(!z3.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(J));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(q&&W.alg!==q)return!1;return!0}catch{return!1}}function k3($,q){if((q==="v4"||!q)&&R3.test($))return!0;if((q==="v6"||!q)&&M3.test($))return!0;return!1}class a extends C{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==_.string){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.string,received:W.parsedType}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let X=$.data.length>W.value,H=$.data.length<W.value;if(X||H){if(J=this._getOrReturnCtx($,J),X)D(J,{code:F.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(H)D(J,{code:F.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!j3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"email",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!w8)w8=new RegExp(O3,"u");if(!w8.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"emoji",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!_3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"uuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!D3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"nanoid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!V3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!F3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"cuid2",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!U3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"ulid",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),D(J,{validation:"url",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"regex",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!Mq(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!C3.test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!K3(W).test($.data))J=this._getOrReturnCtx($,J),D(J,{code:F.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!L3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"duration",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!I3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"ip",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!P3($.data,W.alg))J=this._getOrReturnCtx($,J),D(J,{validation:"jwt",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!k3($.data,W.version))J=this._getOrReturnCtx($,J),D(J,{validation:"cidr",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!E3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64",code:F.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!A3.test($.data))J=this._getOrReturnCtx($,J),D(J,{validation:"base64url",code:F.invalid_string,message:W.message}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((J)=>$.test(J),{validation:q,code:F.invalid_string,...N.errToObj(Q)})}_addCheck($){return new a({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...N.errToObj($)})}url($){return this._addCheck({kind:"url",...N.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...N.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...N.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...N.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...N.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...N.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...N.errToObj($)})}base64($){return this._addCheck({kind:"base64",...N.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...N.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...N.errToObj($)})}ip($){return this._addCheck({kind:"ip",...N.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...N.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...N.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...N.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...N.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...N.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...N.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...N.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...N.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...N.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...N.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...N.errToObj(q)})}nonempty($){return this.min(1,N.errToObj($))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}a.create=($)=>{return new a({checks:[],typeName:S.ZodString,coerce:$?.coerce??!1,...A($)})};function b3($,q){let Q=($.toString().split(".")[1]||"").length,J=(q.toString().split(".")[1]||"").length,W=Q>J?Q:J,X=Number.parseInt($.toFixed(W).replace(".","")),H=Number.parseInt(q.toFixed(W).replace(".",""));return X%H/10**W}class D$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==_.number){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.number,received:W.parsedType}),R}let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="int"){if(!K.isInteger($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.invalid_type,expected:"integer",received:"float",message:W.message}),J.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if(b3($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_finite,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new D$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new D$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:N.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}finite($){return this._addCheck({kind:"finite",message:N.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&K.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}D$.create=($)=>{return new D$({checks:[],typeName:S.ZodNumber,coerce:$?.coerce||!1,...A($)})};class z$ extends C{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==_.bigint)return this._getInvalidInput($);let Q=void 0,J=new v;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),D(Q,{code:F.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),J.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),D(Q,{code:F.not_multiple_of,multipleOf:W.value,message:W.message}),J.dirty()}else K.assertNever(W);return{status:J.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.bigint,received:q.parsedType}),R}gte($,q){return this.setLimit("min",$,!0,N.toString(q))}gt($,q){return this.setLimit("min",$,!1,N.toString(q))}lte($,q){return this.setLimit("max",$,!0,N.toString(q))}lt($,q){return this.setLimit("max",$,!1,N.toString(q))}setLimit($,q,Q,J){return new z$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:N.toString(J)}]})}_addCheck($){return new z$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:N.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}z$.create=($)=>{return new z$({checks:[],typeName:S.ZodBigInt,coerce:$?.coerce??!1,...A($)})};class l$ extends C{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==_.boolean){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.boolean,received:Q.parsedType}),R}return y($.data)}}l$.create=($)=>{return new l$({typeName:S.ZodBoolean,coerce:$?.coerce||!1,...A($)})};class E$ extends C{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==_.date){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_type,expected:_.date,received:W.parsedType}),R}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return D(W,{code:F.invalid_date}),R}let Q=new v,J=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)J=this._getOrReturnCtx($,J),D(J,{code:F.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else K.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:N.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:N.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}E$.create=($)=>{return new E$({checks:[],coerce:$?.coerce||!1,typeName:S.ZodDate,...A($)})};class z6 extends C{_parse($){if(this._getType($)!==_.symbol){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.symbol,received:Q.parsedType}),R}return y($.data)}}z6.create=($)=>{return new z6({typeName:S.ZodSymbol,...A($)})};class u$ extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.undefined,received:Q.parsedType}),R}return y($.data)}}u$.create=($)=>{return new u$({typeName:S.ZodUndefined,...A($)})};class c$ extends C{_parse($){if(this._getType($)!==_.null){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.null,received:Q.parsedType}),R}return y($.data)}}c$.create=($)=>{return new c$({typeName:S.ZodNull,...A($)})};class A$ extends C{constructor(){super(...arguments);this._any=!0}_parse($){return y($.data)}}A$.create=($)=>{return new A$({typeName:S.ZodAny,...A($)})};class _$ extends C{constructor(){super(...arguments);this._unknown=!0}_parse($){return y($.data)}}_$.create=($)=>{return new _$({typeName:S.ZodUnknown,...A($)})};class X$ extends C{_parse($){let q=this._getOrReturnCtx($);return D(q,{code:F.invalid_type,expected:_.never,received:q.parsedType}),R}}X$.create=($)=>{return new X$({typeName:S.ZodNever,...A($)})};class L6 extends C{_parse($){if(this._getType($)!==_.undefined){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.void,received:Q.parsedType}),R}return y($.data)}}L6.create=($)=>{return new L6({typeName:S.ZodVoid,...A($)})};class s extends C{_parse($){let{ctx:q,status:Q}=this._processInputParams($),J=this._def;if(q.parsedType!==_.array)return D(q,{code:F.invalid_type,expected:_.array,received:q.parsedType}),R;if(J.exactLength!==null){let X=q.data.length>J.exactLength.value,H=q.data.length<J.exactLength.value;if(X||H)D(q,{code:X?F.too_big:F.too_small,minimum:H?J.exactLength.value:void 0,maximum:X?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(q.data.length<J.minLength.value)D(q,{code:F.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(q.data.length>J.maxLength.value)D(q,{code:F.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((X,H)=>{return J.type._parseAsync(new e(q,X,q.path,H))})).then((X)=>{return v.mergeArray(Q,X)});let W=[...q.data].map((X,H)=>{return J.type._parseSync(new e(q,X,q.path,H))});return v.mergeArray(Q,W)}get element(){return this._def.type}min($,q){return new s({...this._def,minLength:{value:$,message:N.toString(q)}})}max($,q){return new s({...this._def,maxLength:{value:$,message:N.toString(q)}})}length($,q){return new s({...this._def,exactLength:{value:$,message:N.toString(q)}})}nonempty($){return this.min(1,$)}}s.create=($,q)=>{return new s({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...A(q)})};function y$($){if($ instanceof Z){let q={};for(let Q in $.shape){let J=$.shape[Q];q[Q]=t.create(y$(J))}return new Z({...$._def,shape:()=>q})}else if($ instanceof s)return new s({...$._def,type:y$($.element)});else if($ instanceof t)return t.create(y$($.unwrap()));else if($ instanceof B$)return B$.create(y$($.unwrap()));else if($ instanceof H$)return H$.create($.items.map((q)=>y$(q)));else return $}class Z extends C{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=K.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==_.object){let G=this._getOrReturnCtx($);return D(G,{code:F.invalid_type,expected:_.object,received:G.parsedType}),R}let{status:Q,ctx:J}=this._processInputParams($),{shape:W,keys:X}=this._getCached(),H=[];if(!(this._def.catchall instanceof X$&&this._def.unknownKeys==="strip")){for(let G in J.data)if(!X.includes(G))H.push(G)}let Y=[];for(let G of X){let w=W[G],V=J.data[G];Y.push({key:{status:"valid",value:G},value:w._parse(new e(J,V,J.path,G)),alwaysSet:G in J.data})}if(this._def.catchall instanceof X$){let G=this._def.unknownKeys;if(G==="passthrough")for(let w of H)Y.push({key:{status:"valid",value:w},value:{status:"valid",value:J.data[w]}});else if(G==="strict"){if(H.length>0)D(J,{code:F.unrecognized_keys,keys:H}),Q.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let w of H){let V=J.data[w];Y.push({key:{status:"valid",value:w},value:G._parse(new e(J,V,J.path,w)),alwaysSet:w in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let G=[];for(let w of Y){let V=await w.key,U=await w.value;G.push({key:V,value:U,alwaysSet:w.alwaysSet})}return G}).then((G)=>{return v.mergeObjectSync(Q,G)});else return v.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return N.errToObj,new Z({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let J=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:N.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new Z({...this._def,unknownKeys:"strip"})}passthrough(){return new Z({...this._def,unknownKeys:"passthrough"})}extend($){return new Z({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new Z({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new Z({...this._def,catchall:$})}pick($){let q={};for(let Q of K.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}omit($){let q={};for(let Q of K.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new Z({...this._def,shape:()=>q})}deepPartial(){return y$(this)}partial($){let q={};for(let Q of K.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])q[Q]=J;else q[Q]=J.optional()}return new Z({...this._def,shape:()=>q})}required($){let q={};for(let Q of K.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof t)W=W._def.innerType;q[Q]=W}return new Z({...this._def,shape:()=>q})}keyof(){return Eq(K.objectKeys(this.shape))}}Z.create=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.strictCreate=($,q)=>{return new Z({shape:()=>$,unknownKeys:"strict",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};Z.lazycreate=($,q)=>{return new Z({shape:$,unknownKeys:"strip",catchall:X$.create(),typeName:S.ZodObject,...A(q)})};class d$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function J(W){for(let H of W)if(H.result.status==="valid")return H.result;for(let H of W)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let X=W.map((H)=>new c(H.ctx.common.issues));return D(q,{code:F.invalid_union,unionErrors:X}),R}if(q.common.async)return Promise.all(Q.map(async(W)=>{let X={...q,common:{...q.common,issues:[]},parent:null};return{result:await W._parseAsync({data:q.data,path:q.path,parent:X}),ctx:X}})).then(J);else{let W=void 0,X=[];for(let Y of Q){let G={...q,common:{...q.common,issues:[]},parent:null},w=Y._parseSync({data:q.data,path:q.path,parent:G});if(w.status==="valid")return w;else if(w.status==="dirty"&&!W)W={result:w,ctx:G};if(G.common.issues.length)X.push(G.common.issues)}if(W)return q.common.issues.push(...W.ctx.common.issues),W.result;let H=X.map((Y)=>new c(Y));return D(q,{code:F.invalid_union,unionErrors:H}),R}}get options(){return this._def.options}}d$.create=($,q)=>{return new d$({options:$,typeName:S.ZodUnion,...A(q)})};var G$=($)=>{if($ instanceof n$)return G$($.schema);else if($ instanceof $$)return G$($.innerType());else if($ instanceof i$)return[$.value];else if($ instanceof L$)return $.options;else if($ instanceof r$)return K.objectValues($.enum);else if($ instanceof o$)return G$($._def.innerType);else if($ instanceof u$)return[void 0];else if($ instanceof c$)return[null];else if($ instanceof t)return[void 0,...G$($.unwrap())];else if($ instanceof B$)return[null,...G$($.unwrap())];else if($ instanceof U0)return G$($.unwrap());else if($ instanceof s$)return G$($.unwrap());else if($ instanceof a$)return G$($._def.innerType);else return[]};class F0 extends C{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.object)return D(q,{code:F.invalid_type,expected:_.object,received:q.parsedType}),R;let Q=this.discriminator,J=q.data[Q],W=this.optionsMap.get(J);if(!W)return D(q,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),R;if(q.common.async)return W._parseAsync({data:q.data,path:q.path,parent:q});else return W._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let J=new Map;for(let W of q){let X=G$(W.shape[$]);if(!X.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of X){if(J.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);J.set(H,W)}}return new F0({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:J,...A(Q)})}}function V8($,q){let Q=W$($),J=W$(q);if($===q)return{valid:!0,data:$};else if(Q===_.object&&J===_.object){let W=K.objectKeys(q),X=K.objectKeys($).filter((Y)=>W.indexOf(Y)!==-1),H={...$,...q};for(let Y of X){let G=V8($[Y],q[Y]);if(!G.valid)return{valid:!1};H[Y]=G.data}return{valid:!0,data:H}}else if(Q===_.array&&J===_.array){if($.length!==q.length)return{valid:!1};let W=[];for(let X=0;X<$.length;X++){let H=$[X],Y=q[X],G=V8(H,Y);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(Q===_.date&&J===_.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class p$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=(W,X)=>{if(w0(W)||w0(X))return R;let H=V8(W.value,X.value);if(!H.valid)return D(Q,{code:F.invalid_intersection_types}),R;if(V0(W)||V0(X))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,X])=>J(W,X));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}p$.create=($,q,Q)=>{return new p$({left:$,right:q,typeName:S.ZodIntersection,...A(Q)})};class H$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.array)return D(Q,{code:F.invalid_type,expected:_.array,received:Q.parsedType}),R;if(Q.data.length<this._def.items.length)return D(Q,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;if(!this._def.rest&&Q.data.length>this._def.items.length)D(Q,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let W=[...Q.data].map((X,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new e(Q,X,Q.path,H))}).filter((X)=>!!X);if(Q.common.async)return Promise.all(W).then((X)=>{return v.mergeArray(q,X)});else return v.mergeArray(q,W)}get items(){return this._def.items}rest($){return new H$({...this._def,rest:$})}}H$.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new H$({items:$,typeName:S.ZodTuple,rest:null,...A(q)})};class j6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.object)return D(Q,{code:F.invalid_type,expected:_.object,received:Q.parsedType}),R;let J=[],W=this._def.keyType,X=this._def.valueType;for(let H in Q.data)J.push({key:W._parse(new e(Q,H,Q.path,H)),value:X._parse(new e(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return v.mergeObjectAsync(q,J);else return v.mergeObjectSync(q,J)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof C)return new j6({keyType:$,valueType:q,typeName:S.ZodRecord,...A(Q)});return new j6({keyType:a.create(),valueType:$,typeName:S.ZodRecord,...A(q)})}}class O6 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.map)return D(Q,{code:F.invalid_type,expected:_.map,received:Q.parsedType}),R;let J=this._def.keyType,W=this._def.valueType,X=[...Q.data.entries()].map(([H,Y],G)=>{return{key:J._parse(new e(Q,H,Q.path,[G,"key"])),value:W._parse(new e(Q,Y,Q.path,[G,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of X){let G=await Y.key,w=await Y.value;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of X){let{key:G,value:w}=Y;if(G.status==="aborted"||w.status==="aborted")return R;if(G.status==="dirty"||w.status==="dirty")q.dirty();H.set(G.value,w.value)}return{status:q.value,value:H}}}}O6.create=($,q,Q)=>{return new O6({valueType:q,keyType:$,typeName:S.ZodMap,...A(Q)})};class C$ extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==_.set)return D(Q,{code:F.invalid_type,expected:_.set,received:Q.parsedType}),R;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)D(Q,{code:F.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),q.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)D(Q,{code:F.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),q.dirty()}let W=this._def.valueType;function X(Y){let G=new Set;for(let w of Y){if(w.status==="aborted")return R;if(w.status==="dirty")q.dirty();G.add(w.value)}return{status:q.value,value:G}}let H=[...Q.data.values()].map((Y,G)=>W._parse(new e(Q,Y,Q.path,G)));if(Q.common.async)return Promise.all(H).then((Y)=>X(Y));else return X(H)}min($,q){return new C$({...this._def,minSize:{value:$,message:N.toString(q)}})}max($,q){return new C$({...this._def,maxSize:{value:$,message:N.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}C$.create=($,q)=>{return new C$({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...A(q)})};class m$ extends C{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.function)return D(q,{code:F.invalid_type,expected:_.function,received:q.parsedType}),R;function Q(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_arguments,argumentsError:Y}})}function J(H,Y){return D6({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,h$(),Y$].filter((G)=>!!G),issueData:{code:F.invalid_return_type,returnTypeError:Y}})}let W={errorMap:q.common.contextualErrorMap},X=q.data;if(this._def.returns instanceof K$){let H=this;return y(async function(...Y){let G=new c([]),w=await H._def.args.parseAsync(Y,W).catch((M)=>{throw G.addIssue(Q(Y,M)),G}),V=await Reflect.apply(X,this,w);return await H._def.returns._def.type.parseAsync(V,W).catch((M)=>{throw G.addIssue(J(V,M)),G})})}else{let H=this;return y(function(...Y){let G=H._def.args.safeParse(Y,W);if(!G.success)throw new c([Q(Y,G.error)]);let w=Reflect.apply(X,this,G.data),V=H._def.returns.safeParse(w,W);if(!V.success)throw new c([J(w,V.error)]);return V.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new m$({...this._def,args:H$.create($).rest(_$.create())})}returns($){return new m$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new m$({args:$?$:H$.create([]).rest(_$.create()),returns:q||_$.create(),typeName:S.ZodFunction,...A(Q)})}}class n$ extends C{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}n$.create=($,q)=>{return new n$({getter:$,typeName:S.ZodLazy,...A(q)})};class i$ extends C{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return D(q,{received:q.data,code:F.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:$.data}}get value(){return this._def.value}}i$.create=($,q)=>{return new i$({value:$,typeName:S.ZodLiteral,...A(q)})};function Eq($,q){return new L$({values:$,typeName:S.ZodEnum,...A(q)})}class L$ extends C{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{expected:K.joinValues(Q),received:q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return D(q,{received:q.data,code:F.invalid_enum_value,options:Q}),R}return y($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return L$.create($,{...this._def,...q})}exclude($,q=this._def){return L$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}L$.create=Eq;class r$ extends C{_parse($){let q=K.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==_.string&&Q.parsedType!==_.number){let J=K.objectValues(q);return D(Q,{expected:K.joinValues(J),received:Q.parsedType,code:F.invalid_type}),R}if(!this._cache)this._cache=new Set(K.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let J=K.objectValues(q);return D(Q,{received:Q.data,code:F.invalid_enum_value,options:J}),R}return y($.data)}get enum(){return this._def.values}}r$.create=($,q)=>{return new r$({values:$,typeName:S.ZodNativeEnum,...A(q)})};class K$ extends C{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==_.promise&&q.common.async===!1)return D(q,{code:F.invalid_type,expected:_.promise,received:q.parsedType}),R;let Q=q.parsedType===_.promise?q.data:Promise.resolve(q.data);return y(Q.then((J)=>{return this._def.type.parseAsync(J,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}K$.create=($,q)=>{return new K$({type:$,typeName:S.ZodPromise,...A(q)})};class $$ extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),J=this._def.effect||null,W={addIssue:(X)=>{if(D(Q,X),X.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),J.type==="preprocess"){let X=J.transform(Q.data,W);if(Q.common.async)return Promise.resolve(X).then(async(H)=>{if(q.value==="aborted")return R;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return R;if(Y.status==="dirty")return M$(Y.value);if(q.value==="dirty")return M$(Y.value);return Y});else{if(q.value==="aborted")return R;let H=this._def.schema._parseSync({data:X,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")return M$(H.value);if(q.value==="dirty")return M$(H.value);return H}}if(J.type==="refinement"){let X=(H)=>{let Y=J.refinement(H,W);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return R;if(H.status==="dirty")q.dirty();return X(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(J.type==="transform")if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!U$(X))return R;let H=J.transform(X.value,W);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(!U$(X))return R;return Promise.resolve(J.transform(X.value,W)).then((H)=>({status:q.value,value:H}))});K.assertNever(J)}}$$.create=($,q,Q)=>{return new $$({schema:$,typeName:S.ZodEffects,effect:q,...A(Q)})};$$.createWithPreprocess=($,q,Q)=>{return new $$({schema:q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...A(Q)})};class t extends C{_parse($){if(this._getType($)===_.undefined)return y(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}t.create=($,q)=>{return new t({innerType:$,typeName:S.ZodOptional,...A(q)})};class B$ extends C{_parse($){if(this._getType($)===_.null)return y(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}B$.create=($,q)=>{return new B$({innerType:$,typeName:S.ZodNullable,...A(q)})};class o$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===_.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}o$.create=($,q)=>{return new o$({innerType:$,typeName:S.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...A(q)})};class a$ extends C{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(g$(J))return J.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new c(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}a$.create=($,q)=>{return new a$({innerType:$,typeName:S.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...A(q)})};class N6 extends C{_parse($){if(this._getType($)!==_.nan){let Q=this._getOrReturnCtx($);return D(Q,{code:F.invalid_type,expected:_.nan,received:Q.parsedType}),R}return{status:"valid",value:$.data}}}N6.create=($)=>{return new N6({typeName:S.ZodNaN,...A($)})};var Z3=Symbol("zod_brand");class U0 extends C{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class R6 extends C{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return R;if(W.status==="dirty")return q.dirty(),M$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return R;if(J.status==="dirty")return q.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,q){return new R6({in:$,out:q,typeName:S.ZodPipeline})}}class s$ extends C{_parse($){let q=this._def.innerType._parse($),Q=(J)=>{if(U$(J))J.value=Object.freeze(J.value);return J};return g$(q)?q.then((J)=>Q(J)):Q(q)}unwrap(){return this._def.innerType}}s$.create=($,q)=>{return new s$({innerType:$,typeName:S.ZodReadonly,...A(q)})};function Nq($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Aq($,q={},Q){if($)return A$.create().superRefine((J,W)=>{let X=$(J);if(X instanceof Promise)return X.then((H)=>{if(!H){let Y=Nq(q,J),G=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:G})}});if(!X){let H=Nq(q,J),Y=H.fatal??Q??!0;W.addIssue({code:"custom",...H,fatal:Y})}return});return A$.create()}var f3={object:Z.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var T3=($,q={message:`Input not instance of ${$.name}`})=>Aq((Q)=>Q instanceof $,q),Cq=a.create,Kq=D$.create,x3=N6.create,v3=z$.create,Iq=l$.create,h3=E$.create,g3=z6.create,y3=u$.create,m3=c$.create,l3=A$.create,u3=_$.create,c3=X$.create,d3=L6.create,p3=s.create,n3=Z.create,i3=Z.strictCreate,r3=d$.create,o3=F0.create,a3=p$.create,s3=H$.create,t3=j6.create,e3=O6.create,$X=C$.create,qX=m$.create,QX=n$.create,JX=i$.create,WX=L$.create,XX=r$.create,HX=K$.create,YX=$$.create,GX=t.create,BX=B$.create,wX=$$.createWithPreprocess,VX=R6.create,FX=()=>Cq().optional(),UX=()=>Kq().optional(),_X=()=>Iq().optional(),DX={string:($)=>a.create({...$,coerce:!0}),number:($)=>D$.create({...$,coerce:!0}),boolean:($)=>l$.create({...$,coerce:!0}),bigint:($)=>z$.create({...$,coerce:!0}),date:($)=>E$.create({...$,coerce:!0})};var zX=R;class _0{config;blacklistedTokens=new Map;constructor($){this.config=$;if(!$.secret)throw Error("JWT secret is required")}generateTokens($){let q=Math.floor(Date.now()/1000),Q=this.parseExpiration(this.config.expiresIn||"1h"),J={sub:$.sub,...$,iat:q,exp:q+Q,iss:this.config.issuer,aud:this.config.audience},W=j$.sign(J,this.config.secret,{algorithm:this.config.algorithm||"HS256"}),X={sub:$.sub,type:"refresh",iat:q,exp:q+this.parseExpiration(this.config.refreshExpiresIn||"7d"),iss:this.config.issuer,aud:this.config.audience},H=j$.sign(X,this.config.refreshSecret||this.config.secret,{algorithm:this.config.algorithm||"HS256"});return{accessToken:W,refreshToken:H,expiresIn:Q}}verifyAccessToken($){if(this.isBlacklisted($))throw Error("Token has been revoked");try{return j$.verify($,this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience})}catch(q){if(q instanceof Error)throw Error(`Invalid token: ${q.message}`);throw Error("Invalid token")}}verifyRefreshToken($){if(this.isBlacklisted($))throw Error("Refresh token has been revoked");try{let q=j$.verify($,this.config.refreshSecret||this.config.secret,{algorithms:[this.config.algorithm||"HS256"],issuer:this.config.issuer,audience:this.config.audience});if(q.type!=="refresh")throw Error("Invalid refresh token type");return q}catch(q){if(q instanceof Error)throw Error(`Invalid refresh token: ${q.message}`);throw Error("Invalid refresh token")}}refreshAccessToken($){let q=this.verifyRefreshToken($);return this.blacklistToken($),this.generateTokens({sub:q.sub,...Object.fromEntries(Object.entries(q).filter(([Q])=>!["iat","exp","iss","aud","type"].includes(Q)))})}decodeToken($){try{return j$.decode($)}catch{return null}}blacklistToken($){let Q=this.decodeToken($)?.exp??Math.floor(Date.now()/1000)+3600;this.blacklistedTokens.set($,Q)}isBlacklisted($){let q=this.blacklistedTokens.get($);if(q===void 0)return!1;if(q<Math.floor(Date.now()/1000))return this.blacklistedTokens.delete($),!1;return!0}cleanupBlacklist(){let $=Math.floor(Date.now()/1000);for(let[q,Q]of this.blacklistedTokens)if(Q<$)this.blacklistedTokens.delete(q)}parseExpiration($){if(typeof $==="number")return $;let q={s:1,m:60,h:3600,d:86400,w:604800},Q=$.match(/^(\d+)([smhdw])$/);if(!Q)throw Error(`Invalid expiration format: ${$}`);let[,J,W]=Q;return parseInt(J)*q[W]}}var LX=B.object({sub:B.string(),iat:B.number().optional(),exp:B.number().optional(),iss:B.string().optional(),aud:B.string().optional()}).passthrough(),jX=B.object({username:B.string().min(1),password:B.string().min(1)}),OX=B.object({refreshToken:B.string().min(1)});w$();class M6{config;userProvider;jwtProvider;constructor($,q){this.config=$;this.userProvider=q;this.jwtProvider=new _0($)}async login($,q){let Q=await this.userProvider.findByCredentials($,q);if(!Q)throw new f("Invalid credentials");let J=this.jwtProvider.generateTokens({sub:Q.id,username:Q.username,email:Q.email,roles:Q.roles||[],permissions:Q.permissions||[]});return{user:Q,tokens:J}}async refresh($){try{return this.jwtProvider.refreshAccessToken($)}catch(q){throw new I$(q instanceof Error?q.message:"Invalid refresh token")}}async logout($,q){if(this.jwtProvider.blacklistToken($),q)this.jwtProvider.blacklistToken(q)}async verifyToken($){try{let q=this.jwtProvider.verifyAccessToken($),Q=await this.userProvider.findById(q.sub);if(!Q)throw new f("User not found");return Q}catch(q){if(q instanceof Error){if(q.message.includes("expired"))throw new S6;throw new I$(q.message)}throw new I$("Token verification failed")}}getUserFromToken($){return this.jwtProvider.verifyAccessToken($)}hasRoles($,q){let Q=$.roles||[];return q.every((J)=>Q.includes(J))}hasPermissions($,q){let Q=$.permissions||[];return q.every((J)=>Q.includes(J))}async register($){if(!this.userProvider.createUser)throw Error("UserProvider does not support user creation");let q=await this.userProvider.createUser($),Q=this.jwtProvider.generateTokens({sub:q.id,username:q.username,email:q.email,roles:q.roles||[],permissions:q.permissions||[]});return{user:q,tokens:Q}}cleanup(){this.jwtProvider.cleanupBlacklist()}getJWTProvider(){return this.jwtProvider}}class Zq{users=new Map;async findByCredentials($,q){for(let[Q,J]of this.users)if(J.username===$){if(await this.verifyPassword(q,J.passwordHash)){let{passwordHash:X,...H}=J;return H}}return null}async findById($){let q=this.users.get($);if(q){let{passwordHash:Q,...J}=q;return J}return null}async hashPassword($){return Buffer.from($).toString("base64")}async verifyPassword($,q){return await this.hashPassword($)===q}async createUser($){let q=crypto.randomUUID(),Q=await this.hashPassword($.password),J={id:q,username:$.username,email:$.email,roles:$.roles||["user"],passwordHash:Q};this.users.set(q,J);let{passwordHash:W,...X}=J;return X}}var uG=require("reflect-metadata"),_8=Symbol("route:metadata"),D8=Symbol("controller:metadata"),fq=Symbol("parameter:metadata"),Tq=Symbol("dependency:metadata"),z8=Symbol("websocket:metadata"),xq=Symbol("websocket:handler:metadata"),L8=Symbol("graphql:resolver"),E6=Symbol("graphql:field"),j8=Symbol("auth:metadata"),O8=Symbol("oauth:metadata"),N8=Symbol("roles:metadata"),R8=Symbol("permissions:metadata"),S8=Symbol("minimum-role:metadata"),M8=Symbol("resource-permission:metadata"),E8=Symbol("session:metadata"),A8=Symbol("csrf:metadata");class b{routes=new Map;controllers=new Map;routesByController=new Map;websockets=new Map;graphqlResolvers=new Map;graphqlFields=new Map;registerRoute($){let q=this.getRouteKey($.target,$.propertyKey);if(this.routes.set(q,$),!this.routesByController.has($.target))this.routesByController.set($.target,[]);this.routesByController.get($.target).push($)}registerController($,q){this.controllers.set($,q)}getRoutes(){return Array.from(this.routes.values())}getRoute($,q){let Q=this.getRouteKey($,q);return this.routes.get(Q)}getRoutesByController($){return this.routesByController.get($)||[]}getController($){return this.controllers.get($)}getControllers(){return new Map(this.controllers)}registerWebSocket($){this.websockets.set($.target,$)}getWebSockets(){return Array.from(this.websockets.values())}getWebSocket($){return this.websockets.get($)}registerGraphQLResolver($){this.graphqlResolvers.set($.target,$)}registerGraphQLField($){let q=this.getRouteKey($.target,$.propertyKey);this.graphqlFields.set(q,$)}getGraphQLResolvers(){return Array.from(this.graphqlResolvers.values())}getGraphQLResolver($){return this.graphqlResolvers.get($)}getGraphQLFields(){return Array.from(this.graphqlFields.values())}getGraphQLFieldsByResolver($){return Array.from(this.graphqlFields.values()).filter((q)=>q.target===$)}clear(){this.routes.clear(),this.controllers.clear(),this.routesByController.clear(),this.websockets.clear(),this.graphqlResolvers.clear(),this.graphqlFields.clear()}getRouteKey($,q){return`${$.name}:${q}`}static defineRoute($,q,Q){let J=this.getRouteMetadata($,q),W={...J,...Q,target:$.constructor,propertyKey:q,middleware:[...J?.middleware||[],...Q.middleware||[]],parameters:Q.parameters||J?.parameters||[],dependencies:Q.dependencies||J?.dependencies||[],responses:Q.responses||J?.responses||[],auth:Q.auth||J?.auth,oauth:Q.oauth||J?.oauth,roles:Q.roles||J?.roles,permissions:Q.permissions||J?.permissions,minimumRole:Q.minimumRole||J?.minimumRole,resourcePermission:Q.resourcePermission||J?.resourcePermission,session:Q.session||J?.session,csrf:Q.csrf||J?.csrf};Reflect.defineMetadata(_8,W,$,q)}static defineParameter($,q,Q,J){let W=this.getParameterMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(fq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,parameters:W})}static defineDependency($,q,Q,J){let W=this.getDependencyMetadata($,q)||[];W[Q]=J,Reflect.defineMetadata(Tq,W,$,q);let X=this.getRouteMetadata($,q);this.defineRoute($,q,{...X,dependencies:W})}static defineController($,q){Reflect.defineMetadata(D8,q,$)}static getRouteMetadata($,q){return Reflect.getMetadata(_8,$,q)}static getParameterMetadata($,q){return Reflect.getMetadata(fq,$,q)}static getDependencyMetadata($,q){return Reflect.getMetadata(Tq,$,q)}static getControllerMetadata($){return Reflect.getMetadata(D8,$)}static hasControllerMetadata($){return Reflect.hasMetadata(D8,$)}static hasRouteMetadata($,q){return Reflect.hasMetadata(_8,$,q)}static getRouteMethods($){let q=new Set,Q=[],J=$.prototype;while(J&&J!==Object.prototype){for(let W of Object.getOwnPropertyNames(J)){if(W==="constructor"||q.has(W))continue;if(q.add(W),this.hasRouteMetadata(J,W))Q.push(W)}J=Object.getPrototypeOf(J)}return Q}static defineWebSocket($,q){let J={...this.getWebSocketMetadata($),...q,target:$};Reflect.defineMetadata(z8,J,$)}static defineWebSocketHandler($,q,Q){let J=this.getWebSocketMetadata($.constructor)||{};switch(Q.type){case"connect":J.onConnect=q;break;case"message":J.onMessage=q,J.messageSchema=Q.schema;break;case"disconnect":J.onDisconnect=q;break}this.defineWebSocket($.constructor,J),Reflect.defineMetadata(xq,Q,$,q)}static getWebSocketMetadata($){return Reflect.getMetadata(z8,$)}static getWebSocketHandlerMetadata($,q){return Reflect.getMetadata(xq,$,q)}static hasWebSocketMetadata($){return Reflect.hasMetadata(z8,$)}static defineGraphQLResolver($,q){Reflect.defineMetadata(L8,q,$)}static defineGraphQLField($,q,Q){Reflect.defineMetadata(E6,Q,$,q);let J=this.getGraphQLFieldsMetadata($.constructor)||[];J.push(Q),Reflect.defineMetadata(E6,J,$.constructor)}static getGraphQLResolverMetadata($){return Reflect.getMetadata(L8,$)}static getGraphQLFieldsMetadata($){return Reflect.getMetadata(E6,$)||[]}static getGraphQLFieldMetadata($,q){return Reflect.getMetadata(E6,$,q)}static hasGraphQLResolverMetadata($){return Reflect.hasMetadata(L8,$)}static hasGraphQLFieldMetadata($,q){return Reflect.hasMetadata(E6,$,q)}static defineAuth($,q,Q){Reflect.defineMetadata(j8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,auth:Q})}static getAuthMetadata($,q){return Reflect.getMetadata(j8,$,q)}static hasAuthMetadata($,q){return Reflect.hasMetadata(j8,$,q)}static defineOAuth($,q,Q){Reflect.defineMetadata(O8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,oauth:Q})}static getOAuthMetadata($,q){return Reflect.getMetadata(O8,$,q)}static hasOAuthMetadata($,q){return Reflect.hasMetadata(O8,$,q)}static defineRoles($,q,Q){Reflect.defineMetadata(N8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,roles:Q})}static definePermissions($,q,Q){Reflect.defineMetadata(R8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,permissions:Q})}static defineMinimumRole($,q,Q){Reflect.defineMetadata(S8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,minimumRole:Q})}static getRolesMetadata($,q){return Reflect.getMetadata(N8,$,q)}static getPermissionsMetadata($,q){return Reflect.getMetadata(R8,$,q)}static getMinimumRoleMetadata($,q){return Reflect.getMetadata(S8,$,q)}static hasRolesMetadata($,q){return Reflect.hasMetadata(N8,$,q)}static hasPermissionsMetadata($,q){return Reflect.hasMetadata(R8,$,q)}static hasMinimumRoleMetadata($,q){return Reflect.hasMetadata(S8,$,q)}static defineResourcePermission($,q,Q){Reflect.defineMetadata(M8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,resourcePermission:Q})}static getResourcePermissionMetadata($,q){return Reflect.getMetadata(M8,$,q)}static hasResourcePermissionMetadata($,q){return Reflect.hasMetadata(M8,$,q)}static defineSession($,q,Q){Reflect.defineMetadata(E8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,session:Q})}static defineCSRF($,q,Q){Reflect.defineMetadata(A8,Q,$,q);let J=this.getRouteMetadata($,q);this.defineRoute($,q,{...J,csrf:Q})}static getSessionMetadata($,q){return Reflect.getMetadata(E8,$,q)}static getCSRFMetadata($,q){return Reflect.getMetadata(A8,$,q)}static hasSessionMetadata($,q){return Reflect.hasMetadata(E8,$,q)}static hasCSRFMetadata($,q){return Reflect.hasMetadata(A8,$,q)}}function xX($){return(q,Q)=>{let J={required:!$?.optional,config:$};b.defineAuth(q,Q,J)}}function vX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-user",required:!1})}}function hX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"token",required:!1})}}function C8($){return async(q,Q)=>{let J=q.req.header("Authorization");if(!J||!J.startsWith("Bearer "))q.set("auth.error","Missing or invalid Authorization header"),q.set("auth.authenticated",!1);else{let W=J.substring(7);try{let X=$.verifyAccessToken(W);q.set("auth.user",X),q.set("auth.token",W),q.set("auth.authenticated",!0)}catch(X){q.set("auth.error",X instanceof Error?X.message:"Authentication failed"),q.set("auth.authenticated",!1)}}await Q()}}function T($){return $.get("auth.user")||null}function K8($){return $.get("auth.token")||null}function gX($){return $.get("auth.authenticated")===!0}function yX($){return $.get("auth.error")||null}w$();w$();class vq{config;name="auth";version="1.0.0";authService;compileExtended=!1;constructor($){this.config=$;this.authService=new M6($.jwt,$.userProvider)}async install($){let q=C8(this.authService.getJWTProvider());if($.use(q),$.getContainer().register(M6,{factory:()=>this.authService,scope:"singleton"}),this.config.enableDefaultRoutes!==!1)this.addDefaultRoutes($);this.extendRouterCompiler($)}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0,$.use(async(Q,J)=>{Q.set("authService",this.authService),await J()});let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getHono(),J=$.getMetadata().getRoutes();for(let W of J){let X=b.getAuthMetadata(W.target.prototype,W.propertyKey);if(W.auth?.required||X?.required){let Y=W.auth?.config||X?.config;Q.use(W.path,async(G,w)=>{if(G.req.method!==W.method)return w();let V=G.get("auth.user"),U=G.get("auth.error");if(!V)throw new f(U||"Authentication required");if(Y?.roles?.length){if(!this.authService.hasRoles(V,Y.roles))throw new x(`Required roles: ${Y.roles.join(", ")}`)}if(Y?.permissions?.length){if(!this.authService.hasPermissions(V,Y.permissions))throw new x(`Required permissions: ${Y.permissions.join(", ")}`)}await w()})}}}}buildPath($){return $.path}pathMatches($,q){let Q=$.replace(/:([^/]+)/g,"([^/]+)");return new RegExp(`^${Q}$`).test(q)}addDefaultRoutes($){let q=this.config.routes||{};if($.post(q.login||"/auth/login",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X}=J;try{let H=await this.authService.login(W,X);return{success:!0,user:H.user,tokens:H.tokens}}catch(H){throw new f(H instanceof Error?H.message:"Login failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(1)})}}),$.post(q.refresh||"/auth/refresh",{handler:async(Q)=>{let J=await Q.req.json(),{refreshToken:W}=J;try{return{success:!0,tokens:await this.authService.refresh(W)}}catch(X){throw new f(X instanceof Error?X.message:"Token refresh failed")}},schema:{body:B.object({refreshToken:B.string().min(1)})}}),$.post(q.logout||"/auth/logout",{handler:async(Q)=>{let J=K8(Q),W=await Q.req.json(),{refreshToken:X}=W;if(J)await this.authService.logout(J,X);return{success:!0,message:"Logged out successfully"}},schema:{body:B.object({refreshToken:B.string().optional()})}}),"createUser"in this.config.userProvider)$.post(q.register||"/auth/register",{handler:async(Q)=>{let J=await Q.req.json(),{username:W,password:X,email:H}=J;try{let Y=await this.authService.register({username:W,password:X,email:H});return{success:!0,user:Y.user,tokens:Y.tokens}}catch(Y){throw new f(Y instanceof Error?Y.message:"Registration failed")}},schema:{body:B.object({username:B.string().min(1),password:B.string().min(6),email:B.string().email().optional()})}});$.get("/auth/me",{handler:async(Q)=>{let J=T(Q);if(!J)throw new f("Not authenticated");return{success:!0,user:J}}})}getAuthService(){return this.authService}}class A6{name;config;constructor($,q){this.name=$;this.config=q}getAuthUrl($,q){let Q=new URLSearchParams({client_id:this.config.clientId,redirect_uri:this.config.redirectUri,response_type:"code",state:$,scope:this.config.scopes?.join(" ")||""});if(q&&this.config.pkce)Q.set("code_challenge",q),Q.set("code_challenge_method","S256");return`${this.config.authUrl}?${Q.toString()}`}async exchangeCodeForTokens($,q){let Q=new URLSearchParams({client_id:this.config.clientId,client_secret:this.config.clientSecret,code:$,grant_type:"authorization_code",redirect_uri:this.config.redirectUri});if(q&&this.config.pkce)Q.set("code_verifier",q);let J=await fetch(this.config.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!J.ok){let X=await J.text();throw Error(`Token exchange failed: ${X}`)}let W=await J.json();return{accessToken:W.access_token,refreshToken:W.refresh_token,expiresIn:W.expires_in,tokenType:W.token_type||"Bearer",scope:W.scope}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/json"}});if(!q.ok){let J=await q.text();throw Error(`Failed to get user info: ${J}`)}let Q=await q.json();return this.mapUserInfo(Q)}mapUserInfo($){return{id:$.id||$.sub,email:$.email,name:$.name,username:$.login||$.preferred_username,avatar:$.avatar_url||$.picture,provider:this.name,...$}}}class hq extends A6{constructor($,q,Q){super("google",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v2/userinfo",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.email,name:$.name,username:$.email,avatar:$.picture,provider:"google",verified:$.verified_email,locale:$.locale,raw:$}}}class gq extends A6{constructor($,q,Q){super("github",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["user:email"],authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",pkce:!1})}mapUserInfo($){return{id:$.id.toString(),email:$.email,name:$.name,username:$.login,avatar:$.avatar_url,provider:"github",company:$.company,location:$.location,bio:$.bio,raw:$}}async getUserInfo($){let q=await fetch(this.config.userInfoUrl,{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(!q.ok)throw Error(`Failed to get user info: ${await q.text()}`);let Q=await q.json();if(!Q.email)try{let J=await fetch("https://api.github.com/user/emails",{headers:{Authorization:`Bearer ${$}`,Accept:"application/vnd.github.v3+json","User-Agent":"VeloceTS-OAuth"}});if(J.ok){let X=(await J.json()).find((H)=>H.primary);if(X)Q.email=X.email}}catch(J){}return this.mapUserInfo(Q)}}class yq extends A6{constructor($,q,Q,J="common"){super("microsoft",{clientId:$,clientSecret:q,redirectUri:Q,scopes:["openid","profile","email"],authUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/${J}/oauth2/v2.0/token`,userInfoUrl:"https://graph.microsoft.com/v1.0/me",pkce:!0})}mapUserInfo($){return{id:$.id,email:$.mail||$.userPrincipalName,name:$.displayName,username:$.userPrincipalName,avatar:void 0,provider:"microsoft",jobTitle:$.jobTitle,department:$.department,officeLocation:$.officeLocation,raw:$}}}class z0{static generateCodeVerifier(){let $=new Uint8Array(32);return crypto.getRandomValues($),this.base64URLEncode($)}static async generateCodeChallenge($){let Q=new TextEncoder().encode($),J=await crypto.subtle.digest("SHA-256",Q);return this.base64URLEncode(new Uint8Array(J))}static async generatePKCEChallenge(){let $=this.generateCodeVerifier(),q=await this.generateCodeChallenge($);return{codeVerifier:$,codeChallenge:q,codeChallengeMethod:"S256"}}static base64URLEncode($){return btoa(String.fromCharCode(...$)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}class L0{states=new Map;ttl=600000;generateState($){let q=crypto.randomUUID();return this.states.set(q,{timestamp:Date.now(),data:$}),this.cleanup(),q}validateState($){let q=this.states.get($);if(!q)return{valid:!1};if(Date.now()-q.timestamp>this.ttl)return this.states.delete($),{valid:!1};return this.states.delete($),{valid:!0,data:q.data}}cleanup(){let $=Date.now();for(let[q,Q]of this.states.entries())if($-Q.timestamp>this.ttl)this.states.delete(q)}}var I8=B.object({code:B.string(),state:B.string(),error:B.string().optional(),error_description:B.string().optional()}),mX=B.object({accessToken:B.string(),refreshToken:B.string().optional(),expiresIn:B.number().optional(),tokenType:B.string(),scope:B.string().optional()}),lX=B.object({id:B.string(),email:B.string().optional(),name:B.string().optional(),username:B.string().optional(),avatar:B.string().optional(),provider:B.string()}).passthrough();function uX($){return(q,Q)=>{let J={provider:$.provider,config:$};b.defineOAuth(q,Q,J)}}function cX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-user",required:!0})}}function dX(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"oauth-token",required:!0})}}function pX($){return $.get("oauth.user")||null}function nX($){return $.get("oauth.token")||null}function iX($){return $.get("oauth.authenticated")===!0}function rX($){return $.get("oauth.provider")||null}class mq{config;name="oauth";version="1.0.0";dependencies=["auth"];stateManager=new L0;pkceStore=new Map;pkceStoreTTLMs=600000;constructor($){this.config=$}async install($){this.addOAuthRoutes($),this.extendRouterCompiler($)}addOAuthRoutes($){let q=this.config.routes||{};$.get(q.login||"/auth/oauth/:provider",{handler:async(Q)=>{let J=Q.req.param("provider"),W=this.config.providers[J];if(!W)return Q.json({error:"Unknown OAuth provider"},400);let X=this.stateManager.generateState({provider:J}),H;if(this.cleanupPkceStore(),W.config.pkce){let Y=await z0.generatePKCEChallenge();this.pkceStore.set(X,{challenge:Y,expiresAt:Date.now()+this.pkceStoreTTLMs}),H=W.getAuthUrl(X,Y.codeChallenge)}else H=W.getAuthUrl(X);return Q.json({authUrl:H,state:X,provider:J})}}),$.get(q.callback||"/auth/oauth/:provider/callback",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.query(),X=I8.parse(W);if(X.error)return Q.json({error:"OAuth error",description:X.error_description||X.error},400);let H=this.stateManager.validateState(X.state);if(!H.valid||H.data?.provider!==J)return Q.json({error:"Invalid state parameter"},400);let Y=this.config.providers[J];if(!Y)return Q.json({error:"Unknown OAuth provider"},400);try{let w=this.pkceStore.get(X.state)?.challenge.codeVerifier,V=await Y.exchangeCodeForTokens(X.code,w),U=await Y.getUserInfo(V.accessToken);this.pkceStore.delete(X.state);let M=null;if(this.config.userProvider)M=await this.findOrCreateUser(U);if(this.config.onUserLogin)await this.config.onUserLogin(U,M);let O=null;if(this.config.authService&&M)O=this.config.authService.getJWTProvider().generateTokens({sub:String(M.id??M.username??U.id),username:M.username,email:M.email});return Q.json({success:!0,user:M||U,oauthTokens:V,jwtTokens:O,provider:J})}catch(G){return console.error("OAuth callback error:",G),Q.json({error:"OAuth authentication failed",message:G instanceof Error?G.message:"Unknown error"},500)}}}),$.get("/auth/oauth/:provider/user",{handler:async(Q)=>{let J=Q.req.param("provider"),W=Q.req.header("Authorization");if(!W||!W.startsWith("Bearer "))return Q.json({error:"Missing OAuth access token"},401);let X=W.substring(7),H=this.config.providers[J];if(!H)return Q.json({error:"Unknown OAuth provider"},400);try{let Y=await H.getUserInfo(X);return Q.json({user:Y})}catch(Y){return Q.json({error:"Failed to get user info",message:Y instanceof Error?Y.message:"Unknown error"},400)}}})}cleanupPkceStore(){let $=Date.now();for(let[q,Q]of this.pkceStore)if(Q.expiresAt<$)this.pkceStore.delete(q)}async findOrCreateUser($){if(!this.config.userProvider)return null;let q=await this.findUserByOAuthId($.id,$.provider);if(!q&&$.email)q=await this.findUserByEmail($.email);if(!q){if(q=await this.createUserFromOAuth($),this.config.onUserCreated)await this.config.onUserCreated($)}return q}async findUserByOAuthId($,q){return null}async findUserByEmail($){return null}async createUserFromOAuth($){if(!this.config.userProvider||!("createUser"in this.config.userProvider))throw Error("User provider does not support user creation");let q={username:$.username||$.email||`${$.provider}_${$.id}`,email:$.email,password:crypto.randomUUID(),roles:["user"],oauthId:$.id,oauthProvider:$.provider,name:$.name,avatar:$.avatar};return await this.config.userProvider.createUser(q)}extendRouterCompiler($){}getProvider($){return this.config.providers[$]}getProviders(){return{...this.config.providers}}}class t${roles=new Map;hierarchy=new Map;compiledPermissions=new Map;defineRole($){if(this.roles.set($.name,$),$.inherits&&$.inherits.length>0)this.hierarchy.set($.name,$.inherits);this.compiledPermissions.clear()}defineRoles($){for(let q of $)this.defineRole(q)}getRolePermissions($){if(this.compiledPermissions.has($))return Array.from(this.compiledPermissions.get($));let q=new Set;return this.collectPermissions($,q,new Set),this.compiledPermissions.set($,q),Array.from(q)}roleHasPermission($,q){return this.getRolePermissions($).includes(q)}userHasPermission($,q){for(let Q of $)if(this.roleHasPermission(Q,q))return!0;return!1}userHasRoles($,q){return q.every((Q)=>$.includes(Q))}userHasAnyRole($,q){return q.some((Q)=>$.includes(Q))}getRolesWithPermission($){let q=[];for(let Q of this.roles.keys())if(this.roleHasPermission(Q,$))q.push(Q);return q}getRoleHierarchy($){let q=[];return this.collectParentRoles($,q,new Set),q}roleInheritsFrom($,q){return this.getRoleHierarchy($).includes(q)}getAllRoles(){return Array.from(this.roles.values())}getRole($){return this.roles.get($)}roleExists($){return this.roles.has($)}validateRoles($){let q=[],Q=[];for(let J of $)if(this.roleExists(J))q.push(J);else Q.push(J);return{valid:q,invalid:Q}}getEffectiveRoles($){let q=new Set;for(let Q of $)q.add(Q),this.getRoleHierarchy(Q).forEach((W)=>q.add(W));return Array.from(q)}compareRoleLevels($,q){let Q=this.getRole($),J=this.getRole(q),W=Q?.level??0,X=J?.level??0;return W-X}getHighestRoleLevel($){let q=0;for(let Q of $){let J=this.getRole(Q);if(J&&J.level&&J.level>q)q=J.level}return q}collectPermissions($,q,Q){if(Q.has($))throw Error(`Circular role inheritance detected: ${$}`);Q.add($);let J=this.roles.get($);if(!J)throw Error(`Role not found: ${$}`);J.permissions.forEach((X)=>q.add(X));let W=this.hierarchy.get($)||[];for(let X of W)this.collectPermissions(X,q,new Set(Q))}collectParentRoles($,q,Q){if(Q.has($))return;Q.add($);let J=this.hierarchy.get($)||[];for(let W of J)q.push(W),this.collectParentRoles(W,q,Q)}}function P8(){let $=new t$;return $.defineRoles([{name:"guest",description:"Guest user with minimal permissions",permissions:["read:public"],level:1},{name:"user",description:"Regular authenticated user",permissions:["read:own","write:own","read:public"],inherits:["guest"],level:10},{name:"moderator",description:"Moderator with content management permissions",permissions:["read:all","write:all","moderate:content"],inherits:["user"],level:50},{name:"admin",description:"Administrator with full system access",permissions:["*"],inherits:["moderator"],level:100},{name:"super-admin",description:"Super administrator with unrestricted access",permissions:["*","system:*"],inherits:["admin"],level:1000}]),$}var oX=B.object({name:B.string().min(1),description:B.string().optional(),permissions:B.array(B.string()),inherits:B.array(B.string()).optional(),level:B.number().optional()}),aX=B.object({userId:B.string(),roles:B.array(B.string())}),sX=B.object({userId:B.string(),permission:B.string()});class e${static matches($,q){if(q==="*")return!0;if(q.endsWith("*")){let Q=q.slice(0,-1);return $.startsWith(Q)}return $===q}static hasPermission($,q){return $.some((Q)=>this.matches(q,Q))}static filterByPattern($,q){return $.filter((Q)=>this.matches(Q,q))}}w$();function lq($){return(q,Q)=>{let W={config:Array.isArray($)?{roles:$,requireAll:!1,allowInherited:!0}:{requireAll:!1,allowInherited:!0,...$}};b.defineRoles(q,Q,W)}}function uq($){return(q,Q)=>{let W={config:Array.isArray($)?{permissions:$,requireAll:!1}:{requireAll:!1,...$}};b.definePermissions(q,Q,W)}}function k8($){return lq([$])}function tX($){return uq([$])}function eX(){return k8("admin")}function $H(){return k8("super-admin")}function qH($){return(q,Q)=>{b.defineMinimumRole(q,Q,{roleName:$})}}function b8($){return async(q,Q)=>{q.set("rbac",$),await Q()}}class C6{rbac;constructor($){this.rbac=$}checkRoles($,q){let Q=T($);if(!Q)throw new x("Authentication required for role check");let J=Q.roles||[],W=q.allowInherited?this.rbac.getEffectiveRoles(J):J,X;if(q.requireAll)X=q.roles.every((H)=>W.includes(H));else X=q.roles.some((H)=>W.includes(H));if(!X){let H=q.requireAll?"all":"any";throw new x(`Access denied. Required ${H} of roles: ${q.roles.join(", ")}`)}}checkPermissions($,q){let Q=T($);if(!Q)throw new x("Authentication required for permission check");let J=Q.roles||[],W=new Set;for(let Y of J)this.rbac.getRolePermissions(Y).forEach((w)=>W.add(w));let X=Array.from(W),H;if(q.requireAll)H=q.permissions.every((Y)=>e$.hasPermission(X,Y));else H=q.permissions.some((Y)=>e$.hasPermission(X,Y));if(!H){let Y=q.requireAll?"all":"any";throw new x(`Access denied. Required ${Y} of permissions: ${q.permissions.join(", ")}`)}}checkMinimumRole($,q){let Q=T($);if(!Q)throw new x("Authentication required for role level check");let J=Q.roles||[],W=this.rbac.getHighestRoleLevel(J),X=this.rbac.getRole(q);if(!X)throw Error(`Required role not found: ${q}`);let H=X.level||0;if(W<H)throw new x(`Access denied. Minimum role level required: ${q} (level ${H})`)}}function cq($){return $.get("rbac")||null}function Z8($){return T($)?.roles||[]}function dq($){let q=cq($),Q=Z8($);if(!q)return[];let J=new Set;for(let W of Q)q.getRolePermissions(W).forEach((H)=>J.add(H));return Array.from(J)}function QH($,q){return Z8($).includes(q)}function JH($,q){let Q=dq($);return e$.hasPermission(Q,q)}w$();class pq{config;name="rbac";version="1.0.0";dependencies=["auth"];rbac;guard;constructor($={}){this.config=$;if($.rbac)this.rbac=$.rbac;else if($.useDefaults!==!1)this.rbac=P8();else this.rbac=new t$;if($.roles)this.rbac.defineRoles($.roles);this.guard=new C6(this.rbac)}async install($){let q=b8(this.rbac);if($.use(q),$.getContainer().register(t$,{factory:()=>this.rbac,scope:"singleton"}),$.getContainer().register(C6,{factory:()=>this.guard,scope:"singleton"}),this.injectRouteGuards($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}injectRouteGuards($){let q=$.getMetadata();for(let Q of q.getRoutes())if(Q.roles||Q.permissions||Q.minimumRole){let J=this.buildRBACMiddleware(Q);q.registerRoute({...Q,middleware:[J,...Q.middleware||[]]})}}buildRBACMiddleware($){let q=this.guard,Q=$.roles?.config,J=$.permissions?.config,W=$.minimumRole;return async(X,H)=>{if(!T(X))throw new f("Authentication required");if(Q)q.checkRoles(X,Q);if(J)q.checkPermissions(X,J);if(W)q.checkMinimumRole(X,W.roleName);await H()}}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.get(q.roles||"/rbac/roles",{middleware:[Q],handler:(J)=>{let W=this.rbac.getAllRoles();return J.json({success:!0,roles:W.map((X)=>({name:X.name,description:X.description,permissions:X.permissions,inherits:X.inherits,level:X.level}))})}}),$.get("/rbac/roles/:roleName",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName"),X=this.rbac.getRole(W);if(!X)return J.json({error:"Role not found"},404);let H=this.rbac.getRolePermissions(W),Y=this.rbac.getRoleHierarchy(W);return J.json({success:!0,role:{...X,effectivePermissions:H,hierarchy:Y}})}}),$.get("/rbac/roles/:roleName/permissions",{middleware:[Q],handler:(J)=>{let W=J.req.param("roleName");if(!this.rbac.roleExists(W))return J.json({error:"Role not found"},404);let X=this.rbac.getRolePermissions(W);return J.json({success:!0,role:W,permissions:X})}}),$.post("/rbac/check-permission",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X,permission:H}=W;if(!Array.isArray(X)||!H)return J.json({error:"Invalid request body"},400);let Y=this.rbac.userHasPermission(X,H);return J.json({success:!0,hasPermission:Y,roles:X,permission:H})}}),$.post("/rbac/check-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userRoles:X,requiredRoles:H,requireAll:Y=!1}=W;if(!Array.isArray(X)||!Array.isArray(H))return J.json({error:"Invalid request body"},400);let G=Y?this.rbac.userHasRoles(X,H):this.rbac.userHasAnyRole(X,H);return J.json({success:!0,hasRoles:G,userRoles:X,requiredRoles:H,requireAll:Y})}}),$.post("/rbac/effective-roles",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=this.rbac.getEffectiveRoles(X);return J.json({success:!0,inputRoles:X,effectiveRoles:H})}}),$.post("/rbac/user-permissions",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{roles:X}=W;if(!Array.isArray(X))return J.json({error:"Invalid request body"},400);let H=new Set;for(let Y of X)if(this.rbac.roleExists(Y))this.rbac.getRolePermissions(Y).forEach((w)=>H.add(w));return J.json({success:!0,roles:X,permissions:Array.from(H)})}})}getRBACManager(){return this.rbac}getGuard(){return this.guard}}class K6{resourcePermissions=new Map;permissionPolicies=new Map;grantPermission($){let q=this.getPermissionKey($.userId,$.resource);if(!this.resourcePermissions.has(q))this.resourcePermissions.set(q,[]);this.resourcePermissions.get(q).push($)}revokePermission($,q,Q){let J=this.getPermissionKey($,q);if(!Q){this.resourcePermissions.delete(J);return}let X=(this.resourcePermissions.get(J)||[]).filter((H)=>H.resourceId!==Q);if(X.length===0)this.resourcePermissions.delete(J);else this.resourcePermissions.set(J,X)}hasPermission($){let{user:q,resource:Q,action:J,attributes:W}=$;if(this.checkRoleBasedPermission(q,J,Q))return!0;let X=this.getPermissionKey(q.id,Q?.constructor?.name||"unknown"),H=this.resourcePermissions.get(X)||[];for(let Y of H){if(Y.expiresAt&&Y.expiresAt<new Date)continue;if(Y.resourceId&&Q?.id!==Y.resourceId)continue;for(let G of Y.permissions)if(this.matchesPermission(G,J,Q,W)){if(G.conditions&&!this.evaluateConditions(G.conditions,$))continue;return!0}}return this.checkPermissionPolicies($)}getUserPermissions($,q,Q){let J=this.getPermissionKey($,q),W=this.resourcePermissions.get(J)||[],X=[];for(let H of W){if(H.expiresAt&&H.expiresAt<new Date)continue;if(Q&&H.resourceId&&H.resourceId!==Q)continue;X.push(...H.permissions)}return X}getUserResources($){let q=new Set;for(let[Q,J]of this.resourcePermissions.entries())if(Q.startsWith(`${$}:`)){let W=Q.substring($.length+1);q.add(W)}return Array.from(q)}definePolicy($,q){this.permissionPolicies.set($,q)}filterResources($,q,Q,J=(W)=>W.constructor.name){return $.filter((W)=>{let X={user:q,resource:W,action:Q};return this.hasPermission(X)})}filterAttributes($,q,Q,J){let W={user:q,resource:$,action:Q,attributes:J};if(!this.hasPermission(W))return[];let X=$?.constructor?.name||"unknown",H=this.getUserPermissions(q.id,X,$?.id),Y=new Set;for(let G of H)if(G.action===Q||G.action==="*")if(G.attributes)G.attributes.forEach((w)=>Y.add(w));else J.forEach((w)=>Y.add(w));return Array.from(Y)}getPermissionKey($,q){return`${$}:${q}`}checkRoleBasedPermission($,q,Q){return!1}matchesPermission($,q,Q,J){if($.action!=="*"&&$.action!==q)return!1;let W=Q?.constructor?.name||"unknown";if($.resource!=="*"&&$.resource!==W)return!1;if(J&&$.attributes){if(!J.some((H)=>$.attributes.includes(H)||$.attributes.includes("*")))return!1}return!0}evaluateConditions($,q){return $.every((Q)=>this.evaluateCondition(Q,q))}evaluateCondition($,q){let Q=this.getFieldValue($.field,q);switch($.operator){case"eq":return Q===$.value;case"ne":return Q!==$.value;case"in":return Array.isArray($.value)&&$.value.includes(Q);case"nin":return Array.isArray($.value)&&!$.value.includes(Q);case"gt":return Q>$.value;case"gte":return Q>=$.value;case"lt":return Q<$.value;case"lte":return Q<=$.value;case"contains":return String(Q).includes(String($.value));case"startsWith":return String(Q).startsWith(String($.value));case"endsWith":return String(Q).endsWith(String($.value));default:return!1}}getFieldValue($,q){let Q=$.split("."),J=q;for(let W of Q)if(J&&typeof J==="object")J=J[W];else return;return J}checkPermissionPolicies($){for(let q of this.permissionPolicies.values())if(q.evaluate($))return!0;return!1}}class j0{name="ownership";description="User can access resources they own";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q)return!1;return Q.userId===q.id||Q.ownerId===q.id||Q.createdBy===q.id||Q.owner===q.id}}class O0{name="team-membership";description="User can access resources belonging to their team";evaluate($){let{user:q,resource:Q}=$;if(!Q||!q||!q.teamId)return!1;return Q.teamId===q.teamId}}class N0{name="public-resource";description="Anyone can read public resources";evaluate($){let{resource:q,action:Q}=$;if(!q||Q!=="read")return!1;return q.isPublic===!0||q.visibility==="public"}}var nq=B.object({action:B.string(),resource:B.string(),conditions:B.array(B.object({field:B.string(),operator:B.enum(["eq","ne","in","nin","gt","gte","lt","lte","contains","startsWith","endsWith"]),value:B.any()})).optional(),attributes:B.array(B.string()).optional()}),WH=B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(nq),grantedBy:B.string().optional(),grantedAt:B.date().optional(),expiresAt:B.date().optional()}),XH=B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()});w$();function O$($){return(q,Q)=>{let J={config:$};b.defineResourcePermission(q,Q,J)}}function HH($,q){return O$({action:"read",resource:$,attributes:q})}function YH($,q){return O$({action:"write",resource:$,attributes:q})}function GH($,q){return O$({action:"update",resource:$,attributes:q})}function BH($){return O$({action:"delete",resource:$})}function wH($="access"){return O$({action:$,conditions:[{field:"resource.userId",operator:"eq",value:"{{user.id}}"}]})}function VH($="access"){return O$({action:$,conditions:[{field:"resource.teamId",operator:"eq",value:"{{user.teamId}}"}]})}function FH(){return O$({action:"read",conditions:[{field:"resource.isPublic",operator:"eq",value:!0}]})}function UH($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-resource",required:!0,metadata:{action:$}})}}function _H($="read"){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"filtered-attributes",required:!0,metadata:{action:$}})}}function f8($){return async(q,Q)=>{q.set("permissionManager",$),await Q()}}class I6{permissionManager;constructor($){this.permissionManager=$}checkResourcePermission($,q,Q){let J=T($);if(!J)throw new x("Authentication required for permission check");let W={user:J,resource:Q,action:q.action,attributes:q.attributes};if(q.conditions)W.conditions=q.conditions.map((H)=>({...H,value:this.resolveTemplateValue(H.value,W)}));if(!this.permissionManager.hasPermission(W))throw new x(`Access denied. Required permission: ${q.action} on ${q.resource||"resource"}`)}filterResource($,q,Q){let J=T($);if(!J)return null;let W={user:J,resource:q,action:Q};return this.permissionManager.hasPermission(W)?q:null}filterResources($,q,Q){let J=T($);if(!J)return[];return this.permissionManager.filterResources(q,J,Q)}filterAttributes($,q,Q,J){let W=T($);if(!W)return[];return this.permissionManager.filterAttributes(q,W,Q,J)}resolveTemplateValue($,q){if(typeof $==="string"&&$.startsWith("{{")&&$.endsWith("}}")){let Q=$.slice(2,-2);return this.getNestedValue(q,Q)}return $}getNestedValue($,q){return q.split(".").reduce((Q,J)=>Q?.[J],$)}}function T8($){return $.get("permissionManager")||null}function iq($,q,Q,J){let W=T8($),X=T($);if(!W||!X)return!1;let H={user:X,resource:q,action:Q,attributes:J};return W.hasPermission(H)}function DH($,q,Q){let J=T8($),W=T($);if(!J||!W)return[];return J.getUserPermissions(W.id,q,Q).map((H)=>H.action)}function zH($,q,Q){return iq($,q,Q)}w$();class rq{config;name="permissions";version="1.0.0";dependencies=["auth"];permissionManager;guard;constructor($={}){this.config=$;if(this.permissionManager=$.permissionManager||new K6,$.enableDefaultPolicies!==!1)this.permissionManager.definePolicy("ownership",new j0),this.permissionManager.definePolicy("team-membership",new O0),this.permissionManager.definePolicy("public-resource",new N0);this.guard=new I6(this.permissionManager)}async install($){let q=f8(this.permissionManager);if($.use(q),$.getContainer().register(K6,{factory:()=>this.permissionManager,scope:"singleton"}),$.getContainer().register(I6,{factory:()=>this.guard,scope:"singleton"}),this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($)}extendRouterCompiler($){let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.resourcePermission)this.addPermissionGuards($,J)}}addPermissionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{},Q=async(J,W)=>{if(!T(J))throw new f("Authentication required");await W()};$.post(q.grant||"/permissions/grant",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y,permissions:G,expiresAt:w}=W,V={userId:X,resource:H,resourceId:Y,permissions:G,grantedBy:"system",grantedAt:new Date,expiresAt:w?new Date(w):void 0};return this.permissionManager.grantPermission(V),J.json({success:!0,message:"Permission granted successfully",permission:V})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional(),permissions:B.array(B.object({action:B.string(),resource:B.string(),conditions:B.array(B.any()).optional(),attributes:B.array(B.string()).optional()})),expiresAt:B.string().optional()})}}),$.delete(q.revoke||"/permissions/revoke",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,resource:H,resourceId:Y}=W;return this.permissionManager.revokePermission(X,H,Y),J.json({success:!0,message:"Permission revoked successfully"})},schema:{body:B.object({userId:B.string(),resource:B.string(),resourceId:B.string().optional()})}}),$.post(q.check||"/permissions/check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resource:Y,resourceId:G,attributes:w}=W,V={user:{id:X},resource:G?{id:G}:void 0,action:H,attributes:w},U=this.permissionManager.hasPermission(V);return J.json({success:!0,hasPermission:U,context:{userId:X,action:H,resource:Y,resourceId:G,attributes:w}})},schema:{body:B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()})}}),$.get("/permissions/user/:userId/resource/:resource",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=J.req.param("resource"),H=J.req.query("resourceId"),Y=this.permissionManager.getUserPermissions(W,X,H);return J.json({success:!0,userId:W,resource:X,resourceId:H,permissions:Y})}}),$.get("/permissions/user/:userId/resources",{middleware:[Q],handler:(J)=>{let W=J.req.param("userId"),X=this.permissionManager.getUserResources(W);return J.json({success:!0,userId:W,resources:X})}}),$.post("/permissions/bulk-check",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{checks:X}=W,H=X.map((Y)=>{let G={user:{id:Y.userId},resource:Y.resourceId?{id:Y.resourceId}:void 0,action:Y.action,attributes:Y.attributes},w=this.permissionManager.hasPermission(G);return{...Y,hasPermission:w}});return J.json({success:!0,results:H})},schema:{body:B.object({checks:B.array(B.object({userId:B.string(),action:B.string(),resource:B.string(),resourceId:B.string().optional(),attributes:B.array(B.string()).optional()}))})}}),$.post("/permissions/filter-resources",{middleware:[Q],handler:async(J)=>{let W=await J.req.json(),{userId:X,action:H,resources:Y}=W,G={id:X},w=this.permissionManager.filterResources(Y,G,H);return J.json({success:!0,userId:X,action:H,totalResources:Y.length,filteredResources:w.length,resources:w})},schema:{body:B.object({userId:B.string(),action:B.string(),resources:B.array(B.any())})}})}getPermissionManager(){return this.permissionManager}getGuard(){return this.guard}}class $6{sessions=new Map;cleanupTimer;constructor($=60000){if(this.cleanupTimer=setInterval(()=>this.cleanup(),$),typeof process<"u"&&process.on){let q=()=>clearInterval(this.cleanupTimer);process.on("exit",q),process.on("SIGTERM",q),process.on("SIGINT",q)}}async get($){let q=this.sessions.get($);if(!q)return null;if(q.expiresAt&&q.expiresAt<new Date)return this.sessions.delete($),null;return q}async set($,q){this.sessions.set($,q)}async destroy($){this.sessions.delete($)}async touch($){let q=this.sessions.get($);if(q)q.updatedAt=new Date,this.sessions.set($,q)}async clear(){this.sessions.clear()}async length(){return this.sessions.size}async all(){return Array.from(this.sessions.values())}cleanup(){let $=new Date;for(let[q,Q]of this.sessions.entries())if(Q.expiresAt&&Q.expiresAt<$)this.sessions.delete(q)}}class R0{redis;prefix="sess:";constructor($,q){this.redis=$;if(q)this.prefix=q}async get($){let q=this.prefix+$,Q=await this.redis.get(q);if(!Q)return null;try{let J=JSON.parse(Q);if(J.createdAt=new Date(J.createdAt),J.updatedAt=new Date(J.updatedAt),J.expiresAt)J.expiresAt=new Date(J.expiresAt);return J}catch(J){return null}}async set($,q){let Q=this.prefix+$,J=JSON.stringify(q);if(q.expiresAt){let W=Math.floor((q.expiresAt.getTime()-Date.now())/1000);if(W>0)await this.redis.setex(Q,W,J)}else await this.redis.set(Q,J)}async destroy($){let q=this.prefix+$;await this.redis.del(q)}async touch($){let q=await this.get($);if(q)q.updatedAt=new Date,await this.set($,q)}async clear(){let $=await this.redis.keys(this.prefix+"*");if($.length>0)await this.redis.del(...$)}async length(){return(await this.redis.keys(this.prefix+"*")).length}async all(){let $=await this.redis.keys(this.prefix+"*"),q=[];for(let Q of $){let J=await this.redis.get(Q);if(J)try{let W=JSON.parse(J);if(W.createdAt=new Date(W.createdAt),W.updatedAt=new Date(W.updatedAt),W.expiresAt)W.expiresAt=new Date(W.expiresAt);q.push(W)}catch(W){}}return q}}class P6{store;config;constructor($,q){this.store=$;this.config={name:"sessionId",maxAge:86400000,secure:!1,httpOnly:!0,sameSite:"lax",path:"/",rolling:!1,genid:()=>crypto.randomUUID(),...q,domain:q.domain}}async createSession($,q={},Q){let J=this.config.genid(),W=new Date,X=Q?.maxAge||this.config.maxAge,H={id:J,userId:$,data:q,createdAt:W,updatedAt:W,expiresAt:new Date(W.getTime()+X),ipAddress:Q?.ipAddress,userAgent:Q?.userAgent,csrfToken:this.generateCSRFToken()};return await this.store.set(J,H),H}async getSession($){return await this.store.get($)}async updateSession($,q){let Q=await this.store.get($);if(!Q)return null;if(Q.data={...Q.data,...q},Q.updatedAt=new Date,this.config.rolling)Q.expiresAt=new Date(Date.now()+this.config.maxAge);return await this.store.set($,Q),Q}async touchSession($){if(this.config.rolling){let q=await this.store.get($);if(q)q.updatedAt=new Date,q.expiresAt=new Date(Date.now()+this.config.maxAge),await this.store.set($,q)}else await this.store.touch($)}async destroySession($){await this.store.destroy($)}async regenerateSession($){let q=await this.store.get($);if(!q)return null;let Q=this.config.genid(),J={...q,id:Q,updatedAt:new Date,csrfToken:this.generateCSRFToken()};return await this.store.set(Q,J),await this.store.destroy($),J}async getUserSessions($){return(await this.store.all()).filter((Q)=>Q.userId===$)}async destroyUserSessions($){let q=await this.getUserSessions($);for(let Q of q)await this.store.destroy(Q.id)}validateCSRFToken($,q){return $.csrfToken===q}generateCSRFToken(){return crypto.randomUUID()}getCookieOptions(){let $={maxAge:this.config.maxAge,secure:this.config.secure,httpOnly:this.config.httpOnly,sameSite:this.config.sameSite,path:this.config.path};if(this.config.domain)$.domain=this.config.domain;return $}getConfig(){return{...this.config}}getStore(){return this.store}}class k6{tokenStore=new Map;tokenTTL=3600000;generateToken($){let q=crypto.randomUUID(),Q=new Date(Date.now()+this.tokenTTL);return this.tokenStore.set($,{token:q,expiresAt:Q}),this.cleanup(),q}validateToken($,q){let Q=this.tokenStore.get($);if(!Q)return!1;if(Q.expiresAt<new Date)return this.tokenStore.delete($),!1;return Q.token===q}removeToken($){this.tokenStore.delete($)}cleanup(){let $=new Date;for(let[q,Q]of this.tokenStore.entries())if(Q.expiresAt<$)this.tokenStore.delete(q)}}var LH=B.object({id:B.string(),userId:B.string(),data:B.record(B.any()),createdAt:B.date(),updatedAt:B.date(),expiresAt:B.date().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional(),csrfToken:B.string().optional()}),jH=B.object({name:B.string().optional(),secret:B.string(),maxAge:B.number().optional(),secure:B.boolean().optional(),httpOnly:B.boolean().optional(),sameSite:B.enum(["strict","lax","none"]).optional(),domain:B.string().optional(),path:B.string().optional(),rolling:B.boolean().optional()}),OH=B.object({userId:B.string(),data:B.record(B.any()).optional(),maxAge:B.number().optional(),ipAddress:B.string().optional(),userAgent:B.string().optional()}),NH=B.object({data:B.record(B.any())});w$();var q6=require("hono/cookie");function RH($={}){return(q,Q)=>{let J={config:$};b.defineSession(q,Q,J)}}function SH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"current-session",required:!0})}}function MH($){return(q,Q,J)=>{if(Q)b.defineParameter(q,Q,J,{index:J,type:"session-data",required:!1,metadata:{key:$}})}}function EH(){return($,q,Q)=>{if(q)b.defineParameter($,q,Q,{index:Q,type:"csrf-token",required:!0})}}function AH(){return($,q)=>{b.defineCSRF($,q,{required:!0})}}function x8($,q){return async(Q,J)=>{let W=$.getConfig(),X=q6.getCookie(Q,W.name),H=null;if(X){if(H=await $.getSession(X),H)await $.touchSession(X)}Q.set("session",H),Q.set("sessionManager",$),Q.set("csrfProtection",q),await J()}}class Z6{sessionManager;csrfProtection;constructor($,q){this.sessionManager=$;this.csrfProtection=q}checkSession($,q){let Q=q$($);if(q.required&&!Q)throw new f("Session required");if(Q&&q.csrf)this.checkCSRF($,Q)}checkCSRF($,q){if(!this.csrfProtection)throw Error("CSRF protection not configured");let Q=$.req.header("X-CSRF-Token")||$.req.query("_csrf");if(!Q)throw new x("CSRF token required");if(!this.csrfProtection.validateToken(q.id,Q))throw new x("Invalid CSRF token")}async createSession($,q,Q={}){let J=b6($);if(!J)throw Error("Session manager not available");let W=$.req.header("X-Forwarded-For")||$.req.header("X-Real-IP")||"unknown",X=$.req.header("User-Agent")||"unknown",H=await J.createSession(q,Q,{ipAddress:W,userAgent:X}),Y=J.getCookieOptions();return q6.setCookie($,J.getConfig().name,H.id,Y),$.set("session",H),H}async updateSession($,q){let Q=q$($),J=b6($);if(!Q||!J)return null;let W=await J.updateSession(Q.id,q);if(W)$.set("session",W);return W}async destroySession($){let q=q$($),Q=b6($);if(!q||!Q)return;await Q.destroySession(q.id);let J=Q.getConfig();if(q6.setCookie($,J.name,"",{...Q.getCookieOptions(),maxAge:0}),$.set("session",null),this.csrfProtection)this.csrfProtection.removeToken(q.id)}async regenerateSession($){let q=q$($),Q=b6($);if(!q||!Q)return null;let J=await Q.regenerateSession(q.id);if(J){let W=Q.getCookieOptions();if(q6.setCookie($,Q.getConfig().name,J.id,W),$.set("session",J),this.csrfProtection)this.csrfProtection.removeToken(q.id),this.csrfProtection.generateToken(J.id)}return J}generateCSRFToken($){let q=q$($);if(!q||!this.csrfProtection)return null;return this.csrfProtection.generateToken(q.id)}}function q$($){return $.get("session")||null}function b6($){return $.get("sessionManager")||null}function CH($){return $.get("csrfProtection")||null}function KH($,q){let Q=q$($);if(!Q)return null;if(q)return Q.data[q];return Q.data}function IH($){return q$($)!==null}function PH($){return q$($)?.userId||null}function kH($,q,Q){let J=q$($);if(J)J.data[q]=Q,$.set("session",J)}function bH($,q){let Q=q$($);if(Q&&q in Q.data)delete Q.data[q],$.set("session",Q)}class oq{config;name="session";version="1.0.0";sessionManager;csrfProtection;guard;compileExtended=!1;cleanupIntervalId;constructor($){this.config=$;let q;if($.store)q=$.store;else if($.storeType==="redis"&&$.redis)q=new R0($.redis);else q=new $6;if(this.sessionManager=new P6(q,$.session),$.csrf?.enabled!==!1)this.csrfProtection=new k6;this.guard=new Z6(this.sessionManager,this.csrfProtection)}async install($){let q=x8(this.sessionManager,this.csrfProtection);if($.use(q),$.getContainer().register(P6,{factory:()=>this.sessionManager,scope:"singleton"}),$.getContainer().register(Z6,{factory:()=>this.guard,scope:"singleton"}),this.csrfProtection)$.getContainer().register(k6,{factory:()=>this.csrfProtection,scope:"singleton"});if(this.extendRouterCompiler($),this.config.enableManagementRoutes!==!1)this.addManagementRoutes($);if(this.sessionManager.getStore()instanceof $6)this.setupCleanup()}extendRouterCompiler($){if(this.compileExtended)return;this.compileExtended=!0;let q=$.compile.bind($);$.compile=async()=>{await q();let Q=$.getMetadata().getRoutes();for(let J of Q)if(J.session||J.csrf)this.addSessionGuards($,J)}}addSessionGuards($,q){}addManagementRoutes($){let q=this.config.routes||{};if($.post(q.create||"/session/create",{handler:async(Q)=>{let J=await Q.req.json(),{userId:W,data:X}=J,H=await this.guard.createSession(Q,W,X);return Q.json({success:!0,message:"Session created successfully",session:{id:H.id,userId:H.userId,data:H.data,createdAt:H.createdAt,expiresAt:H.expiresAt}})},schema:{body:B.object({userId:B.string(),data:B.record(B.any()).optional()})}}),$.post(q.destroy||"/session/destroy",{handler:async(Q)=>{return await this.guard.destroySession(Q),Q.json({success:!0,message:"Session destroyed successfully"})}}),$.post(q.regenerate||"/session/regenerate",{handler:async(Q)=>{let J=await this.guard.regenerateSession(Q);if(!J)return Q.json({error:"No active session to regenerate"},400);return Q.json({success:!0,message:"Session regenerated successfully",session:{id:J.id,userId:J.userId,data:J.data,createdAt:J.createdAt,expiresAt:J.expiresAt}})}}),$.get(q.data||"/session/data",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return Q.json({success:!0,data:J.data})}}),$.put(q.data||"/session/data",{handler:async(Q)=>{let J=await Q.req.json(),{data:W}=J,X=await this.guard.updateSession(Q,W);if(!X)return Q.json({error:"No active session to update"},400);return Q.json({success:!0,message:"Session data updated successfully",data:X.data})},schema:{body:B.object({data:B.record(B.any())})}}),this.csrfProtection)$.get(q.csrf||"/session/csrf-token",{handler:(Q)=>{let J=this.guard.generateCSRFToken(Q);if(!J)return Q.json({error:"No active session or CSRF not enabled"},400);return Q.json({success:!0,csrfToken:J})}});$.get("/session/info",{handler:(Q)=>{let J=Q.get("session");if(!J)return Q.json({success:!0,authenticated:!1,session:null});return Q.json({success:!0,authenticated:!0,session:{id:J.id,userId:J.userId,createdAt:J.createdAt,updatedAt:J.updatedAt,expiresAt:J.expiresAt,ipAddress:J.ipAddress,userAgent:J.userAgent}})}}),$.get("/session/all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);let W=await this.sessionManager.getUserSessions(J.userId);return Q.json({success:!0,sessions:W.map((X)=>({id:X.id,createdAt:X.createdAt,updatedAt:X.updatedAt,expiresAt:X.expiresAt,ipAddress:X.ipAddress,userAgent:X.userAgent,current:X.id===J.id}))})}}),$.post("/session/destroy-all",{handler:async(Q)=>{let J=Q.get("session");if(!J)return Q.json({error:"No active session"},400);return await this.sessionManager.destroyUserSessions(J.userId),Q.json({success:!0,message:"All sessions destroyed successfully"})}}),$.get("/session/stats",{handler:async(Q)=>{if(!Q.get("session"))return Q.json({error:"Authentication required"},401);let W=this.sessionManager.getStore(),X=await W.length(),H=await W.all(),Y={totalSessions:X,activeSessions:H.filter((G)=>!G.expiresAt||G.expiresAt>new Date).length,expiredSessions:H.filter((G)=>G.expiresAt&&G.expiresAt<=new Date).length,uniqueUsers:new Set(H.map((G)=>G.userId)).size};return Q.json({success:!0,stats:Y})}})}setupCleanup(){if(this.cleanupIntervalId)return;let $=900000;if(this.cleanupIntervalId=setInterval(()=>{let q=this.sessionManager.getStore();if(q instanceof $6)q.cleanup()},$),typeof process<"u"&&process.on)process.on("exit",()=>{if(this.cleanupIntervalId)clearInterval(this.cleanupIntervalId)})}getSessionManager(){return this.sessionManager}getCSRFProtection(){return this.csrfProtection}getGuard(){return this.guard}}
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=8B320935F10B909264756E2164756E21
|