@zuplo/runtime 6.52.23 → 6.52.25
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/out/esm/index.js +1 -1
- package/package.json +1 -1
package/out/esm/index.js
CHANGED
|
@@ -56,7 +56,7 @@ import{a as Xt,d as qe,e as uw,f as Ia,g as Sa,h as cw,i as lw}from"./chunk-VNF2
|
|
|
56
56
|
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!S.has("X-Amz-Expires")&&S.set("X-Amz-Expires","86400"),S.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),S.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),S.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");y||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=Yh(this.encodedPath);let N=new Set;this.encodedSearch=[...this.url.searchParams].filter(([D])=>{if(!D)return!1;if(this.service==="s3"){if(N.has(D))return!1;N.add(D)}return!0}).map(D=>D.map(z=>Yh(encodeURIComponent(z)))).sort(([D,z],[I,M])=>D<I?-1:D>I?1:z<M?-1:z>M?1:0).map(D=>D.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let e=this.datetime.slice(0,8),r=[this.secretAccessKey,e,this.region,this.service].join(),n=this.cache.get(r);if(!n){let o=await to("AWS4"+this.secretAccessKey,e),s=await to(o,this.region),a=await to(s,this.service);n=await to(a,"aws4_request"),this.cache.set(r,n)}return yu(await to(n,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,yu(await Xh(await this.canonicalString()))].join(`
|
|
57
57
|
`)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
|
|
58
58
|
`,this.signedHeaders,await this.hexBodyHash()].join(`
|
|
59
|
-
`)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256");if(e==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new U("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=yu(await Xh(this.body||""))}return e}};async function to(t,e){let r=await crypto.subtle.importKey("raw",typeof t=="string"?bu.encode(t):t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",r,bu.encode(e))}i(to,"hmac");async function Xh(t){return crypto.subtle.digest("SHA-256",typeof t=="string"?bu.encode(t):t)}i(Xh,"hash");function yu(t){return Array.prototype.map.call(new Uint8Array(t),e=>("0"+e.toString(16)).slice(-2)).join("")}i(yu,"buf2hex");function Yh(t){return t.replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}i(Yh,"encodeRfc3986");function hx(t,e){let{hostname:r,pathname:n}=t,o=r.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[s,a]=(o||["",""]).slice(1,3);if(a==="us-gov")a="us-gov-west-1";else if(a==="s3"||a==="s3-accelerate")a="us-east-1",s="s3";else if(s==="iot")r.startsWith("iot.")?s="execute-api":r.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=n==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){let u=(e.get("X-Amz-Target")||"").split(".")[0];u==="AnyScaleFrontendService"?s="application-autoscaling":u==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else a==null&&s.startsWith("s3-")?(a=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):a&&/-\d$/.test(s)&&!/-\d$/.test(a)&&([s,a]=[a,s]);return s in Qh?[Qh[s],a]:[s,a]}i(hx,"guessServiceRegion");function gx(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:t===43?62:t===47?63:0}i(gx,"b64ToUint6");function eg(t,e){let r=t.replace(/[^A-Za-z0-9+/]/g,""),n=r.length,o=e?Math.ceil((n*3+1>>2)/e)*e:n*3+1>>2,s=new Uint8Array(o),a,u,c=0,l=0;for(let d=0;d<n;d++)if(u=d&3,c|=gx(r.charCodeAt(d))<<6*(3-u),u===3||n-d===1){for(a=0;a<3&&l<o;)s[l]=c>>>(16>>>a&24)&255,a++,l++;c=0}return s}i(eg,"base64Decode");function Bi(t){return t<26?t+65:t<52?t+71:t<62?t-4:t===62?43:t===63?47:65}i(Bi,"uint6ToB64");function tg(t){let e=2,r="",n=t.length,o=0;for(let s=0;s<n;s++)e=s%3,o|=t[s]<<(16>>>e&24),(e===2||t.length-s===1)&&(r+=String.fromCodePoint(Bi(o>>>18&63),Bi(o>>>12&63),Bi(o>>>6&63),Bi(o&63)),o=0);return r.substring(0,r.length-2+e)+(e===2?"":e===1?"=":"==")}i(tg,"base64Encode");function en(t){let e=t.toString();return`${e.length===1?"0":""}${e}`}i(en,"numberToString");function yx(t){let e=t.getTimezoneOffset(),r=Math.abs(e),n=e>0?"-":"+",o=en(Math.floor(r/60)),s=en(r%60);return`${n}${o}${s}`}i(yx,"getCLFOffset");function wu(t=new Date){if(!(t instanceof Date))throw new Error("clf-date: invalid parameter");let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=en(t.getDate()),n=e[t.getMonth()],o=t.getFullYear(),s=en(t.getHours()),a=en(t.getMinutes()),u=en(t.getSeconds()),c=yx(t);return`${r}/${n}/${o}:${s}:${a}:${u} ${c}`}i(wu,"toCLFDate");var rg=Ke("zuplo:runtime"),bx="X-Amzn-Trace-Id",vx="x-amzn-errortype",ng=[],wx=i(async(t,e,r)=>{let n=r;for await(let o of ng)n=await o(t,e,r);return n},"onSendingAwsLambdaEvent"),it=class extends U{static{i(this,"AwsLambdaError")}traceId;errorType;constructor(e,r){super(`Failed to invoke AWS Lambda function. ${e}`),this.traceId=r.get(bx)??void 0,this.errorType=r.get(vx)??void 0}},xx={addSendingAwsLambdaEventHook:i(t=>{ng.push(t)},"addSendingAwsLambdaEventHook")};async function Rx(t,e){b("handler.aws-lambda");let{accessKeyId:r,secretAccessKey:n,region:o,functionName:s,useLambdaProxyIntegration:a=!0,useAwsResourcePathStyle:u=!1,binaryMediaTypes:c}=e.route.handler.options;if(!r)throw new g("awsAccessKeyId is not set in the handler options");if(!n)throw new g("secretAccessKey is not set in the handler options");if(!o)throw new g("region is not set in the handler options");if(!s)throw new g("functionName is not set in the handler options");let l=new Yr({accessKeyId:r,secretAccessKey:n}),d=`https://lambda.${o}.amazonaws.com/2015-03-31/functions/${s}/invocations`;if(rg(`AWS Lambda URL: ${d}`),!a)return l.fetch(d,{body:await t.arrayBuffer()});let[p,m]=await Sx(t,{binaryMediaTypes:c}),{options:f}=e.route.handler,h;f&&typeof f=="object"&&"payloadFormatVersion"in f&&f.payloadFormatVersion==="2.0"?h=Ix(t,e):h=await Px(t,e,{useAwsResourcePathStyle:u}),rg("Calling onSendingAwsLambdaEvent hook");let y=await wx(t,e,h);y.body=p,y.isBase64Encoded=m;let w=await l.fetch(d,{body:JSON.stringify(y)});try{return _x(w)}catch(E){if(E instanceof it){let S=f&&typeof f=="object"&&"returnAmazonTraceIdHeader"in f&&f.returnAmazonTraceIdHeader&&E.traceId?{AMZN_TRACE_ID_HEADER:E.traceId}:void 0;return A.internalServerError(t,e,void 0,S)}throw E}}i(Rx,"awsLambdaHandler");async function _x(t){let e;try{e=await t.json()}catch{throw new it("Lambda response did not contain valid JSON",t.headers)}if(t.status!==200)throw e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?new it(e.message,t.headers):new it(`Status: ${t.statusText}`,t.headers);if(e&&typeof e=="object"&&"errorMessage"in e&&typeof e.errorMessage=="string")throw new it(e.errorMessage,t.headers);if(!e||typeof e!="object"||!("statusCode"in e)||typeof e.statusCode!="number")return new Response(JSON.stringify(e),{status:t.status,headers:{"content-type":"application/json"}});let r=new Headers;if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new it(`Response headers must be an object. Received ${typeof e.headers}`,t.headers);for(let[o,s]of Object.entries(e.headers))r.set(o,s)}if("cookies"in e&&e.cookies){if(!Array.isArray(e.cookies))throw new it(`Response cookies must be an array. Received ${typeof e.cookies}`,t.headers);r.set("cookie",e.cookies.join(";"))}let n;if("isBase64Encoded"in e&&typeof e.isBase64Encoded!="boolean")throw new it(`Response property isBase64Encoded must be a boolean. Received ${typeof e.isBase64Encoded}`,t.headers);if("isBase64Encoded"in e&&e.isBase64Encoded===!0){if(!("body"in e))throw new it("Response was set to base64 encoded but no body was set",t.headers);if(typeof e.body!="string")throw new it("Response was set to base64 encoded but body was not a string",t.headers);n=eg(e.body)}else"body"in e&&typeof e.body=="string"?n=e.statusCode===204&&e.body===""?null:e.body:"body"in e&&e.body!==null&&e.body!==void 0?n=JSON.stringify(e.body):n=null;if(n!==null&&"bodyEncoding"in e){if(typeof e.bodyEncoding!="string"||!(e.bodyEncoding==="gzip"||e.bodyEncoding==="deflate"))throw new it(`Response property bodyEncoding can only be set to 'gzip' or 'deflate'. Received ${e.bodyEncoding}`,t.headers);let o=new Blob([n]).stream().pipeThrough(new DecompressionStream(e.bodyEncoding));n=await new Response(o).arrayBuffer()}return new Response(n,{headers:r,status:e.statusCode})}i(_x,"getResponse");async function Px(t,e,{useAwsResourcePathStyle:r}){let n={},o={};t.headers.forEach((l,d)=>{n[d]=l,o[d]=[l]});let s=t.query,a={};for(let[l,d]of Object.entries(s))a[l]||(a[l]=[]),a[l].push(d);let u=new URL(t.url);return{version:"1.0",resource:u.pathname,path:u.pathname,httpMethod:t.method,headers:n,multiValueHeaders:o,queryStringParameters:s,multiValueQueryStringParameters:a,requestContext:{accountId:null,apiId:null,authorizer:{claims:{},scopes:[]},domainName:u.hostname,domainPrefix:null,extendedRequestId:e.requestId,httpMethod:t.method,identity:{accessKey:null,accountId:null,caller:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,sourceIp:t.headers.get("CF-Connecting-IP"),user:null,userAgent:t.headers.get("user-agent"),userArn:null,clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},path:u.pathname,protocol:"HTTP/1.1",requestId:e.requestId,requestTime:wu(),requestTimeEpoch:new Date().valueOf(),resourceId:e.route.operationId??null,resourcePath:Ex(e.route.path,r),stage:null},pathParameters:t.params,stageVariables:null}}i(Px,"buildEventVersion1");function Ix(t,e){let r={};t.headers.forEach((s,a)=>{r[a]=s});let n=new URL(t.url);return{version:"2.0",routeKey:null,rawPath:n.pathname,rawQueryString:n.search,cookies:[],headers:r,queryStringParameters:t.query,requestContext:{accountId:null,apiId:null,authentication:{clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},authorizer:{jwt:{claims:{},scopes:[]}},domainName:n.hostname,domainPrefix:null,http:{method:t.method,path:n.pathname,protocol:"HTTP/1.1",sourceIp:t.headers.get("CF-Connecting-IP"),userAgent:t.headers.get("user-agent")},requestId:e.requestId,routeKey:null,stage:null,time:wu(),timeEpoch:new Date().valueOf()},pathParameters:t.params,stageVariables:null}}i(Ix,"buildEventVersion2");async function Sx(t,{binaryMediaTypes:e}){let r,n=!1,o=t.headers.get("content-type");if(t.method==="GET"||t.method==="HEAD")r=null;else if(e&&o&&kx(e,o)){let s=await t.arrayBuffer();r=tg(new Uint8Array(s)),n=!0}else r=await t.clone().text();return[r,n]}i(Sx,"getBodyResult");function kx(t,e){let r=e.split(";")[0].trim().toLowerCase();return t.findIndex(n=>n==="*/*"?!0:n.toLowerCase()===r)>-1}i(kx,"matchesContentType");function Ex(t,e=!1){if(!e)return t;let r=gu(t),n=Kh(t),o={};return r.forEach(s=>{typeof s=="string"?o[s]=`{${s}}`:o[s.name]=`{${s.name}}`}),n(o)}i(Ex,"getResourcePath");var Tx=[502,503,504];async function tn(t,e){if(Tx.includes(t.status)){let r=pe.getLogger(e),o=await t.clone().text(),s={};for(let[a,u]of t.headers)s[a]=u;r.warn(`BadGatewayResponse ${t.status}`,{status:t.status,statusText:t.statusText,body:o,headers:s})}}i(tn,"logBadGatewayResponses");var xu;function ir(t){if(xu===void 0){let r=x.instance.runtime.ZUPLO_HANDLER_WRITE_LOG_LEVEL;["debug","info","warn","error"].includes(r??"")||(r="debug"),xu=r}return t.log[xu]}i(ir,"getHandlerUserLogFunction");async function $x(t,e){b("handler.open-api");let r=x.instance.build.BUILD_ID,{buildAssetsUrl:n}=x.instance,o=e.route.handler.options,{openApiFilePath:s}=o;if(!s)throw new g("Open API Spec Handler must have 'openApiFilePath' specified");let a=Ox(s);if(!a.isValid)throw new g(a.error);let u=`${n}/${r}${s.substring(1)}`,c=await G.fetch(u,{method:t.method,body:t.body,headers:t.headers});if(c.status!==200)return A.notFound(t,e,{detail:"OpenAPI file could not be found."});let l=new Response(c.body,{headers:{"content-type":"application/json","content-encoding":c.headers.get("content-encoding")||"",vary:"Accept-Encoding"},status:c.status,statusText:c.statusText});return tn(l,e),l}i($x,"openApiSpecHandler");var Ox=i(t=>t.startsWith("./")?t.startsWith("./config")?t.endsWith(".oas.json")?{isValid:!0}:{isValid:!1,error:"'openApiFilePath' must point to a file ending in '.oas.json'"}:{isValid:!1,error:"'openApiFilePath' must point to a file in your /config directory"}:{isValid:!1,error:"'openApiFilePath' must start with './'"},"validateOpenApiPath");async function Cx(t,e){b("handler.redirect");let r=e.route.handler.options;if(!r.location)throw new g("Redirect Handler must have 'location' specified");let n=r.status??302;return new Response(null,{status:n,headers:{location:r.location}})}i(Cx,"redirectHandler");async function Ax(t){if(b("handler.zuplo-service-proxy"),Object.entries(t.params).length!==1)throw new g("The service proxy handler only supports one wildcard path parameter. Change your url to something like '/service/{path}'");let e=new URL(t.params.path,x.instance.zuploEdgeApiUrl),r=new Headers(t.headers);return r.set("Authorization",`Bearer ${x.instance.authApiJWT}`),G.fetch(e,{method:t.method,headers:r,body:t.body})}i(Ax,"zuploServiceProxy");function Nx(t,e){let r=t.endsWith("/"),n=e.startsWith("/");return r&&n?`${t.substring(0,t.length-1)}${e}`:!r&&!n?`${t}/${e}`:`${t}${e}`}i(Nx,"join");async function Lx(t,e){b("handler.url-forward");let r=ir(e),n=e.route.handler.options,o=n.forwardSearch!==!1,s;if(x.instance.build.COMPATIBILITY_FLAGS.useForwardRedirectsPropOnUrlForwardHandler?s=n.followRedirects===!0?"follow":"manual":typeof n.followRedirects<"u"&&b("handler.url-forward.follow-redirects"),!n.baseUrl)throw new Error("URL Forward Handler must have 'baseUrl' specified");if(!n||typeof n.__rewriteFunction!="function")throw new g("Invalid options for this route");let a=or(e),u=new URL(t.url),c=n.__rewriteFunction(t,a),l=Nx(c,u.pathname),d=o?`${l}${u.search}`:l.toString(),p=Date.now();r(`URL Forwarding to '${d}'`);let m=await fetch(d,{method:t.method,body:t.body,headers:t.headers,redirect:s}),f=Date.now()-p;return r(`URL Forward received response ${m.status} - ${m.statusText} in ${f}ms`),tn(m,e),m}i(Lx,"urlForwardHandler");var zx=i((t,e)=>{let r=new URL(t),n=new URL(e);for(let[o,s]of n.searchParams.entries())r.searchParams.append(o,s);return r.toString()},"addQuery");async function Dx(t,e){b("handler.url-rewrite");let r=ir(e),n=e.route.handler.options,o=n.forwardSearch!==!1,s=n.followRedirects??!1;if(!n||typeof n.__rewriteFunction!="function")throw new g("Invalid options for this route");let a=or(e),u=n.__rewriteFunction(t,a),c=o?zx(u,t.url):u,l=Date.now();r(`URL Rewriting to '${c}'`);let d=await fetch(c.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:s?"follow":"manual"}),p=Date.now()-l;return r(`URL Rewrite received response ${d.status} - ${d.statusText} in ${p}ms`),tn(d,e),d}i(Dx,"urlRewriteHandler");async function Zx(t,e){b("handler.websocket");let r=e.route.handler.options,n=ir(e);if(!r||!r.rewritePattern)throw new g("WebSocket Handler must have option 'rewritePattern' specified");let o=t.headers.get("Upgrade");if(!o||o!=="websocket")return A.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new g("Invalid options for this route");let s=or(e),a=r.__rewriteFunction(t,s),u=Date.now();n(`Attempting WebSocket connection to '${a}'`),a=a.replace(/^(ws)/,"http");let c=await fetch(a,{method:t.method,headers:t.headers,body:t.body});if(c.status!==101||!c.webSocket){let d=await c.text(),p=`WebSocket connection error - ${c.status}: ${c.statusText}, content: '${d}'`;throw new Error(p)}let l=Date.now()-u;return n(`WebSocket connected, received response ${c.status} - ${c.statusText} in ${l}ms`),new Response(null,{status:101,webSocket:c.webSocket})}i(Zx,"webSocketHandler");async function Ux(t,e){let r=Ae.instance.runtimeSettings.developerPortal.urls?.[0];if(!r)throw new g("Developer portal hostname is not configured.");let n=jx(t.url,r);return e.log.info(`Redirecting from legacy dev portal to ${n}`),new Response(null,{status:301,headers:{location:n}})}i(Ux,"redirectLegacyDevPortal");function jx(t,e){let r=new URL(t),n=e,o=r.hostname.endsWith("zuplo.dev")||r.hostname.endsWith("zuplo.app");if(!n&&o&&(n=`${r.hostname.split(".")[0]}.zuplo.site`),!n)throw new g("Could not determine the hostname for the developer portal");let s=r.pathname.split("/")[1];if(!s)throw new g("The request URL does not contain a valid developer portal base path. This handler cannot be used on a root path");return r.hostname=n,r.pathname=r.pathname.substring(s.length+1),r.toString()}i(jx,"getDevPortalRedirectUrl");var Ru=i((t,e)=>t.map((n,o)=>{let s;if(typeof n.module=="object"&&(s=n.module[n.export]),!s||typeof s!="function"){let a=e==="inbound"?"WebSocketInboundPolicy":"WebSocketOutboundPolicy",u=`policy in position: ${o+1}, export name: ${n.export}`;throw new g(`${a} - Websocket policy must be a valid function (${u})`)}return s}),"getWebSocketPolicyFunctions"),og=i(async(t,e,r,n,o,s)=>{let a=t.data;if(s&&s.length>0){let u=[...s];for(;u.length>0;){let c=u.shift();if(!c)return a;if(a=await c(a,r,e,n,o),a===void 0)return}}return a},"webSocketPolicyProcessor");function ig(t,e,r,n,o){t.addEventListener("close",()=>{e.close()}),t.addEventListener("error",s=>{n.log.error("WebSocket error: ",s),e.send(JSON.stringify(s))}),t.addEventListener("message",s=>{try{let u=i(async c=>{let l=await og(c,t,e,r,n,o);l!==void 0&&e.send(l)},"innerPipeline")(s).catch(n.log.error);n.waitUntil(u)}catch(a){n.log.error(a)}})}i(ig,"wireUpListeners");async function Mx(t,e){b("handler.websocket-pipeline");let r=e.route.handler.options,n=ir(e);if(!r||!r.rewritePattern)throw new g("WebSocket Pipeline Handler must have option 'rewritePattern' specified");let o=t.headers.get("Upgrade");if(!o||o!=="websocket")return A.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new g("Invalid options for this route");let s=or(e),a=r.__rewriteFunction(t,s),u=Date.now();n(`Attempting WebSocket connection to '${a}'`),a=a.replace(/^(ws)/,"http");let c=await fetch(a,{method:t.method,headers:t.headers,body:t.body});if(c.status!==101||!c.webSocket){let w=await c.text(),E=`WebSocket connection error - ${c.status}: ${c.statusText}, content: '${w}'`;throw new Error(E)}let l=new WebSocketPair,[d,p]=Object.values(l),m=Date.now()-u;n(`WebSocket connected, received response ${c.status} - ${c.statusText} in ${m}ms`);let f=c.webSocket;f.accept(),p.accept();let h=r.policies&&r.policies.inbound?Ru(r.policies.inbound,"inbound"):[],y=r.policies&&r.policies.outbound?Ru(r.policies.outbound,"outbound"):[];return ig(p,f,t,e,h),ig(f,p,t,e,y),new Response(null,{status:101,webSocket:d})}i(Mx,"webSocketPipelineHandler");import{AsyncLocalStorage as qx}from"node:async_hooks";var sg=new qx;function ag(t,e){return sg.run(t,e)}i(ag,"runWithInvokeHeaders");function ug(){return sg.getStore()??{}}i(ug,"getInvokeHeaders");var T={};Qt(T,{BRAND:()=>fR,DIRTY:()=>wr,EMPTY_PATH:()=>Vx,INVALID:()=>ce,NEVER:()=>XR,OK:()=>Be,ParseStatus:()=>He,Schema:()=>ve,ZodAny:()=>ur,ZodArray:()=>Mt,ZodBigInt:()=>Rr,ZodBoolean:()=>_r,ZodBranded:()=>io,ZodCatch:()=>Nr,ZodDate:()=>Pr,ZodDefault:()=>Ar,ZodDiscriminatedUnion:()=>Ji,ZodEffects:()=>mt,ZodEnum:()=>Or,ZodError:()=>Qe,ZodFirstPartyTypeKind:()=>le,ZodFunction:()=>Qi,ZodIntersection:()=>Er,ZodIssueCode:()=>j,ZodLazy:()=>Tr,ZodLiteral:()=>$r,ZodMap:()=>un,ZodNaN:()=>ln,ZodNativeEnum:()=>Cr,ZodNever:()=>yt,ZodNull:()=>Sr,ZodNullable:()=>Et,ZodNumber:()=>xr,ZodObject:()=>Xe,ZodOptional:()=>dt,ZodParsedType:()=>re,ZodPipeline:()=>so,ZodPromise:()=>cr,ZodReadonly:()=>Lr,ZodRecord:()=>Ki,ZodSchema:()=>ve,ZodSet:()=>cn,ZodString:()=>ar,ZodSymbol:()=>sn,ZodTransformer:()=>mt,ZodTuple:()=>kt,ZodType:()=>ve,ZodUndefined:()=>Ir,ZodUnion:()=>kr,ZodUnknown:()=>jt,ZodVoid:()=>an,addIssueToContext:()=>ee,any:()=>_R,array:()=>kR,bigint:()=>bR,boolean:()=>wg,coerce:()=>QR,custom:()=>yg,date:()=>vR,datetimeRegex:()=>hg,defaultErrorMap:()=>Zt,discriminatedUnion:()=>OR,effect:()=>HR,enum:()=>jR,function:()=>DR,getErrorMap:()=>rn,getParsedType:()=>St,instanceof:()=>gR,intersection:()=>CR,isAborted:()=>Vi,isAsync:()=>nn,isDirty:()=>Gi,isValid:()=>sr,late:()=>hR,lazy:()=>ZR,literal:()=>UR,makeIssue:()=>ro,map:()=>LR,nan:()=>yR,nativeEnum:()=>MR,never:()=>IR,null:()=>RR,nullable:()=>BR,number:()=>vg,object:()=>ER,objectUtil:()=>_u,oboolean:()=>KR,onumber:()=>JR,optional:()=>FR,ostring:()=>WR,pipeline:()=>GR,preprocess:()=>VR,promise:()=>qR,quotelessJson:()=>Hx,record:()=>NR,set:()=>zR,setErrorMap:()=>Bx,strictObject:()=>TR,string:()=>bg,symbol:()=>wR,transformer:()=>HR,tuple:()=>AR,undefined:()=>xR,union:()=>$R,unknown:()=>PR,util:()=>Re,void:()=>SR});var Re;(function(t){t.assertEqual=o=>{};function e(o){}i(e,"assertIs"),t.assertIs=e;function r(o){throw new Error}i(r,"assertNever"),t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(u=>typeof o[o[u]]!="number"),a={};for(let u of s)a[u]=o[u];return t.objectValues(a)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},t.find=(o,s)=>{for(let a of o)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}i(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var _u;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(_u||(_u={}));var re=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),St=i(t=>{switch(typeof t){case"undefined":return re.undefined;case"string":return re.string;case"number":return Number.isNaN(t)?re.nan:re.number;case"boolean":return re.boolean;case"function":return re.function;case"bigint":return re.bigint;case"symbol":return re.symbol;case"object":return Array.isArray(t)?re.array:t===null?re.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?re.promise:typeof Map<"u"&&t instanceof Map?re.map:typeof Set<"u"&&t instanceof Set?re.set:typeof Date<"u"&&t instanceof Date?re.date:re.object;default:return re.unknown}},"getParsedType");var j=Re.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"]),Hx=i(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Qe=class t extends Error{static{i(this,"ZodError")}get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let u=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(r(a))):u[l]=u[l]||{_errors:[]},u=u[l],c++}}},"processError");return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Qe.create=t=>new Qe(t);var Fx=i((t,e)=>{let r;switch(t.code){case j.invalid_type:t.received===re.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case j.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Re.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:r=`Unrecognized key(s) in object: ${Re.joinValues(t.keys,", ")}`;break;case j.invalid_union:r="Invalid input";break;case j.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Re.joinValues(t.options)}`;break;case j.invalid_enum_value:r=`Invalid enum value. Expected ${Re.joinValues(t.options)}, received '${t.received}'`;break;case j.invalid_arguments:r="Invalid function arguments";break;case j.invalid_return_type:r="Invalid function return type";break;case j.invalid_date:r="Invalid date";break;case j.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Re.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case j.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case j.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case j.custom:r="Invalid input";break;case j.invalid_intersection_types:r="Intersection results could not be merged";break;case j.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case j.not_finite:r="Number must be finite";break;default:r=e.defaultError,Re.assertNever(t)}return{message:r}},"errorMap"),Zt=Fx;var cg=Zt;function Bx(t){cg=t}i(Bx,"setErrorMap");function rn(){return cg}i(rn,"getErrorMap");var ro=i(t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let u="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)u=l(a,{data:e,defaultError:u}).message;return{...o,path:s,message:u}},"makeIssue"),Vx=[];function ee(t,e){let r=rn(),n=ro({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Zt?void 0:Zt].filter(o=>!!o)});t.common.issues.push(n)}i(ee,"addIssueToContext");var He=class t{static{i(this,"ParseStatus")}constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return ce;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return ce;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}},ce=Object.freeze({status:"aborted"}),wr=i(t=>({status:"dirty",value:t}),"DIRTY"),Be=i(t=>({status:"valid",value:t}),"OK"),Vi=i(t=>t.status==="aborted","isAborted"),Gi=i(t=>t.status==="dirty","isDirty"),sr=i(t=>t.status==="valid","isValid"),nn=i(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync");var se;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(se||(se={}));var Wi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},pg=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},no,oo,pt=class{static{i(this,"ParseInputLazyPath")}constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},lg=i((t,e)=>{if(sr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Qe(t.common.issues);return this._error=r,this._error}}},"handleResult");function he(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:i((a,u)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??u.defaultError}:typeof u.data>"u"?{message:c??n??u.defaultError}:a.code!=="invalid_type"?{message:u.defaultError}:{message:c??r??u.defaultError}},"customMap"),description:o}}i(he,"processCreateParams");var ve=class{static{i(this,"ZodType")}get description(){return this._def.description}_getType(e){return St(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:St(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new He,ctx:{common:e.parent.common,data:e.data,parsedType:St(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(nn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)},o=this._parseSync({data:e,path:n.path,parent:n});return lg(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return sr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>sr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(nn(o)?o:Promise.resolve(o));return lg(n,s)}refine(e,r){let n=i(o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r,"getIssueProperties");return this._refinement((o,s)=>{let a=e(o),u=i(()=>s.addIssue({code:j.custom,...n(o)}),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(u(),!1)):a?!0:(u(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new mt({schema:this,typeName:le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:i(r=>this["~validate"](r),"validate")}}optional(){return dt.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Mt.create(this)}promise(){return cr.create(this,this._def)}or(e){return kr.create([this,e],this._def)}and(e){return Er.create(this,e,this._def)}transform(e){return new mt({...he(this._def),schema:this,typeName:le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ar({...he(this._def),innerType:this,defaultValue:r,typeName:le.ZodDefault})}brand(){return new io({typeName:le.ZodBranded,type:this,...he(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Nr({...he(this._def),innerType:this,catchValue:r,typeName:le.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return so.create(this,e)}readonly(){return Lr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Gx=/^c[^\s-]{8,}$/i,Wx=/^[0-9a-z]+$/,Jx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Kx=/^[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,Qx=/^[a-z0-9_-]{21}$/i,Xx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yx=/^[-+]?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)?)??$/,eR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pu,rR=/^(?:(?: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])$/,nR=/^(?:(?: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])$/,oR=/^(([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]))$/,iR=/^(([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])$/,sR=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,aR=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mg="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",uR=new RegExp(`^${mg}$`);function fg(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}i(fg,"timeRegexSource");function cR(t){return new RegExp(`^${fg(t)}$`)}i(cR,"timeRegex");function hg(t){let e=`${mg}T${fg(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}i(hg,"datetimeRegex");function lR(t,e){return!!((e==="v4"||!e)&&rR.test(t)||(e==="v6"||!e)&&oR.test(t))}i(lR,"isValidIP");function dR(t,e){if(!Xx.test(t))return!1;try{let[r]=t.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}i(dR,"isValidJWT");function pR(t,e){return!!((e==="v4"||!e)&&nR.test(t)||(e==="v6"||!e)&&iR.test(t))}i(pR,"isValidCidr");var ar=class t extends ve{static{i(this,"ZodString")}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==re.string){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.string,received:s.parsedType}),ce}let n=new He,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,u=e.data.length<s.value;(a||u)&&(o=this._getOrReturnCtx(e,o),a?ee(o,{code:j.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&ee(o,{code:j.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")eR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"email",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Pu||(Pu=new RegExp(tR,"u")),Pu.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"emoji",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Kx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"uuid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Qx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"nanoid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Gx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cuid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Wx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cuid2",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Jx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"ulid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),ee(o,{validation:"url",code:j.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"regex",code:j.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?hg(s).test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?uR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?cR(s).test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Yx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"duration",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?lR(e.data,s.version)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"ip",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?dR(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"jwt",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?pR(e.data,s.version)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cidr",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?sR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"base64",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?aR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"base64url",code:j.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:j.invalid_string,...se.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...se.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...se.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...se.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...se.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...se.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...se.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...se.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...se.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...se.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...se.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...se.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...se.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...se.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...se.errToObj(r)})}nonempty(e){return this.min(1,se.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ar.create=t=>new ar({checks:[],typeName:le.ZodString,coerce:t?.coerce??!1,...he(t)});function mR(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}i(mR,"floatSafeRemainder");var xr=class t extends ve{static{i(this,"ZodNumber")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==re.number){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.number,received:s.parsedType}),ce}let n,o=new He;for(let s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ee(n,{code:j.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?mR(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_finite,message:s.message}),o.dirty()):Re.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,se.toString(r))}gt(e,r){return this.setLimit("min",e,!1,se.toString(r))}lte(e,r){return this.setLimit("max",e,!0,se.toString(r))}lt(e,r){return this.setLimit("max",e,!1,se.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:se.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:se.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:se.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:se.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Re.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};xr.create=t=>new xr({checks:[],typeName:le.ZodNumber,coerce:t?.coerce||!1,...he(t)});var Rr=class t extends ve{static{i(this,"ZodBigInt")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==re.bigint)return this._getInvalidInput(e);let n,o=new He;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):Re.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return ee(r,{code:j.invalid_type,expected:re.bigint,received:r.parsedType}),ce}gte(e,r){return this.setLimit("min",e,!0,se.toString(r))}gt(e,r){return this.setLimit("min",e,!1,se.toString(r))}lte(e,r){return this.setLimit("max",e,!0,se.toString(r))}lt(e,r){return this.setLimit("max",e,!1,se.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:se.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:se.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:se.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Rr.create=t=>new Rr({checks:[],typeName:le.ZodBigInt,coerce:t?.coerce??!1,...he(t)});var _r=class extends ve{static{i(this,"ZodBoolean")}_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==re.boolean){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.boolean,received:n.parsedType}),ce}return Be(e.data)}};_r.create=t=>new _r({typeName:le.ZodBoolean,coerce:t?.coerce||!1,...he(t)});var Pr=class t extends ve{static{i(this,"ZodDate")}_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==re.date){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.date,received:s.parsedType}),ce}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_date}),ce}let n=new He,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:se.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:se.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Pr.create=t=>new Pr({checks:[],coerce:t?.coerce||!1,typeName:le.ZodDate,...he(t)});var sn=class extends ve{static{i(this,"ZodSymbol")}_parse(e){if(this._getType(e)!==re.symbol){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.symbol,received:n.parsedType}),ce}return Be(e.data)}};sn.create=t=>new sn({typeName:le.ZodSymbol,...he(t)});var Ir=class extends ve{static{i(this,"ZodUndefined")}_parse(e){if(this._getType(e)!==re.undefined){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.undefined,received:n.parsedType}),ce}return Be(e.data)}};Ir.create=t=>new Ir({typeName:le.ZodUndefined,...he(t)});var Sr=class extends ve{static{i(this,"ZodNull")}_parse(e){if(this._getType(e)!==re.null){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.null,received:n.parsedType}),ce}return Be(e.data)}};Sr.create=t=>new Sr({typeName:le.ZodNull,...he(t)});var ur=class extends ve{static{i(this,"ZodAny")}constructor(){super(...arguments),this._any=!0}_parse(e){return Be(e.data)}};ur.create=t=>new ur({typeName:le.ZodAny,...he(t)});var jt=class extends ve{static{i(this,"ZodUnknown")}constructor(){super(...arguments),this._unknown=!0}_parse(e){return Be(e.data)}};jt.create=t=>new jt({typeName:le.ZodUnknown,...he(t)});var yt=class extends ve{static{i(this,"ZodNever")}_parse(e){let r=this._getOrReturnCtx(e);return ee(r,{code:j.invalid_type,expected:re.never,received:r.parsedType}),ce}};yt.create=t=>new yt({typeName:le.ZodNever,...he(t)});var an=class extends ve{static{i(this,"ZodVoid")}_parse(e){if(this._getType(e)!==re.undefined){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.void,received:n.parsedType}),ce}return Be(e.data)}};an.create=t=>new an({typeName:le.ZodVoid,...he(t)});var Mt=class t extends ve{static{i(this,"ZodArray")}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==re.array)return ee(r,{code:j.invalid_type,expected:re.array,received:r.parsedType}),ce;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,u=r.data.length<o.exactLength.value;(a||u)&&(ee(r,{code:a?j.too_big:j.too_small,minimum:u?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(ee(r,{code:j.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(ee(r,{code:j.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,u)=>o.type._parseAsync(new pt(r,a,r.path,u)))).then(a=>He.mergeArray(n,a));let s=[...r.data].map((a,u)=>o.type._parseSync(new pt(r,a,r.path,u)));return He.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:se.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:se.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:se.toString(r)}})}nonempty(e){return this.min(1,e)}};Mt.create=(t,e)=>new Mt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:le.ZodArray,...he(e)});function on(t){if(t instanceof Xe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=dt.create(on(n))}return new Xe({...t._def,shape:i(()=>e,"shape")})}else return t instanceof Mt?new Mt({...t._def,type:on(t.element)}):t instanceof dt?dt.create(on(t.unwrap())):t instanceof Et?Et.create(on(t.unwrap())):t instanceof kt?kt.create(t.items.map(e=>on(e))):t}i(on,"deepPartialify");var Xe=class t extends ve{static{i(this,"ZodObject")}constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Re.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==re.object){let l=this._getOrReturnCtx(e);return ee(l,{code:j.invalid_type,expected:re.object,received:l.parsedType}),ce}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),u=[];if(!(this._def.catchall instanceof yt&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||u.push(l);let c=[];for(let l of a){let d=s[l],p=o.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new pt(o,p,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof yt){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of u)c.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")u.length>0&&(ee(o,{code:j.unrecognized_keys,keys:u}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of u){let p=o.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new pt(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of c){let p=await d.key,m=await d.value;l.push({key:p,value:m,alwaysSet:d.alwaysSet})}return l}).then(l=>He.mergeObjectSync(n,l)):He.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return se.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:i((r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:se.errToObj(e).message??o}:{message:o}},"errorMap")}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:i(()=>({...this._def.shape(),...e}),"shape")})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:i(()=>({...this._def.shape(),...e._def.shape()}),"shape"),typeName:le.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Re.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:i(()=>r,"shape")})}omit(e){let r={};for(let n of Re.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:i(()=>r,"shape")})}deepPartial(){return on(this)}partial(e){let r={};for(let n of Re.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:i(()=>r,"shape")})}required(e){let r={};for(let n of Re.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof dt;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:i(()=>r,"shape")})}keyof(){return gg(Re.objectKeys(this.shape))}};Xe.create=(t,e)=>new Xe({shape:i(()=>t,"shape"),unknownKeys:"strip",catchall:yt.create(),typeName:le.ZodObject,...he(e)});Xe.strictCreate=(t,e)=>new Xe({shape:i(()=>t,"shape"),unknownKeys:"strict",catchall:yt.create(),typeName:le.ZodObject,...he(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:yt.create(),typeName:le.ZodObject,...he(e)});var kr=class extends ve{static{i(this,"ZodUnion")}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;let a=s.map(u=>new Qe(u.ctx.common.issues));return ee(r,{code:j.invalid_union,unionErrors:a}),ce}if(i(o,"handleResults"),r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},d=c._parseSync({data:r.data,path:r.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let u=a.map(c=>new Qe(c));return ee(r,{code:j.invalid_union,unionErrors:u}),ce}}get options(){return this._def.options}};kr.create=(t,e)=>new kr({options:t,typeName:le.ZodUnion,...he(e)});var Ut=i(t=>t instanceof Tr?Ut(t.schema):t instanceof mt?Ut(t.innerType()):t instanceof $r?[t.value]:t instanceof Or?t.options:t instanceof Cr?Re.objectValues(t.enum):t instanceof Ar?Ut(t._def.innerType):t instanceof Ir?[void 0]:t instanceof Sr?[null]:t instanceof dt?[void 0,...Ut(t.unwrap())]:t instanceof Et?[null,...Ut(t.unwrap())]:t instanceof io||t instanceof Lr?Ut(t.unwrap()):t instanceof Nr?Ut(t._def.innerType):[],"getDiscriminator"),Ji=class t extends ve{static{i(this,"ZodDiscriminatedUnion")}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.object)return ee(r,{code:j.invalid_type,expected:re.object,received:r.parsedType}),ce;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(ee(r,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let a=Ut(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of a){if(o.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);o.set(u,s)}}return new t({typeName:le.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...he(n)})}};function Iu(t,e){let r=St(t),n=St(e);if(t===e)return{valid:!0,data:t};if(r===re.object&&n===re.object){let o=Re.objectKeys(e),s=Re.objectKeys(t).filter(u=>o.indexOf(u)!==-1),a={...t,...e};for(let u of s){let c=Iu(t[u],e[u]);if(!c.valid)return{valid:!1};a[u]=c.data}return{valid:!0,data:a}}else if(r===re.array&&n===re.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let a=t[s],u=e[s],c=Iu(a,u);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===re.date&&n===re.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}i(Iu,"mergeValues");var Er=class extends ve{static{i(this,"ZodIntersection")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=i((s,a)=>{if(Vi(s)||Vi(a))return ce;let u=Iu(s.value,a.value);return u.valid?((Gi(s)||Gi(a))&&r.dirty(),{status:r.value,value:u.data}):(ee(n,{code:j.invalid_intersection_types}),ce)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Er.create=(t,e,r)=>new Er({left:t,right:e,typeName:le.ZodIntersection,...he(r)});var kt=class t extends ve{static{i(this,"ZodTuple")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.array)return ee(n,{code:j.invalid_type,expected:re.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return ee(n,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(ee(n,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((a,u)=>{let c=this._def.items[u]||this._def.rest;return c?c._parse(new pt(n,a,n.path,u)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>He.mergeArray(r,a)):He.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};kt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kt({items:t,typeName:le.ZodTuple,rest:null,...he(e)})};var Ki=class t extends ve{static{i(this,"ZodRecord")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.object)return ee(n,{code:j.invalid_type,expected:re.object,received:n.parsedType}),ce;let o=[],s=this._def.keyType,a=this._def.valueType;for(let u in n.data)o.push({key:s._parse(new pt(n,u,n.path,u)),value:a._parse(new pt(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?He.mergeObjectAsync(r,o):He.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ve?new t({keyType:e,valueType:r,typeName:le.ZodRecord,...he(n)}):new t({keyType:ar.create(),valueType:e,typeName:le.ZodRecord,...he(r)})}},un=class extends ve{static{i(this,"ZodMap")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.map)return ee(n,{code:j.invalid_type,expected:re.map,received:n.parsedType}),ce;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([u,c],l)=>({key:o._parse(new pt(n,u,n.path,[l,"key"])),value:s._parse(new pt(n,c,n.path,[l,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return ce;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),u.set(l.value,d.value)}return{status:r.value,value:u}})}else{let u=new Map;for(let c of a){let l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return ce;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),u.set(l.value,d.value)}return{status:r.value,value:u}}}};un.create=(t,e,r)=>new un({valueType:e,keyType:t,typeName:le.ZodMap,...he(r)});var cn=class t extends ve{static{i(this,"ZodSet")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.set)return ee(n,{code:j.invalid_type,expected:re.set,received:n.parsedType}),ce;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(ee(n,{code:j.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(ee(n,{code:j.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(c){let l=new Set;for(let d of c){if(d.status==="aborted")return ce;d.status==="dirty"&&r.dirty(),l.add(d.value)}return{status:r.value,value:l}}i(a,"finalizeSet");let u=[...n.data.values()].map((c,l)=>s._parse(new pt(n,c,n.path,l)));return n.common.async?Promise.all(u).then(c=>a(c)):a(u)}min(e,r){return new t({...this._def,minSize:{value:e,message:se.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:se.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};cn.create=(t,e)=>new cn({valueType:t,minSize:null,maxSize:null,typeName:le.ZodSet,...he(e)});var Qi=class t extends ve{static{i(this,"ZodFunction")}constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.function)return ee(r,{code:j.invalid_type,expected:re.function,received:r.parsedType}),ce;function n(u,c){return ro({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rn(),Zt].filter(l=>!!l),issueData:{code:j.invalid_arguments,argumentsError:c}})}i(n,"makeArgsIssue");function o(u,c){return ro({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rn(),Zt].filter(l=>!!l),issueData:{code:j.invalid_return_type,returnTypeError:c}})}i(o,"makeReturnsIssue");let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof cr){let u=this;return Be(async function(...c){let l=new Qe([]),d=await u._def.args.parseAsync(c,s).catch(f=>{throw l.addIssue(n(c,f)),l}),p=await Reflect.apply(a,this,d);return await u._def.returns._def.type.parseAsync(p,s).catch(f=>{throw l.addIssue(o(p,f)),l})})}else{let u=this;return Be(function(...c){let l=u._def.args.safeParse(c,s);if(!l.success)throw new Qe([n(c,l.error)]);let d=Reflect.apply(a,this,l.data),p=u._def.returns.safeParse(d,s);if(!p.success)throw new Qe([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:kt.create(e).rest(jt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||kt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:le.ZodFunction,...he(n)})}},Tr=class extends ve{static{i(this,"ZodLazy")}get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Tr.create=(t,e)=>new Tr({getter:t,typeName:le.ZodLazy,...he(e)});var $r=class extends ve{static{i(this,"ZodLiteral")}_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return ee(r,{received:r.data,code:j.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}};$r.create=(t,e)=>new $r({value:t,typeName:le.ZodLiteral,...he(e)});function gg(t,e){return new Or({values:t,typeName:le.ZodEnum,...he(e)})}i(gg,"createZodEnum");var Or=class t extends ve{static{i(this,"ZodEnum")}constructor(){super(...arguments),no.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return ee(r,{expected:Re.joinValues(n),received:r.parsedType,code:j.invalid_type}),ce}if(Wi(this,no,"f")||pg(this,no,new Set(this._def.values),"f"),!Wi(this,no,"f").has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return ee(r,{received:r.data,code:j.invalid_enum_value,options:n}),ce}return Be(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};no=new WeakMap;Or.create=gg;var Cr=class extends ve{static{i(this,"ZodNativeEnum")}constructor(){super(...arguments),oo.set(this,void 0)}_parse(e){let r=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==re.string&&n.parsedType!==re.number){let o=Re.objectValues(r);return ee(n,{expected:Re.joinValues(o),received:n.parsedType,code:j.invalid_type}),ce}if(Wi(this,oo,"f")||pg(this,oo,new Set(Re.getValidEnumValues(this._def.values)),"f"),!Wi(this,oo,"f").has(e.data)){let o=Re.objectValues(r);return ee(n,{received:n.data,code:j.invalid_enum_value,options:o}),ce}return Be(e.data)}get enum(){return this._def.values}};oo=new WeakMap;Cr.create=(t,e)=>new Cr({values:t,typeName:le.ZodNativeEnum,...he(e)});var cr=class extends ve{static{i(this,"ZodPromise")}unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.promise&&r.common.async===!1)return ee(r,{code:j.invalid_type,expected:re.promise,received:r.parsedType}),ce;let n=r.parsedType===re.promise?r.data:Promise.resolve(r.data);return Be(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};cr.create=(t,e)=>new cr({type:t,typeName:le.ZodPromise,...he(e)});var mt=class extends ve{static{i(this,"ZodEffects")}innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i(a=>{ee(n,a),a.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async u=>{if(r.value==="aborted")return ce;let c=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"?wr(c.value):r.value==="dirty"?wr(c.value):c});{if(r.value==="aborted")return ce;let u=this._def.schema._parseSync({data:a,path:n.path,parent:n});return u.status==="aborted"?ce:u.status==="dirty"?wr(u.value):r.value==="dirty"?wr(u.value):u}}if(o.type==="refinement"){let a=i(u=>{let c=o.refinement(u,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?ce:(u.status==="dirty"&&r.dirty(),a(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?ce:(u.status==="dirty"&&r.dirty(),a(u.value).then(()=>({status:r.value,value:u.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sr(a))return a;let u=o.transform(a.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>sr(a)?Promise.resolve(o.transform(a.value,s)).then(u=>({status:r.value,value:u})):a);Re.assertNever(o)}};mt.create=(t,e,r)=>new mt({schema:t,typeName:le.ZodEffects,effect:e,...he(r)});mt.createWithPreprocess=(t,e,r)=>new mt({schema:e,effect:{type:"preprocess",transform:t},typeName:le.ZodEffects,...he(r)});var dt=class extends ve{static{i(this,"ZodOptional")}_parse(e){return this._getType(e)===re.undefined?Be(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dt.create=(t,e)=>new dt({innerType:t,typeName:le.ZodOptional,...he(e)});var Et=class extends ve{static{i(this,"ZodNullable")}_parse(e){return this._getType(e)===re.null?Be(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:le.ZodNullable,...he(e)});var Ar=class extends ve{static{i(this,"ZodDefault")}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===re.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ar.create=(t,e)=>new Ar({innerType:t,typeName:le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...he(e)});var Nr=class extends ve{static{i(this,"ZodCatch")}_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return nn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qe(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Qe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Nr.create=(t,e)=>new Nr({innerType:t,typeName:le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...he(e)});var ln=class extends ve{static{i(this,"ZodNaN")}_parse(e){if(this._getType(e)!==re.nan){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.nan,received:n.parsedType}),ce}return{status:"valid",value:e.data}}};ln.create=t=>new ln({typeName:le.ZodNaN,...he(t)});var fR=Symbol("zod_brand"),io=class extends ve{static{i(this,"ZodBranded")}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},so=class t extends ve{static{i(this,"ZodPipeline")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return i(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(r.dirty(),wr(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:le.ZodPipeline})}},Lr=class extends ve{static{i(this,"ZodReadonly")}_parse(e){let r=this._def.innerType._parse(e),n=i(o=>(sr(o)&&(o.value=Object.freeze(o.value)),o),"freeze");return nn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Lr.create=(t,e)=>new Lr({innerType:t,typeName:le.ZodReadonly,...he(e)});function dg(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}i(dg,"cleanParams");function yg(t,e={},r){return t?ur.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(a=>{if(!a){let u=dg(e,n),c=u.fatal??r??!0;o.addIssue({code:"custom",...u,fatal:c})}});if(!s){let a=dg(e,n),u=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:u})}}):ur.create()}i(yg,"custom");var hR={object:Xe.lazycreate},le;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(le||(le={}));var gR=i((t,e={message:`Input not instance of ${t.name}`})=>yg(r=>r instanceof t,e),"instanceOfType"),bg=ar.create,vg=xr.create,yR=ln.create,bR=Rr.create,wg=_r.create,vR=Pr.create,wR=sn.create,xR=Ir.create,RR=Sr.create,_R=ur.create,PR=jt.create,IR=yt.create,SR=an.create,kR=Mt.create,ER=Xe.create,TR=Xe.strictCreate,$R=kr.create,OR=Ji.create,CR=Er.create,AR=kt.create,NR=Ki.create,LR=un.create,zR=cn.create,DR=Qi.create,ZR=Tr.create,UR=$r.create,jR=Or.create,MR=Cr.create,qR=cr.create,HR=mt.create,FR=dt.create,BR=Et.create,VR=mt.createWithPreprocess,GR=so.create,WR=i(()=>bg().optional(),"ostring"),JR=i(()=>vg().optional(),"onumber"),KR=i(()=>wg().optional(),"oboolean"),QR={string:i(t=>ar.create({...t,coerce:!0}),"string"),number:i(t=>xr.create({...t,coerce:!0}),"number"),boolean:i(t=>_r.create({...t,coerce:!0}),"boolean"),bigint:i(t=>Rr.create({...t,coerce:!0}),"bigint"),date:i(t=>Pr.create({...t,coerce:!0}),"date")};var XR=ce;var lr="2.0",xg;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(xg||(xg={}));var dn=T.union([T.string(),T.number().int()]);var YR=T.object({jsonrpc:T.literal(lr),id:dn,error:T.object({code:T.number().int(),message:T.string(),data:T.optional(T.unknown())})}).strict();var Su=T.object({_meta:T.optional(T.object({}).passthrough())}).passthrough(),pn=T.object({method:T.string(),params:T.optional(Su)}),Rg=T.object({jsonrpc:T.literal(lr)}).merge(pn).strict();var e_=T.union([T.string(),T.number().int()]),t_=T.object({progressToken:T.optional(e_)}).passthrough(),qt=T.object({_meta:T.optional(t_)}).passthrough(),Ht=T.object({method:T.string(),params:T.optional(qt)}),_g=T.object({jsonrpc:T.literal(lr),id:dn}).merge(Ht).strict();var Ft=T.object({_meta:T.optional(T.object({}).passthrough())}).passthrough(),TU=Ft.strict(),Pg=T.object({jsonrpc:T.literal(lr),id:dn,result:Ft}).strict();var ao=i(t=>_g.safeParse(t).success,"isJSONRPCRequest"),Ig=i(t=>Rg.safeParse(t).success,"isJSONRPCNotification"),Xi=i(t=>Pg.safeParse(t).success,"isJSONRPCResponse");var uo=class{static{i(this,"NoOpLogger")}debug(){}info(){}warn(){}error(){}};function Yi(){return new uo}i(Yi,"createDefaultLogger");var ku=T.string();var co=Ht.extend({params:qt.extend({cursor:T.optional(ku)}).optional()}),lo=Ft.extend({nextCursor:T.optional(ku)});var Sg=T.object({uri:T.string(),mimeType:T.optional(T.string())}).passthrough(),Eu=Sg.extend({text:T.string()}),Tu=Sg.extend({blob:T.string().base64()}),r_=T.object({uri:T.string(),name:T.string(),description:T.optional(T.string()),mimeType:T.optional(T.string())}).passthrough(),n_=T.object({uriTemplate:T.string(),name:T.string(),description:T.optional(T.string()),mimeType:T.optional(T.string())}).passthrough(),QU=co.extend({method:T.literal("resources/list")}),XU=lo.extend({resources:T.array(r_)}),YU=co.extend({method:T.literal("resources/templates/list")}),ej=lo.extend({resourceTemplates:T.array(n_)}),tj=Ht.extend({method:T.literal("resources/read"),params:qt.extend({uri:T.string()})}),rj=Ft.extend({contents:T.array(T.union([Eu,Tu]))}),nj=pn.extend({method:T.literal("notifications/resources/list_changed")}),oj=Ht.extend({method:T.literal("resources/subscribe"),params:qt.extend({uri:T.string()})}),ij=Ht.extend({method:T.literal("resources/unsubscribe"),params:qt.extend({uri:T.string()})}),sj=pn.extend({method:T.literal("notifications/resources/updated"),params:Su.extend({uri:T.string()})});var kg=T.object({type:T.literal("text"),text:T.string()}).passthrough(),Eg=T.object({type:T.literal("image"),data:T.string().base64(),mimeType:T.string()}).passthrough(),Tg=T.object({type:T.literal("audio"),data:T.string().base64(),mimeType:T.string()}).passthrough(),$g=T.object({type:T.literal("resource"),resource:T.union([Eu,Tu])}).passthrough();var o_=T.object({title:T.optional(T.string()),readOnlyHint:T.optional(T.boolean()),destructiveHint:T.optional(T.boolean()),idempotentHint:T.optional(T.boolean()),openWorldHint:T.optional(T.boolean())}).passthrough(),i_=T.object({name:T.string(),description:T.optional(T.string()),inputSchema:T.object({type:T.literal("object"),properties:T.optional(T.object({}).passthrough())}).passthrough(),annotations:T.optional(o_)}).passthrough(),yj=co.extend({method:T.literal("tools/list")}),bj=lo.extend({tools:T.array(i_)}),s_=Ft.extend({content:T.array(T.union([kg,Eg,Tg,$g])),isError:T.boolean().default(!1).optional()}),vj=s_.or(Ft.extend({toolResult:T.unknown()})),Og=Ht.extend({method:T.literal("tools/call"),params:qt.extend({name:T.string(),arguments:T.optional(T.record(T.unknown()))})}),wj=pn.extend({method:T.literal("notifications/tools/list_changed")});var Cg="2025-03-26";var es=class{static{i(this,"MCPServer")}capabilities;tools=new Map;name;version;instructions;logger;constructor(e){this.name=e.name||"MCP Server",this.version=e.version||"1.0.0",this.instructions=e.instructions||void 0,this.logger=e.logger||Yi(),this.capabilities={tools:{supported:!0,available:[]},...e.capabilities}}withTransport(e){e.onMessage(async r=>{try{if(ao(r)){let n=await this.handleRequest(r);if(n)return await e.send(n),n}else{if(Ig(r))return await this.handleNotification(r),null;if(Xi(r))return this.logger.debug("Received response:",r),null}}catch(n){if(this.logger.error("Error processing message:",n),ao(r)){let o={jsonrpc:"2.0",id:r.id,error:{code:-32603,message:n instanceof Error?n.message:"Internal error"}};return await e.send(o),o}}return null})}getTool(e){throw new Error("Method not implemented.")}getTools(){throw new Error("Method not implemented.")}getCapabilities(){return{...this.capabilities}}addTool(e){let{name:r,validator:n,handler:o,description:s=`Execute the ${r} tool`}=e,u={tool:{name:r,description:s,inputSchema:n.jsonSchema},validator:n,handler:o};this.tools.set(r,u),this.updateAvailableTools()}removeTool(e){let r=this.tools.delete(e);return r&&this.updateAvailableTools(),r}getToolDefinitions(){return Array.from(this.tools.values()).map(e=>e.tool)}async handleRequest(e){try{switch(e.method){case"ping":return this.handlePing(e);case"initialize":return this.handleInitialize(e);case"tools/list":return this.handleToolListRequest(e);case"tools/call":return this.handleToolCallRequest(e);default:return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Method "${e.method}" not found`}}}}catch(r){return this.logger.error("Error handling request:",r),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Internal error"}}}}async handleNotification(e){this.logger.debug("Received notification:",e.method)}handlePing(e){return{jsonrpc:"2.0",id:e.id,result:{}}}handleInitialize(e){let r={protocolVersion:Cg,capabilities:this.getCapabilities(),serverInfo:{name:this.name,version:this.version},...this.instructions?{instructions:this.instructions}:{}};return{jsonrpc:"2.0",id:e.id,result:r}}async handleToolListRequest(e){let n={tools:Array.from(this.tools.entries()).map(([o,s])=>s.tool)};return{jsonrpc:"2.0",id:e.id,result:n}}async handleToolCallRequest(e){let r=Og.safeParse(e);if(!r.success)return this.logger.warn("Could not validate tool call:",r.error),{jsonrpc:"2.0",id:e.id,error:{code:-32600,message:`Invalid request ${r.error}`}};let n=r.data,o=n.params.name,s=this.tools.get(o);if(!s)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Tool "${o}" not found`}};let a=n.params.arguments??{},u=s.validator.parse(a);if(!u.success)return{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid params",data:u.error}};try{let c=u.data,l=await s.handler(c);return{jsonrpc:"2.0",id:e.id,result:l}}catch(c){return this.logger.error(`Error executing tool "${o}":`,c),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:c instanceof Error?c.message:"Tool execution error"}}}}updateAvailableTools(){this.capabilities.tools&&(this.capabilities.tools.available=Array.from(this.tools.keys()))}};var ts=class{static{i(this,"HTTPStreamableTransport")}messageHandler=null;closeCallback=null;options;connected=!1;enableStreaming=!1;sessions=new Map;streams=new Map;logger;constructor(e={},r=!1){this.options={timeout:30*60*1e3,enableSessions:!1,...e},this.logger=e.logger||Yi(),r&&this.startSessionCleanup()}onError(e){throw new Error("Method not implemented.")}getSessionId(){throw new Error("Method not implemented.")}setSessionId(e){throw new Error("Method not implemented.")}async connect(){this.connected=!0}async send(e){if(!this.connected)throw new Error("Transport not connected");if(Xi(e)){for(let[r,n]of this.sessions.entries())for(let[o,s]of n.streams.entries())if(s.pendingRequests.has(e.id)){await this.sendToStream(s,e),s.pendingRequests.delete(e.id),s.pendingRequests.size===0&&await this.closeStream(r,o);return}}else for(let r of this.sessions.values()){let n=[...r.streams.values()][0];n&&(await this.sendToStream(n,e),ao(e)&&n.pendingRequests.add(e.id))}}onMessage(e){this.messageHandler=e}onClose(e){this.closeCallback=e}async close(){this.connected=!1;for(let e of this.sessions.values()){for(let[r,n]of e.streams.entries())try{await n.writer.close()}catch(o){this.logger.warn("Error closing stream:",o)}e.streams.clear()}this.sessions.clear(),this.closeCallback&&this.closeCallback()}async handleRequest(e){if(!this.connected)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Transport not connected"},id:null}),{status:503,headers:{"Content-Type":"application/json"}});if(!this.messageHandler)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"No message handler registered"},id:null}),{status:500,headers:{"Content-Type":"application/json"}});let r=e.method.toUpperCase();try{this.validateOrigin(e);let n=e.headers.get("Mcp-Session-Id"),o;if(n&&(o=this.sessions.get(n),!o&&r!=="DELETE"))return new Response(null,{status:404});switch(r){case"POST":return await this.handlePostRequest(e,o);case"GET":return await this.handleGetRequest(e,o);case"DELETE":return await this.handleDeleteRequest(e,o?.id);default:return new Response(null,{status:405,headers:{Allow:"POST, GET, DELETE"}})}}catch(n){this.logger.error("Error handling request:",n);let o=400,s={jsonrpc:"2.0",error:{code:-32603,message:n||"Server error"},id:null};return new Response(JSON.stringify(s),{status:o,headers:{"Content-Type":"application/json"}})}}async handlePostRequest(e,r){let n=e.headers.get("Accept")||"";if(!n.includes("application/json")&&!n.includes("text/event-stream"))return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32600,message:"Not Acceptable: Client must accept application/json and text/event-stream"},id:null}),{status:406,headers:{"Content-Type":"application/json"}});let o=await this.extractJSONRPC(e);if(!o||Array.isArray(o)&&o.length===0)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null}),{status:400,headers:{"Content-Type":"application/json"}});let s=Array.isArray(o)?o:[o],a=s.some(c=>this.isRequest(c)),u=r;if(this.options.enableSessions&&!u&&s.some(c=>this.isRequest(c)&&c.method==="initialize")){let c=this.generateFallbackUUID();u=this.createSession(c)}try{if(!a){for(let m of s)await this.messageHandler?.(m);return new Response(null,{status:202,headers:u?{"Mcp-Session-Id":u.id}:void 0})}if(!this.enableStreaming){let m=[];for(let y of s)if(this.isRequest(y)){let w=await this.messageHandler?.(y);w&&m.push(w)}else await this.messageHandler?.(y);let f=m.length===1?m[0]:m,h={"Content-Type":"application/json"};return u&&(h["Mcp-Session-Id"]=u.id),new Response(JSON.stringify(f),{status:200,headers:h})}let{stream:c,streamId:l}=this.createStream(u),d=[];for(let m of s)if(this.isRequest(m)){this.streams.get(l)?.pendingRequests.add(m.id);let f=this.messageHandler?.(m);d.push(f)}else await this.messageHandler?.(m);let p={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};return u&&(p["Mcp-Session-Id"]=u.id),new Response(c.readable,{headers:p})}catch(c){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:c||"Internal error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}})}}async handleGetRequest(e,r){if(!(e.headers.get("Accept")||"").includes("text/event-stream"))return new Response(null,{status:406,headers:{"Content-Type":"application/json"}});if(this.options.enableSessions&&!r)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Session required"},id:null}),{status:400,headers:{"Content-Type":"application/json"}});let{stream:o,streamId:s}=this.createStream(r),a=e.headers.get("Last-Event-ID");a&&r&&await this.replayMessages(r,s,a);let u={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};return r&&(u["Mcp-Session-Id"]=r.id),new Response(o.readable,{headers:u})}async handleDeleteRequest(e,r){if(!r)return new Response(null,{status:400});if(this.options.enableSessions&&r){let n=this.sessions.get(r);if(n){for(let[o,s]of n.streams.entries())await this.closeStream(r,o);return this.sessions.delete(r),new Response(null,{status:204})}}return new Response(null,{status:404})}async sendToStream(e,r){try{let n=String(++e.eventCounter),o=JSON.stringify(r);e.messages.push(r),e.messages.length>100&&e.messages.shift();let s=`id: ${n}
|
|
59
|
+
`)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256");if(e==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new U("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=yu(await Xh(this.body||""))}return e}};async function to(t,e){let r=await crypto.subtle.importKey("raw",typeof t=="string"?bu.encode(t):t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",r,bu.encode(e))}i(to,"hmac");async function Xh(t){return crypto.subtle.digest("SHA-256",typeof t=="string"?bu.encode(t):t)}i(Xh,"hash");function yu(t){return Array.prototype.map.call(new Uint8Array(t),e=>("0"+e.toString(16)).slice(-2)).join("")}i(yu,"buf2hex");function Yh(t){return t.replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}i(Yh,"encodeRfc3986");function hx(t,e){let{hostname:r,pathname:n}=t,o=r.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[s,a]=(o||["",""]).slice(1,3);if(a==="us-gov")a="us-gov-west-1";else if(a==="s3"||a==="s3-accelerate")a="us-east-1",s="s3";else if(s==="iot")r.startsWith("iot.")?s="execute-api":r.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=n==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){let u=(e.get("X-Amz-Target")||"").split(".")[0];u==="AnyScaleFrontendService"?s="application-autoscaling":u==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else a==null&&s.startsWith("s3-")?(a=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):a&&/-\d$/.test(s)&&!/-\d$/.test(a)&&([s,a]=[a,s]);return s in Qh?[Qh[s],a]:[s,a]}i(hx,"guessServiceRegion");function gx(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:t===43?62:t===47?63:0}i(gx,"b64ToUint6");function eg(t,e){let r=t.replace(/[^A-Za-z0-9+/]/g,""),n=r.length,o=e?Math.ceil((n*3+1>>2)/e)*e:n*3+1>>2,s=new Uint8Array(o),a,u,c=0,l=0;for(let d=0;d<n;d++)if(u=d&3,c|=gx(r.charCodeAt(d))<<6*(3-u),u===3||n-d===1){for(a=0;a<3&&l<o;)s[l]=c>>>(16>>>a&24)&255,a++,l++;c=0}return s}i(eg,"base64Decode");function Bi(t){return t<26?t+65:t<52?t+71:t<62?t-4:t===62?43:t===63?47:65}i(Bi,"uint6ToB64");function tg(t){let e=2,r="",n=t.length,o=0;for(let s=0;s<n;s++)e=s%3,o|=t[s]<<(16>>>e&24),(e===2||t.length-s===1)&&(r+=String.fromCodePoint(Bi(o>>>18&63),Bi(o>>>12&63),Bi(o>>>6&63),Bi(o&63)),o=0);return r.substring(0,r.length-2+e)+(e===2?"":e===1?"=":"==")}i(tg,"base64Encode");function en(t){let e=t.toString();return`${e.length===1?"0":""}${e}`}i(en,"numberToString");function yx(t){let e=t.getTimezoneOffset(),r=Math.abs(e),n=e>0?"-":"+",o=en(Math.floor(r/60)),s=en(r%60);return`${n}${o}${s}`}i(yx,"getCLFOffset");function wu(t=new Date){if(!(t instanceof Date))throw new Error("clf-date: invalid parameter");let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=en(t.getDate()),n=e[t.getMonth()],o=t.getFullYear(),s=en(t.getHours()),a=en(t.getMinutes()),u=en(t.getSeconds()),c=yx(t);return`${r}/${n}/${o}:${s}:${a}:${u} ${c}`}i(wu,"toCLFDate");var rg=Ke("zuplo:runtime"),bx="X-Amzn-Trace-Id",vx="x-amzn-errortype",ng=[],wx=i(async(t,e,r)=>{let n=r;for await(let o of ng)n=await o(t,e,r);return n},"onSendingAwsLambdaEvent"),it=class extends U{static{i(this,"AwsLambdaError")}traceId;errorType;constructor(e,r){super(`Failed to invoke AWS Lambda function. ${e}`),this.traceId=r.get(bx)??void 0,this.errorType=r.get(vx)??void 0}},xx={addSendingAwsLambdaEventHook:i(t=>{ng.push(t)},"addSendingAwsLambdaEventHook")};async function Rx(t,e){b("handler.aws-lambda");let{accessKeyId:r,secretAccessKey:n,region:o,functionName:s,useLambdaProxyIntegration:a=!0,useAwsResourcePathStyle:u=!1,binaryMediaTypes:c}=e.route.handler.options;if(!r)throw new g("awsAccessKeyId is not set in the handler options");if(!n)throw new g("secretAccessKey is not set in the handler options");if(!o)throw new g("region is not set in the handler options");if(!s)throw new g("functionName is not set in the handler options");let l=new Yr({accessKeyId:r,secretAccessKey:n}),d=`https://lambda.${o}.amazonaws.com/2015-03-31/functions/${s}/invocations`;if(rg(`AWS Lambda URL: ${d}`),!a)return l.fetch(d,{body:await t.arrayBuffer()});let[p,m]=await Sx(t,{binaryMediaTypes:c}),{options:f}=e.route.handler,h;f&&typeof f=="object"&&"payloadFormatVersion"in f&&f.payloadFormatVersion==="2.0"?h=Ix(t,e):h=await Px(t,e,{useAwsResourcePathStyle:u}),rg("Calling onSendingAwsLambdaEvent hook");let y=await wx(t,e,h);y.body=p,y.isBase64Encoded=m;let w=await l.fetch(d,{body:JSON.stringify(y)});try{return _x(w)}catch(E){if(E instanceof it){let S=f&&typeof f=="object"&&"returnAmazonTraceIdHeader"in f&&f.returnAmazonTraceIdHeader&&E.traceId?{AMZN_TRACE_ID_HEADER:E.traceId}:void 0;return A.internalServerError(t,e,void 0,S)}throw E}}i(Rx,"awsLambdaHandler");async function _x(t){let e;try{e=await t.json()}catch{throw new it("Lambda response did not contain valid JSON",t.headers)}if(t.status!==200)throw e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?new it(e.message,t.headers):new it(`Status: ${t.statusText}`,t.headers);if(e&&typeof e=="object"&&"errorMessage"in e&&typeof e.errorMessage=="string")throw new it(e.errorMessage,t.headers);if(!e||typeof e!="object"||!("statusCode"in e)||typeof e.statusCode!="number")return new Response(JSON.stringify(e),{status:t.status,headers:{"content-type":"application/json"}});let r=new Headers;if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new it(`Response headers must be an object. Received ${typeof e.headers}`,t.headers);for(let[o,s]of Object.entries(e.headers))r.set(o,s)}if("cookies"in e&&e.cookies){if(!Array.isArray(e.cookies))throw new it(`Response cookies must be an array. Received ${typeof e.cookies}`,t.headers);r.set("cookie",e.cookies.join(";"))}let n;if("isBase64Encoded"in e&&typeof e.isBase64Encoded!="boolean")throw new it(`Response property isBase64Encoded must be a boolean. Received ${typeof e.isBase64Encoded}`,t.headers);if("isBase64Encoded"in e&&e.isBase64Encoded===!0){if(!("body"in e))throw new it("Response was set to base64 encoded but no body was set",t.headers);if(typeof e.body!="string")throw new it("Response was set to base64 encoded but body was not a string",t.headers);n=eg(e.body)}else"body"in e&&typeof e.body=="string"?n=e.statusCode===204&&e.body===""?null:e.body:"body"in e&&e.body!==null&&e.body!==void 0?n=JSON.stringify(e.body):n=null;if(n!==null&&"bodyEncoding"in e){if(typeof e.bodyEncoding!="string"||!(e.bodyEncoding==="gzip"||e.bodyEncoding==="deflate"))throw new it(`Response property bodyEncoding can only be set to 'gzip' or 'deflate'. Received ${e.bodyEncoding}`,t.headers);let o=new Blob([n]).stream().pipeThrough(new DecompressionStream(e.bodyEncoding));n=await new Response(o).arrayBuffer()}return new Response(n,{headers:r,status:e.statusCode})}i(_x,"getResponse");async function Px(t,e,{useAwsResourcePathStyle:r}){let n={},o={};t.headers.forEach((l,d)=>{n[d]=l,o[d]=[l]});let s=t.query,a={};for(let[l,d]of Object.entries(s))a[l]||(a[l]=[]),a[l].push(d);let u=new URL(t.url);return{version:"1.0",resource:u.pathname,path:u.pathname,httpMethod:t.method,headers:n,multiValueHeaders:o,queryStringParameters:s,multiValueQueryStringParameters:a,requestContext:{accountId:null,apiId:null,authorizer:{claims:{},scopes:[]},domainName:u.hostname,domainPrefix:null,extendedRequestId:e.requestId,httpMethod:t.method,identity:{accessKey:null,accountId:null,caller:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,sourceIp:t.headers.get("CF-Connecting-IP"),user:null,userAgent:t.headers.get("user-agent"),userArn:null,clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},path:u.pathname,protocol:"HTTP/1.1",requestId:e.requestId,requestTime:wu(),requestTimeEpoch:new Date().valueOf(),resourceId:e.route.operationId??null,resourcePath:Ex(e.route.path,r),stage:null},pathParameters:t.params,stageVariables:null}}i(Px,"buildEventVersion1");function Ix(t,e){let r={};t.headers.forEach((s,a)=>{r[a]=s});let n=new URL(t.url);return{version:"2.0",routeKey:null,rawPath:n.pathname,rawQueryString:n.search,cookies:[],headers:r,queryStringParameters:t.query,requestContext:{accountId:null,apiId:null,authentication:{clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},authorizer:{jwt:{claims:{},scopes:[]}},domainName:n.hostname,domainPrefix:null,http:{method:t.method,path:n.pathname,protocol:"HTTP/1.1",sourceIp:t.headers.get("CF-Connecting-IP"),userAgent:t.headers.get("user-agent")},requestId:e.requestId,routeKey:null,stage:null,time:wu(),timeEpoch:new Date().valueOf()},pathParameters:t.params,stageVariables:null}}i(Ix,"buildEventVersion2");async function Sx(t,{binaryMediaTypes:e}){let r,n=!1,o=t.headers.get("content-type");if(t.method==="GET"||t.method==="HEAD")r=null;else if(e&&o&&kx(e,o)){let s=await t.arrayBuffer();r=tg(new Uint8Array(s)),n=!0}else r=await t.clone().text();return[r,n]}i(Sx,"getBodyResult");function kx(t,e){let r=e.split(";")[0].trim().toLowerCase();return t.findIndex(n=>n==="*/*"?!0:n.toLowerCase()===r)>-1}i(kx,"matchesContentType");function Ex(t,e=!1){if(!e)return t;let r=gu(t),n=Kh(t),o={};return r.forEach(s=>{typeof s=="string"?o[s]=`{${s}}`:o[s.name]=`{${s.name}}`}),n(o)}i(Ex,"getResourcePath");var Tx=[502,503,504];async function tn(t,e){if(Tx.includes(t.status)){let r=pe.getLogger(e),o=await t.clone().text(),s={};for(let[a,u]of t.headers)s[a]=u;r.warn(`BadGatewayResponse ${t.status}`,{status:t.status,statusText:t.statusText,body:o,headers:s})}}i(tn,"logBadGatewayResponses");var xu;function ir(t){if(xu===void 0){let r=x.instance.runtime.ZUPLO_HANDLER_WRITE_LOG_LEVEL;["debug","info","warn","error"].includes(r??"")||(r="debug"),xu=r}return t.log[xu]}i(ir,"getHandlerUserLogFunction");async function $x(t,e){b("handler.open-api");let r=x.instance.build.BUILD_ID,{buildAssetsUrl:n}=x.instance,o=e.route.handler.options,{openApiFilePath:s}=o;if(!s)throw new g("Open API Spec Handler must have 'openApiFilePath' specified");let a=Ox(s);if(!a.isValid)throw new g(a.error);let u=`${n}/${r}${s.substring(1)}`,c=await G.fetch(u,{method:t.method,body:t.body,headers:t.headers});if(c.status!==200)return A.notFound(t,e,{detail:"OpenAPI file could not be found."});let l=new Response(c.body,{headers:{"content-type":"application/json","content-encoding":c.headers.get("content-encoding")||"",vary:"Accept-Encoding"},status:c.status,statusText:c.statusText});return tn(l,e),l}i($x,"openApiSpecHandler");var Ox=i(t=>t.startsWith("./")?t.startsWith("./config")?t.endsWith(".oas.json")?{isValid:!0}:{isValid:!1,error:"'openApiFilePath' must point to a file ending in '.oas.json'"}:{isValid:!1,error:"'openApiFilePath' must point to a file in your /config directory"}:{isValid:!1,error:"'openApiFilePath' must start with './'"},"validateOpenApiPath");async function Cx(t,e){b("handler.redirect");let r=e.route.handler.options;if(!r.location)throw new g("Redirect Handler must have 'location' specified");let n=r.status??302;return new Response(null,{status:n,headers:{location:r.location}})}i(Cx,"redirectHandler");async function Ax(t){if(b("handler.zuplo-service-proxy"),Object.entries(t.params).length!==1)throw new g("The service proxy handler only supports one wildcard path parameter. Change your url to something like '/service/{path}'");let e=new URL(t.params.path,x.instance.zuploEdgeApiUrl),r=new Headers(t.headers);return r.set("Authorization",`Bearer ${x.instance.authApiJWT}`),G.fetch(e,{method:t.method,headers:r,body:t.body})}i(Ax,"zuploServiceProxy");function Nx(t,e){let r=t.endsWith("/"),n=e.startsWith("/");return r&&n?`${t.substring(0,t.length-1)}${e}`:!r&&!n?`${t}/${e}`:`${t}${e}`}i(Nx,"join");async function Lx(t,e){b("handler.url-forward");let r=ir(e),n=e.route.handler.options,o=n.forwardSearch!==!1,s;if(x.instance.build.COMPATIBILITY_FLAGS.useForwardRedirectsPropOnUrlForwardHandler?s=n.followRedirects===!0?"follow":"manual":typeof n.followRedirects<"u"&&b("handler.url-forward.follow-redirects"),!n.baseUrl)throw new Error("URL Forward Handler must have 'baseUrl' specified");if(!n||typeof n.__rewriteFunction!="function")throw new g("Invalid options for this route");let a=or(e),u=new URL(t.url),c=n.__rewriteFunction(t,a),l=Nx(c,u.pathname),d=o?`${l}${u.search}`:l.toString(),p=Date.now();r(`URL Forwarding to '${d}'`);let m=await fetch(d,{method:t.method,body:t.body,headers:t.headers,redirect:s}),f=Date.now()-p;return r(`URL Forward received response ${m.status} - ${m.statusText} in ${f}ms`),tn(m,e),m}i(Lx,"urlForwardHandler");var zx=i((t,e)=>{let r=new URL(t),n=new URL(e);for(let[o,s]of n.searchParams.entries())r.searchParams.append(o,s);return r.toString()},"addQuery");async function Dx(t,e){b("handler.url-rewrite");let r=ir(e),n=e.route.handler.options,o=n.forwardSearch!==!1,s=n.followRedirects??!1;if(!n||typeof n.__rewriteFunction!="function")throw new g("Invalid options for this route");let a=or(e),u=n.__rewriteFunction(t,a),c=o?zx(u,t.url):u,l=Date.now();r(`URL Rewriting to '${c}'`);let d=await fetch(c.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:s?"follow":"manual"}),p=Date.now()-l;return r(`URL Rewrite received response ${d.status} - ${d.statusText} in ${p}ms`),tn(d,e),d}i(Dx,"urlRewriteHandler");async function Zx(t,e){b("handler.websocket");let r=e.route.handler.options,n=ir(e);if(!r||!r.rewritePattern)throw new g("WebSocket Handler must have option 'rewritePattern' specified");let o=t.headers.get("Upgrade");if(!o||o!=="websocket")return A.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new g("Invalid options for this route");let s=or(e),a=r.__rewriteFunction(t,s),u=Date.now();n(`Attempting WebSocket connection to '${a}'`),a=a.replace(/^(ws)/,"http");let c=await fetch(a,{method:t.method,headers:t.headers,body:t.body});if(c.status!==101||!c.webSocket){let d=await c.text(),p=`WebSocket connection error - ${c.status}: ${c.statusText}, content: '${d}'`;throw new Error(p)}let l=Date.now()-u;return n(`WebSocket connected, received response ${c.status} - ${c.statusText} in ${l}ms`),new Response(null,{status:101,webSocket:c.webSocket})}i(Zx,"webSocketHandler");async function Ux(t,e){let r=Ae.instance.runtimeSettings.developerPortal.urls?.[0];if(!r)throw new g("Developer portal hostname is not configured.");let n=jx(t.url,r);return e.log.info(`Redirecting from legacy dev portal to ${n}`),new Response(null,{status:301,headers:{location:n}})}i(Ux,"redirectLegacyDevPortal");function jx(t,e){let r=new URL(t),n=r.pathname.split("/")[1];if(!n)throw new g("The request URL does not contain a valid developer portal base path. This handler cannot be used on a root path");return r.hostname=e,r.pathname=r.pathname.substring(n.length+1),r.toString()}i(jx,"getDevPortalRedirectUrl");var Ru=i((t,e)=>t.map((n,o)=>{let s;if(typeof n.module=="object"&&(s=n.module[n.export]),!s||typeof s!="function"){let a=e==="inbound"?"WebSocketInboundPolicy":"WebSocketOutboundPolicy",u=`policy in position: ${o+1}, export name: ${n.export}`;throw new g(`${a} - Websocket policy must be a valid function (${u})`)}return s}),"getWebSocketPolicyFunctions"),og=i(async(t,e,r,n,o,s)=>{let a=t.data;if(s&&s.length>0){let u=[...s];for(;u.length>0;){let c=u.shift();if(!c)return a;if(a=await c(a,r,e,n,o),a===void 0)return}}return a},"webSocketPolicyProcessor");function ig(t,e,r,n,o){t.addEventListener("close",()=>{e.close()}),t.addEventListener("error",s=>{n.log.error("WebSocket error: ",s),e.send(JSON.stringify(s))}),t.addEventListener("message",s=>{try{let u=i(async c=>{let l=await og(c,t,e,r,n,o);l!==void 0&&e.send(l)},"innerPipeline")(s).catch(n.log.error);n.waitUntil(u)}catch(a){n.log.error(a)}})}i(ig,"wireUpListeners");async function Mx(t,e){b("handler.websocket-pipeline");let r=e.route.handler.options,n=ir(e);if(!r||!r.rewritePattern)throw new g("WebSocket Pipeline Handler must have option 'rewritePattern' specified");let o=t.headers.get("Upgrade");if(!o||o!=="websocket")return A.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new g("Invalid options for this route");let s=or(e),a=r.__rewriteFunction(t,s),u=Date.now();n(`Attempting WebSocket connection to '${a}'`),a=a.replace(/^(ws)/,"http");let c=await fetch(a,{method:t.method,headers:t.headers,body:t.body});if(c.status!==101||!c.webSocket){let w=await c.text(),E=`WebSocket connection error - ${c.status}: ${c.statusText}, content: '${w}'`;throw new Error(E)}let l=new WebSocketPair,[d,p]=Object.values(l),m=Date.now()-u;n(`WebSocket connected, received response ${c.status} - ${c.statusText} in ${m}ms`);let f=c.webSocket;f.accept(),p.accept();let h=r.policies&&r.policies.inbound?Ru(r.policies.inbound,"inbound"):[],y=r.policies&&r.policies.outbound?Ru(r.policies.outbound,"outbound"):[];return ig(p,f,t,e,h),ig(f,p,t,e,y),new Response(null,{status:101,webSocket:d})}i(Mx,"webSocketPipelineHandler");import{AsyncLocalStorage as qx}from"node:async_hooks";var sg=new qx;function ag(t,e){return sg.run(t,e)}i(ag,"runWithInvokeHeaders");function ug(){return sg.getStore()??{}}i(ug,"getInvokeHeaders");var T={};Qt(T,{BRAND:()=>fR,DIRTY:()=>wr,EMPTY_PATH:()=>Vx,INVALID:()=>ce,NEVER:()=>XR,OK:()=>Be,ParseStatus:()=>He,Schema:()=>ve,ZodAny:()=>ur,ZodArray:()=>Mt,ZodBigInt:()=>Rr,ZodBoolean:()=>_r,ZodBranded:()=>io,ZodCatch:()=>Nr,ZodDate:()=>Pr,ZodDefault:()=>Ar,ZodDiscriminatedUnion:()=>Ji,ZodEffects:()=>mt,ZodEnum:()=>Or,ZodError:()=>Qe,ZodFirstPartyTypeKind:()=>le,ZodFunction:()=>Qi,ZodIntersection:()=>Er,ZodIssueCode:()=>j,ZodLazy:()=>Tr,ZodLiteral:()=>$r,ZodMap:()=>un,ZodNaN:()=>ln,ZodNativeEnum:()=>Cr,ZodNever:()=>yt,ZodNull:()=>Sr,ZodNullable:()=>Et,ZodNumber:()=>xr,ZodObject:()=>Xe,ZodOptional:()=>dt,ZodParsedType:()=>re,ZodPipeline:()=>so,ZodPromise:()=>cr,ZodReadonly:()=>Lr,ZodRecord:()=>Ki,ZodSchema:()=>ve,ZodSet:()=>cn,ZodString:()=>ar,ZodSymbol:()=>sn,ZodTransformer:()=>mt,ZodTuple:()=>kt,ZodType:()=>ve,ZodUndefined:()=>Ir,ZodUnion:()=>kr,ZodUnknown:()=>jt,ZodVoid:()=>an,addIssueToContext:()=>ee,any:()=>_R,array:()=>kR,bigint:()=>bR,boolean:()=>wg,coerce:()=>QR,custom:()=>yg,date:()=>vR,datetimeRegex:()=>hg,defaultErrorMap:()=>Zt,discriminatedUnion:()=>OR,effect:()=>HR,enum:()=>jR,function:()=>DR,getErrorMap:()=>rn,getParsedType:()=>St,instanceof:()=>gR,intersection:()=>CR,isAborted:()=>Vi,isAsync:()=>nn,isDirty:()=>Gi,isValid:()=>sr,late:()=>hR,lazy:()=>ZR,literal:()=>UR,makeIssue:()=>ro,map:()=>LR,nan:()=>yR,nativeEnum:()=>MR,never:()=>IR,null:()=>RR,nullable:()=>BR,number:()=>vg,object:()=>ER,objectUtil:()=>_u,oboolean:()=>KR,onumber:()=>JR,optional:()=>FR,ostring:()=>WR,pipeline:()=>GR,preprocess:()=>VR,promise:()=>qR,quotelessJson:()=>Hx,record:()=>NR,set:()=>zR,setErrorMap:()=>Bx,strictObject:()=>TR,string:()=>bg,symbol:()=>wR,transformer:()=>HR,tuple:()=>AR,undefined:()=>xR,union:()=>$R,unknown:()=>PR,util:()=>Re,void:()=>SR});var Re;(function(t){t.assertEqual=o=>{};function e(o){}i(e,"assertIs"),t.assertIs=e;function r(o){throw new Error}i(r,"assertNever"),t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(u=>typeof o[o[u]]!="number"),a={};for(let u of s)a[u]=o[u];return t.objectValues(a)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},t.find=(o,s)=>{for(let a of o)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}i(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var _u;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(_u||(_u={}));var re=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),St=i(t=>{switch(typeof t){case"undefined":return re.undefined;case"string":return re.string;case"number":return Number.isNaN(t)?re.nan:re.number;case"boolean":return re.boolean;case"function":return re.function;case"bigint":return re.bigint;case"symbol":return re.symbol;case"object":return Array.isArray(t)?re.array:t===null?re.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?re.promise:typeof Map<"u"&&t instanceof Map?re.map:typeof Set<"u"&&t instanceof Set?re.set:typeof Date<"u"&&t instanceof Date?re.date:re.object;default:return re.unknown}},"getParsedType");var j=Re.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"]),Hx=i(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Qe=class t extends Error{static{i(this,"ZodError")}get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let u=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(r(a))):u[l]=u[l]||{_errors:[]},u=u[l],c++}}},"processError");return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Qe.create=t=>new Qe(t);var Fx=i((t,e)=>{let r;switch(t.code){case j.invalid_type:t.received===re.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case j.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Re.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:r=`Unrecognized key(s) in object: ${Re.joinValues(t.keys,", ")}`;break;case j.invalid_union:r="Invalid input";break;case j.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Re.joinValues(t.options)}`;break;case j.invalid_enum_value:r=`Invalid enum value. Expected ${Re.joinValues(t.options)}, received '${t.received}'`;break;case j.invalid_arguments:r="Invalid function arguments";break;case j.invalid_return_type:r="Invalid function return type";break;case j.invalid_date:r="Invalid date";break;case j.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Re.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case j.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case j.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case j.custom:r="Invalid input";break;case j.invalid_intersection_types:r="Intersection results could not be merged";break;case j.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case j.not_finite:r="Number must be finite";break;default:r=e.defaultError,Re.assertNever(t)}return{message:r}},"errorMap"),Zt=Fx;var cg=Zt;function Bx(t){cg=t}i(Bx,"setErrorMap");function rn(){return cg}i(rn,"getErrorMap");var ro=i(t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let u="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)u=l(a,{data:e,defaultError:u}).message;return{...o,path:s,message:u}},"makeIssue"),Vx=[];function ee(t,e){let r=rn(),n=ro({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Zt?void 0:Zt].filter(o=>!!o)});t.common.issues.push(n)}i(ee,"addIssueToContext");var He=class t{static{i(this,"ParseStatus")}constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return ce;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return ce;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}},ce=Object.freeze({status:"aborted"}),wr=i(t=>({status:"dirty",value:t}),"DIRTY"),Be=i(t=>({status:"valid",value:t}),"OK"),Vi=i(t=>t.status==="aborted","isAborted"),Gi=i(t=>t.status==="dirty","isDirty"),sr=i(t=>t.status==="valid","isValid"),nn=i(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync");var se;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(se||(se={}));var Wi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},pg=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},no,oo,pt=class{static{i(this,"ParseInputLazyPath")}constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},lg=i((t,e)=>{if(sr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Qe(t.common.issues);return this._error=r,this._error}}},"handleResult");function he(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:i((a,u)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??u.defaultError}:typeof u.data>"u"?{message:c??n??u.defaultError}:a.code!=="invalid_type"?{message:u.defaultError}:{message:c??r??u.defaultError}},"customMap"),description:o}}i(he,"processCreateParams");var ve=class{static{i(this,"ZodType")}get description(){return this._def.description}_getType(e){return St(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:St(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new He,ctx:{common:e.parent.common,data:e.data,parsedType:St(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(nn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)},o=this._parseSync({data:e,path:n.path,parent:n});return lg(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return sr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>sr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:St(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(nn(o)?o:Promise.resolve(o));return lg(n,s)}refine(e,r){let n=i(o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r,"getIssueProperties");return this._refinement((o,s)=>{let a=e(o),u=i(()=>s.addIssue({code:j.custom,...n(o)}),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(u(),!1)):a?!0:(u(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new mt({schema:this,typeName:le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:i(r=>this["~validate"](r),"validate")}}optional(){return dt.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Mt.create(this)}promise(){return cr.create(this,this._def)}or(e){return kr.create([this,e],this._def)}and(e){return Er.create(this,e,this._def)}transform(e){return new mt({...he(this._def),schema:this,typeName:le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ar({...he(this._def),innerType:this,defaultValue:r,typeName:le.ZodDefault})}brand(){return new io({typeName:le.ZodBranded,type:this,...he(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Nr({...he(this._def),innerType:this,catchValue:r,typeName:le.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return so.create(this,e)}readonly(){return Lr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Gx=/^c[^\s-]{8,}$/i,Wx=/^[0-9a-z]+$/,Jx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Kx=/^[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,Qx=/^[a-z0-9_-]{21}$/i,Xx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yx=/^[-+]?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)?)??$/,eR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pu,rR=/^(?:(?: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])$/,nR=/^(?:(?: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])$/,oR=/^(([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]))$/,iR=/^(([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])$/,sR=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,aR=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mg="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",uR=new RegExp(`^${mg}$`);function fg(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}i(fg,"timeRegexSource");function cR(t){return new RegExp(`^${fg(t)}$`)}i(cR,"timeRegex");function hg(t){let e=`${mg}T${fg(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}i(hg,"datetimeRegex");function lR(t,e){return!!((e==="v4"||!e)&&rR.test(t)||(e==="v6"||!e)&&oR.test(t))}i(lR,"isValidIP");function dR(t,e){if(!Xx.test(t))return!1;try{let[r]=t.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}i(dR,"isValidJWT");function pR(t,e){return!!((e==="v4"||!e)&&nR.test(t)||(e==="v6"||!e)&&iR.test(t))}i(pR,"isValidCidr");var ar=class t extends ve{static{i(this,"ZodString")}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==re.string){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.string,received:s.parsedType}),ce}let n=new He,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,u=e.data.length<s.value;(a||u)&&(o=this._getOrReturnCtx(e,o),a?ee(o,{code:j.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&ee(o,{code:j.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")eR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"email",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Pu||(Pu=new RegExp(tR,"u")),Pu.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"emoji",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Kx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"uuid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Qx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"nanoid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Gx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cuid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Wx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cuid2",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Jx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"ulid",code:j.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),ee(o,{validation:"url",code:j.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"regex",code:j.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?hg(s).test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?uR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?cR(s).test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{code:j.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Yx.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"duration",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?lR(e.data,s.version)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"ip",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?dR(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"jwt",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?pR(e.data,s.version)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"cidr",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?sR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"base64",code:j.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?aR.test(e.data)||(o=this._getOrReturnCtx(e,o),ee(o,{validation:"base64url",code:j.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:j.invalid_string,...se.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...se.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...se.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...se.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...se.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...se.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...se.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...se.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...se.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...se.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...se.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...se.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...se.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...se.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...se.errToObj(r)})}nonempty(e){return this.min(1,se.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ar.create=t=>new ar({checks:[],typeName:le.ZodString,coerce:t?.coerce??!1,...he(t)});function mR(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}i(mR,"floatSafeRemainder");var xr=class t extends ve{static{i(this,"ZodNumber")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==re.number){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.number,received:s.parsedType}),ce}let n,o=new He;for(let s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ee(n,{code:j.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?mR(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_finite,message:s.message}),o.dirty()):Re.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,se.toString(r))}gt(e,r){return this.setLimit("min",e,!1,se.toString(r))}lte(e,r){return this.setLimit("max",e,!0,se.toString(r))}lt(e,r){return this.setLimit("max",e,!1,se.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:se.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:se.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:se.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:se.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Re.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};xr.create=t=>new xr({checks:[],typeName:le.ZodNumber,coerce:t?.coerce||!1,...he(t)});var Rr=class t extends ve{static{i(this,"ZodBigInt")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==re.bigint)return this._getInvalidInput(e);let n,o=new He;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ee(n,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):Re.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return ee(r,{code:j.invalid_type,expected:re.bigint,received:r.parsedType}),ce}gte(e,r){return this.setLimit("min",e,!0,se.toString(r))}gt(e,r){return this.setLimit("min",e,!1,se.toString(r))}lte(e,r){return this.setLimit("max",e,!0,se.toString(r))}lt(e,r){return this.setLimit("max",e,!1,se.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:se.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:se.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:se.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Rr.create=t=>new Rr({checks:[],typeName:le.ZodBigInt,coerce:t?.coerce??!1,...he(t)});var _r=class extends ve{static{i(this,"ZodBoolean")}_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==re.boolean){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.boolean,received:n.parsedType}),ce}return Be(e.data)}};_r.create=t=>new _r({typeName:le.ZodBoolean,coerce:t?.coerce||!1,...he(t)});var Pr=class t extends ve{static{i(this,"ZodDate")}_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==re.date){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_type,expected:re.date,received:s.parsedType}),ce}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return ee(s,{code:j.invalid_date}),ce}let n=new He,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),ee(o,{code:j.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:se.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:se.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Pr.create=t=>new Pr({checks:[],coerce:t?.coerce||!1,typeName:le.ZodDate,...he(t)});var sn=class extends ve{static{i(this,"ZodSymbol")}_parse(e){if(this._getType(e)!==re.symbol){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.symbol,received:n.parsedType}),ce}return Be(e.data)}};sn.create=t=>new sn({typeName:le.ZodSymbol,...he(t)});var Ir=class extends ve{static{i(this,"ZodUndefined")}_parse(e){if(this._getType(e)!==re.undefined){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.undefined,received:n.parsedType}),ce}return Be(e.data)}};Ir.create=t=>new Ir({typeName:le.ZodUndefined,...he(t)});var Sr=class extends ve{static{i(this,"ZodNull")}_parse(e){if(this._getType(e)!==re.null){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.null,received:n.parsedType}),ce}return Be(e.data)}};Sr.create=t=>new Sr({typeName:le.ZodNull,...he(t)});var ur=class extends ve{static{i(this,"ZodAny")}constructor(){super(...arguments),this._any=!0}_parse(e){return Be(e.data)}};ur.create=t=>new ur({typeName:le.ZodAny,...he(t)});var jt=class extends ve{static{i(this,"ZodUnknown")}constructor(){super(...arguments),this._unknown=!0}_parse(e){return Be(e.data)}};jt.create=t=>new jt({typeName:le.ZodUnknown,...he(t)});var yt=class extends ve{static{i(this,"ZodNever")}_parse(e){let r=this._getOrReturnCtx(e);return ee(r,{code:j.invalid_type,expected:re.never,received:r.parsedType}),ce}};yt.create=t=>new yt({typeName:le.ZodNever,...he(t)});var an=class extends ve{static{i(this,"ZodVoid")}_parse(e){if(this._getType(e)!==re.undefined){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.void,received:n.parsedType}),ce}return Be(e.data)}};an.create=t=>new an({typeName:le.ZodVoid,...he(t)});var Mt=class t extends ve{static{i(this,"ZodArray")}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==re.array)return ee(r,{code:j.invalid_type,expected:re.array,received:r.parsedType}),ce;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,u=r.data.length<o.exactLength.value;(a||u)&&(ee(r,{code:a?j.too_big:j.too_small,minimum:u?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(ee(r,{code:j.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(ee(r,{code:j.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,u)=>o.type._parseAsync(new pt(r,a,r.path,u)))).then(a=>He.mergeArray(n,a));let s=[...r.data].map((a,u)=>o.type._parseSync(new pt(r,a,r.path,u)));return He.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:se.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:se.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:se.toString(r)}})}nonempty(e){return this.min(1,e)}};Mt.create=(t,e)=>new Mt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:le.ZodArray,...he(e)});function on(t){if(t instanceof Xe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=dt.create(on(n))}return new Xe({...t._def,shape:i(()=>e,"shape")})}else return t instanceof Mt?new Mt({...t._def,type:on(t.element)}):t instanceof dt?dt.create(on(t.unwrap())):t instanceof Et?Et.create(on(t.unwrap())):t instanceof kt?kt.create(t.items.map(e=>on(e))):t}i(on,"deepPartialify");var Xe=class t extends ve{static{i(this,"ZodObject")}constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Re.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==re.object){let l=this._getOrReturnCtx(e);return ee(l,{code:j.invalid_type,expected:re.object,received:l.parsedType}),ce}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),u=[];if(!(this._def.catchall instanceof yt&&this._def.unknownKeys==="strip"))for(let l in o.data)a.includes(l)||u.push(l);let c=[];for(let l of a){let d=s[l],p=o.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new pt(o,p,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof yt){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of u)c.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")u.length>0&&(ee(o,{code:j.unrecognized_keys,keys:u}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of u){let p=o.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new pt(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of c){let p=await d.key,m=await d.value;l.push({key:p,value:m,alwaysSet:d.alwaysSet})}return l}).then(l=>He.mergeObjectSync(n,l)):He.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return se.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:i((r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:se.errToObj(e).message??o}:{message:o}},"errorMap")}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:i(()=>({...this._def.shape(),...e}),"shape")})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:i(()=>({...this._def.shape(),...e._def.shape()}),"shape"),typeName:le.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Re.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:i(()=>r,"shape")})}omit(e){let r={};for(let n of Re.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:i(()=>r,"shape")})}deepPartial(){return on(this)}partial(e){let r={};for(let n of Re.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:i(()=>r,"shape")})}required(e){let r={};for(let n of Re.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof dt;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:i(()=>r,"shape")})}keyof(){return gg(Re.objectKeys(this.shape))}};Xe.create=(t,e)=>new Xe({shape:i(()=>t,"shape"),unknownKeys:"strip",catchall:yt.create(),typeName:le.ZodObject,...he(e)});Xe.strictCreate=(t,e)=>new Xe({shape:i(()=>t,"shape"),unknownKeys:"strict",catchall:yt.create(),typeName:le.ZodObject,...he(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:yt.create(),typeName:le.ZodObject,...he(e)});var kr=class extends ve{static{i(this,"ZodUnion")}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;let a=s.map(u=>new Qe(u.ctx.common.issues));return ee(r,{code:j.invalid_union,unionErrors:a}),ce}if(i(o,"handleResults"),r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},d=c._parseSync({data:r.data,path:r.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let u=a.map(c=>new Qe(c));return ee(r,{code:j.invalid_union,unionErrors:u}),ce}}get options(){return this._def.options}};kr.create=(t,e)=>new kr({options:t,typeName:le.ZodUnion,...he(e)});var Ut=i(t=>t instanceof Tr?Ut(t.schema):t instanceof mt?Ut(t.innerType()):t instanceof $r?[t.value]:t instanceof Or?t.options:t instanceof Cr?Re.objectValues(t.enum):t instanceof Ar?Ut(t._def.innerType):t instanceof Ir?[void 0]:t instanceof Sr?[null]:t instanceof dt?[void 0,...Ut(t.unwrap())]:t instanceof Et?[null,...Ut(t.unwrap())]:t instanceof io||t instanceof Lr?Ut(t.unwrap()):t instanceof Nr?Ut(t._def.innerType):[],"getDiscriminator"),Ji=class t extends ve{static{i(this,"ZodDiscriminatedUnion")}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.object)return ee(r,{code:j.invalid_type,expected:re.object,received:r.parsedType}),ce;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(ee(r,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let a=Ut(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of a){if(o.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);o.set(u,s)}}return new t({typeName:le.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...he(n)})}};function Iu(t,e){let r=St(t),n=St(e);if(t===e)return{valid:!0,data:t};if(r===re.object&&n===re.object){let o=Re.objectKeys(e),s=Re.objectKeys(t).filter(u=>o.indexOf(u)!==-1),a={...t,...e};for(let u of s){let c=Iu(t[u],e[u]);if(!c.valid)return{valid:!1};a[u]=c.data}return{valid:!0,data:a}}else if(r===re.array&&n===re.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let a=t[s],u=e[s],c=Iu(a,u);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===re.date&&n===re.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}i(Iu,"mergeValues");var Er=class extends ve{static{i(this,"ZodIntersection")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=i((s,a)=>{if(Vi(s)||Vi(a))return ce;let u=Iu(s.value,a.value);return u.valid?((Gi(s)||Gi(a))&&r.dirty(),{status:r.value,value:u.data}):(ee(n,{code:j.invalid_intersection_types}),ce)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Er.create=(t,e,r)=>new Er({left:t,right:e,typeName:le.ZodIntersection,...he(r)});var kt=class t extends ve{static{i(this,"ZodTuple")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.array)return ee(n,{code:j.invalid_type,expected:re.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return ee(n,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(ee(n,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((a,u)=>{let c=this._def.items[u]||this._def.rest;return c?c._parse(new pt(n,a,n.path,u)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>He.mergeArray(r,a)):He.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};kt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kt({items:t,typeName:le.ZodTuple,rest:null,...he(e)})};var Ki=class t extends ve{static{i(this,"ZodRecord")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.object)return ee(n,{code:j.invalid_type,expected:re.object,received:n.parsedType}),ce;let o=[],s=this._def.keyType,a=this._def.valueType;for(let u in n.data)o.push({key:s._parse(new pt(n,u,n.path,u)),value:a._parse(new pt(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?He.mergeObjectAsync(r,o):He.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ve?new t({keyType:e,valueType:r,typeName:le.ZodRecord,...he(n)}):new t({keyType:ar.create(),valueType:e,typeName:le.ZodRecord,...he(r)})}},un=class extends ve{static{i(this,"ZodMap")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.map)return ee(n,{code:j.invalid_type,expected:re.map,received:n.parsedType}),ce;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([u,c],l)=>({key:o._parse(new pt(n,u,n.path,[l,"key"])),value:s._parse(new pt(n,c,n.path,[l,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return ce;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),u.set(l.value,d.value)}return{status:r.value,value:u}})}else{let u=new Map;for(let c of a){let l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return ce;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),u.set(l.value,d.value)}return{status:r.value,value:u}}}};un.create=(t,e,r)=>new un({valueType:e,keyType:t,typeName:le.ZodMap,...he(r)});var cn=class t extends ve{static{i(this,"ZodSet")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==re.set)return ee(n,{code:j.invalid_type,expected:re.set,received:n.parsedType}),ce;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(ee(n,{code:j.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(ee(n,{code:j.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(c){let l=new Set;for(let d of c){if(d.status==="aborted")return ce;d.status==="dirty"&&r.dirty(),l.add(d.value)}return{status:r.value,value:l}}i(a,"finalizeSet");let u=[...n.data.values()].map((c,l)=>s._parse(new pt(n,c,n.path,l)));return n.common.async?Promise.all(u).then(c=>a(c)):a(u)}min(e,r){return new t({...this._def,minSize:{value:e,message:se.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:se.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};cn.create=(t,e)=>new cn({valueType:t,minSize:null,maxSize:null,typeName:le.ZodSet,...he(e)});var Qi=class t extends ve{static{i(this,"ZodFunction")}constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.function)return ee(r,{code:j.invalid_type,expected:re.function,received:r.parsedType}),ce;function n(u,c){return ro({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rn(),Zt].filter(l=>!!l),issueData:{code:j.invalid_arguments,argumentsError:c}})}i(n,"makeArgsIssue");function o(u,c){return ro({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rn(),Zt].filter(l=>!!l),issueData:{code:j.invalid_return_type,returnTypeError:c}})}i(o,"makeReturnsIssue");let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof cr){let u=this;return Be(async function(...c){let l=new Qe([]),d=await u._def.args.parseAsync(c,s).catch(f=>{throw l.addIssue(n(c,f)),l}),p=await Reflect.apply(a,this,d);return await u._def.returns._def.type.parseAsync(p,s).catch(f=>{throw l.addIssue(o(p,f)),l})})}else{let u=this;return Be(function(...c){let l=u._def.args.safeParse(c,s);if(!l.success)throw new Qe([n(c,l.error)]);let d=Reflect.apply(a,this,l.data),p=u._def.returns.safeParse(d,s);if(!p.success)throw new Qe([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:kt.create(e).rest(jt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||kt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:le.ZodFunction,...he(n)})}},Tr=class extends ve{static{i(this,"ZodLazy")}get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Tr.create=(t,e)=>new Tr({getter:t,typeName:le.ZodLazy,...he(e)});var $r=class extends ve{static{i(this,"ZodLiteral")}_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return ee(r,{received:r.data,code:j.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}};$r.create=(t,e)=>new $r({value:t,typeName:le.ZodLiteral,...he(e)});function gg(t,e){return new Or({values:t,typeName:le.ZodEnum,...he(e)})}i(gg,"createZodEnum");var Or=class t extends ve{static{i(this,"ZodEnum")}constructor(){super(...arguments),no.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return ee(r,{expected:Re.joinValues(n),received:r.parsedType,code:j.invalid_type}),ce}if(Wi(this,no,"f")||pg(this,no,new Set(this._def.values),"f"),!Wi(this,no,"f").has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return ee(r,{received:r.data,code:j.invalid_enum_value,options:n}),ce}return Be(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};no=new WeakMap;Or.create=gg;var Cr=class extends ve{static{i(this,"ZodNativeEnum")}constructor(){super(...arguments),oo.set(this,void 0)}_parse(e){let r=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==re.string&&n.parsedType!==re.number){let o=Re.objectValues(r);return ee(n,{expected:Re.joinValues(o),received:n.parsedType,code:j.invalid_type}),ce}if(Wi(this,oo,"f")||pg(this,oo,new Set(Re.getValidEnumValues(this._def.values)),"f"),!Wi(this,oo,"f").has(e.data)){let o=Re.objectValues(r);return ee(n,{received:n.data,code:j.invalid_enum_value,options:o}),ce}return Be(e.data)}get enum(){return this._def.values}};oo=new WeakMap;Cr.create=(t,e)=>new Cr({values:t,typeName:le.ZodNativeEnum,...he(e)});var cr=class extends ve{static{i(this,"ZodPromise")}unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==re.promise&&r.common.async===!1)return ee(r,{code:j.invalid_type,expected:re.promise,received:r.parsedType}),ce;let n=r.parsedType===re.promise?r.data:Promise.resolve(r.data);return Be(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};cr.create=(t,e)=>new cr({type:t,typeName:le.ZodPromise,...he(e)});var mt=class extends ve{static{i(this,"ZodEffects")}innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i(a=>{ee(n,a),a.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async u=>{if(r.value==="aborted")return ce;let c=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"?wr(c.value):r.value==="dirty"?wr(c.value):c});{if(r.value==="aborted")return ce;let u=this._def.schema._parseSync({data:a,path:n.path,parent:n});return u.status==="aborted"?ce:u.status==="dirty"?wr(u.value):r.value==="dirty"?wr(u.value):u}}if(o.type==="refinement"){let a=i(u=>{let c=o.refinement(u,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?ce:(u.status==="dirty"&&r.dirty(),a(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?ce:(u.status==="dirty"&&r.dirty(),a(u.value).then(()=>({status:r.value,value:u.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sr(a))return a;let u=o.transform(a.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>sr(a)?Promise.resolve(o.transform(a.value,s)).then(u=>({status:r.value,value:u})):a);Re.assertNever(o)}};mt.create=(t,e,r)=>new mt({schema:t,typeName:le.ZodEffects,effect:e,...he(r)});mt.createWithPreprocess=(t,e,r)=>new mt({schema:e,effect:{type:"preprocess",transform:t},typeName:le.ZodEffects,...he(r)});var dt=class extends ve{static{i(this,"ZodOptional")}_parse(e){return this._getType(e)===re.undefined?Be(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dt.create=(t,e)=>new dt({innerType:t,typeName:le.ZodOptional,...he(e)});var Et=class extends ve{static{i(this,"ZodNullable")}_parse(e){return this._getType(e)===re.null?Be(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:le.ZodNullable,...he(e)});var Ar=class extends ve{static{i(this,"ZodDefault")}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===re.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ar.create=(t,e)=>new Ar({innerType:t,typeName:le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...he(e)});var Nr=class extends ve{static{i(this,"ZodCatch")}_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return nn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qe(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Qe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Nr.create=(t,e)=>new Nr({innerType:t,typeName:le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...he(e)});var ln=class extends ve{static{i(this,"ZodNaN")}_parse(e){if(this._getType(e)!==re.nan){let n=this._getOrReturnCtx(e);return ee(n,{code:j.invalid_type,expected:re.nan,received:n.parsedType}),ce}return{status:"valid",value:e.data}}};ln.create=t=>new ln({typeName:le.ZodNaN,...he(t)});var fR=Symbol("zod_brand"),io=class extends ve{static{i(this,"ZodBranded")}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},so=class t extends ve{static{i(this,"ZodPipeline")}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return i(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(r.dirty(),wr(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:le.ZodPipeline})}},Lr=class extends ve{static{i(this,"ZodReadonly")}_parse(e){let r=this._def.innerType._parse(e),n=i(o=>(sr(o)&&(o.value=Object.freeze(o.value)),o),"freeze");return nn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Lr.create=(t,e)=>new Lr({innerType:t,typeName:le.ZodReadonly,...he(e)});function dg(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}i(dg,"cleanParams");function yg(t,e={},r){return t?ur.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(a=>{if(!a){let u=dg(e,n),c=u.fatal??r??!0;o.addIssue({code:"custom",...u,fatal:c})}});if(!s){let a=dg(e,n),u=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:u})}}):ur.create()}i(yg,"custom");var hR={object:Xe.lazycreate},le;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(le||(le={}));var gR=i((t,e={message:`Input not instance of ${t.name}`})=>yg(r=>r instanceof t,e),"instanceOfType"),bg=ar.create,vg=xr.create,yR=ln.create,bR=Rr.create,wg=_r.create,vR=Pr.create,wR=sn.create,xR=Ir.create,RR=Sr.create,_R=ur.create,PR=jt.create,IR=yt.create,SR=an.create,kR=Mt.create,ER=Xe.create,TR=Xe.strictCreate,$R=kr.create,OR=Ji.create,CR=Er.create,AR=kt.create,NR=Ki.create,LR=un.create,zR=cn.create,DR=Qi.create,ZR=Tr.create,UR=$r.create,jR=Or.create,MR=Cr.create,qR=cr.create,HR=mt.create,FR=dt.create,BR=Et.create,VR=mt.createWithPreprocess,GR=so.create,WR=i(()=>bg().optional(),"ostring"),JR=i(()=>vg().optional(),"onumber"),KR=i(()=>wg().optional(),"oboolean"),QR={string:i(t=>ar.create({...t,coerce:!0}),"string"),number:i(t=>xr.create({...t,coerce:!0}),"number"),boolean:i(t=>_r.create({...t,coerce:!0}),"boolean"),bigint:i(t=>Rr.create({...t,coerce:!0}),"bigint"),date:i(t=>Pr.create({...t,coerce:!0}),"date")};var XR=ce;var lr="2.0",xg;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(xg||(xg={}));var dn=T.union([T.string(),T.number().int()]);var YR=T.object({jsonrpc:T.literal(lr),id:dn,error:T.object({code:T.number().int(),message:T.string(),data:T.optional(T.unknown())})}).strict();var Su=T.object({_meta:T.optional(T.object({}).passthrough())}).passthrough(),pn=T.object({method:T.string(),params:T.optional(Su)}),Rg=T.object({jsonrpc:T.literal(lr)}).merge(pn).strict();var e_=T.union([T.string(),T.number().int()]),t_=T.object({progressToken:T.optional(e_)}).passthrough(),qt=T.object({_meta:T.optional(t_)}).passthrough(),Ht=T.object({method:T.string(),params:T.optional(qt)}),_g=T.object({jsonrpc:T.literal(lr),id:dn}).merge(Ht).strict();var Ft=T.object({_meta:T.optional(T.object({}).passthrough())}).passthrough(),TU=Ft.strict(),Pg=T.object({jsonrpc:T.literal(lr),id:dn,result:Ft}).strict();var ao=i(t=>_g.safeParse(t).success,"isJSONRPCRequest"),Ig=i(t=>Rg.safeParse(t).success,"isJSONRPCNotification"),Xi=i(t=>Pg.safeParse(t).success,"isJSONRPCResponse");var uo=class{static{i(this,"NoOpLogger")}debug(){}info(){}warn(){}error(){}};function Yi(){return new uo}i(Yi,"createDefaultLogger");var ku=T.string();var co=Ht.extend({params:qt.extend({cursor:T.optional(ku)}).optional()}),lo=Ft.extend({nextCursor:T.optional(ku)});var Sg=T.object({uri:T.string(),mimeType:T.optional(T.string())}).passthrough(),Eu=Sg.extend({text:T.string()}),Tu=Sg.extend({blob:T.string().base64()}),r_=T.object({uri:T.string(),name:T.string(),description:T.optional(T.string()),mimeType:T.optional(T.string())}).passthrough(),n_=T.object({uriTemplate:T.string(),name:T.string(),description:T.optional(T.string()),mimeType:T.optional(T.string())}).passthrough(),QU=co.extend({method:T.literal("resources/list")}),XU=lo.extend({resources:T.array(r_)}),YU=co.extend({method:T.literal("resources/templates/list")}),ej=lo.extend({resourceTemplates:T.array(n_)}),tj=Ht.extend({method:T.literal("resources/read"),params:qt.extend({uri:T.string()})}),rj=Ft.extend({contents:T.array(T.union([Eu,Tu]))}),nj=pn.extend({method:T.literal("notifications/resources/list_changed")}),oj=Ht.extend({method:T.literal("resources/subscribe"),params:qt.extend({uri:T.string()})}),ij=Ht.extend({method:T.literal("resources/unsubscribe"),params:qt.extend({uri:T.string()})}),sj=pn.extend({method:T.literal("notifications/resources/updated"),params:Su.extend({uri:T.string()})});var kg=T.object({type:T.literal("text"),text:T.string()}).passthrough(),Eg=T.object({type:T.literal("image"),data:T.string().base64(),mimeType:T.string()}).passthrough(),Tg=T.object({type:T.literal("audio"),data:T.string().base64(),mimeType:T.string()}).passthrough(),$g=T.object({type:T.literal("resource"),resource:T.union([Eu,Tu])}).passthrough();var o_=T.object({title:T.optional(T.string()),readOnlyHint:T.optional(T.boolean()),destructiveHint:T.optional(T.boolean()),idempotentHint:T.optional(T.boolean()),openWorldHint:T.optional(T.boolean())}).passthrough(),i_=T.object({name:T.string(),description:T.optional(T.string()),inputSchema:T.object({type:T.literal("object"),properties:T.optional(T.object({}).passthrough())}).passthrough(),annotations:T.optional(o_)}).passthrough(),yj=co.extend({method:T.literal("tools/list")}),bj=lo.extend({tools:T.array(i_)}),s_=Ft.extend({content:T.array(T.union([kg,Eg,Tg,$g])),isError:T.boolean().default(!1).optional()}),vj=s_.or(Ft.extend({toolResult:T.unknown()})),Og=Ht.extend({method:T.literal("tools/call"),params:qt.extend({name:T.string(),arguments:T.optional(T.record(T.unknown()))})}),wj=pn.extend({method:T.literal("notifications/tools/list_changed")});var Cg="2025-03-26";var es=class{static{i(this,"MCPServer")}capabilities;tools=new Map;name;version;instructions;logger;constructor(e){this.name=e.name||"MCP Server",this.version=e.version||"1.0.0",this.instructions=e.instructions||void 0,this.logger=e.logger||Yi(),this.capabilities={tools:{supported:!0,available:[]},...e.capabilities}}withTransport(e){e.onMessage(async r=>{try{if(ao(r)){let n=await this.handleRequest(r);if(n)return await e.send(n),n}else{if(Ig(r))return await this.handleNotification(r),null;if(Xi(r))return this.logger.debug("Received response:",r),null}}catch(n){if(this.logger.error("Error processing message:",n),ao(r)){let o={jsonrpc:"2.0",id:r.id,error:{code:-32603,message:n instanceof Error?n.message:"Internal error"}};return await e.send(o),o}}return null})}getTool(e){throw new Error("Method not implemented.")}getTools(){throw new Error("Method not implemented.")}getCapabilities(){return{...this.capabilities}}addTool(e){let{name:r,validator:n,handler:o,description:s=`Execute the ${r} tool`}=e,u={tool:{name:r,description:s,inputSchema:n.jsonSchema},validator:n,handler:o};this.tools.set(r,u),this.updateAvailableTools()}removeTool(e){let r=this.tools.delete(e);return r&&this.updateAvailableTools(),r}getToolDefinitions(){return Array.from(this.tools.values()).map(e=>e.tool)}async handleRequest(e){try{switch(e.method){case"ping":return this.handlePing(e);case"initialize":return this.handleInitialize(e);case"tools/list":return this.handleToolListRequest(e);case"tools/call":return this.handleToolCallRequest(e);default:return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Method "${e.method}" not found`}}}}catch(r){return this.logger.error("Error handling request:",r),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Internal error"}}}}async handleNotification(e){this.logger.debug("Received notification:",e.method)}handlePing(e){return{jsonrpc:"2.0",id:e.id,result:{}}}handleInitialize(e){let r={protocolVersion:Cg,capabilities:this.getCapabilities(),serverInfo:{name:this.name,version:this.version},...this.instructions?{instructions:this.instructions}:{}};return{jsonrpc:"2.0",id:e.id,result:r}}async handleToolListRequest(e){let n={tools:Array.from(this.tools.entries()).map(([o,s])=>s.tool)};return{jsonrpc:"2.0",id:e.id,result:n}}async handleToolCallRequest(e){let r=Og.safeParse(e);if(!r.success)return this.logger.warn("Could not validate tool call:",r.error),{jsonrpc:"2.0",id:e.id,error:{code:-32600,message:`Invalid request ${r.error}`}};let n=r.data,o=n.params.name,s=this.tools.get(o);if(!s)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Tool "${o}" not found`}};let a=n.params.arguments??{},u=s.validator.parse(a);if(!u.success)return{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid params",data:u.error}};try{let c=u.data,l=await s.handler(c);return{jsonrpc:"2.0",id:e.id,result:l}}catch(c){return this.logger.error(`Error executing tool "${o}":`,c),{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:c instanceof Error?c.message:"Tool execution error"}}}}updateAvailableTools(){this.capabilities.tools&&(this.capabilities.tools.available=Array.from(this.tools.keys()))}};var ts=class{static{i(this,"HTTPStreamableTransport")}messageHandler=null;closeCallback=null;options;connected=!1;enableStreaming=!1;sessions=new Map;streams=new Map;logger;constructor(e={},r=!1){this.options={timeout:30*60*1e3,enableSessions:!1,...e},this.logger=e.logger||Yi(),r&&this.startSessionCleanup()}onError(e){throw new Error("Method not implemented.")}getSessionId(){throw new Error("Method not implemented.")}setSessionId(e){throw new Error("Method not implemented.")}async connect(){this.connected=!0}async send(e){if(!this.connected)throw new Error("Transport not connected");if(Xi(e)){for(let[r,n]of this.sessions.entries())for(let[o,s]of n.streams.entries())if(s.pendingRequests.has(e.id)){await this.sendToStream(s,e),s.pendingRequests.delete(e.id),s.pendingRequests.size===0&&await this.closeStream(r,o);return}}else for(let r of this.sessions.values()){let n=[...r.streams.values()][0];n&&(await this.sendToStream(n,e),ao(e)&&n.pendingRequests.add(e.id))}}onMessage(e){this.messageHandler=e}onClose(e){this.closeCallback=e}async close(){this.connected=!1;for(let e of this.sessions.values()){for(let[r,n]of e.streams.entries())try{await n.writer.close()}catch(o){this.logger.warn("Error closing stream:",o)}e.streams.clear()}this.sessions.clear(),this.closeCallback&&this.closeCallback()}async handleRequest(e){if(!this.connected)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Transport not connected"},id:null}),{status:503,headers:{"Content-Type":"application/json"}});if(!this.messageHandler)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"No message handler registered"},id:null}),{status:500,headers:{"Content-Type":"application/json"}});let r=e.method.toUpperCase();try{this.validateOrigin(e);let n=e.headers.get("Mcp-Session-Id"),o;if(n&&(o=this.sessions.get(n),!o&&r!=="DELETE"))return new Response(null,{status:404});switch(r){case"POST":return await this.handlePostRequest(e,o);case"GET":return await this.handleGetRequest(e,o);case"DELETE":return await this.handleDeleteRequest(e,o?.id);default:return new Response(null,{status:405,headers:{Allow:"POST, GET, DELETE"}})}}catch(n){this.logger.error("Error handling request:",n);let o=400,s={jsonrpc:"2.0",error:{code:-32603,message:n||"Server error"},id:null};return new Response(JSON.stringify(s),{status:o,headers:{"Content-Type":"application/json"}})}}async handlePostRequest(e,r){let n=e.headers.get("Accept")||"";if(!n.includes("application/json")&&!n.includes("text/event-stream"))return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32600,message:"Not Acceptable: Client must accept application/json and text/event-stream"},id:null}),{status:406,headers:{"Content-Type":"application/json"}});let o=await this.extractJSONRPC(e);if(!o||Array.isArray(o)&&o.length===0)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null}),{status:400,headers:{"Content-Type":"application/json"}});let s=Array.isArray(o)?o:[o],a=s.some(c=>this.isRequest(c)),u=r;if(this.options.enableSessions&&!u&&s.some(c=>this.isRequest(c)&&c.method==="initialize")){let c=this.generateFallbackUUID();u=this.createSession(c)}try{if(!a){for(let m of s)await this.messageHandler?.(m);return new Response(null,{status:202,headers:u?{"Mcp-Session-Id":u.id}:void 0})}if(!this.enableStreaming){let m=[];for(let y of s)if(this.isRequest(y)){let w=await this.messageHandler?.(y);w&&m.push(w)}else await this.messageHandler?.(y);let f=m.length===1?m[0]:m,h={"Content-Type":"application/json"};return u&&(h["Mcp-Session-Id"]=u.id),new Response(JSON.stringify(f),{status:200,headers:h})}let{stream:c,streamId:l}=this.createStream(u),d=[];for(let m of s)if(this.isRequest(m)){this.streams.get(l)?.pendingRequests.add(m.id);let f=this.messageHandler?.(m);d.push(f)}else await this.messageHandler?.(m);let p={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};return u&&(p["Mcp-Session-Id"]=u.id),new Response(c.readable,{headers:p})}catch(c){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:c||"Internal error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}})}}async handleGetRequest(e,r){if(!(e.headers.get("Accept")||"").includes("text/event-stream"))return new Response(null,{status:406,headers:{"Content-Type":"application/json"}});if(this.options.enableSessions&&!r)return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Session required"},id:null}),{status:400,headers:{"Content-Type":"application/json"}});let{stream:o,streamId:s}=this.createStream(r),a=e.headers.get("Last-Event-ID");a&&r&&await this.replayMessages(r,s,a);let u={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};return r&&(u["Mcp-Session-Id"]=r.id),new Response(o.readable,{headers:u})}async handleDeleteRequest(e,r){if(!r)return new Response(null,{status:400});if(this.options.enableSessions&&r){let n=this.sessions.get(r);if(n){for(let[o,s]of n.streams.entries())await this.closeStream(r,o);return this.sessions.delete(r),new Response(null,{status:204})}}return new Response(null,{status:404})}async sendToStream(e,r){try{let n=String(++e.eventCounter),o=JSON.stringify(r);e.messages.push(r),e.messages.length>100&&e.messages.shift();let s=`id: ${n}
|
|
60
60
|
data: ${o}
|
|
61
61
|
|
|
62
62
|
`;await e.writer.write(new TextEncoder().encode(s))}catch(n){this.logger.warn("Error sending to stream:",n)}}async closeStream(e,r){let n=this.sessions.get(e);if(!n)return;let o=n.streams.get(r);if(o){try{await o.writer.close()}catch(s){this.logger.warn("Error closing stream:",s)}n.streams.delete(r),this.streams.delete(r)}}createSession(e){let r={id:e,createdAt:Date.now(),lastActivity:Date.now(),streams:new Map};return this.sessions.set(e,r),r}createStream(e){let r=new TransformStream,n=r.writable.getWriter(),o=crypto.randomUUID?.()||this.generateFallbackUUID(),s={id:o,writer:n,eventCounter:0,messages:[],pendingRequests:new Set};return this.streams.set(o,s),e&&(e.streams.set(o,s),e.lastActivity=Date.now()),{stream:r,streamId:o}}async replayMessages(e,r,n){for(let o of e.streams.values()){if(o.id===r)continue;let s=Number.parseInt(n,10);if(Number.isNaN(s))continue;let a=o.messages.slice(s),u=this.streams.get(r);if(u&&a.length>0)for(let c of a)await this.sendToStream(u,c)}}startSessionCleanup(){setInterval(()=>{let e=Date.now();for(let[r,n]of this.sessions.entries()){let o=this.options.timeout??6e4;if(e-n.lastActivity>o){for(let[s,a]of n.streams.entries()){try{a.writer.close().catch(u=>this.logger.warn("Error closing stream:",u))}catch(u){this.logger.warn("Error closing stream:",u)}this.streams.delete(s)}this.sessions.delete(r)}}},6e4)}async extractJSONRPC(e){try{let n=await e.clone().text();if(!n)throw new Error("Empty request body");return JSON.parse(n)}catch(r){throw new Error(`Failed to parse JSON-RPC message: ${r}`)}}validateOrigin(e){let r=e.headers.get("Origin");if(r&&!this.isValidOrigin(r))throw new Error("Invalid origin")}isValidOrigin(e){return!0}isRequest(e){return e!==null&&typeof e=="object"&&"jsonrpc"in e&&e.jsonrpc==="2.0"&&"method"in e&&"id"in e&&e.id!==null&&e.id!==void 0}generateFallbackUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}};var rs=class{static{i(this,"OpenApiUrlBuilder")}path;searchParams=new URLSearchParams;constructor(e){this.path=e}addParameter(e,r,n){let o=this.getParameterValue(e,r,n);if(o!=null)switch(e.in){case"path":this.addPathParameter(e.name,o);break;case"query":this.addQueryParameter(e.name,o);break;default:break}}getParameterValue(e,r,n){switch(e.in){case"path":return r?.[e.name];case"query":return n?.[e.name];default:return}}addPathParameter(e,r){let n=encodeURIComponent(String(r));this.path=this.path.replace(`{${e}}`,n)}addQueryParameter(e,r){Array.isArray(r)?r.forEach(n=>{n!=null&&this.searchParams.append(e,String(n))}):typeof r=="object"&&r!==null?this.searchParams.append(e,JSON.stringify(r)):this.searchParams.append(e,String(r))}toString(){let e=this.cleanupUrlPatternSyntax(this.path),r=this.searchParams.toString();return r?`${e}?${r}`:e}cleanupUrlPatternSyntax(e){return e.replace(/\{\/\}\?/g,"/").replace(/\{\/\}[*+]/g,"/").replace(/\{\/\}/g,"/").replace(/(\{[^}]*\})[?*+]/g,"$1")}};var fo=class{static{i(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(t,e,r,n,o,s){this.type=t,this.name=e,this.prefix=r,this.value=n,this.suffix=o,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},a_=/[$_\p{ID_Start}]/u,u_=/[$_\u200C\u200D\p{ID_Continue}]/u,Ou=".*";function c_(t,e){return(e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}i(c_,"Re");function Lg(t,e=!1){let r=[],n=0;for(;n<t.length;){let o=t[n],s=i(function(a){if(!e)throw new TypeError(a);r.push({type:"INVALID_CHAR",index:n,value:t[n++]})},"c");if(o==="*"){r.push({type:"ASTERISK",index:n,value:t[n++]});continue}if(o==="+"||o==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:t[n++]});continue}if(o==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:t[n++]});continue}if(o==="{"){r.push({type:"OPEN",index:n,value:t[n++]});continue}if(o==="}"){r.push({type:"CLOSE",index:n,value:t[n++]});continue}if(o===":"){let a="",u=n+1;for(;u<t.length;){let c=t.substr(u,1);if(u===n+1&&a_.test(c)||u!==n+1&&u_.test(c)){a+=t[u++];continue}break}if(!a){s(`Missing parameter name at ${n}`);continue}r.push({type:"NAME",index:n,value:a}),n=u;continue}if(o==="("){let a=1,u="",c=n+1,l=!1;if(t[c]==="?"){s(`Pattern cannot start with "?" at ${c}`);continue}for(;c<t.length;){if(!c_(t[c],!1)){s(`Invalid character '${t[c]}' at ${c}.`),l=!0;break}if(t[c]==="\\"){u+=t[c++]+t[c++];continue}if(t[c]===")"){if(a--,a===0){c++;break}}else if(t[c]==="("&&(a++,t[c+1]!=="?")){s(`Capturing groups are not allowed at ${c}`),l=!0;break}u+=t[c++]}if(l)continue;if(a){s(`Unbalanced pattern at ${n}`);continue}if(!u){s(`Missing pattern at ${n}`);continue}r.push({type:"REGEX",index:n,value:u}),n=c;continue}r.push({type:"CHAR",index:n,value:t[n++]})}return r.push({type:"END",index:n,value:""}),r}i(Lg,"v");function zg(t,e={}){let r=Lg(t);e.delimiter??="/#?",e.prefixes??="./";let n=`[^${ft(e.delimiter)}]+?`,o=[],s=0,a=0,u="",c=new Set,l=i(N=>{if(a<r.length&&r[a].type===N)return r[a++].value},"a"),d=i(()=>l("OTHER_MODIFIER")??l("ASTERISK"),"f"),p=i(N=>{let D=l(N);if(D!==void 0)return D;let{type:z,index:I}=r[a];throw new TypeError(`Unexpected ${z} at ${I}, expected ${N}`)},"d"),m=i(()=>{let N="",D;for(;D=l("CHAR")??l("ESCAPED_CHAR");)N+=D;return N},"T"),f=i(N=>N,"Se"),h=e.encodePart||f,y="",w=i(N=>{y+=N},"U"),E=i(()=>{y.length&&(o.push(new fo(3,"","",h(y),"",3)),y="")},"$"),S=i((N,D,z,I,M)=>{let K=3;switch(M){case"?":K=1;break;case"*":K=0;break;case"+":K=2;break}if(!D&&!z&&K===3){w(N);return}if(E(),!D&&!z){if(!N)return;o.push(new fo(3,"","",h(N),"",K));return}let W;z?z==="*"?W=Ou:W=z:W=n;let C=2;W===n?(C=1,W=""):W===Ou&&(C=0,W="");let k;if(D?k=D:z&&(k=s++),c.has(k))throw new TypeError(`Duplicate name '${k}'.`);c.add(k),o.push(new fo(C,k,h(N),W,h(I),K))},"V");for(;a<r.length;){let N=l("CHAR"),D=l("NAME"),z=l("REGEX");if(!D&&!z&&(z=l("ASTERISK")),D||z){let M=N??"";e.prefixes.indexOf(M)===-1&&(w(M),M=""),E();let K=d();S(M,D,z,"",K);continue}let I=N??l("ESCAPED_CHAR");if(I){w(I);continue}if(l("OPEN")){let M=m(),K=l("NAME"),W=l("REGEX");!K&&!W&&(W=l("ASTERISK"));let C=m();p("CLOSE");let k=d();S(M,K,W,C,k);continue}E(),p("END")}return o}i(zg,"D");function ft(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}i(ft,"S");function Ag(t){return t&&t.ignoreCase?"ui":"u"}i(Ag,"X");function l_(t,e,r){return Dg(zg(t,r),e,r)}i(l_,"Z");function mn(t){switch(t){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}i(mn,"k");function Dg(t,e,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let u of t){if(u.type===3){u.modifier===3?n+=ft(u.value):n+=`(?:${ft(u.value)})${mn(u.modifier)}`;continue}e&&e.push(u.name);let c=`[^${ft(r.delimiter)}]+?`,l=u.value;if(u.type===1?l=c:u.type===0&&(l=Ou),!u.prefix.length&&!u.suffix.length){u.modifier===3||u.modifier===1?n+=`(${l})${mn(u.modifier)}`:n+=`((?:${l})${mn(u.modifier)})`;continue}if(u.modifier===3||u.modifier===1){n+=`(?:${ft(u.prefix)}(${l})${ft(u.suffix)})`,n+=mn(u.modifier);continue}n+=`(?:${ft(u.prefix)}`,n+=`((?:${l})(?:`,n+=ft(u.suffix),n+=ft(u.prefix),n+=`(?:${l}))*)${ft(u.suffix)})`,u.modifier===0&&(n+="?")}let o=`[${ft(r.endsWith)}]|$`,s=`[${ft(r.delimiter)}]`;if(r.end)return r.strict||(n+=`${s}?`),r.endsWith.length?n+=`(?=${o})`:n+="$",new RegExp(n,Ag(r));r.strict||(n+=`(?:${s}(?=${o}))?`);let a=!1;if(t.length){let u=t[t.length-1];u.type===3&&u.modifier===3&&(a=r.delimiter.indexOf(u)>-1)}return a||(n+=`(?=${s}|${o})`),new RegExp(n,Ag(r))}i(Dg,"F");var pr={delimiter:"",prefixes:"",sensitive:!0,strict:!0},d_={delimiter:".",prefixes:"",sensitive:!0,strict:!0},p_={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function m_(t,e){return t.length?t[0]==="/"?!0:!e||t.length<2?!1:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":!1}i(m_,"J");function Zg(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}i(Zg,"Q");function f_(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}i(f_,"Ee");function Ug(t){return!t||t.length<2?!1:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}i(Ug,"W");var jg=["ftp","file","http","https","ws","wss"];function Mg(t){if(!t)return!0;for(let e of jg)if(t.test(e))return!0;return!1}i(Mg,"N");function h_(t,e){if(t=Zg(t,"#"),e||t==="")return t;let r=new URL("https://example.com");return r.hash=t,r.hash?r.hash.substring(1,r.hash.length):""}i(h_,"te");function g_(t,e){if(t=Zg(t,"?"),e||t==="")return t;let r=new URL("https://example.com");return r.search=t,r.search?r.search.substring(1,r.search.length):""}i(g_,"re");function y_(t,e){return e||t===""?t:Ug(t)?Fg(t):Hg(t)}i(y_,"ne");function b_(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.password=t,r.password}i(b_,"se");function v_(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.username=t,r.username}i(v_,"ie");function w_(t,e,r){if(r||t==="")return t;if(e&&!jg.includes(e))return new URL(`${e}:${t}`).pathname;let n=t[0]=="/";return t=new URL(n?t:"/-"+t,"https://example.com").pathname,n||(t=t.substring(2,t.length)),t}i(w_,"ae");function x_(t,e,r){return qg(e)===t&&(t=""),r||t===""?t:Bg(t)}i(x_,"oe");function R_(t,e){return t=f_(t,":"),e||t===""?t:Cu(t)}i(R_,"ce");function qg(t){switch(t){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}i(qg,"_");function Cu(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}i(Cu,"y");function __(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}i(__,"le");function P_(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}i(P_,"fe");function Hg(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}i(Hg,"z");function Fg(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}i(Fg,"j");function Bg(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}i(Bg,"K");function I_(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}i(I_,"he");function S_(t){return t===""?t:new URL(`data:${t}`).pathname}i(S_,"ue");function k_(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}i(k_,"de");function E_(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}i(E_,"pe");var T_=class{static{i(this,"H")}#e;#t=[];#n={};#r=0;#o=1;#i=0;#s=0;#u=0;#c=0;#l=!1;constructor(t){this.#e=t}get result(){return this.#n}parse(){for(this.#t=Lg(this.#e,!0);this.#r<this.#t.length;this.#r+=this.#o){if(this.#o=1,this.#t[this.#r].type==="END"){if(this.#s===0){this.#v(),this.#m()?this.#a(9,1):this.#f()?this.#a(8,1):this.#a(7,0);continue}else if(this.#s===2){this.#h(5);continue}this.#a(10,0);break}if(this.#u>0)if(this.#S())this.#u-=1;else continue;if(this.#I()){this.#u+=1;continue}switch(this.#s){case 0:this.#w()&&this.#h(1);break;case 1:if(this.#w()){this.#T();let t=7,e=1;this.#R()?(t=2,e=3):this.#l&&(t=2),this.#a(t,e)}break;case 2:this.#y()?this.#h(3):(this.#b()||this.#f()||this.#m())&&this.#h(5);break;case 3:this.#_()?this.#a(4,1):this.#y()&&this.#a(5,1);break;case 4:this.#y()&&this.#a(5,1);break;case 5:this.#k()?this.#c+=1:this.#E()&&(this.#c-=1),this.#P()&&!this.#c?this.#a(6,1):this.#b()?this.#a(7,0):this.#f()?this.#a(8,1):this.#m()&&this.#a(9,1);break;case 6:this.#b()?this.#a(7,0):this.#f()?this.#a(8,1):this.#m()&&this.#a(9,1);break;case 7:this.#f()?this.#a(8,1):this.#m()&&this.#a(9,1);break;case 8:this.#m()&&this.#a(9,1);break;case 9:break;case 10:break}}this.#n.hostname!==void 0&&this.#n.port===void 0&&(this.#n.port="")}#a(t,e){switch(this.#s){case 0:break;case 1:this.#n.protocol=this.#p();break;case 2:break;case 3:this.#n.username=this.#p();break;case 4:this.#n.password=this.#p();break;case 5:this.#n.hostname=this.#p();break;case 6:this.#n.port=this.#p();break;case 7:this.#n.pathname=this.#p();break;case 8:this.#n.search=this.#p();break;case 9:this.#n.hash=this.#p();break;case 10:break}this.#s!==0&&t!==10&&([1,2,3,4].includes(this.#s)&&[6,7,8,9].includes(t)&&(this.#n.hostname??=""),[1,2,3,4,5,6].includes(this.#s)&&[8,9].includes(t)&&(this.#n.pathname??=this.#l?"/":""),[1,2,3,4,5,6,7].includes(this.#s)&&t===9&&(this.#n.search??="")),this.#x(t,e)}#x(t,e){this.#s=t,this.#i=this.#r+e,this.#r+=e,this.#o=0}#v(){this.#r=this.#i,this.#o=0}#h(t){this.#v(),this.#s=t}#g(t){return t<0&&(t=this.#t.length-t),t<this.#t.length?this.#t[t]:this.#t[this.#t.length-1]}#d(t,e){let r=this.#g(t);return r.value===e&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#w(){return this.#d(this.#r,":")}#R(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#y(){return this.#d(this.#r,"@")}#_(){return this.#d(this.#r,":")}#P(){return this.#d(this.#r,":")}#b(){return this.#d(this.#r,"/")}#f(){if(this.#d(this.#r,"?"))return!0;if(this.#t[this.#r].value!=="?")return!1;let t=this.#g(this.#r-1);return t.type!=="NAME"&&t.type!=="REGEX"&&t.type!=="CLOSE"&&t.type!=="ASTERISK"}#m(){return this.#d(this.#r,"#")}#I(){return this.#t[this.#r].type=="OPEN"}#S(){return this.#t[this.#r].type=="CLOSE"}#k(){return this.#d(this.#r,"[")}#E(){return this.#d(this.#r,"]")}#p(){let t=this.#t[this.#r],e=this.#g(this.#i).index;return this.#e.substring(e,t.index)}#T(){let t={};Object.assign(t,pr),t.encodePart=Cu;let e=l_(this.#p(),void 0,t);this.#l=Mg(e)}},$u=["protocol","username","password","hostname","port","pathname","search","hash"],dr="*";function Ng(t,e){if(typeof t!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(t,e);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}i(Ng,"ge");function Bt(t,e){return e?mo(t):t}i(Bt,"b");function po(t,e,r){let n;if(typeof e.baseURL=="string")try{n=new URL(e.baseURL),e.protocol===void 0&&(t.protocol=Bt(n.protocol.substring(0,n.protocol.length-1),r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&(t.username=Bt(n.username,r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&e.password===void 0&&(t.password=Bt(n.password,r)),e.protocol===void 0&&e.hostname===void 0&&(t.hostname=Bt(n.hostname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&(t.port=Bt(n.port,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&(t.pathname=Bt(n.pathname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&(t.search=Bt(n.search.substring(1,n.search.length),r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&e.hash===void 0&&(t.hash=Bt(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(`invalid baseURL '${e.baseURL}'.`)}if(typeof e.protocol=="string"&&(t.protocol=R_(e.protocol,r)),typeof e.username=="string"&&(t.username=v_(e.username,r)),typeof e.password=="string"&&(t.password=b_(e.password,r)),typeof e.hostname=="string"&&(t.hostname=y_(e.hostname,r)),typeof e.port=="string"&&(t.port=x_(e.port,t.protocol,r)),typeof e.pathname=="string"){if(t.pathname=e.pathname,n&&!m_(t.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(t.pathname=Bt(n.pathname.substring(0,o+1),r)+t.pathname)}t.pathname=w_(t.pathname,t.protocol,r)}return typeof e.search=="string"&&(t.search=g_(e.search,r)),typeof e.hash=="string"&&(t.hash=h_(e.hash,r)),t}i(po,"w");function mo(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}i(mo,"C");function $_(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}i($_,"Oe");function O_(t,e){e.delimiter??="/#?",e.prefixes??="./",e.sensitive??=!1,e.strict??=!1,e.end??=!0,e.start??=!0,e.endsWith="";let r=".*",n=`[^${$_(e.delimiter)}]+?`,o=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let a=0;a<t.length;++a){let u=t[a];if(u.type===3){if(u.modifier===3){s+=mo(u.value);continue}s+=`{${mo(u.value)}}${mn(u.modifier)}`;continue}let c=u.hasCustomName(),l=!!u.suffix.length||!!u.prefix.length&&(u.prefix.length!==1||!e.prefixes.includes(u.prefix)),d=a>0?t[a-1]:null,p=a<t.length-1?t[a+1]:null;if(!l&&c&&u.type===1&&u.modifier===3&&p&&!p.prefix.length&&!p.suffix.length)if(p.type===3){let m=p.value.length>0?p.value[0]:"";l=o.test(m)}else l=!p.hasCustomName();if(!l&&!u.prefix.length&&d&&d.type===3){let m=d.value[d.value.length-1];l=e.prefixes.includes(m)}l&&(s+="{"),s+=mo(u.prefix),c&&(s+=`:${u.name}`),u.type===2?s+=`(${u.value})`:u.type===1?c||(s+=`(${n})`):u.type===0&&(!c&&(!d||d.type===3||d.modifier!==3||l||u.prefix!=="")?s+="*":s+=`(${r})`),u.type===1&&c&&u.suffix.length&&o.test(u.suffix[0])&&(s+="\\"),s+=mo(u.suffix),l&&(s+="}"),u.modifier!==3&&(s+=mn(u.modifier))}return s}i(O_,"ke");var Vg=class{static{i(this,"me")}#e;#t={};#n={};#r={};#o={};#i=!1;constructor(t={},e,r){try{let n;if(typeof e=="string"?n=e:r=e,typeof t=="string"){let u=new T_(t);if(u.parse(),t=u.result,n===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=n}else{if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let o={ignoreCase:r.ignoreCase===!0},s={pathname:dr,protocol:dr,username:dr,password:dr,hostname:dr,port:dr,search:dr,hash:dr};this.#e=po(s,t,!0),qg(this.#e.protocol)===this.#e.port&&(this.#e.port="");let a;for(a of $u){if(!(a in this.#e))continue;let u={},c=this.#e[a];switch(this.#n[a]=[],a){case"protocol":Object.assign(u,pr),u.encodePart=Cu;break;case"username":Object.assign(u,pr),u.encodePart=__;break;case"password":Object.assign(u,pr),u.encodePart=P_;break;case"hostname":Object.assign(u,d_),Ug(c)?u.encodePart=Fg:u.encodePart=Hg;break;case"port":Object.assign(u,pr),u.encodePart=Bg;break;case"pathname":Mg(this.#t.protocol)?(Object.assign(u,p_,o),u.encodePart=I_):(Object.assign(u,pr,o),u.encodePart=S_);break;case"search":Object.assign(u,pr,o),u.encodePart=k_;break;case"hash":Object.assign(u,pr,o),u.encodePart=E_;break}try{this.#o[a]=zg(c,u),this.#t[a]=Dg(this.#o[a],this.#n[a],u),this.#r[a]=O_(this.#o[a],u),this.#i=this.#i||this.#o[a].some(l=>l.type===2)}catch{throw new TypeError(`invalid ${a} pattern '${this.#e[a]}'.`)}}}catch(n){throw new TypeError(`Failed to construct 'URLPattern': ${n.message}`)}}test(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return!1;try{typeof t=="object"?r=po(r,t,!1):r=po(r,Ng(t,e),!1)}catch{return!1}let n;for(n of $u)if(!this.#t[n].exec(r[n]))return!1;return!0}exec(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?r=po(r,t,!1):r=po(r,Ng(t,e),!1)}catch{return null}let n={};e?n.inputs=[t,e]:n.inputs=[t];let o;for(o of $u){let s=this.#t[o].exec(r[o]);if(!s)return null;let a={};for(let[u,c]of this.#n[o].entries())if(typeof c=="string"||typeof c=="number"){let l=s[u+1];a[c]=l}n[o]={input:r[o]??"",groups:a}}return n}static compareComponent(t,e,r){let n=i((u,c)=>{for(let l of["type","modifier","prefix","value","suffix"]){if(u[l]<c[l])return-1;if(u[l]!==c[l])return 1}return 0},"o"),o=new fo(3,"","","","",3),s=new fo(0,"","","","",3),a=i((u,c)=>{let l=0;for(;l<Math.min(u.length,c.length);++l){let d=n(u[l],c[l]);if(d)return d}return u.length===c.length?0:n(u[l]??o,c[l]??o)},"s");return!e.#r[t]&&!r.#r[t]?0:e.#r[t]&&!r.#r[t]?a(e.#o[t],[s]):!e.#r[t]&&r.#r[t]?a([s],r.#o[t]):a(e.#o[t],r.#o[t])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#i}};var ns=class{static{i(this,"UrlPatternBuilder")}pattern;pathParams={};searchParams=new URLSearchParams;constructor(e){this.pattern=new Vg({pathname:e})}addParameter(e,r,n){let o=this.getParameterValue(e,r,n);if(o!=null)switch(e.in){case"path":this.addPathParameter(e.name,o);break;case"query":this.addQueryParameter(e.name,o);break;default:break}}getParameterValue(e,r,n){switch(e.in){case"path":return r?.[e.name];case"query":return n?.[e.name];default:return}}addPathParameter(e,r){this.pathParams[e]=String(r)}addQueryParameter(e,r){Array.isArray(r)?r.forEach(n=>{n!=null&&this.searchParams.append(e,String(n))}):typeof r=="object"&&r!==null?this.searchParams.append(e,JSON.stringify(r)):this.searchParams.append(e,String(r))}toString(){let e=this.pattern.pathname.replace(/:(\w+)(\([^)]*\))?([*+?])?/g,(n,o)=>this.pathParams[o]?encodeURIComponent(this.pathParams[o]):n),r=this.searchParams.toString();return r?`${e}?${r}`:e}};var os=class{constructor(e){this.routeData=e}static{i(this,"McpUrlBuilder")}build(e,r){let n=this.routeData.pathMode==="url-pattern",o=this.routeData.pathPattern?this.routeData.pathPattern:this.routeData.path,s=n?new ns(o):new rs(o),a=this.routeData.raw()?.parameters||[];for(let u of a)s.addParameter(u,e,r);return s.toString()}};var ho=class{static{i(this,"CustomValidator")}jsonSchema;parseFn;constructor(e,r){this.jsonSchema=e,this.parseFn=r}parse(e){return this.parseFn(e)}};var ge={};Qt(ge,{$brand:()=>is,$input:()=>_d,$output:()=>Rd,NEVER:()=>hE,ZodAny:()=>db,ZodArray:()=>fb,ZodBase64:()=>Lp,ZodBase64URL:()=>zp,ZodBigInt:()=>Xo,ZodBigIntFormat:()=>Up,ZodBoolean:()=>Qo,ZodCIDRv4:()=>Ap,ZodCIDRv6:()=>Np,ZodCUID:()=>Sp,ZodCUID2:()=>kp,ZodCatch:()=>Nb,ZodCustom:()=>oa,ZodDate:()=>Js,ZodDefault:()=>Eb,ZodDiscriminatedUnion:()=>hb,ZodE164:()=>Dp,ZodEmail:()=>Rp,ZodEmoji:()=>Pp,ZodEnum:()=>Yo,ZodError:()=>ik,ZodFile:()=>Ib,ZodGUID:()=>Ks,ZodIPv4:()=>Op,ZodIPv6:()=>Cp,ZodIntersection:()=>gb,ZodIssueCode:()=>mE,ZodJWT:()=>Zp,ZodKSUID:()=>$p,ZodLazy:()=>jb,ZodLiteral:()=>_b,ZodMap:()=>wb,ZodNaN:()=>zb,ZodNanoID:()=>Ip,ZodNever:()=>pb,ZodNonOptional:()=>Vp,ZodNull:()=>cb,ZodNullable:()=>kb,ZodNumber:()=>Ko,ZodNumberFormat:()=>xn,ZodObject:()=>ra,ZodOptional:()=>Bp,ZodPipe:()=>Gp,ZodPrefault:()=>$b,ZodPromise:()=>qb,ZodReadonly:()=>Db,ZodRealError:()=>wn,ZodRecord:()=>Hp,ZodSet:()=>xb,ZodString:()=>Ws,ZodStringFormat:()=>Oe,ZodSuccess:()=>Ab,ZodSymbol:()=>ab,ZodTemplateLiteral:()=>Ub,ZodTransform:()=>Sb,ZodTuple:()=>bb,ZodType:()=>we,ZodULID:()=>Ep,ZodURL:()=>_p,ZodUUID:()=>Kt,ZodUndefined:()=>ub,ZodUnion:()=>qp,ZodUnknown:()=>jp,ZodVoid:()=>mb,ZodXID:()=>Tp,_ZodString:()=>xp,_default:()=>Tb,any:()=>Hk,array:()=>Mp,base64:()=>$k,base64url:()=>Ok,bigint:()=>Zk,boolean:()=>sb,catch:()=>Lb,check:()=>Hb,cidrv4:()=>Ek,cidrv6:()=>Tk,clone:()=>st,coerce:()=>bp,config:()=>Ue,core:()=>Jt,cuid:()=>xk,cuid2:()=>Rk,custom:()=>uE,date:()=>Bk,discriminatedUnion:()=>Kk,e164:()=>Ck,email:()=>pk,emoji:()=>vk,endsWith:()=>qo,enum:()=>Rb,file:()=>rE,flattenError:()=>Io,float32:()=>Nk,float64:()=>Lk,formatError:()=>So,function:()=>up,getErrorMap:()=>yE,globalRegistry:()=>Ot,gt:()=>Gt,gte:()=>et,guid:()=>mk,includes:()=>jo,instanceof:()=>cE,int:()=>wp,int32:()=>zk,int64:()=>Uk,intersection:()=>yb,ipv4:()=>Sk,ipv6:()=>kk,iso:()=>Gs,json:()=>dE,jwt:()=>Ak,keyof:()=>Vk,ksuid:()=>Ik,lazy:()=>Mb,length:()=>vn,literal:()=>Pb,locales:()=>No,looseObject:()=>Jk,lowercase:()=>Zo,lt:()=>Vt,lte:()=>ht,map:()=>Yk,maxLength:()=>bn,maxSize:()=>yn,mime:()=>Ho,minLength:()=>fr,minSize:()=>qr,multipleOf:()=>Mr,nan:()=>iE,nanoid:()=>wk,nativeEnum:()=>tE,negative:()=>ep,never:()=>ta,nonnegative:()=>rp,nonoptional:()=>Cb,nonpositive:()=>tp,normalize:()=>Fo,null:()=>lb,nullable:()=>Ys,nullish:()=>nE,number:()=>ib,object:()=>Gk,optional:()=>Xs,overwrite:()=>Wt,parse:()=>fp,parseAsync:()=>hp,partialRecord:()=>Xk,pipe:()=>ea,positive:()=>Yd,prefault:()=>Ob,preprocess:()=>pE,prettifyError:()=>Bu,promise:()=>aE,property:()=>np,readonly:()=>Zb,record:()=>vb,refine:()=>Fb,regex:()=>Do,regexes:()=>Ur,registry:()=>Ps,safeParse:()=>gp,safeParseAsync:()=>yp,set:()=>eE,setErrorMap:()=>gE,size:()=>zo,startsWith:()=>Mo,strictObject:()=>Wk,string:()=>vp,stringbool:()=>lE,success:()=>oE,superRefine:()=>Bb,symbol:()=>Mk,templateLiteral:()=>sE,toJSONSchema:()=>cp,toLowerCase:()=>Vo,toUpperCase:()=>Go,transform:()=>Fp,treeifyError:()=>Fu,trim:()=>Bo,tuple:()=>Qk,uint32:()=>Dk,uint64:()=>jk,ulid:()=>_k,undefined:()=>qk,union:()=>na,unknown:()=>Qs,uppercase:()=>Uo,url:()=>bk,uuid:()=>fk,uuidv4:()=>hk,uuidv6:()=>gk,uuidv7:()=>yk,void:()=>Fk,xid:()=>Pk});var Jt={};Qt(Jt,{$ZodAny:()=>hl,$ZodArray:()=>vl,$ZodAsyncError:()=>Tt,$ZodBase64:()=>sl,$ZodBase64URL:()=>al,$ZodBigInt:()=>Rs,$ZodBigIntFormat:()=>dl,$ZodBoolean:()=>$o,$ZodCIDRv4:()=>nl,$ZodCIDRv6:()=>ol,$ZodCUID:()=>Vc,$ZodCUID2:()=>Gc,$ZodCatch:()=>zl,$ZodCheck:()=>Le,$ZodCheckBigIntFormat:()=>Rc,$ZodCheckEndsWith:()=>Nc,$ZodCheckGreaterThan:()=>bs,$ZodCheckIncludes:()=>Cc,$ZodCheckLengthEquals:()=>Ec,$ZodCheckLessThan:()=>ys,$ZodCheckLowerCase:()=>$c,$ZodCheckMaxLength:()=>Sc,$ZodCheckMaxSize:()=>_c,$ZodCheckMimeType:()=>zc,$ZodCheckMinLength:()=>kc,$ZodCheckMinSize:()=>Pc,$ZodCheckMultipleOf:()=>wc,$ZodCheckNumberFormat:()=>xc,$ZodCheckOverwrite:()=>Dc,$ZodCheckProperty:()=>Lc,$ZodCheckRegex:()=>Tc,$ZodCheckSizeEquals:()=>Ic,$ZodCheckStartsWith:()=>Ac,$ZodCheckStringFormat:()=>hn,$ZodCheckUpperCase:()=>Oc,$ZodCustom:()=>ql,$ZodDate:()=>bl,$ZodDefault:()=>Cl,$ZodDiscriminatedUnion:()=>xl,$ZodE164:()=>ul,$ZodEmail:()=>qc,$ZodEmoji:()=>Fc,$ZodEnum:()=>Sl,$ZodError:()=>Po,$ZodFile:()=>El,$ZodFunction:()=>Vs,$ZodGUID:()=>jc,$ZodIPv4:()=>tl,$ZodIPv6:()=>rl,$ZodISODate:()=>Xc,$ZodISODateTime:()=>Qc,$ZodISODuration:()=>el,$ZodISOTime:()=>Yc,$ZodIntersection:()=>Rl,$ZodJWT:()=>cl,$ZodKSUID:()=>Kc,$ZodLazy:()=>Ml,$ZodLiteral:()=>kl,$ZodMap:()=>Pl,$ZodNaN:()=>Dl,$ZodNanoID:()=>Bc,$ZodNever:()=>gl,$ZodNonOptional:()=>Nl,$ZodNull:()=>fl,$ZodNullable:()=>Ol,$ZodNumber:()=>xs,$ZodNumberFormat:()=>ll,$ZodObject:()=>wl,$ZodOptional:()=>$l,$ZodPipe:()=>Co,$ZodPrefault:()=>Al,$ZodPromise:()=>jl,$ZodReadonly:()=>Zl,$ZodRealError:()=>fn,$ZodRecord:()=>_l,$ZodRegistry:()=>gn,$ZodSet:()=>Il,$ZodString:()=>To,$ZodStringFormat:()=>$e,$ZodSuccess:()=>Ll,$ZodSymbol:()=>pl,$ZodTemplateLiteral:()=>Ul,$ZodTransform:()=>Tl,$ZodTuple:()=>jr,$ZodType:()=>de,$ZodULID:()=>Wc,$ZodURL:()=>Hc,$ZodUUID:()=>Mc,$ZodUndefined:()=>ml,$ZodUnion:()=>_s,$ZodUnknown:()=>Oo,$ZodVoid:()=>yl,$ZodXID:()=>Jc,$brand:()=>is,$constructor:()=>_,$input:()=>_d,$output:()=>Rd,Doc:()=>Eo,JSONSchema:()=>Xy,JSONSchemaGenerator:()=>Jo,_any:()=>Vd,_array:()=>op,_base64:()=>qs,_base64url:()=>Hs,_bigint:()=>Ud,_boolean:()=>Dd,_catch:()=>KS,_cidrv4:()=>js,_cidrv6:()=>Ms,_coercedBigint:()=>jd,_coercedBoolean:()=>Zd,_coercedDate:()=>Qd,_coercedNumber:()=>Od,_coercedString:()=>Id,_cuid:()=>As,_cuid2:()=>Ns,_custom:()=>Wo,_date:()=>Kd,_default:()=>GS,_discriminatedUnion:()=>zS,_e164:()=>Fs,_email:()=>Is,_emoji:()=>Os,_endsWith:()=>qo,_enum:()=>MS,_file:()=>sp,_float32:()=>Ad,_float64:()=>Nd,_gt:()=>Gt,_gte:()=>et,_guid:()=>Lo,_includes:()=>jo,_int:()=>Cd,_int32:()=>Ld,_int64:()=>Md,_intersection:()=>DS,_ipv4:()=>Zs,_ipv6:()=>Us,_isoDate:()=>kd,_isoDateTime:()=>Sd,_isoDuration:()=>Td,_isoTime:()=>Ed,_jwt:()=>Bs,_ksuid:()=>Ds,_lazy:()=>ek,_length:()=>vn,_literal:()=>HS,_lowercase:()=>Zo,_lt:()=>Vt,_lte:()=>ht,_map:()=>US,_max:()=>ht,_maxLength:()=>bn,_maxSize:()=>yn,_mime:()=>Ho,_min:()=>et,_minLength:()=>fr,_minSize:()=>qr,_multipleOf:()=>Mr,_nan:()=>Xd,_nanoid:()=>Cs,_nativeEnum:()=>qS,_negative:()=>ep,_never:()=>Wd,_nonnegative:()=>rp,_nonoptional:()=>WS,_nonpositive:()=>tp,_normalize:()=>Fo,_null:()=>Bd,_nullable:()=>VS,_number:()=>$d,_optional:()=>BS,_overwrite:()=>Wt,_parse:()=>us,_parseAsync:()=>ls,_pipe:()=>QS,_positive:()=>Yd,_promise:()=>tk,_property:()=>np,_readonly:()=>XS,_record:()=>ZS,_refine:()=>rk,_regex:()=>Do,_safeParse:()=>ps,_safeParseAsync:()=>ms,_set:()=>jS,_size:()=>zo,_startsWith:()=>Mo,_string:()=>Pd,_stringbool:()=>ap,_success:()=>JS,_symbol:()=>Hd,_templateLiteral:()=>YS,_toLowerCase:()=>Vo,_toUpperCase:()=>Go,_transform:()=>FS,_trim:()=>Bo,_tuple:()=>ip,_uint32:()=>zd,_uint64:()=>qd,_ulid:()=>Ls,_undefined:()=>Fd,_union:()=>LS,_unknown:()=>Gd,_uppercase:()=>Uo,_url:()=>$s,_uuid:()=>Ss,_uuidv4:()=>ks,_uuidv6:()=>Es,_uuidv7:()=>Ts,_void:()=>Jd,_xid:()=>zs,clone:()=>st,config:()=>Ue,flattenError:()=>Io,formatError:()=>So,function:()=>up,globalConfig:()=>go,globalRegistry:()=>Ot,isValidBase64:()=>il,isValidBase64URL:()=>py,isValidJWT:()=>my,locales:()=>No,parse:()=>cs,parseAsync:()=>ds,prettifyError:()=>Bu,regexes:()=>Ur,registry:()=>Ps,safeParse:()=>Vu,safeParseAsync:()=>Gu,toDotPath:()=>Wg,toJSONSchema:()=>cp,treeifyError:()=>Fu,util:()=>te,version:()=>Zc});function _(t,e,r){function n(u,c){var l;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(l=u._zod).traits??(l.traits=new Set),u._zod.traits.add(t),e(u,c);for(let d in a.prototype)Object.defineProperty(u,d,{value:a.prototype[d].bind(u)});u._zod.constr=a,u._zod.def=c}i(n,"init");let o=r?.Parent??Object;class s extends o{static{i(this,"Definition")}}Object.defineProperty(s,"name",{value:t});function a(u){var c;let l=r?.Parent?new s:this;n(l,u),(c=l._zod).deferred??(c.deferred=[]);for(let d of l._zod.deferred)d();return l}return i(a,"_"),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i(u=>r?.Parent&&u instanceof r.Parent?!0:u?._zod?.traits?.has(t),"value")}),Object.defineProperty(a,"name",{value:t}),a}i(_,"$constructor");var is=Symbol("zod_brand"),Tt=class extends Error{static{i(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},go={};function Ue(t){return t&&Object.assign(go,t),go}i(Ue,"config");var te={};Qt(te,{BIGINT_FORMAT_RANGES:()=>qu,Class:()=>Nu,NUMBER_FORMAT_RANGES:()=>Mu,aborted:()=>Dr,allowsEval:()=>Zu,assert:()=>z_,assertEqual:()=>C_,assertIs:()=>N_,assertNever:()=>L_,assertNotEqual:()=>A_,assignProp:()=>Du,cached:()=>bo,cleanEnum:()=>J_,cleanRegex:()=>vo,clone:()=>st,createTransparentProxy:()=>q_,defineLazy:()=>ke,esc:()=>zr,escapeRegex:()=>$t,extend:()=>B_,finalizeIssue:()=>at,floatSafeRemainder:()=>zu,getElementAtPath:()=>Z_,getLengthableOrigin:()=>_o,getParsedType:()=>M_,getSizableOrigin:()=>Ro,getValidEnumValues:()=>D_,isObject:()=>as,isPlainObject:()=>wo,issue:()=>Hu,joinValues:()=>Z,jsonStringifyReplacer:()=>Lu,merge:()=>V_,normalizeParams:()=>J,nullish:()=>mr,numKeys:()=>j_,omit:()=>F_,optionalKeys:()=>ju,partial:()=>G_,pick:()=>H_,prefixIssues:()=>Ye,primitiveTypes:()=>Uu,promiseAllObject:()=>U_,propertyKeyTypes:()=>xo,randomString:()=>ss,required:()=>W_,stringifyPrimitive:()=>ne,unwrapMessage:()=>yo});function C_(t){return t}i(C_,"assertEqual");function A_(t){return t}i(A_,"assertNotEqual");function N_(t){}i(N_,"assertIs");function L_(t){throw new Error}i(L_,"assertNever");function z_(t){}i(z_,"assert");function D_(t){let e=Object.keys(t).filter(n=>typeof t[t[n]]!="number"),r={};for(let n of e)r[n]=t[n];return Object.values(r)}i(D_,"getValidEnumValues");function Z(t,e="|"){return t.map(r=>ne(r)).join(e)}i(Z,"joinValues");function Lu(t,e){return typeof e=="bigint"?e.toString():e}i(Lu,"jsonStringifyReplacer");function bo(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}i(bo,"cached");function mr(t){return t==null}i(mr,"nullish");function vo(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}i(vo,"cleanRegex");function zu(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}i(zu,"floatSafeRemainder");function ke(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}i(ke,"defineLazy");function Du(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}i(Du,"assignProp");function Z_(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}i(Z_,"getElementAtPath");function U_(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}i(U_,"promiseAllObject");function ss(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}i(ss,"randomString");function zr(t){return JSON.stringify(t)}i(zr,"esc");function as(t){return typeof t=="object"&&t!==null}i(as,"isObject");var Zu=bo(()=>{try{let t=Function;return new t(""),!0}catch{return!1}});function wo(t){return typeof t=="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype}i(wo,"isPlainObject");function j_(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}i(j_,"numKeys");var M_=i(t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},"getParsedType"),xo=new Set(["string","number","symbol"]),Uu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function $t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i($t,"escapeRegex");function st(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}i(st,"clone");function J(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:i(()=>e,"error")};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:i(()=>e.error,"error")}:e}i(J,"normalizeParams");function q_(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}i(q_,"createTransparentProxy");function ne(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}i(ne,"stringifyPrimitive");function ju(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional")}i(ju,"optionalKeys");var Mu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},qu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function H_(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return st(t,{...t._zod.def,shape:r,checks:[]})}i(H_,"pick");function F_(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return st(t,{...t._zod.def,shape:r,checks:[]})}i(F_,"omit");function B_(t,e){let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return Du(this,"shape",n),n},checks:[]};return st(t,r)}i(B_,"extend");function V_(t,e){return st(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return Du(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}i(V_,"merge");function G_(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return st(e,{...e._zod.def,shape:o,checks:[]})}i(G_,"partial");function W_(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return st(e,{...e._zod.def,shape:o,checks:[]})}i(W_,"required");function Dr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r].continue!==!0)return!0;return!1}i(Dr,"aborted");function Ye(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}i(Ye,"prefixIssues");function yo(t){return typeof t=="string"?t:t?.message}i(yo,"unwrapMessage");function at(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=yo(t.inst?._zod.def?.error?.(t))??yo(e?.error?.(t))??yo(r.customError?.(t))??yo(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}i(at,"finalizeIssue");function Ro(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}i(Ro,"getSizableOrigin");function _o(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}i(_o,"getLengthableOrigin");function Hu(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}i(Hu,"issue");function J_(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}i(J_,"cleanEnum");var Nu=class{static{i(this,"Class")}constructor(...e){}};var Gg=i((t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,Lu,2)},enumerable:!0})},"initializer"),Po=_("$ZodError",Gg),fn=_("$ZodError",Gg,{Parent:Error});function Io(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}i(Io,"flattenError");function So(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.errors.map(u=>o({issues:u}));else if(a.code==="invalid_key")o({issues:a.issues});else if(a.code==="invalid_element")o({issues:a.issues});else if(a.path.length===0)n._errors.push(r(a));else{let u=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(r(a))):u[l]=u[l]||{_errors:[]},u=u[l],c++}}},"processError");return o(t),n}i(So,"formatError");function Fu(t,e){let r=e||function(s){return s.message},n={errors:[]},o=i((s,a=[])=>{var u,c;for(let l of s.issues)if(l.code==="invalid_union")l.errors.map(d=>o({issues:d},l.path));else if(l.code==="invalid_key")o({issues:l.issues},l.path);else if(l.code==="invalid_element")o({issues:l.issues},l.path);else{let d=[...a,...l.path];if(d.length===0){n.errors.push(r(l));continue}let p=n,m=0;for(;m<d.length;){let f=d[m],h=m===d.length-1;typeof f=="string"?(p.properties??(p.properties={}),(u=p.properties)[f]??(u[f]={errors:[]}),p=p.properties[f]):(p.items??(p.items=[]),(c=p.items)[f]??(c[f]={errors:[]}),p=p.items[f]),h&&p.errors.push(r(l)),m++}}},"processError");return o(t),n}i(Fu,"treeifyError");function Wg(t){let e=[];for(let r of t)typeof r=="number"?e.push(`[${r}]`):typeof r=="symbol"?e.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?e.push(`[${JSON.stringify(r)}]`):(e.length&&e.push("."),e.push(r));return e.join("")}i(Wg,"toDotPath");function Bu(t){let e=[],r=[...t.issues].sort((n,o)=>n.path.length-o.path.length);for(let n of r)e.push(`\u2716 ${n.message}`),n.path?.length&&e.push(` \u2192 at ${Wg(n.path)}`);return e.join(`
|