@zuplo/runtime 7.13.13 → 7.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@ import{a as kf}from"./chunk-UKQQD2JN.js";import{a as s,c as xe}from"./chunk-TYV5
32
32
  `))):c=e.stylize("[Circular]","special")),Ef(a)){if(n&&t.match(/^\d+$/))return c;a=JSON.stringify(""+t),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+c}s(Po,"formatProperty");function Fv(e,r){if(Ef(r))return e.stylize("undefined","undefined");if(Nf(r)){let i="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}if(Lv(r))return e.stylize(""+r,"number");if(Rv(r))return e.stylize(""+r,"boolean");if(Tf(r))return e.stylize("null","null")}s(Fv,"formatPrimitive");function Bv(e,r,i){let o=0;return e.reduce(function(n,a){return o++,a.indexOf(`
33
33
  `)>=0&&o++,n+a.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?i[0]+(r===""?"":r+`
34
34
  `)+" "+e.join(`,
35
- `)+" "+i[1]:i[0]+r+" "+e.join(", ")+" "+i[1]}s(Bv,"reduceToSingleString");var jf=s((e,...r)=>Af(Ae,e,r),"format");var Eo=class{static{s(this,"Debugger")}manager;ns;color;last;enabled;constructor(r,i){this.manager=r,this.ns=i,this.color=Pf(i),this.last=0,this.enabled=r.enabled.some(o=>o.test(i))}log(...r){if(!this.enabled)return;let i,o=r[0];typeof o=="function"?i=o():i=String(o);let t=Date.now()-(this.last||Date.now());i=jf(i,...r);let n=`${this.color(this.ns)} ${i} ${this.color(`+${t}ms`)}`;console.log(n),this.last=Date.now()}},No=class{static{s(this,"DebugManager")}debuggers;enabled;constructor(r){this.debuggers=new Map,this.enabled=r??[]}};function Jv(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(r=>new RegExp(`^${r}$`)))}s(Jv,"extract");var dn;function fn(e){let r=globalThis.DEBUG;dn||(dn=new No(Jv(r)));let i=new Eo(dn,e);return dn.debuggers.set(e,i),Object.assign(i.log.bind(i),{self:i})}s(fn,"debug");var Kv=/: client error \((?:Connect|SendRequest)\):/;function Hv(e){return e instanceof TypeError&&e.message.startsWith("error sending request ")&&Kv.test(e.message)}s(Hv,"isDenoClientError");function er(e,r){return r?e.catch(i=>{throw Hv(i)?new sn(i):i}):e}s(er,"wrapDenoNetworkErrors");function Gv(e){if(e.length>=255)throw new TypeError("Alphabet too long");let r=new Uint8Array(256);for(let u=0;u<r.length;u++)r[u]=255;for(let u=0;u<e.length;u++){let d=e.charAt(u),f=d.charCodeAt(0);if(r[f]!==255)throw new TypeError(d+" is ambiguous");r[f]=u}let i=e.length,o=e.charAt(0),t=Math.log(i)/Math.log(256),n=Math.log(256)/Math.log(i);function a(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";let d=0,f=0,p=0,m=u.length;for(;p!==m&&u[p]===0;)p++,d++;let h=(m-p)*n+1>>>0,$=new Uint8Array(h);for(;p!==m;){let I=u[p],z=0;for(let O=h-1;(I!==0||z<f)&&O!==-1;O--,z++)I+=256*$[O]>>>0,$[O]=I%i>>>0,I=I/i>>>0;if(I!==0)throw new Error("Non-zero carry");f=z,p++}let x=h-f;for(;x!==h&&$[x]===0;)x++;let S=o.repeat(d);for(;x<h;++x)S+=e.charAt($[x]);return S}s(a,"encode");function c(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;let d=0,f=0,p=0;for(;u[d]===o;)f++,d++;let m=(u.length-d)*t+1>>>0,h=new Uint8Array(m);for(;d<u.length;){let I=u.charCodeAt(d);if(I>255)return;let z=r[I];if(z===255)return;let O=0;for(let U=m-1;(z!==0||O<p)&&U!==-1;U--,O++)z+=i*h[U]>>>0,h[U]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");p=O,d++}let $=m-p;for(;$!==m&&h[$]===0;)$++;let x=new Uint8Array(f+(m-$)),S=f;for(;$!==m;)x[S++]=h[$++];return x}s(c,"decodeUnsafe");function l(u){let d=c(u);if(d)return d;throw new Error("Non-base"+i+" character")}return s(l,"decode"),{encode:a,decodeUnsafe:c,decode:l}}s(Gv,"base");var Cf=Gv;var Wv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Rf=Cf(Wv);var To="2025-02-06",Zf=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2026-03-01":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1}});function Lf(e={}){let{runtime:r="cloudflare"}=e;return new W({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:To,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Zf[To]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:r,__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"bckt_mock"}})}s(Lf,"getMockEnvironment");var qv=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Xv(e,r){let i=e.__ZUPLO_TRUSTED_IP_HEADER?.trim();if(!i)return r?bo:If;if(!qv.test(i))throw new an(`__ZUPLO_TRUSTED_IP_HEADER is set to '${i}', which is not a valid HTTP header name. Header names may only contain the RFC 9110 token characters (letters, digits, and !#$%&'*+-.^_\`|~) - spaces, colons and tabs are not allowed. Set it to a valid header name such as '${bo}' or 'cf-connecting-ip'.`);return i.toLowerCase()}s(Xv,"resolveTrustedIpHeader");var W=class e{static{s(this,"Environment")}config;#e;static#n;static#t=!1;static initialize(r){e.#n||(e.#n=new e(r),e.#t=!0)}static get instance(){return e.#t||(ke.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),e.#n??=Lf(),e.#t=!0),e.#n}constructor({build:r,runtime:i}){let o;try{if(i.ZUPLO_SYSTEM_CONFIGURATIONS){let t=new TextDecoder().decode(Rf.decode(i.ZUPLO_SYSTEM_CONFIGURATIONS)),n=JSON.parse(t);for(let a of Object.keys(n))i[a]||(i[a]=n[a])}if(i.__ZUPLO_CONFIG){let t=atob(i.__ZUPLO_CONFIG);o=JSON.parse(t)}}catch(t){ke.console.error("Failed to parse runtime configuration",t)}this.config=o??{},this.build=r,this.runtime=i,this.instanceId=crypto.randomUUID(),this.#e=Xv(i,this.isCloudflare)}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get accountName(){return this.build.ACCOUNT_NAME??this.runtime.ZUPLO_ACCOUNT_NAME??void 0}get projectName(){return this.build.PROJECT_NAME??this.runtime.ZUPLO_PROJECT_NAME??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.runtime.__ZUPLO_EDGE_API_URL??this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get trustedIpHeader(){return this.#e}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let r=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&r}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get budgetRulesCaptureDisabled(){return this.runtime.__ZUPLO_BUDGET_RULES_CAPTURE==="off"}get budgetDimensionLogValuesEnabled(){return this.runtime.__ZUPLO_BUDGET_DIMENSION_LOG_VALUES==="on"}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let r=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,i=this.config.rate_limit_service_timeout_ms,o=r??i;if(!o)return 500;let t=Number(o);return Number.isFinite(t)&&t>0?t:500}};var De=fn("zuplo:runtime:external-service");function Yv(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:r}=W.instance.runtime;if(r&&r!=="undefined")try{let i=atob(r);e=JSON.parse(i)}catch{}return e}s(Yv,"getServiceAuth");async function Mf(e,r){let i=".proxy",o=".tunnel";if(typeof e=="string"){let t=new URL(e),n=t.hostname;if(n.endsWith(i)){let x=n.slice(0,-i.length),S=new URL(`http://${x}${t.pathname}${t.search}`);De(`Routing to proxy: ${S.toString()}`);let I=r??{};return tr(S.toString(),I)}let a=n.endsWith(o),c=n.indexOf(".")===-1;if(!(a||c))throw new B(`Invalid service hostname suffix: ${n}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let u=a?n.slice(0,-o.length):n,d=Yv();if(!d)throw De("There is no external service auth configured for this zup."),new B("There are no external services configured for this zup.");De(`Using external service auth. ClientId: ${d.clientId})`);let f=r??{},p=new Headers(f.headers||{});p.set("CF-Access-Client-Id",d.clientId),p.set("CF-Access-Client-Secret",d.clientSecret),f.headers=p;let m;if(d.customServiceMapping?.[u])m=`https://${d.customServiceMapping[u]}`;else if(W.instance.useLegacyServiceRouting)m=`https://${u}.zuptunnel.com`;else{De("Using sha256 service routing");let x=W.instance.build;if(x.ACCOUNT_NAME&&x.PROJECT_NAME&&x.ENVIRONMENT_TYPE){let S=await Qv(u,x.ACCOUNT_NAME,x.PROJECT_NAME,x.ENVIRONMENT_TYPE),I=Ff(x.ENVIRONMENT_TYPE),z=await Uo(`${x.ACCOUNT_NAME}-${x.PROJECT_NAME}-${I}`);z==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||z==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?m=`https://${S}.zuptunnel.com`:m=`https://${S}.t.zuplo.app`}else throw De("Cannot use sha256 service routing, missing build variables"),new B("Failed to generate fully qualified tunnel url.")}let h=new URL(`${m}${t.pathname}${t.search}`);De(`Calling external service: ${h.toString()}`);let $=await tr(h.toString(),f);if($.status===403&&$.headers.get("cf-access-domain")!==null)throw ke.console.error("403 Forbidden when calling external service.",{clientId:d.clientId,tunnelHost:m}),new B("Could not connect to secure tunnel.");return $}else throw De("Cannot call external service with Request object"),new B("Currently, we only support fetch(<some_string>, ...).")}s(Mf,"externalServiceHandler");async function Vf(e,r){if(typeof e=="string"){let i=new URL(e),o=i.hostname,t=r??{},n=`http://${o}.zuplo.svc.cluster.local:9000`,a=new URL(`${n}${i.pathname}${i.search}`),c=new Headers(t.headers||{});return c.set(xo,o),t.headers=c,await tr(a.toString(),t)}else throw new B("Currently, we only support fetch(<some_string>, ...).")}s(Vf,"clusterServiceHandler");async function Qv(e,r,i,o){let t=e.toLowerCase(),n=r.toLowerCase(),a=i.toLowerCase(),c=Ff(o);De(`Hashing service name: ${n}-${t}.${n}-${a}-${c}`);let l=await Uo(`${n}-${t}`),u=await Uo(`${n}-${a}-${c}`);return`${l}.${u}`}s(Qv,"hashServiceName");async function Uo(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("").slice(0,-1)}s(Uo,"hashSegment");function Ff(e){let r=e.toLowerCase();switch(r){case"production":case"preview":return r;default:return"working-copy"}}s(Ff,"sanitizeEnvironmentType");var jo=new Map;jo.set("service:",Mf);jo.set("local:",Vf);var tr=globalThis.fetch;function Co(e,r){let{transformedInit:i,mtlsCertificate:o}=eh(r);if(typeof e=="string"){let t=new URL(e),n=jo.get(t.protocol);return n?er(n(e,i),W.instance.isDeno):Bf(e,i,o)}else return Bf(e,i,o)}s(Co,"internalFetch");globalThis.fetch=Co;function Bf(e,r,i){if(!i)return er(tr(e,r),W.instance.isDeno);if(W.instance.isCloudflare){let t=W.instance.runtime[i];if(!t)throw new Error(`mTLS certificate binding '${i}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof t!="object"||typeof t.fetch!="function")throw new Error(`mTLS certificate binding '${i}' is not a valid mTLS certificate binding. Make sure it's configured as an mTLS certificate, not an environment variable.`);return er(t.fetch(e,r),W.instance.isDeno)}else if(W.instance.isDeno){let o=globalThis.managedDedicatedMtlsBindings?.[i];if(!o)throw new Error(`mTLS certificate binding '${i}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof o.fetch!="function")throw new Error(`mTLS certificate binding '${i}' is not a valid mTLS certificate binding.`);return er(o.fetch(e,r),!0)}else throw new Error("mTLS client certificates are not supported in this runtime environment")}s(Bf,"performFetch");var eh=s(e=>{if(!e||e instanceof Request)return{transformedInit:e,mtlsCertificate:void 0};let r=e;if(!r.zuplo)return{transformedInit:e,mtlsCertificate:void 0};let i=r.zuplo.mtlsCertificate,o=e;return o.cf={cacheEverything:r.zuplo?.cacheEverything,cacheTtl:r.zuplo?.cacheTtlSeconds},delete e.zuplo,{transformedInit:e,mtlsCertificate:i}},"transformInit");var th={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:Co},ke=th;var rh=fn("zuplo:runtime"),Zo=new TextEncoder,Jf={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},nh=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];function ih(e){let r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r}s(ih,"copyArrayBufferView");function oh(e){return typeof e=="string"?Zo.encode(e):e instanceof ArrayBuffer?e:ih(e)}s(oh,"toCryptoBufferSource");var mn=class e{static{s(this,"AwsClient")}service;region;cache;#e;#n;#t;#r;#i;#o;constructor(r){let{accessKeyId:i,secretAccessKey:o,sessionToken:t,credentials:n,service:a,region:c,cache:l,retries:u,initRetryMs:d}=r;if(typeof n=="function")this.#r=n;else if(n){let f=n;this.#r=()=>Promise.resolve(f)}else this.#e=i,this.#n=o,this.#t=t;this.service=a,this.region=c,this.cache=l||new Map,this.#i=u??0,this.#o=d||50}static fromContext(r,i){let o=zf(r);if(!o)throw new Pe("No AWS credentials are available on the request context. Attach an 'upstream-aws-service-auth' or 'upstream-aws-federated-auth' policy to this route (or run one via context.invokeInboundPolicy) before calling AwsClient.fromContext().");return new e({credentials:o,service:i?.service,region:i?.region})}async#a(){if(this.#r)return this.#r();if(this.#e==null||this.#n==null)throw new Pe("AwsClient requires either 'credentials' or both 'accessKeyId' and 'secretAccessKey'.");return{accessKeyId:this.#e,secretAccessKey:this.#n,sessionToken:this.#t}}async sign(r,i){let o=await this.#a(),t=new Lo(Object.assign({url:r},i,{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,sessionToken:o.sessionToken,service:this.service,region:this.region,cache:this.cache},i?.aws)),n=Object.assign({},i,await t.sign());return delete n.aws,{url:n.url.toString(),request:n}}async fetch(r,i){rh("AWS fetch",r);for(let o=0;o<=this.#i;o++){let{url:t,request:n}=await this.sign(r,i),a=ke.fetch(t,n);if(o===this.#i)return a;let c=await a;if(c.status<500&&c.status!==429)return c;await new Promise(l=>setTimeout(l,Math.random()*this.#o*2**o))}throw new Pe("An unknown error occurred, ensure retries is not negative")}},Lo=class{static{s(this,"AwsV4Signer")}method;url;headers;body;accessKeyId;secretAccessKey;sessionToken;service;region;cache;datetime;signQuery;appendSessionToken;signableHeaders;signedHeaders;canonicalHeaders;credentialString;encodedPath;encodedSearch;constructor({method:r,url:i,headers:o,body:t,accessKeyId:n,secretAccessKey:a,sessionToken:c,service:l,region:u,cache:d,datetime:f,signQuery:p,appendSessionToken:m,allHeaders:h,singleEncode:$}){if(i==null)throw new TypeError("url is a required option");if(n==null)throw new TypeError("accessKeyId is a required option");if(a==null)throw new TypeError("secretAccessKey is a required option");this.method=r||(t?"POST":"GET"),this.url=new URL(i),this.headers=new Headers(o||{}),this.body=t,this.accessKeyId=n,this.secretAccessKey=a,this.sessionToken=c;let x,S;(!l||!u)&&([x,S]=ah(this.url,this.headers)),this.service=l||x||"",this.region=u||S||"us-east-1",this.cache=d||new Map,this.datetime=f||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host");let I=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),I.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&I.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(O=>h||!nh.includes(O)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(O=>O+":"+(O==="host"?this.url.host:(this.headers.get(O)||"").replace(/\s+/g," "))).join(`
35
+ `)+" "+i[1]:i[0]+r+" "+e.join(", ")+" "+i[1]}s(Bv,"reduceToSingleString");var jf=s((e,...r)=>Af(Ae,e,r),"format");var Eo=class{static{s(this,"Debugger")}manager;ns;color;last;enabled;constructor(r,i){this.manager=r,this.ns=i,this.color=Pf(i),this.last=0,this.enabled=r.enabled.some(o=>o.test(i))}log(...r){if(!this.enabled)return;let i,o=r[0];typeof o=="function"?i=o():i=String(o);let t=Date.now()-(this.last||Date.now());i=jf(i,...r);let n=`${this.color(this.ns)} ${i} ${this.color(`+${t}ms`)}`;console.log(n),this.last=Date.now()}},No=class{static{s(this,"DebugManager")}debuggers;enabled;constructor(r){this.debuggers=new Map,this.enabled=r??[]}};function Jv(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(r=>new RegExp(`^${r}$`)))}s(Jv,"extract");var dn;function fn(e){let r=globalThis.DEBUG;dn||(dn=new No(Jv(r)));let i=new Eo(dn,e);return dn.debuggers.set(e,i),Object.assign(i.log.bind(i),{self:i})}s(fn,"debug");var Kv=/: client error \((?:Connect|SendRequest)\):/;function Hv(e){return e instanceof TypeError&&e.message.startsWith("error sending request ")&&Kv.test(e.message)}s(Hv,"isDenoClientError");function er(e,r){return r?e.catch(i=>{throw Hv(i)?new sn(i):i}):e}s(er,"wrapDenoNetworkErrors");function Gv(e){if(e.length>=255)throw new TypeError("Alphabet too long");let r=new Uint8Array(256);for(let u=0;u<r.length;u++)r[u]=255;for(let u=0;u<e.length;u++){let d=e.charAt(u),f=d.charCodeAt(0);if(r[f]!==255)throw new TypeError(d+" is ambiguous");r[f]=u}let i=e.length,o=e.charAt(0),t=Math.log(i)/Math.log(256),n=Math.log(256)/Math.log(i);function a(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";let d=0,f=0,p=0,m=u.length;for(;p!==m&&u[p]===0;)p++,d++;let h=(m-p)*n+1>>>0,$=new Uint8Array(h);for(;p!==m;){let I=u[p],z=0;for(let O=h-1;(I!==0||z<f)&&O!==-1;O--,z++)I+=256*$[O]>>>0,$[O]=I%i>>>0,I=I/i>>>0;if(I!==0)throw new Error("Non-zero carry");f=z,p++}let x=h-f;for(;x!==h&&$[x]===0;)x++;let S=o.repeat(d);for(;x<h;++x)S+=e.charAt($[x]);return S}s(a,"encode");function c(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;let d=0,f=0,p=0;for(;u[d]===o;)f++,d++;let m=(u.length-d)*t+1>>>0,h=new Uint8Array(m);for(;d<u.length;){let I=u.charCodeAt(d);if(I>255)return;let z=r[I];if(z===255)return;let O=0;for(let U=m-1;(z!==0||O<p)&&U!==-1;U--,O++)z+=i*h[U]>>>0,h[U]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");p=O,d++}let $=m-p;for(;$!==m&&h[$]===0;)$++;let x=new Uint8Array(f+(m-$)),S=f;for(;$!==m;)x[S++]=h[$++];return x}s(c,"decodeUnsafe");function l(u){let d=c(u);if(d)return d;throw new Error("Non-base"+i+" character")}return s(l,"decode"),{encode:a,decodeUnsafe:c,decode:l}}s(Gv,"base");var Cf=Gv;var Wv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Rf=Cf(Wv);var To="2025-02-06",Zf=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1,escapeOpenApiPathCharacters:!1,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!1,return501ForUnsupportedHttpMethods:!1,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2026-03-01":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!1,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0,improvedSchemaValidation:!1,serializeMcpParametersByStyle:!1,sanitizeMcpToolNames:!1,omitMcpFieldsNewerThanNegotiatedVersion:!1,treatBlankOptionalStringOptionsAsUnset:!1,failMcpResourceReadsOnErrorStatus:!1,rejectInvalidMcpResourceUris:!1},"2026-11-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0,escapeOpenApiPathCharacters:!0,delimitOpenApiPathParameters:!0,chainResponseSendingHooks:!0,return501ForUnsupportedHttpMethods:!0,improvedSchemaValidation:!0,serializeMcpParametersByStyle:!0,sanitizeMcpToolNames:!0,omitMcpFieldsNewerThanNegotiatedVersion:!0,treatBlankOptionalStringOptionsAsUnset:!0,failMcpResourceReadsOnErrorStatus:!0,rejectInvalidMcpResourceUris:!0}});function Lf(e={}){let{runtime:r="cloudflare"}=e;return new W({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:To,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Zf[To]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:r,__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"bckt_mock"}})}s(Lf,"getMockEnvironment");var qv=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Xv(e,r){let i=e.__ZUPLO_TRUSTED_IP_HEADER?.trim();if(!i)return r?bo:If;if(!qv.test(i))throw new an(`__ZUPLO_TRUSTED_IP_HEADER is set to '${i}', which is not a valid HTTP header name. Header names may only contain the RFC 9110 token characters (letters, digits, and !#$%&'*+-.^_\`|~) - spaces, colons and tabs are not allowed. Set it to a valid header name such as '${bo}' or 'cf-connecting-ip'.`);return i.toLowerCase()}s(Xv,"resolveTrustedIpHeader");var W=class e{static{s(this,"Environment")}config;#e;static#n;static#t=!1;static initialize(r){e.#n||(e.#n=new e(r),e.#t=!0)}static get instance(){return e.#t||(ke.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),e.#n??=Lf(),e.#t=!0),e.#n}constructor({build:r,runtime:i}){let o;try{if(i.ZUPLO_SYSTEM_CONFIGURATIONS){let t=new TextDecoder().decode(Rf.decode(i.ZUPLO_SYSTEM_CONFIGURATIONS)),n=JSON.parse(t);for(let a of Object.keys(n))i[a]||(i[a]=n[a])}if(i.__ZUPLO_CONFIG){let t=atob(i.__ZUPLO_CONFIG);o=JSON.parse(t)}}catch(t){ke.console.error("Failed to parse runtime configuration",t)}this.config=o??{},this.build=r,this.runtime=i,this.instanceId=crypto.randomUUID(),this.#e=Xv(i,this.isCloudflare)}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get accountName(){return this.build.ACCOUNT_NAME??this.runtime.ZUPLO_ACCOUNT_NAME??void 0}get projectName(){return this.build.PROJECT_NAME??this.runtime.ZUPLO_PROJECT_NAME??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.runtime.__ZUPLO_EDGE_API_URL??this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get trustedIpHeader(){return this.#e}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let r=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&r}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get budgetRulesCaptureDisabled(){return this.runtime.__ZUPLO_BUDGET_RULES_CAPTURE==="off"}get budgetDimensionLogValuesEnabled(){return this.runtime.__ZUPLO_BUDGET_DIMENSION_LOG_VALUES==="on"}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let r=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,i=this.config.rate_limit_service_timeout_ms,o=r??i;if(!o)return 500;let t=Number(o);return Number.isFinite(t)&&t>0?t:500}};var De=fn("zuplo:runtime:external-service");function Yv(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:r}=W.instance.runtime;if(r&&r!=="undefined")try{let i=atob(r);e=JSON.parse(i)}catch{}return e}s(Yv,"getServiceAuth");async function Mf(e,r){let i=".proxy",o=".tunnel";if(typeof e=="string"){let t=new URL(e),n=t.hostname;if(n.endsWith(i)){let x=n.slice(0,-i.length),S=new URL(`http://${x}${t.pathname}${t.search}`);De(`Routing to proxy: ${S.toString()}`);let I=r??{};return tr(S.toString(),I)}let a=n.endsWith(o),c=n.indexOf(".")===-1;if(!(a||c))throw new B(`Invalid service hostname suffix: ${n}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let u=a?n.slice(0,-o.length):n,d=Yv();if(!d)throw De("There is no external service auth configured for this zup."),new B("There are no external services configured for this zup.");De(`Using external service auth. ClientId: ${d.clientId})`);let f=r??{},p=new Headers(f.headers||{});p.set("CF-Access-Client-Id",d.clientId),p.set("CF-Access-Client-Secret",d.clientSecret),f.headers=p;let m;if(d.customServiceMapping?.[u])m=`https://${d.customServiceMapping[u]}`;else if(W.instance.useLegacyServiceRouting)m=`https://${u}.zuptunnel.com`;else{De("Using sha256 service routing");let x=W.instance.build;if(x.ACCOUNT_NAME&&x.PROJECT_NAME&&x.ENVIRONMENT_TYPE){let S=await Qv(u,x.ACCOUNT_NAME,x.PROJECT_NAME,x.ENVIRONMENT_TYPE),I=Ff(x.ENVIRONMENT_TYPE),z=await Uo(`${x.ACCOUNT_NAME}-${x.PROJECT_NAME}-${I}`);z==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||z==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?m=`https://${S}.zuptunnel.com`:m=`https://${S}.t.zuplo.app`}else throw De("Cannot use sha256 service routing, missing build variables"),new B("Failed to generate fully qualified tunnel url.")}let h=new URL(`${m}${t.pathname}${t.search}`);De(`Calling external service: ${h.toString()}`);let $=await tr(h.toString(),f);if($.status===403&&$.headers.get("cf-access-domain")!==null)throw ke.console.error("403 Forbidden when calling external service.",{clientId:d.clientId,tunnelHost:m}),new B("Could not connect to secure tunnel.");return $}else throw De("Cannot call external service with Request object"),new B("Currently, we only support fetch(<some_string>, ...).")}s(Mf,"externalServiceHandler");async function Vf(e,r){if(typeof e=="string"){let i=new URL(e),o=i.hostname,t=r??{},n=`http://${o}.zuplo.svc.cluster.local:9000`,a=new URL(`${n}${i.pathname}${i.search}`),c=new Headers(t.headers||{});return c.set(xo,o),t.headers=c,await tr(a.toString(),t)}else throw new B("Currently, we only support fetch(<some_string>, ...).")}s(Vf,"clusterServiceHandler");async function Qv(e,r,i,o){let t=e.toLowerCase(),n=r.toLowerCase(),a=i.toLowerCase(),c=Ff(o);De(`Hashing service name: ${n}-${t}.${n}-${a}-${c}`);let l=await Uo(`${n}-${t}`),u=await Uo(`${n}-${a}-${c}`);return`${l}.${u}`}s(Qv,"hashServiceName");async function Uo(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(n=>n.toString(16).padStart(2,"0")).join("").slice(0,-1)}s(Uo,"hashSegment");function Ff(e){let r=e.toLowerCase();switch(r){case"production":case"preview":return r;default:return"working-copy"}}s(Ff,"sanitizeEnvironmentType");var jo=new Map;jo.set("service:",Mf);jo.set("local:",Vf);var tr=globalThis.fetch;function Co(e,r){let{transformedInit:i,mtlsCertificate:o}=eh(r);if(typeof e=="string"){let t=new URL(e),n=jo.get(t.protocol);return n?er(n(e,i),W.instance.isDeno):Bf(e,i,o)}else return Bf(e,i,o)}s(Co,"internalFetch");globalThis.fetch=Co;function Bf(e,r,i){if(!i)return er(tr(e,r),W.instance.isDeno);if(W.instance.isCloudflare){let t=W.instance.runtime[i];if(!t)throw new Error(`mTLS certificate binding '${i}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof t!="object"||typeof t.fetch!="function")throw new Error(`mTLS certificate binding '${i}' is not a valid mTLS certificate binding. Make sure it's configured as an mTLS certificate, not an environment variable.`);return er(t.fetch(e,r),W.instance.isDeno)}else if(W.instance.isDeno){let o=globalThis.managedDedicatedMtlsBindings?.[i];if(!o)throw new Error(`mTLS certificate binding '${i}' not found. Ensure the certificate is uploaded and properly configured.`);if(typeof o.fetch!="function")throw new Error(`mTLS certificate binding '${i}' is not a valid mTLS certificate binding.`);return er(o.fetch(e,r),!0)}else throw new Error("mTLS client certificates are not supported in this runtime environment")}s(Bf,"performFetch");var eh=s(e=>{if(!e||e instanceof Request)return{transformedInit:e,mtlsCertificate:void 0};let r=e;if(!r.zuplo)return{transformedInit:e,mtlsCertificate:void 0};let i=r.zuplo.mtlsCertificate,o=e;return o.cf={cacheEverything:r.zuplo?.cacheEverything,cacheTtl:r.zuplo?.cacheTtlSeconds},delete e.zuplo,{transformedInit:e,mtlsCertificate:i}},"transformInit");var th={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:Co},ke=th;var rh=fn("zuplo:runtime"),Zo=new TextEncoder,Jf={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},nh=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];function ih(e){let r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r}s(ih,"copyArrayBufferView");function oh(e){return typeof e=="string"?Zo.encode(e):e instanceof ArrayBuffer?e:ih(e)}s(oh,"toCryptoBufferSource");var mn=class e{static{s(this,"AwsClient")}service;region;cache;#e;#n;#t;#r;#i;#o;constructor(r){let{accessKeyId:i,secretAccessKey:o,sessionToken:t,credentials:n,service:a,region:c,cache:l,retries:u,initRetryMs:d}=r;if(typeof n=="function")this.#r=n;else if(n){let f=n;this.#r=()=>Promise.resolve(f)}else this.#e=i,this.#n=o,this.#t=t;this.service=a,this.region=c,this.cache=l||new Map,this.#i=u??0,this.#o=d||50}static fromContext(r,i){let o=zf(r);if(!o)throw new Pe("No AWS credentials are available on the request context. Attach an 'upstream-aws-service-auth' or 'upstream-aws-federated-auth' policy to this route (or run one via context.invokeInboundPolicy) before calling AwsClient.fromContext().");return new e({credentials:o,service:i?.service,region:i?.region})}async#a(){if(this.#r)return this.#r();if(this.#e==null||this.#n==null)throw new Pe("AwsClient requires either 'credentials' or both 'accessKeyId' and 'secretAccessKey'.");return{accessKeyId:this.#e,secretAccessKey:this.#n,sessionToken:this.#t}}async sign(r,i){let o=await this.#a(),t=new Lo(Object.assign({url:r},i,{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,sessionToken:o.sessionToken,service:this.service,region:this.region,cache:this.cache},i?.aws)),n=Object.assign({},i,await t.sign());return delete n.aws,{url:n.url.toString(),request:n}}async fetch(r,i){rh("AWS fetch",r);for(let o=0;o<=this.#i;o++){let{url:t,request:n}=await this.sign(r,i),a=ke.fetch(t,n);if(o===this.#i)return a;let c=await a;if(c.status<500&&c.status!==429)return c;await new Promise(l=>setTimeout(l,Math.random()*this.#o*2**o))}throw new Pe("An unknown error occurred, ensure retries is not negative")}},Lo=class{static{s(this,"AwsV4Signer")}method;url;headers;body;accessKeyId;secretAccessKey;sessionToken;service;region;cache;datetime;signQuery;appendSessionToken;signableHeaders;signedHeaders;canonicalHeaders;credentialString;encodedPath;encodedSearch;constructor({method:r,url:i,headers:o,body:t,accessKeyId:n,secretAccessKey:a,sessionToken:c,service:l,region:u,cache:d,datetime:f,signQuery:p,appendSessionToken:m,allHeaders:h,singleEncode:$}){if(i==null)throw new TypeError("url is a required option");if(n==null)throw new TypeError("accessKeyId is a required option");if(a==null)throw new TypeError("secretAccessKey is a required option");this.method=r||(t?"POST":"GET"),this.url=new URL(i),this.headers=new Headers(o||{}),this.body=t,this.accessKeyId=n,this.secretAccessKey=a,this.sessionToken=c;let x,S;(!l||!u)&&([x,S]=ah(this.url,this.headers)),this.service=l||x||"",this.region=u||S||"us-east-1",this.cache=d||new Map,this.datetime=f||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host");let I=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),I.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&I.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(O=>h||!nh.includes(O)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(O=>O+":"+(O==="host"?this.url.host:(this.headers.get(O)||"").replace(/\s+/g," "))).join(`
36
36
  `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!I.has("X-Amz-Expires")&&I.set("X-Amz-Expires","86400"),I.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),I.set("X-Amz-Credential",`${this.accessKeyId}/${this.credentialString}`),I.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,"/");$||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=Hf(this.encodedPath);let z=new Set;this.encodedSearch=[...this.url.searchParams].filter(([O])=>{if(!O)return!1;if(this.service==="s3"){if(z.has(O))return!1;z.add(O)}return!0}).map(O=>O.map(U=>Hf(encodeURIComponent(U)))).sort(([O,U],[j,J])=>O<j?-1:O>j?1:U<J?-1:U>J?1:0).map(O=>O.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 r=this.datetime.slice(0,8),i=[this.secretAccessKey,r,this.region,this.service].join(),o=this.cache.get(i);if(!o){let t=await rr(`AWS4${this.secretAccessKey}`,r),n=await rr(t,this.region),a=await rr(n,this.service);o=await rr(a,"aws4_request"),this.cache.set(i,o)}return Ro(await rr(o,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,Ro(await Kf(await this.canonicalString()))].join(`
37
37
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,`${this.canonicalHeaders}
38
38
  `,this.signedHeaders,await this.hexBodyHash()].join(`
@@ -98,5 +98,5 @@ ${l}
98
98
  }`,p;try{p=new d(...a,f)(...c)}catch(m){throw new T(`this schema (generated code failed to evaluate: ${m.message})`)}return r?.debug&&(p.code=u),p.definite=o.definite,p}s(fi,"compileFn");function A(e,r){for(let[o,t]of e.constants)if(t===r)return o;let i=`c${e.constantCounter++}`;return e.constants.set(i,r),i}s(A,"addConstant");function Ye(e,r){return e.definite=!1,A(e,r)}s(Ye,"addUserConstant");function P(e){return`v${e.varCounter++}`}s(P,"newVar");function r_(e,r){let i=e._zod.run({value:r,issues:[]},{});if(i&&typeof i.then=="function")return re;let o=i;return o.issues.length===0?o.value:re}s(r_,"runtimeRun");function Y(e,r,i,o,t=!0){let n=e.content.length,a=r.constants.size,c=r.constantCounter,l=r.varCounter;try{return V(e,r,i,o,t)}catch(u){if(!(u instanceof T)||!u.islandable)throw u;if(e.content.length=n,r.constants.size>a){let d=Array.from(r.constants.keys()).slice(a);for(let f of d)r.constants.delete(f)}return r.constantCounter=c,r.varCounter=l,n_(e,r,i,o)}}s(Y,"compileChild");function n_(e,r,i,o){r.definite=!1;let t=A(r,i),n=A(r,r_),a=P(r);return e.write(`const ${a} = ${n}(${t}, ${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}s(n_,"emitRuntimeIsland");var i_=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function o_(e,r,i,o){let t=i._zod.def.checks;if(!t||t.length===0)return o;let n=o;for(let a of t){let c=a._zod.def;if(c.when&&!i_.has(c.check))throw new T('check with a custom "when" condition');switch(c.check){case"greater_than":a_(e,r,c,n);break;case"less_than":s_(e,r,c,n);break;case"multiple_of":c_(e,r,c,n);break;case"number_format":qm(e,c,n);break;case"min_length":{let l=Ue(c.minimum,"min_length"),u=Tu(e,r,n,`${n}.length >= ${l} && ${n}.length < ${c.minimum*2}`);e.write(`if (${u} < ${l}) return INVALID;`);break}case"max_length":{let l=Ue(c.maximum,"max_length"),u=Tu(e,r,n,`${n}.length > ${l}`);e.write(`if (${u} > ${l}) return INVALID;`);break}case"length_equals":{let l=Ue(c.length,"length_equals"),u=Tu(e,r,n,`${n}.length >= ${l} && ${n}.length <= ${c.length*2}`);e.write(`if (${u} !== ${l}) return INVALID;`);break}case"min_size":e.write(`if (${n}.size < ${Ue(c.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${n}.size > ${Ue(c.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${n}.size !== ${Ue(c.size,"size_equals")}) return INVALID;`);break;case"string_format":n=Xm(e,r,c,n);break;case"custom":n=p_(e,r,a,n);break;case"bigint_format":u_(e,c,n);break;case"mime_type":l_(e,r,c,n);break;case"property":f_(e,r,c,n);break;case"properties":d_(e,r,c,n);break;case"overwrite":{let l=P(r);m_(e,r,a,n,l),n=l;break}default:throw new T(`check type ${c.check}`)}}return n}s(o_,"generateChecks");function Tu(e,r,i,o){let t=A(r,He),n=P(r);return e.write(`const ${n} = typeof ${i} === "string" && ${o} ? ${t}(${i}) : ${i}.length;`),n}s(Tu,"codePointLengthVar");function Ue(e,r){if(typeof e!="number"||!Number.isFinite(e))throw new T(`${r} bound of type ${typeof e}`);return`${e}`}s(Ue,"numericOperand");function Wm(e,r){if(typeof r=="bigint")return`${r}n`;if(typeof r=="number"){if(Number.isNaN(r))throw new T("comparison check with NaN bound");return`${r}`}if(r instanceof Date){if(Number.isNaN(r.getTime()))throw new T("comparison check with Invalid Date bound");return A(e,r)}throw new T(`comparison check bound of type ${typeof r}`)}s(Wm,"comparisonOperand");function a_(e,r,i,o){let t=i.inclusive?"<":"<=";e.write(`if (${o} ${t} ${Wm(r,i.value)}) return INVALID;`)}s(a_,"generateGreaterThanCheck");function s_(e,r,i,o){let t=i.inclusive?">":">=";e.write(`if (${o} ${t} ${Wm(r,i.value)}) return INVALID;`)}s(s_,"generateLessThanCheck");function c_(e,r,i,o){if(typeof i.value=="bigint"){if(i.value===BigInt(0))throw new T("multiple_of check with a zero divisor");e.write(`if (${o} % ${i.value}n !== 0n) return INVALID;`)}else{let t=A(r,ir);e.write(`if (${t}(${o}, ${Ue(i.value,"multiple_of")}) !== 0) return INVALID;`)}}s(c_,"generateMultipleOfCheck");function qm(e,r,i){let o=r.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${i})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${i}) || ${i} < -2147483648 || ${i} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${i}) || ${i} < 0 || ${i} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${i}) || ${i} < -3.4028234663852886e38 || ${i} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${i})) return INVALID;`);break;default:throw new T(`number format ${o}`)}}s(qm,"generateNumberFormatCheck");function u_(e,r,i){let o=r.format;if(o)switch(o){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break;default:throw new T(`bigint format ${o}`)}}s(u_,"generateBigIntFormatCheck");function l_(e,r,i,o){let t=i.mime;if(t&&t.length>0){let n=A(r,new Set(t));e.write(`if (!${n}.has(${o}.type)) return INVALID;`)}}s(l_,"generateMimeTypeCheck");function d_(e,r,i,o){if(i.when)throw new T('check with a custom "when" condition');e.write(`if (${o} == null) return INVALID;`);let t=i.shape;for(let n of Reflect.ownKeys(t)){let a=typeof n=="symbol"?A(r,n):ee(n),c=P(r);e.write(`const ${c} = ${o}[${a}];`),Y(e,r,t[n],c,!1)}}s(d_,"generatePropertiesChecks");function f_(e,r,i,o){let t=`${o}[${JSON.stringify(i.property)}]`;V(e,r,i.schema,t)}s(f_,"generatePropertyCheck");function m_(e,r,i,o,t){let n=i._zod.def.tx;if(!n)throw new T("overwrite check without a transform function");if(Qe(n))throw new ve("z.compile: async overwrite transforms are not supported");let a=A(r,n);e.write(`const ${t} = ${a}(${o});`)}s(m_,"generateOverwriteCheck");function Uu(){throw new se}s(Uu,"throwAsync");function Ru(e){this.issues.push(e)}s(Ru,"pushIssue");function p_(e,r,i,o){let t=i._zod.def;if(t.fn){if(Qe(t.fn))throw new ve("z.compile: async .refine() predicates are not supported");let n=Ye(r,t.fn),a=A(r,Uu),c=P(r);return e.write(`const ${c} = ${n}(${o});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`),o}if(i._zod.check){if(Qe(i._zod.check))throw new ve("z.compile: async .superRefine() / check functions are not supported");let n=i._zod.check,c=Ye(r,s(u=>{let d={value:u,issues:[],addIssue:Ru};return n(d)instanceof Promise&&Uu(),d.issues.length===0?d.value:re},"helperFn")),l=P(r);return e.write(`const ${l} = ${c}(${o});`),e.write(`if (${l} === INVALID) return INVALID;`),l}throw new T("custom check without a predicate or check function")}s(p_,"generateCustomRefineCheck");var g_=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Xm(e,r,i,o,t=!0){let n=i.format;if(n==="base64"){let u=A(r,Ir);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(n==="base64url"){let u=A(r,Gn);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(n==="jwt"){let u=A(r,Xn),d=A(r,i.alg??null);return e.write(`if (!${u}(${o}, ${d})) return INVALID;`),o}if(n==="ipv6"){let u=A(r,kr);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(n==="cidrv6"){let u=A(r,Kn);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(n==="credit_card"){let u=A(r,Wn);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(n==="iban"){let u=A(r,qn);return e.write(`if (!${u}(${o})) return INVALID;`),o}let a=i;if(n==="url"||n==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let u=A(r,Fn),d=A(r,i),f=P(r),p=P(r);if(e.write(`const ${f} = ${o}.trim();`),e.write(`const ${p} = ${u}(${f}, ${d});`),e.write(`if (typeof ${p} === "number") return INVALID;`),a.hostname!==void 0){let $=A(r,Bn);e.write(`if (!${$}(${p}, ${d}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let $=A(r,Jn);e.write(`if (!${$}(${p}, ${d}.protocol)) return INVALID;`)}if(!t)return null;let m=P(r),h=a.normalize?`${p}.href`:`${A(r,xr)}(${f})`;return e.write(`const ${m} = ${h};`),m}let c=i.fn;if(c){if(Qe(c))throw new T(`async string format ${n}`);let u=A(r,c);return e.write(`if (!${u}(${o})) return INVALID;`),o}if(g_.has(n)&&i.pattern){let u=A(r,i.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${o})) return INVALID;`),o}let l=i.format;switch(l){case"regex":throw new T("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${ee(i.includes)})) return INVALID;`);break;case"starts_with":{let u=i.prefix;e.write(`if (${o}.slice(0, ${u.length}) !== ${ee(u)}) return INVALID;`);break}case"ends_with":{let u=i.suffix;e.write(`if (${o}.slice(-${u.length}) !== ${ee(u)}) return INVALID;`);break}default:throw new T(`string format ${l}`)}return o}s(Xm,"generateStringFormatCheck");function V(e,r,i,o,t=!0){let n=i._zod.def,a=n.type;if(n.coerce)throw new T(`coercion (z.coerce.${a}())`);let c=t||!!n.checks?.length,l;switch(a){case"string":l=v_(e,r,i,o,c);break;case"number":l=h_(e,i,o);break;case"boolean":l=$_(e,o);break;case"bigint":l=y_(e,i,o);break;case"symbol":l=__(e,o);break;case"undefined":l=b_(e,o);break;case"null":l=x_(e,o);break;case"any":case"unknown":l=o;break;case"never":e.write("return INVALID;"),l=o;break;case"void":l=k_(e,o);break;case"nan":l=I_(e,o);break;case"date":l=w_(e,o);break;case"object":l=S_(e,r,i,o,c);break;case"optional":l=z_(e,r,i,o,c);break;case"nullable":l=A_(e,r,i,o,c);break;case"array":l=D_(e,r,i,o,c);break;case"literal":l=E_(e,r,i,o);break;case"enum":l=N_(e,r,i,o);break;case"readonly":{let u=Km(e,r,i,o),d=P(r);e.write(`const ${d} = Object.freeze(${u});`),l=d;break}case"success":Km(e,r,i,o),l="true";break;case"default":case"prefault":l=T_(e,r,i,o);break;case"nonoptional":l=U_(e,r,i,o);break;case"tuple":l=j_(e,r,i,o);break;case"union":l=C_(e,r,i,o);break;case"intersection":l=L_(e,r,i,o);break;case"record":l=M_(e,r,i,o);break;case"map":l=F_(e,r,i,o);break;case"set":l=B_(e,r,i,o);break;case"file":l=J_(e,o);break;case"template_literal":l=K_(e,r,i,o);break;case"lazy":l=H_(e,r,i,o);break;case"pipe":l=G_(e,r,i,o);break;case"custom":l=W_(e,r,i,o);break;case"transform":l=Y_(e,r,i,o);break;case"catch":l=X_(e,r,i,o);break;default:throw new T(`schema type ${a}`)}return l===null?null:o_(e,r,i,l)}s(V,"generateCheck");function v_(e,r,i,o,t=!0){e.write(`if (typeof ${o} !== "string") return INVALID;`);let n=i._zod.def;return n.format===void 0?o:Xm(e,r,n,o,t)}s(v_,"generateStringCheck");function h_(e,r,i){e.write(`if (typeof ${i} !== "number" || !Number.isFinite(${i})) return INVALID;`);let o=r._zod.def;return o.check==="number_format"&&o.format&&qm(e,{format:o.format},i),i}s(h_,"generateNumberCheck");function $_(e,r){return e.write(`if (typeof ${r} !== "boolean") return INVALID;`),r}s($_,"generateBooleanCheck");function y_(e,r,i){e.write(`if (typeof ${i} !== "bigint") return INVALID;`);let o=r._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break}return i}s(y_,"generateBigIntCheck");function __(e,r){return e.write(`if (typeof ${r} !== "symbol") return INVALID;`),r}s(__,"generateSymbolCheck");function b_(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}s(b_,"generateUndefinedCheck");function x_(e,r){return e.write(`if (${r} !== null) return INVALID;`),r}s(x_,"generateNullCheck");function k_(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}s(k_,"generateVoidCheck");function I_(e,r){return e.write(`if (typeof ${r} !== "number" || !Number.isNaN(${r})) return INVALID;`),r}s(I_,"generateNaNCheck");function w_(e,r){return e.write(`if (!(${r} instanceof Date) || Number.isNaN(${r}.getTime())) return INVALID;`),r}s(w_,"generateDateCheck");function S_(e,r,i,o,t=!0){let n=i._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let a=n.shape,c=Object.keys(a),l=Object.getOwnPropertySymbols(a),u=l.length?[...c,...l]:c,d=s(I=>typeof I=="symbol"?A(r,I):ee(I),"keyExpr"),f=s(I=>typeof I=="symbol"?`[${d(I)}]`:ee(I),"propKey"),p=a;if(c.includes("__proto__"))throw new T('object shape key "__proto__"');let m=new Map;for(let I of u){let z=p[I],O=d(I),U=P(r);if(e.write(`const ${U} = ${o}[${O}];`),z._zod.optin!==void 0){let j=P(r);e.write(`let ${j} = (() => {`),e.indented(J=>{let Yt=Y(J,r,z,U);J.write(`return ${Yt};`)}),e.write("})();"),z._zod.optout==="optional"?(e.write(`if (${j} === INVALID) {`),e.indented(J=>{J.write(`if (${O} in ${o}) return INVALID;`),J.write(`${j} = undefined;`)}),e.write("}")):e.write(`if (${j} === INVALID) return INVALID;`),m.set(I,j)}else{P_(z)&&e.write(`if (!(${O} in ${o})) return INVALID;`);let j=Y(e,r,z,U,t);j!==null&&m.set(I,j)}}let h=n.catchall,$="none";if(h){let I=h._zod.def.type;if(I==="never"){let z=c.map(O=>`k !== ${ee(O)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(O=>{O.write(`if (${z}) return INVALID;`)}),e.write("}")}else(I==="unknown"||I==="any")&&!h._zod.def.checks?.length?$="passthrough":$="schema"}let x=P(r),S=u.some(I=>Jm(p[I])||ju(p[I]));if(!t){if($==="schema"){let I=c.length>0?A(r,new Set(c)):null;e.write(`for (const k in ${o}) {`),e.indented(z=>{z.write('if (k === "__proto__") continue;'),I&&z.write(`if (${I}.has(k)) continue;`);let O=P(r);z.write(`const ${O} = ${o}[k];`),Y(z,r,h,O,!1)}),e.write("}")}return null}if(S){e.write(`const ${x} = {};`);for(let I of u){let z=d(I),O=m.get(I);ju(p[I])?e.write(`if (${z} in ${o}) ${x}[${z}] = ${O};`):Jm(p[I])?e.write(`if (${O} !== undefined || ${z} in ${o}) ${x}[${z}] = ${O};`):e.write(`${x}[${z}] = ${O};`)}}else{let I=u.map(z=>`${f(z)}: ${m.get(z)}`).join(", ");e.write(`const ${x} = { ${I} };`)}if($!=="none"){let I=c.length>0?A(r,new Set(c)):null;e.write(`for (const k in ${o}) {`),e.indented(z=>{if(z.write('if (k === "__proto__") continue;'),I&&z.write(`if (${I}.has(k)) continue;`),$==="passthrough")z.write(`${x}[k] = ${o}[k];`);else{let O=P(r);z.write(`const ${O} = ${o}[k];`);let U=Y(z,r,h,O);z.write(`${x}[k] = ${U};`)}}),e.write("}")}return x}s(S_,"generateObjectCheck");function z_(e,r,i,o,t=!0){let n=i._zod.def;if(O_(i))return V(e,r,n.innerType,o,t);if(n.innerType._zod.optin==="defaulted"){let c=P(r),l=P(r);return e.write(`let ${c};`),e.write(`if (${o} === undefined) {`),e.indented(u=>{u.write(`const ${l} = (() => {`),u.indented(d=>{let f=V(d,r,n.innerType,o);d.write(`return ${f};`)}),u.write("})();"),u.write(`if (${l} !== INVALID) ${c} = ${l};`)}),e.write("} else {"),e.indented(u=>{let d=V(u,r,n.innerType,o);u.write(`${c} = ${d};`)}),e.write("}"),c}let a=t?P(r):null;return a&&e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(c=>{let l=V(c,r,n.innerType,o,t);a&&l!==null&&c.write(`${a} = ${l};`)}),e.write("}"),a}s(z_,"generateOptionalCheck");function O_(e){return e._zod.traits?.has("$ZodExactOptional")===!0}s(O_,"isExactOptional");function P_(e){return e._zod.optin===void 0&&Xe(e)}s(P_,"requiresPresenceCheck");function Xe(e){if(e._zod.def.coerce)return!0;let r=e._zod.def;switch(r.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return r.innerType?Xe(r.innerType):!1;case"literal":return!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return r.innerType?Xe(r.innerType):!0;case"catch":return!0;case"union":return r.options?r.options.some(Xe):!0;case"intersection":return!r.left||!r.right?!0:Xe(r.left)&&Xe(r.right);case"pipe":return r.in?Xe(r.in):!0;default:return!0}}s(Xe,"fastPathAcceptsAbsence");function ju(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}s(ju,"dropsWhenAbsent");function Jm(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&zt(e)}s(Jm,"mayOmitUndefined");function zt(e){let r=e._zod.def;switch(r.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return r.innerType?zt(r.innerType):!0;case"union":return r.options?r.options.some(zt):!0;case"intersection":return!r.left||!r.right||zt(r.left)||zt(r.right);case"pipe":return r.out?zt(r.out):!0;default:return!0}}s(zt,"mayOutputUndefined");function A_(e,r,i,o,t=!0){let n=i._zod.def,a=t?P(r):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${o} !== null) {`),e.indented(c=>{let l=V(c,r,n.innerType,o,t);a&&l!==null&&c.write(`${a} = ${l};`)}),e.write("}"),a}s(A_,"generateNullableCheck");function Zu(e,r,i){for(let[o,t]of ht(r._zod.def.checks))e.write(`if (${i} > ${Ue(o,t._zod.def.check)}) return INVALID;`)}s(Zu,"generateSizeGate");function D_(e,r,i,o,t=!0){let n=i._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`),Zu(e,i,`${o}.length`);let a=t?P(r):null,c=P(r),l=P(r);return a&&e.write(`const ${a} = new Array(${o}.length);`),e.write(`for (let ${c} = 0; ${c} < ${o}.length; ${c}++) {`),e.indented(u=>{u.write(`const ${l} = ${o}[${c}];`);let d=Y(u,r,n.element,l,t);a&&d!==null&&u.write(`${a}[${c}] = ${d};`)}),e.write("}"),a}s(D_,"generateArrayCheck");function E_(e,r,i,o){let n=i._zod.def.values;if(n.length!==1){let c=A(r,new Set(n));return e.write(`if (!${c}.has(${o})) return INVALID;`),o}let a=n[0];if(typeof a=="number"&&Number.isNaN(a)){let c=A(r,new Set(n));return e.write(`if (!${c}.has(${o})) return INVALID;`),o}if(typeof a=="string")e.write(`if (${o} !== ${ee(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${o} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${o} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${o} !== ${a}n) return INVALID;`);else throw new T(`literal type ${typeof a}`);return o}s(E_,"generateLiteralCheck");function N_(e,r,i,o){let t=i._zod.values;if(!t)throw new T("enum schema without enumerated values");let n=A(r,t);return e.write(`if (!${n}.has(${o})) return INVALID;`),o}s(N_,"generateEnumCheck");function Km(e,r,i,o){let t=i._zod.def;return V(e,r,t.innerType,o)}s(Km,"generateWrapperCheck");function T_(e,r,i,o){let t=i._zod.def,a=Object.getOwnPropertyDescriptor(i._zod.def,"defaultValue")?()=>i._zod.def.defaultValue:void 0;if(i._zod.def.type==="prefault"){if(!a)return V(e,r,t.innerType,o);let l=A(r,a),u=P(r);return e.write(`let ${u} = ${o};`),e.write(`if (${o} === undefined) ${u} = ${l}();`),V(e,r,t.innerType,u)}let c=P(r);if(a){let l=A(r,a),u=A(r,or);e.write(`let ${c};`),e.write(`if (${o} === undefined) {`),e.indented(d=>{d.write(`${c} = ${u}(${l}());`)}),e.write("} else {"),e.indented(d=>{let f=V(d,r,t.innerType,o);d.write(`${c} = ${f} === undefined ? ${u}(${l}()) : ${f};`)}),e.write("}")}else e.write(`let ${c};`),e.write(`if (${o} !== undefined) {`),e.indented(l=>{let u=V(l,r,t.innerType,o);l.write(`${c} = ${u};`)}),e.write("}");return c}s(T_,"generateDefaultCheck");function U_(e,r,i,o){let t=i._zod.def,n=V(e,r,t.innerType,o),a=P(r);return e.write(`const ${a} = ${n};`),e.write(`if (${a} === undefined) return INVALID;`),a}s(U_,"generateNonOptionalCheck");function j_(e,r,i,o){let t=i._zod.def,n=t.items,a=t.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let c=Hm(n,"optin"),l=Hm(n,"optout");a?e.write(`if (${o}.length < ${c}) return INVALID;`):e.write(`if (${o}.length < ${c} || ${o}.length > ${n.length}) return INVALID;`);let u=P(r);e.write(`const ${u} = [];`);for(let d=0;d<n.length;d++){let f=n[d];if(d>=l)e.write(`if (${u}.length === ${d}) {`),e.indented(p=>{p.write(`if (${d} < ${o}.length) {`),p.indented(m=>{let h=P(r);m.write(`const ${h} = ${o}[${d}];`);let $=Y(m,r,f,h);m.write(`${u}[${d}] = ${$};`)}),p.write("} else {"),p.indented(m=>{if(ju(f)){m.write(`${u}.length = ${d};`);return}let h=P(r),$=P(r);m.write(`const ${h} = undefined;`),m.write(`const ${$} = (() => {`),m.indented(x=>{let S=Y(x,r,f,h);x.write(`return ${S};`)}),m.write("})();"),m.write(`if (${$} === INVALID || ${$} === undefined) ${u}.length = ${d};`),m.write(`else ${u}[${d}] = ${$};`)}),p.write("}")}),e.write("}");else{let p=P(r);e.write(`const ${p} = ${o}[${d}];`);let m=Y(e,r,f,p);e.write(`${u}[${d}] = ${m};`)}}if(a){let d=P(r),f=P(r);e.write(`for (let ${d} = ${n.length}; ${d} < ${o}.length; ${d}++) {`),e.indented(p=>{p.write(`const ${f} = ${o}[${d}];`);let m=Y(p,r,a,f);p.write(`${u}[${d}] = ${m};`)}),e.write("}")}return u}s(j_,"generateTupleCheck");function Hm(e,r){for(let i=e.length-1;i>=0;i--)if(!(r==="optin"?e[i]._zod.optin!==void 0:e[i]._zod.optout==="optional"))return i+1;return 0}s(Hm,"getTupleOptStart");function C_(e,r,i,o){let t=i._zod.def,n=t.options;if(t.discriminator)return R_(e,r,t,o);if(t.inclusive===!1)throw new T("exclusive unions (z.xor)");if(n.length===0)return e.write("return INVALID;"),o;if(n.length===1)return V(e,r,n[0],o);if(n.every(l=>l._zod.def.type==="literal"&&!l._zod.def.checks?.length)){let l=new Set(n.flatMap(d=>d._zod.def.values)),u=A(r,l);return e.write(`if (!${u}.has(${o})) return INVALID;`),o}let c=P(r);e.write(`let ${c};`);for(let l=0;l<n.length;l++){let u=n[l];l===0?e.write(`${c} = (() => {`):e.write(`if (${c} === INVALID) ${c} = (() => {`),e.indented(d=>{let f=V(d,r,u,o);d.write(`return ${f};`)}),e.write("})();")}return e.write(`if (${c} === INVALID) return INVALID;`),c}s(C_,"generateUnionCheck");function R_(e,r,i,o){if(i.unionFallback)throw new T("discriminated union with unionFallback");if(i.options.length===0)return e.write("return INVALID;"),o;let t=P(r),n=P(r);e.write(`const ${t} = ${o}?.[${ee(i.discriminator)}];`),e.write(`let ${n};`);let a=!0,c=new Set;for(let l of i.options){let u=l._zod.propValues?.[i.discriminator];if(!u||u.size===0)throw new T("discriminated union option without static discriminator values");for(let p of u){if(c.has(p))throw new T(`duplicate discriminator value ${String(p)}`);c.add(p)}let d=Array.from(u,p=>Z_(r,t,p)),f=a?"if":"else if";e.write(`${f} (${d.join(" || ")}) {`),e.indented(p=>{let m=V(p,r,l,o);p.write(`${n} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),n}s(R_,"generateDiscriminatedUnionCheck");function Z_(e,r,i){if(typeof i=="string")return`${r} === ${ee(i)}`;if(typeof i=="number")return Number.isNaN(i)?`Number.isNaN(${r})`:`${r} === ${i}`;if(typeof i=="boolean")return`${r} === ${i}`;if(i===null)return`${r} === null`;if(i===void 0)return`${r} === undefined`;if(typeof i=="bigint")return`${r} === ${i}n`;if(typeof i=="symbol"){let o=A(e,i);return`${r} === ${o}`}throw new T(`literal discriminator value ${String(i)}`)}s(Z_,"literalEquality");function L_(e,r,i,o){let t=i._zod.def;r.definite=!1;let n=Y(e,r,t.left,o),a=Y(e,r,t.right,o),c=A(r,It),l=P(r);return e.write(`const ${l} = ${c}(${n}, ${a});`),e.write(`if (!${l}.valid) return INVALID;`),`${l}.data`}s(L_,"generateIntersectionCheck");function M_(e,r,i,o){let t=i._zod.def,n=A(r,fe);e.write(`if (!${n}(${o})) return INVALID;`);let a=P(r),c=P(r),l=P(r);e.write(`const ${a} = {};`);let u=t,d=u.partial?void 0:t.keyType._zod.values;if(d){let m=[];for(let $ of d){if(!(typeof $=="string"||typeof $=="number"||typeof $=="symbol"))throw new T(`record key value ${String($)}`);let x=typeof $=="number"?$.toString():$;if(x==="__proto__")throw new T('record key "__proto__"');m.push(x);let S=A(r,$),I=V(e,r,t.keyType,S),z=P(r);e.write(`const ${z} = ${o}[${V_(r,x)}];`);let O=Y(e,r,t.valueType,z);e.write(`${a}[${I}] = ${O};`)}let h=A(r,new Set(m));return e.write(`for (const ${c} in ${o}) {`),e.indented($=>{$.write(`if (${h}.has(${c})) continue;`),u.mode==="loose"?$.write(`if (${c} !== "__proto__") ${a}[${c}] = ${o}[${c}];`):$.write("return INVALID;")}),e.write("}"),a}let f=t.keyType._zod.def;if(!(f.type==="string"&&f.format===void 0&&!f.coerce&&(f.checks?.length??0)===0)){let m=t.mode==="loose",h=fi(t.keyType);h.definite===!1&&(r.definite=!1);let $=A(r,h),x=A(r,Se),S=P(r);return Gm(e,r,o,c,I=>{I.write(`let ${S} = ${$}(${c});`),I.write(`if (${S} === INVALID && typeof ${c} === "string" && ${x}.test(${c})) ${S} = ${$}(Number(${c}));`),m?I.write(`if (${S} === INVALID) { ${a}[${c}] = ${o}[${c}]; continue; }`):I.write(`if (${S} === INVALID) return INVALID;`),I.write(`if (${S} === "__proto__") continue;`);let z=P(r);I.write(`const ${z} = ${o}[${c}];`);let O=Y(I,r,t.valueType,z);I.write(`${a}[${S}] = ${O};`)}),a}return Gm(e,r,o,c,m=>{m.write(`const ${l} = ${o}[${c}];`);let h=Y(m,r,t.valueType,l);m.write(`${a}[${c}] = ${h};`)},"return INVALID;"),a}s(M_,"generateRecordCheck");function Gm(e,r,i,o,t,n){let a=A(r,Object.prototype.propertyIsEnumerable),c=P(r),l=P(r),u=P(r);e.write(`const ${c} = Object.getOwnPropertySymbols(${i});`),e.write(`const ${l} = Object.getOwnPropertyNames(${i});`),e.write(`for (let ${u} = 0; ${u} < ${l}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${o} = ${l}[${u}];`),d.write(`if (${o} === "__proto__" || !${a}.call(${i}, ${o})) continue;`),t(d)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${o} = ${c}[${u}];`),d.write(`if (!${a}.call(${i}, ${o})) continue;`),n?d.write(n):t(d)}),e.write("}")}s(Gm,"emitOwnKeys");function V_(e,r){return typeof r=="string"?ee(r):A(e,r)}s(V_,"literalPropertyKey");function F_(e,r,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),Zu(e,i,`${o}.size`);let n=P(r),a=P(r),c=P(r);return e.write(`const ${n} = new Map();`),e.write(`for (const [${a}, ${c}] of ${o}) {`),e.indented(l=>{let u=V(l,r,t.keyType,a),d=V(l,r,t.valueType,c);l.write(`${n}.set(${u}, ${d});`)}),e.write("}"),n}s(F_,"generateMapCheck");function B_(e,r,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),Zu(e,i,`${o}.size`);let n=P(r),a=P(r);return e.write(`const ${n} = new Set();`),e.write(`for (const ${a} of ${o}) {`),e.indented(c=>{let l=V(c,r,t.valueType,a);c.write(`${n}.add(${l});`)}),e.write("}"),n}s(B_,"generateSetCheck");function J_(e,r){return e.write(`if (!(${r} instanceof File)) return INVALID;`),r}s(J_,"generateFileCheck");function K_(e,r,i,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let t=i._zod.pattern;if(t){let n=A(r,t);e.write(`${n}.lastIndex = 0;`),e.write(`if (!${n}.test(${o})) return INVALID;`)}return o}s(K_,"generateTemplateLiteralCheck");function H_(e,r,i,o){let t=i._zod.def,n=Ye(r,t.getter),a=A(r,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(l=>{l.write(`const inner = ${n}();`),l.write(`${a}.parser = function(input) {`),l.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),l.write("};")}),e.write("}");let c=P(r);return e.write(`const ${c} = ${a}.parser(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}s(H_,"generateLazyCheck");function G_(e,r,i,o){let t=i._zod.def,n=V(e,r,t.in,o);if(t.transform){if(Qe(t.transform))throw new ve("z.compile: async transforms in pipes are not supported");let a=t.transform,l=Ye(r,s(d=>{let f={value:d,issues:[],addIssue:Ru},p=a(d,f);return p instanceof Promise?re:f.issues.length===0?p:re},"helperFn")),u=P(r);return e.write(`const ${u} = ${l}(${n});`),e.write(`if (${u} === INVALID) return INVALID;`),V(e,r,t.out,u)}else return V(e,r,t.out,n)}s(G_,"generatePipeCheck");function Qe(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}s(Qe,"isAsyncFunction");function W_(e,r,i,o){let t=i._zod.def;if(t.fn){if(Qe(t.fn))throw new ve("z.compile: async custom predicates are not supported");let n=Ye(r,t.fn),a=A(r,Uu),c=P(r);e.write(`const ${c} = ${n}(${o});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`)}else throw new T("custom schema without a predicate function");return o}s(W_,"generateCustomCheck");function q_(e,r,i){let o=e._zod.run({value:i,issues:[]},{});if(o&&typeof o.then=="function")return re;let t=o;return t.issues.length===0?t.value:r()}s(q_,"runtimeCatch");function X_(e,r,i,o){let t=i._zod.def;if(!t.catchValue[_n])throw new T("catch with a callback (only a constant catch value compiles)",!1);let n=P(r);e.write(`let ${n} = (() => {`),e.indented(u=>{let d=Y(u,r,t.innerType,o);u.write(`return ${d};`)}),e.write("})();");let a=A(r,t.innerType),c=Ye(r,t.catchValue),l=A(r,q_);return e.write(`if (${n} === INVALID) {`),e.indented(u=>{u.write(`${n} = ${l}(${a}, ${c}, ${o});`),u.write(`if (${n} === INVALID) return INVALID;`)}),e.write("}"),n}s(X_,"generateCatchCheck");function Y_(e,r,i,o){let t=i._zod.def;if(t.transform){if(Qe(t.transform))throw new ve("z.compile: async transforms are not supported");let n=t.transform,c=Ye(r,s(u=>{let d={value:u,issues:[],addIssue:Ru},f=n(u,d);return f instanceof Promise?re:d.issues.length===0?f:re},"helperFn")),l=P(r);return e.write(`const ${l} = ${c}(${o});`),e.write(`if (${l} === INVALID) return INVALID;`),l}return o}s(Y_,"generateTransformCheck");function mi(e){return e.checks&&(e.checks=[...e.checks]),e}s(mi,"snapshotChecks");function Lu(e,r){return new e(mi({type:"string",...k(r)}))}s(Lu,"_string");function Mu(e,r){return new e(mi({type:"string",coerce:!0,...k(r)}))}s(Mu,"_coercedString");function pi(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(r)})}s(pi,"_email");function gi(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(r)})}s(gi,"_guid");function vi(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(r)})}s(vi,"_uuid");function hi(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(r)})}s(hi,"_uuidv4");function $i(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(r)})}s($i,"_uuidv6");function yi(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(r)})}s(yi,"_uuidv7");function Rr(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(r)})}s(Rr,"_url");function _i(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(r)})}s(_i,"_emoji");function bi(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(r)})}s(bi,"_nanoid");function xi(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(r)})}s(xi,"_cuid");function ki(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(r)})}s(ki,"_cuid2");function Ii(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(r)})}s(Ii,"_ulid");function wi(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(r)})}s(wi,"_xid");function Si(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(r)})}s(Si,"_ksuid");function zi(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(r)})}s(zi,"_ipv4");function Oi(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(r)})}s(Oi,"_ipv6");function Vu(e,r){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...k(r)})}s(Vu,"_mac");function Pi(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(r)})}s(Pi,"_cidrv4");function Ai(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(r)})}s(Ai,"_cidrv6");function Di(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(r)})}s(Di,"_base64");function Ei(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(r)})}s(Ei,"_base64url");function Ni(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(r)})}s(Ni,"_e164");function Fu(e,r){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...k(r)})}s(Fu,"_creditCard");function Bu(e,r){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...k(r)})}s(Bu,"_iban");function Ti(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(r)})}s(Ti,"_jwt");var Ju={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Zr(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(r)})}s(Zr,"_isoDateTime");function Lr(e,r){return new e({type:"string",format:"date",check:"string_format",...k(r)})}s(Lr,"_isoDate");function Mr(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(r)})}s(Mr,"_isoTime");function Vr(e,r){return new e({type:"string",format:"duration",check:"string_format",...k(r)})}s(Vr,"_isoDuration");function Ku(e,r){return new e(mi({type:"number",checks:[],...k(r)}))}s(Ku,"_number");function Hu(e,r){return new e(mi({type:"number",coerce:!0,checks:[],...k(r)}))}s(Hu,"_coercedNumber");function Gu(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(r)})}s(Gu,"_int");function Wu(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...k(r)})}s(Wu,"_float32");function qu(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...k(r)})}s(qu,"_float64");function Xu(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...k(r)})}s(Xu,"_int32");function Yu(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...k(r)})}s(Yu,"_uint32");function Qu(e,r){return new e({type:"boolean",...k(r)})}s(Qu,"_boolean");function el(e,r){return new e({type:"boolean",coerce:!0,...k(r)})}s(el,"_coercedBoolean");function tl(e,r){return new e({type:"bigint",...k(r)})}s(tl,"_bigint");function rl(e,r){return new e({type:"bigint",coerce:!0,...k(r)})}s(rl,"_coercedBigint");function nl(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...k(r)})}s(nl,"_int64");function il(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...k(r)})}s(il,"_uint64");function ol(e,r){return new e({type:"symbol",...k(r)})}s(ol,"_symbol");function al(e,r){return new e({type:"undefined",...k(r)})}s(al,"_undefined");function sl(e,r){return new e({type:"null",...k(r)})}s(sl,"_null");function cl(e){return new e({type:"any"})}s(cl,"_any");function ul(e){return new e({type:"unknown"})}s(ul,"_unknown");function ll(e,r){return new e({type:"never",...k(r)})}s(ll,"_never");function dl(e,r){return new e({type:"void",...k(r)})}s(dl,"_void");function fl(e,r){return new e({type:"date",...k(r)})}s(fl,"_date");function ml(e,r){return new e({type:"date",coerce:!0,...k(r)})}s(ml,"_coercedDate");function pl(e,r){return new e({type:"nan",...k(r)})}s(pl,"_nan");function $e(e,r){return new jn({check:"less_than",...k(r),value:e,inclusive:!1})}s($e,"_lt");function le(e,r){return new jn({check:"less_than",...k(r),value:e,inclusive:!0})}s(le,"_lte");function ye(e,r){return new Cn({check:"greater_than",...k(r),value:e,inclusive:!1})}s(ye,"_gt");function de(e,r){return new Cn({check:"greater_than",...k(r),value:e,inclusive:!0})}s(de,"_gte");function Ui(e){return ye(0,e)}s(Ui,"_positive");function ji(e){return $e(0,e)}s(ji,"_negative");function Ci(e){return le(0,e)}s(Ci,"_nonpositive");function Ri(e){return de(0,e)}s(Ri,"_nonnegative");function je(e,r){return new Ba({check:"multiple_of",...k(r),value:e})}s(je,"_multipleOf");function Ce(e,r){return new Ha({check:"max_size",...k(r),maximum:e})}s(Ce,"_maxSize");function _e(e,r){return new Ga({check:"min_size",...k(r),minimum:e})}s(_e,"_minSize");function et(e,r){return new Wa({check:"size_equals",...k(r),size:e})}s(et,"_size");function tt(e,r){return new qa({check:"max_length",...k(r),maximum:e})}s(tt,"_maxLength");function ze(e,r){return new Xa({check:"min_length",...k(r),minimum:e})}s(ze,"_minLength");function rt(e,r){return new Ya({check:"length_equals",...k(r),length:e})}s(rt,"_length");function Ot(e,r){return new Qa({check:"string_format",format:"regex",...k(r),pattern:e})}s(Ot,"_regex");function Pt(e){return new es({check:"string_format",format:"lowercase",...k(e)})}s(Pt,"_lowercase");function At(e){return new ts({check:"string_format",format:"uppercase",...k(e)})}s(At,"_uppercase");function Dt(e,r){return new rs({check:"string_format",format:"includes",...k(r),includes:e})}s(Dt,"_includes");function Et(e,r){return new ns({check:"string_format",format:"starts_with",...k(r),prefix:e})}s(Et,"_startsWith");function Nt(e,r){return new is({check:"string_format",format:"ends_with",...k(r),suffix:e})}s(Nt,"_endsWith");function Zi(e,r,i){return new os({check:"property",property:e,schema:r,...k(i)})}s(Zi,"_property");function Tt(e,r){return new as({check:"properties",shape:e,...k(r)})}s(Tt,"_properties");function Ut(e,r){return new ss({check:"mime_type",mime:e,...k(r)})}s(Ut,"_mime");function he(e){return new cs({check:"overwrite",tx:e})}s(he,"_overwrite");function jt(e){return he(r=>r.normalize(e))}s(jt,"_normalize");function Ct(){return he(e=>e.trim())}s(Ct,"_trim");function Rt(){return he(e=>e.toLowerCase())}s(Rt,"_toLowerCase");function Zt(){return he(e=>e.toUpperCase())}s(Zt,"_toUpperCase");function Lt(){return he(e=>Ko(e))}s(Lt,"_slugify");function gl(e,r,i){return new e({type:"array",element:r,...k(i)})}s(gl,"_array");function Q_(e,r,i){return new e({type:"union",options:r,...k(i)})}s(Q_,"_union");function eb(e,r,i){return new e({type:"union",options:r,inclusive:!1,...k(i)})}s(eb,"_xor");function tb(e,r,i,o){return new e({type:"union",options:i,discriminator:r,...k(o)})}s(tb,"_discriminatedUnion");function rb(e,r,i){return new e({type:"intersection",left:r,right:i})}s(rb,"_intersection");function nb(e,r,i,o){let t=i instanceof D,n=t?o:i,a=t?i:null;return new e({type:"tuple",items:r,rest:a,...k(n)})}s(nb,"_tuple");function ib(e,r,i,o){return new e({type:"record",keyType:r,valueType:i,...k(o)})}s(ib,"_record");function ob(e,r,i,o){return new e({type:"map",keyType:r,valueType:i,...k(o)})}s(ob,"_map");function ab(e,r,i){return new e({type:"set",valueType:r,...k(i)})}s(ab,"_set");function sb(e,r,i){let o=Array.isArray(r)?Object.fromEntries(r.map(t=>[t,t])):r;return new e({type:"enum",entries:o,...k(i)})}s(sb,"_enum");function cb(e,r,i){return new e({type:"enum",entries:r,...k(i)})}s(cb,"_nativeEnum");function ub(e,r,i){return new e({type:"literal",values:Array.isArray(r)?r:[r],...k(i)})}s(ub,"_literal");function vl(e,r){return new e({type:"file",...k(r)})}s(vl,"_file");function lb(e,r){return new e({type:"transform",transform:r})}s(lb,"_transform");function db(e,r){return new e({type:"optional",innerType:r})}s(db,"_optional");function fb(e,r){return new e({type:"nullable",innerType:r})}s(fb,"_nullable");function mb(e,r,i){return new e({type:"default",innerType:r,get defaultValue(){return typeof i=="function"?i():or(i)}})}s(mb,"_default");function pb(e,r,i){return new e({type:"nonoptional",innerType:r,...k(i)})}s(pb,"_nonoptional");function gb(e,r){return new e({type:"success",innerType:r})}s(gb,"_success");function vb(e,r,i){return new e({type:"catch",innerType:r,catchValue:typeof i=="function"?i:Yo(i)})}s(vb,"_catch");function hb(e,r,i){return new e({type:"pipe",in:r,out:i})}s(hb,"_pipe");function $b(e,r){return new e({type:"readonly",innerType:r})}s($b,"_readonly");function yb(e,r,i){return new e({type:"template_literal",parts:r,...k(i)})}s(yb,"_templateLiteral");function _b(e,r){return new e({type:"lazy",getter:r})}s(_b,"_lazy");function bb(e,r){return new e({type:"promise",innerType:r})}s(bb,"_promise");function hl(e,r,i){let o=k(i);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:r,...o})}s(hl,"_custom");function $l(e,r,i){return new e({type:"custom",check:"custom",fn:r,...k(i)})}s($l,"_refine");function yl(e,r){let i=Ym(o=>(o.addIssue=t=>{if(typeof t=="string")o.issues.push($t(t,o.value,i._zod.def));else{let n=t;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),"input"in n||(n.input=o.value),n.inst??(n.inst=i),n.continue??(n.continue=!i._zod.def.abort),o.issues.push($t(n))}},e(o.value,o)),r);return i}s(yl,"_superRefine");function Ym(e,r){let i=new M({check:"custom",...k(r)});return i._zod.check=e,i}s(Ym,"_check");function _l(e){let r=new M({check:"describe"});return r._zod.onattach=[i=>{let o=X.get(i)??{};X.add(i,{...o,description:e})}],r._zod.check=()=>{},r}s(_l,"describe");function bl(e){let r=new M({check:"meta"});return r._zod.onattach=[i=>{let o=X.get(i)??{};X.add(i,{...o,...e})}],r._zod.check=()=>{},r}s(bl,"meta");function xl(e,r){let i=k(r),o=i.truthy??["true","1","yes","on","y","enabled"],t=i.falsy??["false","0","no","off","n","disabled"];i.case!=="sensitive"&&(o=o.map(m=>typeof m=="string"?m.toLowerCase():m),t=t.map(m=>typeof m=="string"?m.toLowerCase():m));let n=new Set(o),a=new Set(t),c=e.Codec??Or,l=e.Boolean??Sr,u=e.String??qe,d=new u({type:"string",error:i.error}),f=new l({type:"boolean",error:i.error}),p=new c({type:"pipe",in:d,out:f,transform:s(((m,h)=>{let $=m;return i.case!=="sensitive"&&($=$.toLowerCase()),n.has($)?!0:a.has($)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...n,...a],input:h.value,inst:p,continue:!1}),{})}),"transform"),reverseTransform:s(((m,h)=>m===!0?o[0]||"true":t[0]||"false"),"reverseTransform"),error:i.error});return p._zod.bag.truthy=o,p._zod.bag.falsy=t,p._zod.bag.case=i.case??"insensitive",p}s(xl,"_stringbool");function nt(e,r,i,o={}){let t=k(o),n={check:"string_format",type:"string",format:r,fn:typeof i=="function"?i:c=>i.test(c),...t};return i instanceof RegExp&&(n.pattern=i),new e(n)}s(nt,"_stringFormat");function Fr(e,...r){for(let i of r)for(let o of Reflect.ownKeys(i))Object.prototype.propertyIsEnumerable.call(i,o)&&q(e,o,i[o]);return e}s(Fr,"assignProps");function Re(e){let r=e?.target??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??X,target:r,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}s(Re,"initializeContext");function K(e,r,i,o,t){let n=typeof r.unrepresentable=="function"?r.unrepresentable({zodSchema:e,path:o.path,message:t}):r.unrepresentable;if(n==="any")return!1;if(n===void 0||n==="throw")throw new Error(t);return Object.assign(i,n),!0}s(K,"handleUnrepresentable");function Z(e,r,i={path:[],schemaPath:[]}){var o;let t=e._zod.def,n=r.seen.get(e);if(n)return n.count++,i.schemaPath.includes(e)&&(n.cycle=i.path),n.schema;let a={schema:{},count:1,cycle:void 0,path:i.path};r.seen.set(e,a),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...i,schemaPath:[...i.schemaPath,e],path:i.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,a.schema,d);else{let p=a.schema,m=r.processors[t.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);m(e,r,p,d)}let f=e._zod.parent;f&&(a.ref||(a.ref=f),Z(f,r,d),r.seen.get(f).isParent=!0)}let l=r.metadataRegistry.get(e);return l&&Fr(a.schema,l),r.io==="input"&&ne(e)&&(delete a.schema.examples,delete a.schema.default),r.io==="input"&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,r.seen.get(e).schema}s(Z,"processSchema");function Qm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}s(Qm,"encodeJSONPointerSegment");function Ze(e,r){let i=e.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let a of e.seen.entries()){let c=e.metadataRegistry.get(a[0])?.id;if(c){let l=o.get(c);if(l&&l!==a[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,a[0])}}let t=s(a=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(a[0])?.id,p=e.external.uri??(h=>h);if(f)return{ref:p(f)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${p("__shared")}#/${c}/${Qm(m)}`}}let l="#",u=`${l}/${c}/`;if(a[1]===i&&!a[1].schema.id)return{ref:l};let d=a[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+Qm(d)}},"makeURI"),n=s(a=>{if(a[1].schema.$ref)return;let c=a[1],{ref:l,defId:u}=t(a);c.def={...c.schema},u&&(c.defId=u);let d=c.schema;for(let f in d)delete d[f];d.$ref=l},"extractToDef");if(e.cycles==="throw")for(let a of e.seen.entries()){let c=a[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
99
99
 
100
100
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(r===a[0]){n(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(r!==a[0]&&u){n(a);continue}}if(e.metadataRegistry.get(a[0])?.id){n(a);continue}if(c.cycle){n(a);continue}c.count>1&&e.reused==="ref"&&n(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}s(Ze,"extractDefs");function rp(e){let r=e.anyOf;if(!Array.isArray(r)||r.length===0||e.type!==void 0)return;let i=[];for(let o of r){if(!o||typeof o!="object")return;rp(o);let t=Object.keys(o);if(t.length!==1||t[0]!=="type")return;let n=o.type;for(let a of Array.isArray(n)?n:[n]){if(typeof a!="string")return;i.includes(a)||i.push(a)}}delete e.anyOf,e.type=i.length===1?i[0]:i}s(rp,"compactTypeUnion");var np=new Set(["type","properties","required","additionalProperties"]),ep=["oneOf","anyOf"];function tp(e){let r=e.additionalProperties;return r===void 0||r===!1||typeof r!="object"||r===null?null:Object.keys(r).length?r:null}s(tp,"undeclaredConstraint");function kl(e){let r=[];for(let n of e){if(typeof n!="object"||n.type!=="object")return null;for(let a in n)if(!np.has(a))return null;r.push(n)}let i={},o=new Set;for(let n of r){for(let a in n.properties){if(Object.prototype.hasOwnProperty.call(i,a))continue;let c=[];for(let u of r){let d=u.properties?.[a]??tp(u);d!=null&&(c.some(f=>JSON.stringify(f)===JSON.stringify(d))||c.push(d))}let l=c.length===1?c[0]:kl(c)??{allOf:c};q(i,a,l)}for(let a of n.required??[])o.add(a)}let t={type:"object",properties:i};if(o.size&&(t.required=[...o]),r.every(n=>n.additionalProperties===!1))t.additionalProperties=!1;else{let n=[];for(let a of r){let c=tp(a);c&&!n.some(l=>JSON.stringify(l)===JSON.stringify(c))&&n.push(c)}n.length===1?t.additionalProperties=n[0]:n.length>1&&(t.additionalProperties={allOf:n})}return t}s(kl,"foldObjects");function xb(e){let r=e.allOf;if(!Array.isArray(r)||r.length<2)return;for(let t of np)if(t in e)return;let i=r.filter(t=>ep.some(n=>Array.isArray(t[n]))),o=null;if(!i.length)o=kl(r);else{let t=i[0],n=ep.find(l=>Array.isArray(t[l]));if(Object.keys(t).length!==1)return;let a=r.filter(l=>l!==t),c=t[n].map(l=>kl([...a,l]));if(c.some(l=>!l))return;o={[n]:c}}o&&(delete e.allOf,Fr(e,o))}s(xb,"foldIntersection");function Le(e,r){let i=e.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=s(c=>{let l=e.seen.get(c);if(l.ref===null)return;let u=l.def??l.schema,d={...u},f=l.ref;if(l.ref=null,f){o(f);let m=e.seen.get(f),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Fr(u,h),Fr(u,d),c._zod.parent===f)for(let x in u)x==="$ref"||x==="allOf"||x in d||delete u[x];if(h.$ref&&m.def)for(let x in u)x==="$ref"||x==="allOf"||x in m.def&&JSON.stringify(u[x])===JSON.stringify(m.def[x])&&delete u[x]}let p=c._zod.parent;if(p&&p!==f){o(p);let m=e.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}e.override({zodSchema:c,jsonSchema:u,path:l.path??[]})},"flattenRef");if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())rp(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let l of e.seen.values())for(let u of[l.schema,l.def]){let d=u?.allOf;if(!Array.isArray(d))continue;let f=c.get(d);f?f.push(u):c.set(d,[u])}for(let l of e.intersections)for(let u of c.get(l)??[])xb(u)}}let t={};if(e.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let c=e.external.registry.get(r)?.id;if(!c)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(c)}Fr(t,i.defId?i.schema:i.def??i.schema);let n=e.metadataRegistry.get(r)?.id;n!==void 0&&t.id===n&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let l=c[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,q(a,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let c=JSON.parse(JSON.stringify(t));return Object.defineProperty(c,"~standard",{value:{...r["~standard"],jsonSchema:{input:Mt(r,"input",e.processors),output:Mt(r,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}s(Le,"finalize");function ne(e,r){let i=r??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return ne(o.element,i);if(o.type==="set")return ne(o.valueType,i);if(o.type==="lazy")return ne(o.getter(),i);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return ne(o.innerType,i);if(o.type==="intersection")return ne(o.left,i)||ne(o.right,i);if(o.type==="record"||o.type==="map")return ne(o.keyType,i)||ne(o.valueType,i);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ne(o.in,i)||ne(o.out,i);if(o.type==="object"){for(let t in o.shape)if(ne(o.shape[t],i))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(ne(t,i))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(ne(t,i))return!0;return!!(o.rest&&ne(o.rest,i))}return!1}s(ne,"isTransforming");var Il=s((e,r={})=>i=>{let o=Re({...i,processors:r});return Z(e,o),Ze(o,e),Le(o,e)},"createToJSONSchemaMethod"),Mt=s((e,r,i={})=>o=>{let{libraryOptions:t,target:n}=o??{},a=Re({...t??{},target:n,io:r,processors:i});return Z(e,a),Ze(a,e),Le(a,e)},"createStandardJSONSchemaMethod");var Vt=s((e,r,i)=>{(e[r]===void 0||i>e[r])&&(e[r]=i)},"narrowMin"),Ft=s((e,r,i)=>{(e[r]===void 0||i<e[r])&&(e[r]=i)},"narrowMax"),ip=s((e,r)=>{Vt(e,"minimum",r),Ft(e,"maximum",r)},"narrowBoth"),cp=s((e,r)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(r)||e.multipleOf.push(r)},"addDivisor"),up=s((e,r)=>{e.patterns??(e.patterns=new Set),e.patterns.add(r)},"addPattern"),lp=s((e,r)=>{e.mime=e.mime?e.mime.filter(i=>r.includes(i)):[...r]},"intersectMime"),dp=s((e,r)=>{e.format=r,r.includes("int")&&(e.isInt=!0)},"setFormat"),op=s((e,r)=>Vt(e,"minimum",r.minimum),"minContributor"),ap=s((e,r)=>Ft(e,"maximum",r.maximum),"maxContributor"),sp=s(e=>(r,i)=>{dp(r,i.format);let[o,t]=e[i.format];Vt(r,"minimum",o),Ft(r,"maximum",t)},"formatContributor"),kb={greater_than:s((e,r)=>Vt(e,r.inclusive?"minimum":"exclusiveMinimum",r.value),"greater_than"),less_than:s((e,r)=>Ft(e,r.inclusive?"maximum":"exclusiveMaximum",r.value),"less_than"),multiple_of:s((e,r)=>cp(e,r.value),"multiple_of"),number_format:sp(sr),bigint_format:sp(cr),min_length:op,max_length:ap,length_equals:s((e,r)=>ip(e,r.length),"length_equals"),min_size:op,max_size:ap,size_equals:s((e,r)=>ip(e,r.size),"size_equals"),string_format:s((e,r)=>{dp(e,r.format),r.pattern&&up(e,r.pattern),(r.format==="base64"||r.format==="base64url")&&(e.contentEncoding=r.format),(r.local||r.precision===-1)&&(e.laxFormat=!0)},"string_format"),mime_type:s((e,r)=>lp(e,r.mime),"mime_type")};function H(e){let r={},i=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...i.checks??[]]:i.checks??[];for(let n of o)kb[n._zod.def.check]?.(r,n._zod.def);let t=e._zod.bag;t.minimum!==void 0&&Vt(r,"minimum",t.minimum),t.exclusiveMinimum!==void 0&&Vt(r,"exclusiveMinimum",t.exclusiveMinimum),t.maximum!==void 0&&Ft(r,"maximum",t.maximum),t.exclusiveMaximum!==void 0&&Ft(r,"exclusiveMaximum",t.exclusiveMaximum),t.multipleOf!==void 0&&cp(r,t.multipleOf),t.format!==void 0&&(r.format??(r.format=t.format),t.format.includes("int")&&(r.isInt=!0)),t.mime&&lp(r,t.mime);for(let n of t.patterns??[])up(r,n);return r}s(H,"aggregateChecks");var Ib={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},wb=new Map([[Hn,Ia],[wr,wa]]),fp=s(e=>wb.get(e)??e,"exactPattern"),zl=s((e,r,i,o)=>{let t=i;t.type="string";let{minimum:n,maximum:a,format:c,patterns:l,contentEncoding:u,laxFormat:d}=H(e);if(typeof n=="number"&&(t.minLength=n),typeof a=="number"&&(t.maxLength=a),c&&(t.format=Ib[c]??c,t.format===""&&delete t.format,(c==="time"||d)&&delete t.format),u&&(t.contentEncoding=u),l&&l.size>0){let f=[...l].map(fp);f.length===1?t.pattern=f[0].source:f.length>1&&(t.allOf=[...f.map(p=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},"stringProcessor"),Ol=s((e,r,i,o)=>{let t=i,{minimum:n,maximum:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u,isInt:d}=H(e);t.type=d?"integer":"number";let f=typeof u=="number"&&u>=(n??Number.NEGATIVE_INFINITY),p=typeof l=="number"&&l<=(a??Number.POSITIVE_INFINITY),m=r.target==="draft-04"||r.target==="openapi-3.0";if(f?m?(t.minimum=u,t.exclusiveMinimum=!0):t.exclusiveMinimum=u:typeof n=="number"&&(t.minimum=n),p?m?(t.maximum=l,t.exclusiveMaximum=!0):t.exclusiveMaximum=l:typeof a=="number"&&(t.maximum=a),c){let h=new Set;for(let S of c)Number.isFinite(S)&&S!==0?h.add(Math.abs(S)):K(e,r,t,o,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[$,...x]=h;$!==void 0&&(t.multipleOf=$),x.length&&(t.allOf=[...t.allOf??[],...x.map(S=>({multipleOf:S}))])}},"numberProcessor"),Pl=s((e,r,i,o)=>{i.type="boolean"},"booleanProcessor"),Al=s((e,r,i,o)=>{K(e,r,i,o,"BigInt cannot be represented in JSON Schema")},"bigintProcessor"),Dl=s((e,r,i,o)=>{K(e,r,i,o,"Symbols cannot be represented in JSON Schema")},"symbolProcessor"),El=s((e,r,i,o)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},"nullProcessor"),Nl=s((e,r,i,o)=>{K(e,r,i,o,"Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),Tl=s((e,r,i,o)=>{K(e,r,i,o,"Void cannot be represented in JSON Schema")},"voidProcessor"),Ul=s((e,r,i,o)=>{i.not={}},"neverProcessor"),jl=s((e,r,i,o)=>{},"anyProcessor"),Cl=s((e,r,i,o)=>{},"unknownProcessor"),Rl=s((e,r,i,o)=>{K(e,r,i,o,"Date cannot be represented in JSON Schema")},"dateProcessor"),Zl=s((e,r,i,o)=>{let t=e._zod.def,n=mt(t.entries);if(n.length===0){i.not={};return}n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),i.enum=n},"enumProcessor"),Ll=s((e,r,i,o)=>{let t=e._zod.def;if(t.values.length===0){i.not={};return}let n=[];for(let a of t.values)if(a===void 0){if(K(e,r,i,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(K(e,r,i,o,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(a))}else n.push(a);if(n.length!==0)if(n.length===1){let a=n[0];i.type=a===null?"null":typeof a,r.target==="draft-04"||r.target==="openapi-3.0"?i.enum=[a]:i.const=a}else n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),n.every(a=>typeof a=="boolean")&&(i.type="boolean"),n.every(a=>a===null)&&(i.type="null"),i.enum=n},"literalProcessor"),Ml=s((e,r,i,o)=>{K(e,r,i,o,"NaN cannot be represented in JSON Schema")},"nanProcessor"),Vl=s((e,r,i,o)=>{let t=i,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=n.source},"templateLiteralProcessor"),Fl=s((e,r,i,o)=>{let t=i;t.type="string",t.format="binary",t.contentEncoding="binary";let{minimum:n,maximum:a,mime:c}=H(e);n!==void 0&&(t.minLength=n),a!==void 0&&(t.maxLength=a),c&&(c.length===0?t.not={}:c.length===1?t.contentMediaType=c[0]:t.anyOf=c.map(l=>({contentMediaType:l})))},"fileProcessor"),Bl=s((e,r,i,o)=>{i.type="boolean"},"successProcessor"),Jl=s((e,r,i,o)=>{K(e,r,i,o,"Custom types cannot be represented in JSON Schema")},"customProcessor"),Kl=s((e,r,i,o)=>{K(e,r,i,o,"Function types cannot be represented in JSON Schema")},"functionProcessor"),Hl=s((e,r,i,o)=>{K(e,r,i,o,"Transforms cannot be represented in JSON Schema")},"transformProcessor"),Gl=s((e,r,i,o)=>{K(e,r,i,o,"Map cannot be represented in JSON Schema")},"mapProcessor"),Wl=s((e,r,i,o)=>{K(e,r,i,o,"Set cannot be represented in JSON Schema")},"setProcessor"),ql=s((e,r,i,o)=>{let t=i,n=e._zod.def,{minimum:a,maximum:c}=H(e);typeof a=="number"&&(t.minItems=a),typeof c=="number"&&(t.maxItems=c),t.type="array",t.items=Z(n.element,r,{...o,path:[...o.path,"items"]})},"arrayProcessor");function Br(e){let r=e._zod.def;return r.type==="pipe"&&r.in._zod.traits.has("$ZodTransform")?Br(r.out):r.type==="catch"?Br(r.innerType):e._zod.optin}s(Br,"inputOptin");var Xl=s((e,r,i,o)=>{let t=i,n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&K(e,r,t,o,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let u in a)q(t.properties,u,Z(a[u],r,{...o,path:[...o.path,"properties",u]}));let l=[];for(let u of Object.keys(a)){let d=n.shape[u];(r.io==="input"?Br(d)===void 0:d._zod.optout===void 0)&&l.push(u)}l.length>0&&(t.required=l),n.catchall?._zod.def.type==="never"?t.additionalProperties=!1:n.catchall?n.catchall&&(t.additionalProperties=Z(n.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(t.additionalProperties=!1)},"objectProcessor"),Mi=s((e,r,i,o)=>{let t=e._zod.def,n=t.inclusive===!1,a=t.options.map((c,l)=>Z(c,r,{...o,path:[...o.path,n?"oneOf":"anyOf",l]}));n?i.oneOf=a:i.anyOf=a},"unionProcessor"),Yl=s((e,r,i,o)=>{let t=e._zod.def,n=Z(t.left,r,{...o,path:[...o.path,"allOf",0]}),a=Z(t.right,r,{...o,path:[...o.path,"allOf",1]}),c=s(u=>"allOf"in u&&Object.keys(u).length===1,"isSimpleIntersection"),l=[...c(n)?n.allOf:[n],...c(a)?a.allOf:[a]];i.allOf=l,r.intersections.push(l)},"intersectionProcessor"),Ql=s((e,r,i,o)=>{let t=i,n=e._zod.def;t.type="array";let a=r.target==="draft-2020-12"?"prefixItems":"items",c=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",l=n.items.map(($,x)=>Z($,r,{...o,path:[...o.path,a,x]})),u=n.rest?Z(n.rest,r,{...o,path:[...o.path,c,...r.target==="openapi-3.0"?[n.items.length]:[]]}):null,d=n.items.length;for(;d>0;){let $=n.items[d-1];if(!(r.io==="input"?Br($)!==void 0:$._zod.optout==="optional"))break;d--}let f=n.items.length,p=!n.rest;r.target==="draft-2020-12"?(t.prefixItems=l,p?t.items=!1:u&&(t.items=u),d>0&&(t.minItems=d),p&&(t.maxItems=f)):r.target==="openapi-3.0"?(t.items={anyOf:l},u&&t.items.anyOf.push(u),d>0&&(t.minItems=d),p&&(t.maxItems=f)):(t.items=l,p?t.additionalItems=!1:u&&(t.additionalItems=u),d>0&&(t.minItems=d),p&&(t.maxItems=f));let{minimum:m,maximum:h}=H(e);typeof m=="number"&&(t.minItems=m),typeof h=="number"&&(t.maxItems=h)},"tupleProcessor");function wl(e,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let h=e.get(r)?.def;if(!h)return r;let $=wl(e,h,i);return $===h?r:$}for(let h of["anyOf","oneOf"]){let $=r[h];if(!Array.isArray($))continue;let x=$.map(S=>wl(e,S,i));x.some((S,I)=>S!==$[I])&&(r={...r,[h]:x})}let o=Array.isArray(r.type)?r.type:[r.type],t=!o.includes("string")&&o.some(h=>h==="number"||h==="integer"),n=r.enum??(r.const!==void 0?[r.const]:void 0);if(!t&&!n?.some(h=>typeof h=="number"))return r;let{minimum:a,maximum:c,exclusiveMinimum:l,exclusiveMaximum:u,multipleOf:d,format:f,id:p,...m}=r;return m.enum?m.enum=m.enum.map(h=>typeof h=="number"?String(h):h):typeof m.const=="number"&&(m.const=String(m.const)),t&&(m.type="string",n||(m.pattern=(o.includes("number")?Se:$r).source)),m}s(wl,"stringifyKeyNames");var Sl=new WeakMap;function Sb(e){let r=new Map;for(let o of e.seen.values())o.def&&!r.has(o.schema)&&r.set(o.schema,o);let i=new Map;for(let o of Sl.get(e)??[]){let t=e.seen.get(o),n=(t?.def??t?.schema)?.propertyNames;if(!n||n===!0||i.has(n))continue;let a=wl(r,n,new Set);a!==n&&i.set(n,a)}if(i.size)for(let o of e.seen.values())for(let t of[o.schema,o.def]){let n=t&&i.get(t.propertyNames);n&&(t.propertyNames=n)}}s(Sb,"rewriteKeyNames");var ed=s((e,r,i,o)=>{let t=i,n=e._zod.def;t.type="object";let a=n.keyType,c=H(a).patterns;if(n.mode==="loose"&&c&&c.size>0){let d=Z(n.valueType,r,{...o,path:[...o.path,"patternProperties","*"]});t.patternProperties={};for(let f of c)q(t.patternProperties,fp(f).source,d)}else{if(r.target==="draft-07"||r.target==="draft-2020-12"){t.propertyNames=Z(n.keyType,r,{...o,path:[...o.path,"propertyNames"]});let d=Sl.get(r);d||(d=[],Sl.set(r,d),r.deferred.push(()=>Sb(r))),d.push(e)}t.additionalProperties=Z(n.valueType,r,{...o,path:[...o.path,"additionalProperties"]})}let l=a._zod.values,u=r.io==="input"&&Br(n.valueType)!==void 0;if(l&&!n.partial&&!u){let d=[...l].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(t.required=d.map(String))}},"recordProcessor"),td=s((e,r,i,o)=>{let t=e._zod.def,n=Z(t.innerType,r,o),a=r.seen.get(e);r.target==="openapi-3.0"?(a.ref=t.innerType,i.nullable=!0):i.anyOf=[n,{type:"null"}]},"nullableProcessor"),rd=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},"nonoptionalProcessor"),nd=Symbol();function mp(e,r,i,o,t){let n=!1,a=JSON.stringify(e,(c,l)=>typeof l!="bigint"?l:(n=!0,null));return n?(K(r,i,o,t,"BigInt defaults cannot be represented in JSON Schema"),nd):JSON.parse(a)}s(mp,"serializeDefaultValue");var id=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a=mp(t.defaultValue,e,r,i,o);a!==nd&&(i.default=a)},"defaultProcessor"),od=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);if(n.ref=t.innerType,r.io!=="input")return;let a=mp(t.defaultValue,e,r,i,o);a!==nd&&(i._prefault=a)},"prefaultProcessor"),ad=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{K(e,r,i,o,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},"catchProcessor"),sd=s((e,r,i,o)=>{let t=e._zod.def,n=t.in._zod.traits.has("$ZodTransform"),a=r.io==="input"?n?t.out:t.in:t.out;Z(a,r,o);let c=r.seen.get(e);c.ref=a},"pipeProcessor"),cd=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType,i.readOnly=!0},"readonlyProcessor"),ud=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},"promiseProcessor"),Vi=s((e,r,i,o)=>{let t=e._zod.def;Z(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},"optionalProcessor"),ld=s((e,r,i,o)=>{let t=e._zod.innerType;Z(t,r,o);let n=r.seen.get(e);n.ref=t},"lazyProcessor"),Li={string:zl,number:Ol,boolean:Pl,bigint:Al,symbol:Dl,null:El,undefined:Nl,void:Tl,never:Ul,any:jl,unknown:Cl,date:Rl,enum:Zl,literal:Ll,nan:Ml,template_literal:Vl,file:Fl,success:Bl,custom:Jl,function:Kl,transform:Hl,map:Gl,set:Wl,array:ql,object:Xl,union:Mi,intersection:Yl,tuple:Ql,record:ed,nullable:td,nonoptional:rd,default:id,prefault:od,catch:ad,pipe:sd,readonly:cd,promise:ud,optional:Vi,lazy:ld};function Fi(e,r){if("_idmap"in e){let o=e,t=Re({...r,processors:Li}),n={};for(let l of o._idmap.entries()){let[u,d]=l;Z(d,t)}let a={},c={registry:o,uri:r?.uri,defs:n};t.external=c;for(let l of o._idmap.entries()){let[u,d]=l;Ze(t,d),q(a,u,Le(t,d))}if(Object.keys(n).length>0){let l=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:n}}return{schemas:a}}let i=Re({...r,processors:Li});return Z(e,i),Ze(i,e),Le(i,e)}s(Fi,"toJSONSchema");var Bi=class{static{s(this,"JSONSchemaGenerator")}get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(r){this.ctx.counter=r}get seen(){return this.ctx.seen}constructor(r){let i=r?.target??"draft-2020-12";i==="draft-4"&&(i="draft-04"),i==="draft-7"&&(i="draft-07"),this.ctx=Re({processors:Li,target:i,...r?.metadata&&{metadata:r.metadata},...r?.unrepresentable&&{unrepresentable:r.unrepresentable},...r?.override&&{override:r.override},...r?.io&&{io:r.io}})}process(r,i={path:[],schemaPath:[]}){return Z(r,this.ctx,i)}emit(r,i){i&&(i.cycles&&(this.ctx.cycles=i.cycles),i.reused&&(this.ctx.reused=i.reused),i.external&&(this.ctx.external=i.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Ze(this.ctx,r);let o=Le(this.ctx,r),{"~standard":t,...n}=o;return n}};var pp={};var Xt={};xe(Xt,{ZodAny:()=>Ed,ZodArray:()=>jd,ZodBase64:()=>uo,ZodBase64URL:()=>lo,ZodBigInt:()=>Wt,ZodBigIntFormat:()=>po,ZodBoolean:()=>Gt,ZodCIDRv4:()=>so,ZodCIDRv6:()=>co,ZodCUID:()=>eo,ZodCUID2:()=>to,ZodCatch:()=>nf,ZodCodec:()=>en,ZodCreditCard:()=>Id,ZodCustom:()=>tn,ZodCustomStringFormat:()=>st,ZodDate:()=>Gr,ZodDefault:()=>Xd,ZodDiscriminatedUnion:()=>Rd,ZodE164:()=>fo,ZodEmail:()=>qi,ZodEmoji:()=>Yi,ZodEnum:()=>Jt,ZodExactOptional:()=>$o,ZodFile:()=>Hd,ZodFunction:()=>pf,ZodGUID:()=>Xi,ZodIBAN:()=>wd,ZodIPv4:()=>oo,ZodIPv6:()=>ao,ZodISODate:()=>Ve,ZodISODateTime:()=>Me,ZodISODuration:()=>Be,ZodISOTime:()=>Fe,ZodInstanceOf:()=>hf,ZodIntersection:()=>Zd,ZodJWT:()=>mo,ZodKSUID:()=>io,ZodLazy:()=>df,ZodLiteral:()=>Kd,ZodMAC:()=>kd,ZodMap:()=>Bd,ZodNaN:()=>af,ZodNanoID:()=>Qi,ZodNever:()=>Td,ZodNonOptional:()=>yo,ZodNull:()=>Ad,ZodNullable:()=>qd,ZodNumber:()=>Ht,ZodNumberFormat:()=>ct,ZodObject:()=>qr,ZodOptional:()=>Yr,ZodPipe:()=>Qr,ZodPrefault:()=>Qd,ZodPreprocess:()=>sf,ZodPromise:()=>mf,ZodReadonly:()=>cf,ZodRecord:()=>Bt,ZodSet:()=>Jd,ZodString:()=>Kt,ZodStringFormat:()=>L,ZodSuccess:()=>rf,ZodSymbol:()=>Od,ZodTemplateLiteral:()=>lf,ZodTransform:()=>Gd,ZodTuple:()=>Md,ZodType:()=>E,ZodULID:()=>ro,ZodURL:()=>Hr,ZodUUID:()=>be,ZodUndefined:()=>Pd,ZodUnion:()=>Xr,ZodUnknown:()=>Nd,ZodVoid:()=>Ud,ZodXID:()=>no,ZodXor:()=>Cd,_ZodString:()=>Wi,_default:()=>Yd,_function:()=>Sg,any:()=>ng,array:()=>Wr,base64:()=>Cp,base64url:()=>Rp,bigint:()=>Yp,boolean:()=>zd,catch:()=>of,check:()=>zg,cidrv4:()=>Up,cidrv6:()=>jp,codec:()=>xg,creditCard:()=>Lp,cuid:()=>zp,cuid2:()=>Op,currencyCode:()=>Kp,custom:()=>Og,date:()=>og,describe:()=>Pg,discriminatedUnion:()=>dg,e164:()=>Zp,email:()=>hp,emoji:()=>wp,enum:()=>vo,exactOptional:()=>Wd,file:()=>$g,float32:()=>Gp,float64:()=>Wp,function:()=>Sg,guid:()=>$p,hash:()=>Hp,hex:()=>Jp,hostname:()=>Bp,httpUrl:()=>Ip,iban:()=>Mp,instanceof:()=>Dg,int:()=>Hi,int32:()=>qp,int64:()=>Qp,intersection:()=>Ld,invertCodec:()=>kg,ipv4:()=>Ep,ipv6:()=>Tp,json:()=>Ng,jwt:()=>Vp,keyof:()=>ag,ksuid:()=>Dp,lazy:()=>ff,literal:()=>hg,looseObject:()=>ug,looseRecord:()=>mg,mac:()=>Np,map:()=>pg,meta:()=>Ag,nan:()=>bg,nanoid:()=>Sp,nativeEnum:()=>vg,never:()=>go,nonoptional:()=>tf,null:()=>Dd,nullable:()=>Kr,nullish:()=>yg,number:()=>Sd,object:()=>sg,optional:()=>ot,partialRecord:()=>fg,pipe:()=>Gi,prefault:()=>ef,preprocess:()=>Tg,promise:()=>wg,readonly:()=>uf,record:()=>Fd,refine:()=>gf,set:()=>gg,strictObject:()=>cg,string:()=>Jr,stringFormat:()=>Fp,stringbool:()=>Eg,success:()=>_g,superRefine:()=>vf,symbol:()=>tg,templateLiteral:()=>Ig,transform:()=>ho,tuple:()=>Vd,uint32:()=>Xp,uint64:()=>eg,ulid:()=>Pp,undefined:()=>rg,union:()=>qt,unknown:()=>it,url:()=>kp,uuid:()=>yp,uuidv4:()=>_p,uuidv6:()=>bp,uuidv7:()=>xp,void:()=>ig,xid:()=>Ap,xor:()=>lg});var Ji={};xe(Ji,{endsWith:()=>Nt,gt:()=>ye,gte:()=>de,includes:()=>Dt,length:()=>rt,lowercase:()=>Pt,lt:()=>$e,lte:()=>le,maxLength:()=>tt,maxSize:()=>Ce,mime:()=>Ut,minLength:()=>ze,minSize:()=>_e,multipleOf:()=>je,negative:()=>ji,nonnegative:()=>Ri,nonpositive:()=>Ci,normalize:()=>jt,overwrite:()=>he,positive:()=>Ui,properties:()=>Tt,property:()=>Zi,regex:()=>Ot,size:()=>et,slugify:()=>Lt,startsWith:()=>Et,toLowerCase:()=>Rt,toUpperCase:()=>Zt,trim:()=>Ct,uppercase:()=>At});var gp=new WeakSet([Object.prototype,Error.prototype]);function Ki(e,r,i){Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){let o=i(this);return Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0})}})}s(Ki,"_lazyMethod");var vp=s((e,r)=>{ia.init(e,r),e.name="ZodError";let i=Object.getPrototypeOf(e);gp.has(i)||(gp.add(i),Ki(i,"format",o=>t=>pr(o,t)),Ki(i,"flatten",o=>t=>mr(o,t)),Ki(i,"addIssue",o=>t=>{o.issues.push(t),o.message=JSON.stringify(o.issues,pt,2)}),Ki(i,"addIssues",o=>t=>{o.issues.push(...t),o.message=JSON.stringify(o.issues,pt,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},"initializer"),Ob=g("ZodError",vp),ue=g("ZodError",vp,void 0,{Parent:Error});var dd=yt(ue),fd=_t(ue),md=bt(ue),pd=xt(ue),gd=In(ue),vd=wn(ue),hd=Sn(ue),$d=zn(ue),yd=On(ue),_d=Pn(ue),bd=An(ue),xd=Dn(ue);function Ab(){G.localeError||F(Nr())}s(Ab,"_ensureDefaultLocale");function at(){G.memoizer||F({memoizer:Er()})}s(at,"_ensureDefaultMemoizer");var E=g("ZodType",(e,r)=>(Ab(),D.init(e,r),e.def=r,e.type=r.type,e),{check(...e){let r=this.def;return this.clone(y.mergeDefs(r,{checks:[...r.checks??[],...e.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,r){return C(this,e,r)},brand(){return this},register(e,r){return e.add(this,r),this},refine(e,r){return this.check(gf(e,r))},superRefine(e,r){return this.check(vf(e,r))},overwrite(e){return this.check(he(e))},optional(){return ot(this)},exactOptional(){return Wd(this)},nullable(){return Kr(this)},nullish(){return ot(Kr(this))},nonoptional(e){return tf(this,e)},array(){return Wr(this)},or(e){return qt([this,e])},and(e){return Ld(this,e)},transform(e){return Gi(this,ho(e))},default(e){return Yd(this,e)},prefault(e){return ef(this,e)},catch(e){return of(this,e)},pipe(e){return Gi(this,e)},readonly(){return uf(this)},describe(e){let r=this.clone();return X.add(r,{description:e}),r},meta(...e){if(e.length===0)return X.get(this);let r=this.clone();return X.add(r,e[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...r){return r.length===0?e(this):e(this,...r)},get"~standard"(){return y.hide(this,"~standard",{...Vn(this),jsonSchema:{input:Mt(this,"input"),output:Mt(this,"output")}})},set"~standard"(e){y.own(this,"~standard",e)},parse:s(function e(r,i){return dd(this,r,i,{callee:e})},"_parse"),parseAsync:s(async function e(r,i){return await fd(this,r,i,{callee:e})},"_parseAsync"),safeParse(e,r){return md(this,e,r)},async safeParseAsync(e,r){return pd(this,e,r)},get spa(){return this?.safeParseAsync},set spa(e){y.own(this,"spa",e)},validate(e,r){return gr(this,e,r)},validateAsync(e,r){return vr(this,e,r)},encode:s(function e(r,i){return gd(this,r,i,{callee:e})},"_encode"),decode:s(function e(r,i){return vd(this,r,i,{callee:e})},"_decode"),encodeAsync:s(async function e(r,i){return await hd(this,r,i,{callee:e})},"_encodeAsync"),decodeAsync:s(async function e(r,i){return await $d(this,r,i,{callee:e})},"_decodeAsync"),safeEncode(e,r){return yd(this,e,r)},safeDecode(e,r){return _d(this,e,r)},async safeEncodeAsync(e,r){return bd(this,e,r)},async safeDecodeAsync(e,r){return xd(this,e,r)},toJSONSchema(e){return Il(this,{})(e)},get description(){return X.get(this)?.description},get _def(){return this._zod.def}}),Wi=g("_ZodString",(e,r)=>{qe.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>zl(e,i,o,t)},y.derived({format:s(e=>H(e).format??null,"format"),minLength:s(e=>H(e).minimum??null,"minLength"),maxLength:s(e=>H(e).maximum??null,"maxLength")},{regex(...e){return this.check(Ot(...e))},includes(...e){return this.check(Dt(...e))},startsWith(...e){return this.check(Et(...e))},endsWith(...e){return this.check(Nt(...e))},min(...e){return this.check(ze(...e))},max(...e){return this.check(tt(...e))},length(...e){return this.check(rt(...e))},nonempty(...e){return this.check(ze(1,...e))},lowercase(e){return this.check(Pt(e))},uppercase(e){return this.check(At(e))},trim(){return this.check(Ct())},normalize(...e){return this.check(jt(...e))},toLowerCase(){return this.check(Rt())},toUpperCase(){return this.check(Zt())},slugify(){return this.check(Lt())}})),Kt=g("ZodString",(e,r)=>{qe.init(e,r),Wi.init(e,r)},{email(e){return this.check(pi(qi,e))},url(e){return this.check(Rr(Hr,e))},jwt(e){return this.check(Ti(mo,e))},emoji(e){return this.check(_i(Yi,e))},guid(e){return this.check(gi(Xi,e))},uuid(e){return this.check(vi(be,e))},uuidv4(e){return this.check(hi(be,e))},uuidv6(e){return this.check($i(be,e))},uuidv7(e){return this.check(yi(be,e))},nanoid(e){return this.check(bi(Qi,e))},cuid(e){return this.check(xi(eo,e))},cuid2(e){return this.check(ki(to,e))},ulid(e){return this.check(Ii(ro,e))},base64(e){return this.check(Di(uo,e))},base64url(e){return this.check(Ei(lo,e))},xid(e){return this.check(wi(no,e))},ksuid(e){return this.check(Si(io,e))},ipv4(e){return this.check(zi(oo,e))},ipv6(e){return this.check(Oi(ao,e))},cidrv4(e){return this.check(Pi(so,e))},cidrv6(e){return this.check(Ai(co,e))},e164(e){return this.check(Ni(fo,e))},datetime(e){return this.check(Zr(Me,e))},date(e){return this.check(Lr(Ve,e))},time(e){return this.check(Mr(Fe,e))},duration(e){return this.check(Vr(Be,e))}});function Jr(e){return Lu(Kt,e)}s(Jr,"string");var L=g("ZodStringFormat",(e,r)=>{R.init(e,r),Wi.init(e,r)}),Me=g("ZodISODateTime",(e,r)=>{Is.init(e,r),L.init(e,r)}),Ve=g("ZodISODate",(e,r)=>{ws.init(e,r),L.init(e,r)}),Fe=g("ZodISOTime",(e,r)=>{Ss.init(e,r),L.init(e,r)}),Be=g("ZodISODuration",(e,r)=>{zs.init(e,r),L.init(e,r)}),qi=g("ZodEmail",(e,r)=>{ms.init(e,r),L.init(e,r)});function hp(e){return pi(qi,e)}s(hp,"email");var Xi=g("ZodGUID",(e,r)=>{ds.init(e,r),L.init(e,r)});function $p(e){return gi(Xi,e)}s($p,"guid");var be=g("ZodUUID",(e,r)=>{fs.init(e,r),L.init(e,r)});function yp(e){return vi(be,e)}s(yp,"uuid");function _p(e){return hi(be,e)}s(_p,"uuidv4");function bp(e){return $i(be,e)}s(bp,"uuidv6");function xp(e){return yi(be,e)}s(xp,"uuidv7");var Hr=g("ZodURL",(e,r)=>{vs.init(e,r),L.init(e,r)});function kp(e){return Rr(Hr,e)}s(kp,"url");function Ip(e){return Rr(Hr,{protocol:hr,hostname:za,...y.normalizeParams(e)})}s(Ip,"httpUrl");var Yi=g("ZodEmoji",(e,r)=>{hs.init(e,r),L.init(e,r)});function wp(e){return _i(Yi,e)}s(wp,"emoji");var Qi=g("ZodNanoID",(e,r)=>{$s.init(e,r),L.init(e,r)});function Sp(e){return bi(Qi,e)}s(Sp,"nanoid");var eo=g("ZodCUID",(e,r)=>{ys.init(e,r),L.init(e,r)});function zp(e){return xi(eo,e)}s(zp,"cuid");var to=g("ZodCUID2",(e,r)=>{_s.init(e,r),L.init(e,r)});function Op(e){return ki(to,e)}s(Op,"cuid2");var ro=g("ZodULID",(e,r)=>{bs.init(e,r),L.init(e,r)});function Pp(e){return Ii(ro,e)}s(Pp,"ulid");var no=g("ZodXID",(e,r)=>{xs.init(e,r),L.init(e,r)});function Ap(e){return wi(no,e)}s(Ap,"xid");var io=g("ZodKSUID",(e,r)=>{ks.init(e,r),L.init(e,r)});function Dp(e){return Si(io,e)}s(Dp,"ksuid");var oo=g("ZodIPv4",(e,r)=>{Os.init(e,r),L.init(e,r)});function Ep(e){return zi(oo,e)}s(Ep,"ipv4");var kd=g("ZodMAC",(e,r)=>{As.init(e,r),L.init(e,r)});function Np(e){return Vu(kd,e)}s(Np,"mac");var ao=g("ZodIPv6",(e,r)=>{Ps.init(e,r),L.init(e,r)});function Tp(e){return Oi(ao,e)}s(Tp,"ipv6");var so=g("ZodCIDRv4",(e,r)=>{Ds.init(e,r),L.init(e,r)});function Up(e){return Pi(so,e)}s(Up,"cidrv4");var co=g("ZodCIDRv6",(e,r)=>{Es.init(e,r),L.init(e,r)});function jp(e){return Ai(co,e)}s(jp,"cidrv6");var uo=g("ZodBase64",(e,r)=>{Ns.init(e,r),L.init(e,r)});function Cp(e){return Di(uo,e)}s(Cp,"base64");var lo=g("ZodBase64URL",(e,r)=>{Ts.init(e,r),L.init(e,r)});function Rp(e){return Ei(lo,e)}s(Rp,"base64url");var fo=g("ZodE164",(e,r)=>{Us.init(e,r),L.init(e,r)});function Zp(e){return Ni(fo,e)}s(Zp,"e164");var Id=g("ZodCreditCard",(e,r)=>{js.init(e,r),L.init(e,r)});function Lp(e){return Fu(Id,e)}s(Lp,"creditCard");var wd=g("ZodIBAN",(e,r)=>{Cs.init(e,r),L.init(e,r)});function Mp(e){return Bu(wd,e)}s(Mp,"iban");var mo=g("ZodJWT",(e,r)=>{Rs.init(e,r),L.init(e,r)});function Vp(e){return Ti(mo,e)}s(Vp,"jwt");var st=g("ZodCustomStringFormat",(e,r)=>{Zs.init(e,r),L.init(e,r)});function Fp(e,r,i={}){return nt(st,e,r,i)}s(Fp,"stringFormat");function Bp(e){return nt(st,"hostname",Sa,e)}s(Bp,"hostname");function Jp(e){return nt(st,"hex",Ma,e)}s(Jp,"hex");function Kp(e){return nt(st,"currency_code",Pa,e)}s(Kp,"currencyCode");function Hp(e,r){let i=r?.enc??"hex",o=`${e}_${i}`,t=pe[o];if(!t)throw new Error(`Unrecognized hash format: ${o}`);return nt(st,o,t,r)}s(Hp,"hash");var Ht=g("ZodNumber",(e,r)=>{Yn.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ol(e,i,o,t),e.isFinite=!0},y.derived({minValue:s(e=>{let{minimum:r,exclusiveMinimum:i}=H(e);return Math.max(r??Number.NEGATIVE_INFINITY,i??Number.NEGATIVE_INFINITY)},"minValue"),maxValue:s(e=>{let{maximum:r,exclusiveMaximum:i}=H(e);return Math.min(r??Number.POSITIVE_INFINITY,i??Number.POSITIVE_INFINITY)},"maxValue"),isInt:s(e=>{let{isInt:r,multipleOf:i}=H(e);return!!r||!!i?.some(Number.isSafeInteger)},"isInt"),format:s(e=>H(e).format??null,"format")},{gt(e,r){return this.check(ye(e,r))},gte(e,r){return this.check(de(e,r))},min(e,r){return this.check(de(e,r))},lt(e,r){return this.check($e(e,r))},lte(e,r){return this.check(le(e,r))},max(e,r){return this.check(le(e,r))},int(e){return this.check(Hi(e))},safe(e){return this.check(Hi(e))},positive(e){return this.check(ye(0,e))},nonnegative(e){return this.check(de(0,e))},negative(e){return this.check($e(0,e))},nonpositive(e){return this.check(le(0,e))},multipleOf(e,r){return this.check(je(e,r))},step(e,r){return this.check(je(e,r))},finite(){return this}}));function Sd(e){return Ku(Ht,e)}s(Sd,"number");var ct=g("ZodNumberFormat",(e,r)=>{Ls.init(e,r),Ht.init(e,r)});function Hi(e){return Gu(ct,e)}s(Hi,"int");function Gp(e){return Wu(ct,e)}s(Gp,"float32");function Wp(e){return qu(ct,e)}s(Wp,"float64");function qp(e){return Xu(ct,e)}s(qp,"int32");function Xp(e){return Yu(ct,e)}s(Xp,"uint32");var Gt=g("ZodBoolean",(e,r)=>{Sr.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Pl(e,i,o,t)});function zd(e){return Qu(Gt,e)}s(zd,"boolean");var Wt=g("ZodBigInt",(e,r)=>{Qn.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Al(e,i,o,t)},y.derived({minValue:s(e=>H(e).minimum??null,"minValue"),maxValue:s(e=>H(e).maximum??null,"maxValue"),format:s(e=>H(e).format??null,"format")},{gte(e,r){return this.check(de(e,r))},min(e,r){return this.check(de(e,r))},gt(e,r){return this.check(ye(e,r))},lt(e,r){return this.check($e(e,r))},lte(e,r){return this.check(le(e,r))},max(e,r){return this.check(le(e,r))},positive(e){return this.check(ye(BigInt(0),e))},negative(e){return this.check($e(BigInt(0),e))},nonpositive(e){return this.check(le(BigInt(0),e))},nonnegative(e){return this.check(de(BigInt(0),e))},multipleOf(e,r){return this.check(je(e,r))}}));function Yp(e){return tl(Wt,e)}s(Yp,"bigint");var po=g("ZodBigIntFormat",(e,r)=>{Ms.init(e,r),Wt.init(e,r)});function Qp(e){return nl(po,e)}s(Qp,"int64");function eg(e){return il(po,e)}s(eg,"uint64");var Od=g("ZodSymbol",(e,r)=>{Vs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Dl(e,i,o,t)});function tg(e){return ol(Od,e)}s(tg,"symbol");var Pd=g("ZodUndefined",(e,r)=>{Fs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Nl(e,i,o,t)});function rg(e){return al(Pd,e)}s(rg,"_undefined");var Ad=g("ZodNull",(e,r)=>{Bs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>El(e,i,o,t)});function Dd(e){return sl(Ad,e)}s(Dd,"_null");var Ed=g("ZodAny",(e,r)=>{Js.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>jl(e,i,o,t)});function ng(){return cl(Ed)}s(ng,"any");var Nd=g("ZodUnknown",(e,r)=>{Ks.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Cl(e,i,o,t)});function it(){return ul(Nd)}s(it,"unknown");var Td=g("ZodNever",(e,r)=>{Hs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ul(e,i,o,t)});function go(e){return ll(Td,e)}s(go,"never");var Ud=g("ZodVoid",(e,r)=>{Gs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Tl(e,i,o,t)});function ig(e){return dl(Ud,e)}s(ig,"_void");var Gr=g("ZodDate",(e,r)=>{Ws.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Rl(e,i,o,t),e.min=(i,o)=>e.check(de(i,o)),e.max=(i,o)=>e.check(le(i,o))},y.derived({minDate:s(e=>{let{minimum:r}=H(e);return r?new Date(r):null},"minDate"),maxDate:s(e=>{let{maximum:r}=H(e);return r?new Date(r):null},"maxDate")},{}));function og(e){return fl(Gr,e)}s(og,"date");var jd=g("ZodArray",(e,r)=>{at(),Xs.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ql(e,i,o,t),e.element=r.element},{min(e,r){return this.check(ze(e,r))},nonempty(e){return this.check(ze(1,e))},max(e,r){return this.check(tt(e,r))},length(e,r){return this.check(rt(e,r))},unwrap(){return this.element}});function Wr(e,r){return gl(jd,e,r)}s(Wr,"array");function ag(e){let r=e._zod.def.shape;return vo(Object.keys(r))}s(ag,"keyof");var qr=g("ZodObject",(e,r)=>{at(),Ys.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Xl(e,i,o,t),y.installLazyProp(e,"shape",i=>i._zod.def.shape,!1)},{keyof(){return vo(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(y.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(y.mergeDefs(this._zod.def,{catchall:it()}))},loose(){return this.clone(y.mergeDefs(this._zod.def,{catchall:it()}))},strict(){return this.clone(y.mergeDefs(this._zod.def,{catchall:go()}))},strip(){return this.clone(y.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return y.extend(this,e)},safeExtend(e){return y.safeExtend(this,e)},merge(e){return y.merge(this,e)},pick(e){return y.pick(this,e)},omit(e){return y.omit(this,e)},partial(...e){return y.partial(Yr,this,e[0])},exactPartial(...e){return y.partial($o,this,e[0],"exactPartial")},required(...e){return y.required(yo,this,e[0])}});function sg(e,r){let i={type:"object",shape:e??{},...y.normalizeParams(r)};return new qr(i)}s(sg,"object");function cg(e,r){return new qr({type:"object",shape:e,catchall:go(),...y.normalizeParams(r)})}s(cg,"strictObject");function ug(e,r){return new qr({type:"object",shape:e,catchall:it(),...y.normalizeParams(r)})}s(ug,"looseObject");var Xr=g("ZodUnion",(e,r)=>{zr.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Mi(e,i,o,t),e.options=r.options});function qt(e,r){return new Xr({type:"union",options:e,...y.normalizeParams(r)})}s(qt,"union");var Cd=g("ZodXor",(e,r)=>{Xr.init(e,r),Qs.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Mi(e,i,o,t),e.options=r.options});function lg(e,r){return new Cd({type:"union",options:e,inclusive:!1,...y.normalizeParams(r)})}s(lg,"xor");var Rd=g("ZodDiscriminatedUnion",(e,r)=>{Xr.init(e,r),tc.init(e,r)});function dg(e,r,i){return new Rd({type:"union",options:r,discriminator:e,...y.normalizeParams(i)})}s(dg,"discriminatedUnion");var Zd=g("ZodIntersection",(e,r)=>{rc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Yl(e,i,o,t)});function Ld(e,r){return new Zd({type:"intersection",left:e,right:r})}s(Ld,"intersection");var Md=g("ZodTuple",(e,r)=>{at(),ei.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ql(e,i,o,t)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(r=>new Yr({type:"optional",innerType:r}))})}});function Vd(e,r,i){let o=r instanceof D,t=o?i:r,n=o?r:null;return new Md({type:"tuple",items:e,rest:n,...y.normalizeParams(t)})}s(Vd,"tuple");var Bt=g("ZodRecord",(e,r)=>{at(),nc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ed(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType});function Fd(e,r,i){return!r||!r._zod?new Bt({type:"record",keyType:Jr(),valueType:e,...y.normalizeParams(r)}):new Bt({type:"record",keyType:e,valueType:r,...y.normalizeParams(i)})}s(Fd,"record");function fg(e,r,i){return new Bt({type:"record",keyType:e,valueType:r,...y.normalizeParams(i),partial:!0})}s(fg,"partialRecord");function mg(e,r,i){return new Bt({type:"record",keyType:e,valueType:r,mode:"loose",...y.normalizeParams(i)})}s(mg,"looseRecord");var Bd=g("ZodMap",(e,r)=>{at(),ic.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Gl(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType,e.min=(...i)=>e.check(_e(...i)),e.nonempty=i=>e.check(_e(1,i)),e.max=(...i)=>e.check(Ce(...i)),e.size=(...i)=>e.check(et(...i))});function pg(e,r,i){return new Bd({type:"map",keyType:e,valueType:r,...y.normalizeParams(i)})}s(pg,"map");var Jd=g("ZodSet",(e,r)=>{at(),oc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Wl(e,i,o,t),e.min=(...i)=>e.check(_e(...i)),e.nonempty=i=>e.check(_e(1,i)),e.max=(...i)=>e.check(Ce(...i)),e.size=(...i)=>e.check(et(...i))});function gg(e,r){return new Jd({type:"set",valueType:e,...y.normalizeParams(r)})}s(gg,"set");var Jt=g("ZodEnum",(e,r)=>{ac.init(e,r),E.init(e,r),e._zod.processJSONSchema=(o,t,n)=>Zl(e,o,t,n),e.enum=r.entries,e.options=[...e._zod.values];let i=new Set(Object.keys(r.entries));e.extract=(o,t)=>{let n={};for(let a of o)if(i.has(a))n[a]=r.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Jt({...r,checks:[],...y.normalizeParams(t),entries:n})},e.exclude=(o,t)=>{let n={...r.entries};for(let a of o)if(i.has(a))delete n[a];else throw new Error(`Key ${a} not found in enum`);return new Jt({...r,checks:[],...y.normalizeParams(t),entries:n})}});function vo(e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Jt({type:"enum",entries:i,...y.normalizeParams(r)})}s(vo,"_enum");function vg(e,r){return new Jt({type:"enum",entries:e,...y.normalizeParams(r)})}s(vg,"nativeEnum");var Kd=g("ZodLiteral",(e,r)=>{sc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ll(e,i,o,t),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function hg(e,r){return new Kd({type:"literal",values:Array.isArray(e)?e:[e],...y.normalizeParams(r)})}s(hg,"literal");var Hd=g("ZodFile",(e,r)=>{cc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Fl(e,i,o,t),e.min=(i,o)=>e.check(_e(i,o)),e.max=(i,o)=>e.check(Ce(i,o)),e.mime=(i,o)=>e.check(Ut(Array.isArray(i)?i:[i],o))});function $g(e){return vl(Hd,e)}s($g,"file");var Gd=g("ZodTransform",(e,r)=>{at(),uc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Hl(e,i,o,t),e._zod.parse=(i,o)=>{if(o.direction==="backward")throw new Te(e.constructor.name);i.addIssue=n=>{if(typeof n=="string")i.issues.push(y.issue(n,i.value,r));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=i.value),a.inst??(a.inst=e),i.issues.push(y.issue(a))}};let t=r.transform(i.value,i);return t instanceof Promise?t.then(n=>(i.value=n,i)):(i.value=t,i)}});function ho(e){return new Gd({type:"transform",transform:e})}s(ho,"transform");var Yr=g("ZodOptional",(e,r)=>{ti.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Vi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ot(e){return new Yr({type:"optional",innerType:e})}s(ot,"optional");var $o=g("ZodExactOptional",(e,r)=>{lc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Vi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Wd(e){return new $o({type:"optional",innerType:e})}s(Wd,"exactOptional");var qd=g("ZodNullable",(e,r)=>{dc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>td(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Kr(e){return new qd({type:"nullable",innerType:e})}s(Kr,"nullable");function yg(e){return ot(Kr(e))}s(yg,"nullish");var Xd=g("ZodDefault",(e,r)=>{fc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>id(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yd(e,r){return new Xd({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():y.shallowClone(r)}})}s(Yd,"_default");var Qd=g("ZodPrefault",(e,r)=>{mc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>od(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ef(e,r){return new Qd({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():y.shallowClone(r)}})}s(ef,"prefault");var yo=g("ZodNonOptional",(e,r)=>{pc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>rd(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function tf(e,r){return new yo({type:"nonoptional",innerType:e,...y.normalizeParams(r)})}s(tf,"nonoptional");var rf=g("ZodSuccess",(e,r)=>{gc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Bl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function _g(e){return new rf({type:"success",innerType:e})}s(_g,"success");var nf=g("ZodCatch",(e,r)=>{vc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ad(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function of(e,r){return new nf({type:"catch",innerType:e,catchValue:typeof r=="function"?r:y.constantCatch(r)})}s(of,"_catch");var af=g("ZodNaN",(e,r)=>{hc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ml(e,i,o,t)});function bg(e){return pl(af,e)}s(bg,"nan");var Qr=g("ZodPipe",(e,r)=>{ri.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>sd(e,i,o,t),e.in=r.in,e.out=r.out});function Gi(e,r){return new Qr({type:"pipe",in:e,out:r})}s(Gi,"pipe");var en=g("ZodCodec",(e,r)=>{Qr.init(e,r),Or.init(e,r)});function xg(e,r,i){return new en({type:"pipe",in:e,out:r,transform:i.decode,reverseTransform:i.encode})}s(xg,"codec");function kg(e){let r=e._zod.def;return new en({type:"pipe",in:r.out,out:r.in,transform:r.reverseTransform,reverseTransform:r.transform})}s(kg,"invertCodec");var sf=g("ZodPreprocess",(e,r)=>{Qr.init(e,r),$c.init(e,r)}),cf=g("ZodReadonly",(e,r)=>{yc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>cd(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function uf(e){return new cf({type:"readonly",innerType:e})}s(uf,"readonly");var lf=g("ZodTemplateLiteral",(e,r)=>{_c.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Vl(e,i,o,t)});function Ig(e,r){return new lf({type:"template_literal",parts:e,...y.normalizeParams(r)})}s(Ig,"templateLiteral");var df=g("ZodLazy",(e,r)=>{Pr.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ld(e,i,o,t),e.unwrap=()=>e._zod.def.getter()});function ff(e){return new df({type:"lazy",getter:e})}s(ff,"lazy");var mf=g("ZodPromise",(e,r)=>{xc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ud(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function wg(e){return new mf({type:"promise",innerType:e})}s(wg,"promise");var pf=g("ZodFunction",(e,r)=>{bc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Kl(e,i,o,t)});function Sg(e){return new pf({type:"function",input:Array.isArray(e?.input)?Vd(e?.input):e?.input??Wr(it()),output:e?.output??it()})}s(Sg,"_function");var tn=g("ZodCustom",(e,r)=>{kc.init(e,r),E.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Jl(e,i,o,t)});function zg(e){let r=new M({check:"custom"});return r._zod.check=e,r}s(zg,"check");function Og(e,r){return hl(tn,e??(()=>!0),r)}s(Og,"custom");function gf(e,r={}){return $l(tn,e,r)}s(gf,"refine");function vf(e,r){return yl(e,r)}s(vf,"superRefine");var Pg=_l,Ag=bl,hf=g("ZodInstanceOf",(e,r)=>{tn.init(e,r)},{properties(e,r){return this.check(Tt(e,r))}});function Dg(e,r={}){let i=new hf({type:"custom",check:"custom",fn:s(o=>o instanceof e,"fn"),abort:!0,...y.normalizeParams(r)});return i._zod.bag.Class=e,i._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:i,path:[...i._zod.def.path??[]]})},i}s(Dg,"_instanceof");var Eg=s((...e)=>xl({Codec:en,Boolean:Gt,String:Kt},...e),"stringbool");function Ng(e){let r=ff(()=>qt([Jr(e),Sd(),zd(),Dd(),Wr(r),Fd(Jr(),r)]));return r}s(Ng,"json");function Tg(e,r){return new sf({type:"pipe",in:ho(e),out:r})}s(Tg,"preprocess");var Db={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Eb(e){F({customError:e})}s(Eb,"setErrorMap");function Nb(){return F().customError}s(Nb,"getErrorMap");var $f;$f||($f={});var rn={};xe(rn,{ZodISODate:()=>Ve,ZodISODateTime:()=>Me,ZodISODuration:()=>Be,ZodISOTime:()=>Fe,date:()=>Ub,datetime:()=>Tb,duration:()=>Cb,time:()=>jb});function Tb(e){return Zr(Me,e)}s(Tb,"datetime");function Ub(e){return Lr(Ve,e)}s(Ub,"date");function jb(e){return Mr(Fe,e)}s(jb,"time");function Cb(e){return Vr(Be,e)}s(Cb,"duration");var w={...Xt,...Ji,iso:rn},Rb=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Zb(e,r){let i=e.$schema;return i==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":i==="http://json-schema.org/draft-07/schema#"?"draft-7":i==="http://json-schema.org/draft-04/schema#"?"draft-4":r??"draft-2020-12"}s(Zb,"detectVersion");function Ug(e,r){return e.map((i,o)=>o<r?i:i.optional())}s(Ug,"applyMinItems");function Lb(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}s(Lb,"decodeJSONPointerSegment");function Mb(e,r){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let i=e.slice(1).split("/").filter(Boolean);if(i.length===0)return r.rootSchema;let o=r.version==="draft-2020-12"?"$defs":"definitions";if(i[0]===o){let t=i[1]===void 0?void 0:Lb(i[1]);if(!t||!r.defs[t])throw new Error(`Reference not found: ${e}`);return r.defs[t]}throw new Error(`Reference not found: ${e}`)}s(Mb,"resolveRef");function Vb(e,r){return w.transform(o=>o).check(o=>{let t=o.value;if(typeof t!="object"||t===null||Array.isArray(t))return;let n=Object.getOwnPropertyNames(t);if(r.minProperties!==void 0&&n.length<r.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:r.minProperties,inclusive:!0,message:`Too small: expected object to have >=${r.minProperties} properties`,input:t,inst:e,continue:!0}),r.maxProperties!==void 0&&n.length>r.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:r.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${r.maxProperties} properties`,input:t,inst:e,continue:!0}),r.keySchema)for(let a of n){let c=r.keySchema.safeParse(a);c.success||o.issues.push({code:"invalid_key",origin:"record",issues:c.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}s(Vb,"checkObjectGuards");function yf(e,r){if(e===null)return"z";let i=typeof e;if(i!=="object"){if(i==="number"&&Number.isNaN(e))return null;let o=String(e);return`${i[0]}${o.length}:${o}`}if(r.has(e))return null;r.add(e);try{if(Array.isArray(e)){let n=[];for(let a of e){let c=yf(a,r);if(c===null)return null;n.push(c)}return`a${n.length}:[${n.join(",")}]`}let o=Object.keys(e).sort(),t=[];for(let n of o){let a=yf(e[n],r);if(a===null)return null;t.push(`${n.length}:${n}=${a}`)}return`o${t.length}:{${t.join(",")}}`}finally{r.delete(e)}}s(yf,"canonicalKey");var Fb=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Bb=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function nn(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(nn):typeof e.$ref=="string"?!0:Object.entries(e).some(([r,i])=>Fb.has(r)?nn(i):!Bb.has(r)||typeof i!="object"||i===null?!1:Object.values(i).some(nn))}s(nn,"containsRef");function jg(e){return e===1?"element":"elements"}s(jg,"plural");function Jb(e,r){return w.transform(o=>o).check(o=>{let t=o.value;if(Array.isArray(t)){if(r.uniqueItems===!0){let n=new Map;for(let a=0;a<t.length;a++){let c=yf(t[a],new Set);if(c===null)continue;let l=n.get(c);if(l===void 0){n.set(c,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${l}`,input:t,path:[a],continue:!0})}}if(r.containsSchema){let n=r.minContains??1,a=r.maxContains!==void 0?r.maxContains+1:Number.POSITIVE_INFINITY,c=0;for(let l of t)if(r.containsSchema.safeParse(l).success&&++c>=a)break;c<n&&o.issues.push({code:"custom",message:`Array must contain at least ${n} matching ${jg(n)}; found ${c}`,input:t,continue:!0}),r.maxContains!==void 0&&c>r.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${r.maxContains} matching ${jg(r.maxContains)}`,input:t,continue:!0})}}}).pipe(e)}s(Jb,"checkArrayGuards");function Cg(e,r){if(e!==!1)return e===void 0||e===!0?w.any():ie(e,r)}s(Cg,"getTupleRest");var Kb=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Rg(e,r){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return w.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let t=e.$ref;if(r.refs.has(t))return r.refs.get(t);if(r.processing.has(t))return w.lazy(()=>{if(!r.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return r.refs.get(t)});r.processing.add(t);let n=Mb(t,r),a=ie(n,r);return r.refs.set(t,a),r.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(r.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return w.null();if(t.length===0)return w.never();if(t.length===1)return w.literal(t[0]);if(t.every(a=>typeof a=="string"))return w.enum(t);let n=t.map(a=>w.literal(a));return n.length<2?n[0]:w.union([n[0],n[1],...n.slice(2)])}if(e.const!==void 0)return w.literal(e.const);let i=e.type;if(Array.isArray(i)){let t=i.map(n=>{let a={...e,type:n};return Rg(a,r)});return t.length===0?w.never():t.length===1?t[0]:w.union(t)}if(!i)return w.any();let o;switch(i){case"string":{let t=w.string();if(e.format){let n=e.format;n==="email"?t=t.check(w.email()):n==="uri"||n==="uri-reference"?t=t.check(w.url()):n==="uuid"||n==="guid"?t=t.check(w.uuid()):n==="date-time"?t=t.check(w.iso.datetime({offset:!0})):n==="date"?t=t.check(w.iso.date()):n==="time"?t=t.check(w.regex(Kb)):n==="duration"?t=t.check(w.iso.duration()):n==="hostname"?t=t.check(w.hostname()):n==="ipv4"?t=t.check(w.ipv4()):n==="ipv6"?t=t.check(w.ipv6()):n==="mac"?t=t.check(w.mac()):n==="cidr"?t=t.check(w.cidrv4()):n==="cidr-v6"?t=t.check(w.cidrv6()):n==="base64"?t=t.check(w.base64()):n==="base64url"?t=t.check(w.base64url()):n==="e164"?t=t.check(w.e164()):n==="credit_card"?t=t.check(w.creditCard()):n==="iban"?t=t.check(w.iban()):n==="jwt"?t=t.check(w.jwt()):n==="emoji"?t=t.check(w.emoji()):n==="nanoid"?t=t.check(w.nanoid()):n==="cuid"?t=t.check(w.cuid()):n==="cuid2"?t=t.check(w.cuid2()):n==="ulid"?t=t.check(w.ulid()):n==="xid"?t=t.check(w.xid()):n==="ksuid"&&(t=t.check(w.ksuid()))}typeof e.minLength=="number"&&(t=t.min(e.minLength)),typeof e.maxLength=="number"&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),o=t;break}case"number":case"integer":{let t=i==="integer"?w.number().int():w.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum=="number"?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(t=t.lt(e.maximum)),typeof e.multipleOf=="number"&&(t=t.multipleOf(e.multipleOf)),o=t;break}case"boolean":{o=w.boolean();break}case"null":{o=w.null();break}case"object":{let t={},n=e.properties||{},a=new Set(e.required||[]),c=typeof e.additionalProperties=="object"?ie(e.additionalProperties,r):void 0;for(let[f,p]of Object.entries(n)){let m=ie(p,r);q(t,f,a.has(f)?m:m.optional())}if(e.patternProperties){let f=e.patternProperties,p=Object.keys(f),m=[];for(let $ of p){let x=ie(f[$],r),S=w.string().regex(new RegExp($));m.push(w.looseRecord(S,x))}let h=[];if(Object.keys(t).length>0&&h.push(w.object(t).passthrough()),h.push(...m),h.length===0)o=w.object({}).passthrough();else if(h.length===1)o=h[0];else{let $=w.intersection(h[0],h[1]);for(let x=2;x<h.length;x++)$=w.intersection($,h[x]);o=$}if(e.additionalProperties===!1){let $=Object.keys(t),x=p.map(I=>new RegExp(I)),S=o;o=o.check(I=>{if(!fe(I.value))return;let z=[];for(let O of Object.keys(I.value))$.includes(O)||x.some(U=>U.test(O))||z.push(O);z.length&&I.issues.push({code:"unrecognized_keys",keys:z,input:I.value,inst:S})})}}else{let f=w.object(t);e.additionalProperties===!1?o=f.strict():c?o=f.catchall(c):o=f.passthrough()}let l=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,d=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(l||u!==void 0||d!==void 0){let f;if(l){let p=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;f=ie(p,r)}o=Vb(o,{keySchema:f,minProperties:u,maxProperties:d})}break}case"array":{let t=e.prefixItems,n=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,c=t.map(f=>ie(f,r)),l=Ug(c,a),u=Array.isArray(n)?void 0:Cg(n,r),d=w.tuple(l);o=u?d.rest(u):d,typeof e.minItems=="number"&&(o=o.check(w.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(w.maxLength(e.maxItems)))}else if(Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,c=n.map(f=>ie(f,r)),l=Ug(c,a),u=Cg(e.additionalItems,r),d=w.tuple(l);o=u?d.rest(u):d,typeof e.minItems=="number"&&(o=o.check(w.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(w.maxLength(e.maxItems)))}else if(n!==void 0){let a=ie(n,r),c=w.array(a);typeof e.minItems=="number"&&(c=c.min(e.minItems)),typeof e.maxItems=="number"&&(c=c.max(e.maxItems)),o=c}else o=w.array(w.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=Jb(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?ie(e.contains,r):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${i}`)}return o}s(Rg,"convertBaseSchema");function ie(e,r){if(typeof e=="boolean")return e?w.any():w.never();let i=Rg(e,r),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let c=e.anyOf.map(u=>ie(u,r)),l=w.union(c);i=o?w.intersection(i,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let c=e.oneOf.map(u=>ie(u,r)),l=w.xor(c);i=o?w.intersection(i,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)i=o?i:w.any();else{let c=o?i:ie(e.allOf[0],r),l=o?0:1;for(let u=l;u<e.allOf.length;u++)c=w.intersection(c,ie(e.allOf[u],r));i=c}e.nullable===!0&&r.version==="openapi-3.0"&&(i=w.nullable(i)),e.readOnly===!0&&(i=w.readonly(i)),e.default!==void 0&&(i=i.default(e.default));let t={},n=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let c of n)c in e&&(t[c]=e[c]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let c of a)c in e&&(t[c]=e[c]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!nn(e.propertyNames)&&(t.propertyNames=e.propertyNames);for(let c of["minProperties","maxProperties"])e[c]!==void 0&&(t[c]=e[c])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!nn(e.contains)&&(t.contains=e.contains);for(let c of["uniqueItems","minContains","maxContains"])e[c]!==void 0&&(t[c]=e[c])}for(let c of Object.keys(e))Rb.has(c)||q(t,c,e[c]);return Object.keys(t).length>0&&r.registry.add(i,t),e.description&&(i=i.describe(e.description)),i}s(ie,"convertSchema");function Zg(e,r){if(typeof e=="boolean")return e?w.any():w.never();let i;try{i=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=Zb(i,r?.defaultTarget),t=i.$defs||i.definitions||{},n={version:o,defs:t,refs:new Map,processing:new Set,rootSchema:i,registry:r?.registry??X};return ie(i,n)}s(Zg,"fromJSONSchema");var Lg=Symbol("z.visit/resolving");function on(e,r){let i=typeof r=="function"?r:(a,c)=>{let l=r[a._zod.def.type];return l?l(a,c):a},o=new Map;function t(a){let c=o.get(a);if(c===Lg)return new Pr({type:"lazy",getter:s(()=>o.get(a),"getter")});if(c!==void 0)return c;o.set(a,Lg);let l=n(a),u=i(l,l!==a);return o.set(a,u),u}s(t,"run");function n(a){let c=a._zod.def,l=c.type;switch(l){case"object":{let u=c.shape,d=Object.keys(u),f=!1,p={};for(let h of d){let $=t(u[h]);$!==u[h]&&(f=!0),p[h]=$}let m=c.catchall;return c.catchall&&(m=t(c.catchall),m!==c.catchall&&(f=!0)),f?C(a,{...c,shape:p,catchall:m}):a}case"array":{let u=t(c.element);return u===c.element?a:C(a,{...c,element:u})}case"tuple":{let u=c.items,d=!1,f=[];for(let m of u){let h=t(m);h!==m&&(d=!0),f.push(h)}let p=c.rest;return c.rest&&(p=t(c.rest),p!==c.rest&&(d=!0)),d?C(a,{...c,items:f,rest:p}):a}case"record":case"map":{let u=t(c.keyType),d=t(c.valueType);return u===c.keyType&&d===c.valueType?a:C(a,{...c,keyType:u,valueType:d})}case"set":{let u=t(c.valueType);return u===c.valueType?a:C(a,{...c,valueType:u})}case"union":{let u=c.options,d=!1,f=[];for(let p of u){let m=t(p);m!==p&&(d=!0),f.push(m)}return d?C(a,{...c,options:f}):a}case"intersection":{let u=t(c.left),d=t(c.right);return u===c.left&&d===c.right?a:C(a,{...c,left:u,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=t(c.innerType);return u===c.innerType?a:C(a,{...c,innerType:u})}case"pipe":{let u=t(c.in),d=t(c.out);return u===c.in&&d===c.out?a:C(a,{...c,in:u,out:d})}case"function":{let u=t(c.input),d=t(c.output);return u===c.input&&d===c.output?a:C(a,{...c,input:u,output:d})}case"lazy":{let u=c.getter,{_cachedInner:d,...f}=c;return C(a,{...f,getter:s(()=>t(u()),"getter")})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return s(n,"mapInner"),t(e)}s(on,"visit");function Mg(e){return on(e,{object:s(r=>r.partial(),"object"),union:s(r=>{let i=r._zod.def;return i.discriminator===void 0?r:qt(i.options)},"union")})}s(Mg,"deepPartial");function Hb(e,r){if(!r?.length)return e;let i=e._zod.def;return C(e,ge(i,{checks:[...i.checks??[],...r]}),{parent:!0})}s(Hb,"withChecks");function Vg(e){return Hb(e.out,e.checks)}s(Vg,"outSide");function Gb(e){return e.in._zod.traits.has("$ZodTransform")?Vg(e):e.in}s(Gb,"inSide");function Fg(e){return on(e,{pipe:s(r=>Gb(r._zod.def),"pipe"),default:s((r,i)=>i?ot(r._zod.def.innerType):r,"default"),catch:s((r,i)=>i?r._zod.def.innerType:r,"catch")})}s(Fg,"input");function Bg(e){return on(e,{pipe:s(r=>Vg(r._zod.def),"pipe"),prefault:s((r,i)=>i?r._zod.def.innerType:r,"prefault")})}s(Bg,"output");var _f={};xe(_f,{bigint:()=>Yb,boolean:()=>Xb,date:()=>Qb,number:()=>qb,string:()=>Wb});function Wb(e){return Mu(Kt,e)}s(Wb,"string");function qb(e){return Hu(Ht,e)}s(qb,"number");function Xb(e){return el(Gt,e)}s(Xb,"boolean");function Yb(e){return rl(Wt,e)}s(Yb,"bigint");function Qb(e){return ml(Gr,e)}s(Qb,"date");var Jg="2011-06-15",Kg=Q.object({AccessKeyId:Q.string(),SecretAccessKey:Q.string(),SessionToken:Q.string(),Expiration:Q.union([Q.number(),Q.string()])}),ex=Q.object({AssumeRoleResponse:Q.object({AssumeRoleResult:Q.object({Credentials:Kg})})}),tx=Q.object({AssumeRoleWithWebIdentityResponse:Q.object({AssumeRoleWithWebIdentityResult:Q.object({Credentials:Kg})})});function Hg(e,r){return r||`https://sts.${e}.amazonaws.com/`}s(Hg,"stsEndpoint");function rx(e){return typeof e=="number"?new Date(e*1e3):new Date(e)}s(rx,"normalizeExpiration");function nx(e){return{accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.SessionToken,expiration:rx(e.Expiration)}}s(nx,"toAwsCredentials");async function Gg(e,r,i,o,t){let n=await e.text();if(!e.ok){t?.error({status:e.status,body:n},`AWS STS ${o} request failed`);let l="";throw n.includes("ValidationError")&&n.includes("DurationSeconds")?l=" If 'durationSeconds' exceeds the role's maximum session duration, lower it or raise the role's MaxSessionDuration.":n.includes("AccessDenied")?l=" Check that the role's trust policy allows this principal to assume it.":n.includes("InvalidIdentityToken")&&(l=" The web identity token was rejected. Verify the IAM OIDC provider and that the token audience matches a configured client ID."),new B(`Could not get AWS credentials from STS.${l}`,{cause:new Error(`AWS STS ${o} failed (${e.status}): ${n}`)})}let a;try{a=JSON.parse(n)}catch(l){throw t?.error({body:n},`AWS STS ${o} returned non-JSON`),new B("The response returned from AWS STS is not in the expected format.",{cause:l})}let c=r.safeParse(a);if(!c.success)throw t?.error({body:n,issues:c.error.issues},`AWS STS ${o} response missing credentials`),new B("The response returned from AWS STS is not in the expected format.");return nx(i(c.data))}s(Gg,"parseStsResponse");async function Wg(e,r){let i=new URLSearchParams({Action:"AssumeRoleWithWebIdentity",Version:Jg,RoleArn:e.roleArn,RoleSessionName:e.roleSessionName,WebIdentityToken:e.webIdentityToken,DurationSeconds:String(e.durationSeconds)}),o=await gn({retries:r.retries,retryDelayMs:r.retryDelayMs,logger:r.logger},Hg(e.region,e.stsEndpoint),{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:i});return Gg(o,tx,t=>t.AssumeRoleWithWebIdentityResponse.AssumeRoleWithWebIdentityResult.Credentials,"AssumeRoleWithWebIdentity",r.logger)}s(Wg,"assumeRoleWithWebIdentity");async function qg(e){let r=new URLSearchParams({Action:"AssumeRole",Version:Jg,RoleArn:e.roleArn,RoleSessionName:e.roleSessionName,DurationSeconds:String(e.durationSeconds)});e.externalId&&r.set("ExternalId",e.externalId);let o=await new mn({accessKeyId:e.credentials.accessKeyId,secretAccessKey:e.credentials.secretAccessKey,sessionToken:e.credentials.sessionToken,service:"sts",region:e.region,retries:e.retries}).fetch(Hg(e.region,e.stsEndpoint),{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:r.toString()});return Gg(o,ex,t=>t.AssumeRoleResponse.AssumeRoleResult.Credentials,"AssumeRole",e.logger)}s(qg,"assumeRole");var Xg="zuplo-gateway",Yg=3600,ax="sts.amazonaws.com";function Qg(e,r){return{retries:e?.retries??3,retryDelayMs:e?.retryDelayMs??10,logger:r}}s(Qg,"resolveRetry");function KP(e){let r=typeof e.masterCredentials=="function"?e.masterCredentials:()=>Promise.resolve(e.masterCredentials),i=Qg(e.retry,e.logger);return Mo(async()=>{let o=await r();return qg({region:e.region,roleArn:e.roleArn,roleSessionName:e.roleSessionName??Xg,durationSeconds:e.durationSeconds??Yg,externalId:e.externalId,stsEndpoint:e.stsEndpoint,credentials:o,retries:i.retries,logger:i.logger})},{expirationOffsetSeconds:e.expirationOffsetSeconds})}s(KP,"fromTemporaryCredentials");function sx(e){let r=Qg(e.retry,e.logger);return Mo(async()=>{let i=typeof e.webIdentityToken=="function"?await e.webIdentityToken():e.webIdentityToken;return Wg({region:e.region,roleArn:e.roleArn,webIdentityToken:i,roleSessionName:e.roleSessionName??Xg,durationSeconds:e.durationSeconds??Yg,stsEndpoint:e.stsEndpoint},r)},{expirationOffsetSeconds:e.expirationOffsetSeconds})}s(sx,"fromWebToken");function HP(e){return sx({region:e.region,roleArn:e.roleArn,webIdentityToken:s(()=>vn.getIDToken(e.context,{audience:e.audience??ax}),"webIdentityToken"),roleSessionName:e.roleSessionName,durationSeconds:e.durationSeconds,stsEndpoint:e.stsEndpoint,expirationOffsetSeconds:e.expirationOffsetSeconds,retry:e.retry,logger:e.logger})}s(HP,"fromZuploIdentity");export{an as a,sn as b,B as c,Pe as d,fn as e,lx as f,rv as g,nv as h,iv as i,dx as j,fx as k,mx as l,ov as m,av as n,sv as o,cv as p,uv as q,px as r,gx as s,vx as t,hx as u,$x as v,yx as w,_x as x,bx as y,xx as z,kx as A,If as B,lv as C,dv as D,fv as E,mv as F,pv as G,gv as H,vv as I,hv as J,$v as K,yv as L,_v as M,bv as N,xv as O,kv as P,Iv as Q,wv as R,Ix as S,xo as T,Sv as U,zv as V,wx as W,Sx as X,zx as Y,Ox as Z,Px as _,W as $,ke as aa,ea as ba,Fi as ca,md as da,Jr as ea,hp as fa,kp as ga,Sd as ha,zd as ia,Dd as ja,ng as ka,it as la,Wr as ma,sg as na,ug as oa,qt as pa,dg as qa,Ld as ra,Fd as sa,vo as ta,hg as ua,ot as va,ff as wa,Tg as xa,Db as ya,rn as za,_f as Aa,Q as Ba,Gf as Ca,Xf as Da,Qt as Ea,cn as Fa,un as Ga,gn as Ha,Mx as Ia,zf as Ja,mn as Ka,Lo as La,Yf as Ma,vn as Na,KP as Oa,sx as Pa,HP as Qa};
101
- /*! For license information please see chunk-KA4STQE7.js.LEGAL.txt */
102
- //# sourceMappingURL=chunk-KA4STQE7.js.map
101
+ /*! For license information please see chunk-WUZE2HKB.js.LEGAL.txt */
102
+ //# sourceMappingURL=chunk-WUZE2HKB.js.map