@authhero/cloudflare-adapter 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare-adapter.cjs +1 -2
- package/dist/cloudflare-adapter.d.ts +109 -7
- package/dist/cloudflare-adapter.mjs +3066 -282
- package/package.json +3 -1
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q="application/json",R="Content-Type",C=Symbol(),M=Symbol();function S(t={}){var e;const n=t instanceof Array?Object.fromEntries(t):t;return(e=Object.entries(n).find(([o])=>o.toLowerCase()===R.toLowerCase()))===null||e===void 0?void 0:e[1]}function D(t){return/^application\/.*json.*/.test(t)}const T=function(t,e,n=!1){return Object.entries(e).reduce((o,[i,l])=>{const h=t[i];return Array.isArray(h)&&Array.isArray(l)?o[i]=n?[...h,...l]:l:typeof h=="object"&&typeof l=="object"?o[i]=T(h,l,n):o[i]=l,o},{...t})},w={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...o){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...o):i}};function z(t,e=!1){w.options=e?t:T(w.options,t)}function F(t,e=!1){w.polyfills=e?t:T(w.polyfills,t)}function x(t){w.errorType=t}const L=t=>e=>t.reduceRight((n,o)=>o(n),e)||e;class k extends Error{}const N=t=>{const e=Object.create(null);t=t._addons.reduce((r,s)=>s.beforeRequest&&s.beforeRequest(r,t._options,e)||r,t);const{_url:n,_options:o,_config:i,_catchers:l,_resolvers:h,_middlewares:f,_addons:u}=t,a=new Map(l),m=T(i.options,o);let v=n;const E=L(f)((r,s)=>(v=r,i.polyfill("fetch")(r,s)))(n,m),d=new Error,g=E.catch(r=>{throw{[C]:r}}).then(r=>{var s;if(!r.ok){const c=new k;if(c.cause=d,c.stack=c.stack+`
|
|
2
|
-
CAUSE: `+d.stack,c.response=r,c.status=r.status,c.url=v,r.type==="opaque")throw c;const p=i.errorType==="json"||((s=r.headers.get("Content-Type"))===null||s===void 0?void 0:s.split(";")[0])==="application/json";return(i.errorType?p?r.text():r[i.errorType]():Promise.resolve(r.body)).then(y=>{throw c.message=typeof y=="string"?y:r.statusText,y&&(p&&typeof y=="string"?(c.text=y,c.json=JSON.parse(y)):c[i.errorType]=y),c})}return r}),P=r=>r.catch(s=>{const c=Object.prototype.hasOwnProperty.call(s,C),p=c?s[C]:s,A=(p==null?void 0:p.status)&&a.get(p.status)||a.get(p==null?void 0:p.name)||c&&a.has(C)&&a.get(C);if(A)return A(p,t);const y=a.get(M);if(y)return y(p,t);throw p}),_=r=>s=>P(r?g.then(c=>c&&c[r]()).then(c=>s?s(c):c):g.then(c=>s?s(c):c)),O={_wretchReq:t,_fetchReq:E,_sharedState:e,res:_(null),json:_("json"),blob:_("blob"),formData:_("formData"),arrayBuffer:_("arrayBuffer"),text:_("text"),error(r,s){return a.set(r,s),this},badRequest(r){return this.error(400,r)},unauthorized(r){return this.error(401,r)},forbidden(r){return this.error(403,r)},notFound(r){return this.error(404,r)},timeout(r){return this.error(408,r)},internalError(r){return this.error(500,r)},fetchError(r){return this.error(C,r)}},b=u.reduce((r,s)=>({...r,...typeof s.resolver=="function"?s.resolver(r):s.resolver}),O);return h.reduce((r,s)=>s(r,t),b)},B={_url:"",_options:{},_config:w,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:T(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:T(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:T(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[R]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const n=new Map(this._catchers);return n.set(t,e),{...this,_catchers:n}},catcherFallback(t){return this.catcher(M,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let o=this.url(e).options({method:t});const i=S(o._options.headers),l=this._config.polyfill("FormData",!1),h=typeof n=="object"&&!(l&&n instanceof l)&&(!o._options.headers||!i||D(i));return o=n?h?o.json(n,i):o.body(n):o,N(o._deferred.reduce((f,u)=>u(f,f._url,f._options),o))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=S(this._options.headers);return this.content(e||D(n)&&n||q).body(JSON.stringify(t))}};function j(t="",e={}){return{...B,_url:t,_options:e}}j.default=j;j.options=z;j.errorType=x;j.polyfills=F;j.WretchError=k;const J=(t,e)=>e.skipDedupe||e.method!=="GET",U=(t,e)=>e.method+"@"+t,$=t=>t.clone(),G=({skip:t=J,key:e=U,resolver:n=$}={})=>{const o=new Map;return i=>(l,h)=>{if(t(l,h))return i(l,h);const f=e(l,h);if(!o.has(f))o.set(f,[]);else return new Promise((u,a)=>{o.get(f).push([u,a])});try{return i(l,h).then(u=>(o.get(f).forEach(([a])=>a(n(u))),o.delete(f),u)).catch(u=>{throw o.get(f).forEach(([,a])=>a(u)),o.delete(f),u})}catch(u){return o.delete(f),Promise.reject(u)}}},I=(t,e)=>t*e,K=t=>t&&t.ok,W=({delayTimer:t=500,delayRamp:e=I,maxAttempts:n=10,until:o=K,onRetry:i=null,retryOnNetworkError:l=!1,resolveWithLatestResponse:h=!1,skip:f}={})=>u=>(a,m)=>{let v=0;if(f&&f(a,m))return u(a,m);const E=(d,g)=>Promise.resolve(o(d,g)).then(P=>P?d&&h?d:g?Promise.reject(g):d:(v++,!n||v<=n?new Promise(_=>{const O=e(t,v);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:g,url:a,options:m})).then((b={})=>{var r,s;_(u((r=b&&b.url)!==null&&r!==void 0?r:a,(s=b&&b.options)!==null&&s!==void 0?s:m))}):_(u(a,m))},O)}).then(E).catch(_=>{if(!l)throw _;return E(null,_)}):d&&h?d:Promise.reject(g||new Error("Number of attempts exceeded."))));return u(a,m).then(E).catch(d=>{if(!l)throw d;return E(null,d)})};function H(t){return j(`https://api.cloudflare.com/client/v4/zones/${t.zone_id}`).headers({Authorization:`Bearer ${t.api_key}`,"Content-Type":"application/json"}).middlewares([W(),G()])}async function Y(t){return await H(t).post({hostname:t.domain,ssl:{method:"http",type:"dv"}},"/custom_hostnames").json()}async function Q(t){return await H(t).get(`/custom_hostnames/${t.domain}`).json()}exports.getCustomDomain=Q;exports.registerCustomDomain=Y;
|
|
1
|
+
"use strict";const tt=require("wretch"),rt=(r,e)=>e.skipDedupe||e.method!=="GET",nt=(r,e)=>e.method+"@"+r,st=r=>r.clone(),at=({skip:r=rt,key:e=nt,resolver:t=st}={})=>{const n=new Map;return s=>(a,o)=>{if(r(a,o))return s(a,o);const i=e(a,o);if(!n.has(i))n.set(i,[]);else return new Promise((u,d)=>{n.get(i).push([u,d])});try{return s(a,o).then(u=>(n.get(i).forEach(([d])=>d(t(u))),n.delete(i),u)).catch(u=>{throw n.get(i).forEach(([,d])=>d(u)),n.delete(i),u})}catch(u){return n.delete(i),Promise.reject(u)}}},it=(r,e)=>r*e,ot=r=>r&&r.ok,dt=({delayTimer:r=500,delayRamp:e=it,maxAttempts:t=10,until:n=ot,onRetry:s=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:o=!1,skip:i}={})=>u=>(d,h)=>{let k=0;if(i&&i(d,h))return u(d,h);const O=(w,P)=>Promise.resolve(n(w,P)).then(Ee=>Ee?w&&o?w:P?Promise.reject(P):w:(k++,!t||k<=t?new Promise($=>{const ge=e(r,k);setTimeout(()=>{typeof s=="function"?Promise.resolve(s({response:w,error:P,url:d,options:h})).then((B={})=>{var F,ee;$(u((F=B&&B.url)!==null&&F!==void 0?F:d,(ee=B&&B.options)!==null&&ee!==void 0?ee:h))}):$(u(d,h))},ge)}).then(O).catch($=>{if(!a)throw $;return O(null,$)}):w&&o?w:Promise.reject(P||new Error("Number of attempts exceeded."))));return u(d,h).then(O).catch(w=>{if(!a)throw w;return O(null,w)})};function ct(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function ut(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function te(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function lt(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var o,i,u,d,h,k;const O=typeof s=="string"?a:s,w=O??{},{param:P}=w,Ee=ct(w,["param"]),$=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof s=="string"?{refId:s}:void 0),ge=Object.assign(Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i.metadata),Ee),!((d=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||d===void 0)&&d.param||P?{param:Object.assign(Object.assign({},(k=(h=this._def.openapi)===null||h===void 0?void 0:h.metadata)===null||k===void 0?void 0:k.param),P)}:void 0),B=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys($).length>0?{_internal:$}:void 0),Object.keys(ge).length>0?{metadata:ge}:void 0)}));if(ut(this,"ZodObject")){const F=this.extend;B.extend=function(...ee){var je,Ce,Ne,Re,Ie,Ae;const Me=F.apply(this,ee);return Me._def.openapi={_internal:{extendedFrom:!((Ce=(je=this._def.openapi)===null||je===void 0?void 0:je._internal)===null||Ce===void 0)&&Ce.refId?{refId:(Re=(Ne=this._def.openapi)===null||Ne===void 0?void 0:Ne._internal)===null||Re===void 0?void 0:Re.refId,schema:this}:(Ie=this._def.openapi)===null||Ie===void 0?void 0:Ie._internal.extendedFrom},metadata:(Ae=Me._def.openapi)===null||Ae===void 0?void 0:Ae.metadata},Me}}return B},te(r,"optional"),te(r,"nullable"),te(r,"default"),te(r,"transform"),te(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([i,u])=>{var d,h;u._def.openapi=(h=(d=s[i])===null||d===void 0?void 0:d._def)===null||h===void 0?void 0:h.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var x;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),o={};for(const i of a)o[i]=s[i];return r.objectValues(o)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},r.find=(s,a)=>{for(const o of s)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var $e;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})($e||($e={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},c=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ft=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class S extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let i=n,u=0;for(;u<o.path.length;){const d=o.path[u];u===o.path.length-1?(i[d]=i[d]||{_errors:[]},i[d]._errors.push(t(o))):i[d]=i[d]||{_errors:[]},i=i[d],u++}}};return s(this),n}static assert(e){if(!(e instanceof S))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=r=>new S(r);const X=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}};let qe=X;function ht(r){qe=r}function xe(){return qe}const be=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)i=d(o,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},pt=[];function l(r,e){const t=xe(),n=be({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===X?void 0:X].filter(s=>!!s)});r.common.issues.push(n)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,o=await s.value;n.push({key:a,value:o})}return T.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return y;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}}const y=Object.freeze({status:"aborted"}),H=r=>({status:"dirty",value:r}),Z=r=>({status:"valid",value:r}),Ve=r=>r.status==="aborted",De=r=>r.status==="dirty",se=r=>r.status==="valid",ae=r=>typeof Promise<"u"&&r instanceof Promise;function ke(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Je(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var re,ne;class R{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ze=(r,e)=>{if(se(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new S(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,i)=>{var u,d;const{message:h}=r;return o.code==="invalid_enum_value"?{message:h??i.defaultError}:typeof i.data>"u"?{message:(u=h??n)!==null&&u!==void 0?u:i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:(d=h??t)!==null&&d!==void 0?d:i.defaultError}},description:s}}class g{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ae(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},a=this._parseSync({data:e,path:s.path,parent:s});return ze(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ae(s)?s:Promise.resolve(s));return ze(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),i=()=>a.addIssue({code:c.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(i(),!1)):o?!0:(i(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new C({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return N.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return j.create(this,this._def)}promise(){return Q.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new C({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new me({...v(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Ue({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new _e({...v(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ve.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const mt=/^c[^\s-]{8,}$/i,_t=/^[0-9a-z]+$/,yt=/^[0-9A-HJKMNP-TV-Z]{26}$/,vt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,gt=/^[a-z0-9_-]{21}$/i,xt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,bt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pe;const wt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tt=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Zt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ye="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",St=new RegExp(`^${Ye}$`);function He(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ot(r){return new RegExp(`^${He(r)}$`)}function Ge(r){let e=`${Ye}T${He(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Et(r,e){return!!((e==="v4"||!e)&&wt.test(r)||(e==="v6"||!e)&&Tt.test(r))}class E extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),y}const n=new T;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(s=this._getOrReturnCtx(e,s),o?l(s,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&l(s,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")bt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Pe||(Pe=new RegExp(kt,"u")),Pe.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")vt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")gt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")mt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")_t.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")yt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:c.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:c.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ge(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?St.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Ot(a).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?xt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Et(e.data,a.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:c.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:c.invalid_string,...m.errToObj(n)})}_addCheck(e){return new E({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...m.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...m.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...m.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new E({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}E.create=r=>{var e;return new E({checks:[],typeName:_.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};function jt(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class D extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?jt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}D.create=r=>new D({checks:[],typeName:_.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class L extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.bigint,received:a.parsedType}),y}let n;const s=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}L.create=r=>{var e;return new L({checks:[],typeName:_.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};class ie extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),y}return Z(e.data)}}ie.create=r=>new ie({typeName:_.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class q extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),y}const n=new T;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}q.create=r=>new q({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:_.ZodDate,...v(r)});class we extends g{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),y}return Z(e.data)}}we.create=r=>new we({typeName:_.ZodSymbol,...v(r)});class oe extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),y}return Z(e.data)}}oe.create=r=>new oe({typeName:_.ZodUndefined,...v(r)});class de extends g{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),y}return Z(e.data)}}de.create=r=>new de({typeName:_.ZodNull,...v(r)});class K extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}}K.create=r=>new K({typeName:_.ZodAny,...v(r)});class W extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}}W.create=r=>new W({typeName:_.ZodUnknown,...v(r)});class M extends g{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),y}}M.create=r=>new M({typeName:_.ZodNever,...v(r)});class Te extends g{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),y}return Z(e.data)}}Te.create=r=>new Te({typeName:_.ZodVoid,...v(r)});class j extends g{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return l(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),y;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,i=t.data.length<s.exactLength.value;(o||i)&&(l(t,{code:o?c.too_big:c.too_small,minimum:i?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(l(t,{code:c.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(l(t,{code:c.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,i)=>s.type._parseAsync(new R(t,o,t.path,i)))).then(o=>T.mergeArray(n,o));const a=[...t.data].map((o,i)=>s.type._parseSync(new R(t,o,t.path,i)));return T.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new j({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new j({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new j({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}j.create=(r,e)=>new j({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function Y(r){if(r instanceof b){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=N.create(Y(n))}return new b({...r._def,shape:()=>e})}else return r instanceof j?new j({...r._def,type:Y(r.element)}):r instanceof N?N.create(Y(r.unwrap())):r instanceof z?z.create(Y(r.unwrap())):r instanceof I?I.create(r.items.map(e=>Y(e))):r}class b extends g{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const d=this._getOrReturnCtx(e);return l(d,{code:c.invalid_type,expected:f.object,received:d.parsedType}),y}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const d in s.data)o.includes(d)||i.push(d);const u=[];for(const d of o){const h=a[d],k=s.data[d];u.push({key:{status:"valid",value:d},value:h._parse(new R(s,k,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof M){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of i)u.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(d==="strict")i.length>0&&(l(s,{code:c.unrecognized_keys,keys:i}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of i){const k=s.data[h];u.push({key:{status:"valid",value:h},value:d._parse(new R(s,k,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const h of u){const k=await h.key,O=await h.value;d.push({key:k,value:O,alwaysSet:h.alwaysSet})}return d}).then(d=>T.mergeObjectSync(n,d)):T.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,o,i;const u=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(i=m.errToObj(e).message)!==null&&i!==void 0?i:u}:{message:u}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}deepPartial(){return Y(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof N;)a=a._def.innerType;t[n]=a}}),new b({...this._def,shape:()=>t})}keyof(){return Xe(x.objectKeys(this.shape))}}b.create=(r,e)=>new b({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.strictCreate=(r,e)=>new b({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:_.ZodObject,...v(e)});b.lazycreate=(r,e)=>new b({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:_.ZodObject,...v(e)});class ce extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(i=>new S(i.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:o}),y}if(t.common.async)return Promise.all(n.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(u=>new S(u));return l(t,{code:c.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}}ce.create=(r,e)=>new ce({options:r,typeName:_.ZodUnion,...v(e)});const A=r=>r instanceof fe?A(r.schema):r instanceof C?A(r.innerType()):r instanceof he?[r.value]:r instanceof U?r.options:r instanceof pe?x.objectValues(r.enum):r instanceof me?A(r._def.innerType):r instanceof oe?[void 0]:r instanceof de?[null]:r instanceof N?[void 0,...A(r.unwrap())]:r instanceof z?[null,...A(r.unwrap())]:r instanceof Ue||r instanceof ye?A(r.unwrap()):r instanceof _e?A(r._def.innerType):[];class Oe extends g{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),y;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const o=A(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of o){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new Oe({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}}function Le(r,e){const t=V(r),n=V(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){const s=x.objectKeys(e),a=x.objectKeys(r).filter(i=>s.indexOf(i)!==-1),o={...r,...e};for(const i of a){const u=Le(r[i],e[i]);if(!u.valid)return{valid:!1};o[i]=u.data}return{valid:!0,data:o}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const o=r[a],i=e[a],u=Le(o,i);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ue extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,o)=>{if(Ve(a)||Ve(o))return y;const i=Le(a.value,o.value);return i.valid?((De(a)||De(o))&&t.dirty(),{status:t.value,value:i.data}):(l(n,{code:c.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ue.create=(r,e,t)=>new ue({left:r,right:e,typeName:_.ZodIntersection,...v(t)});class I extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return l(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return l(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((o,i)=>{const u=this._def.items[i]||this._def.rest;return u?u._parse(new R(n,o,n.path,i)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>T.mergeArray(t,o)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:r,typeName:_.ZodTuple,rest:null,...v(e)})};class le extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),y;const s=[],a=this._def.keyType,o=this._def.valueType;for(const i in n.data)s.push({key:a._parse(new R(n,i,n.path,i)),value:o._parse(new R(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?T.mergeObjectAsync(t,s):T.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof g?new le({keyType:e,valueType:t,typeName:_.ZodRecord,...v(n)}):new le({keyType:E.create(),valueType:e,typeName:_.ZodRecord,...v(t)})}}class Ze extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return l(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),y;const s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([i,u],d)=>({key:s._parse(new R(n,i,n.path,[d,"key"])),value:a._parse(new R(n,u,n.path,[d,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const u of o){const d=await u.key,h=await u.value;if(d.status==="aborted"||h.status==="aborted")return y;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),i.set(d.value,h.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const u of o){const d=u.key,h=u.value;if(d.status==="aborted"||h.status==="aborted")return y;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),i.set(d.value,h.value)}return{status:t.value,value:i}}}}Ze.create=(r,e,t)=>new Ze({valueType:e,keyType:r,typeName:_.ZodMap,...v(t)});class J extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return l(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),y;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(l(n,{code:c.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(l(n,{code:c.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(u){const d=new Set;for(const h of u){if(h.status==="aborted")return y;h.status==="dirty"&&t.dirty(),d.add(h.value)}return{status:t.value,value:d}}const i=[...n.data.values()].map((u,d)=>a._parse(new R(n,u,n.path,d)));return n.common.async?Promise.all(i).then(u=>o(u)):o(i)}min(e,t){return new J({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(r,e)=>new J({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});class G extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),y;function n(i,u){return be({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xe(),X].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:u}})}function s(i,u){return be({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xe(),X].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Q){const i=this;return Z(async function(...u){const d=new S([]),h=await i._def.args.parseAsync(u,a).catch(w=>{throw d.addIssue(n(u,w)),d}),k=await Reflect.apply(o,this,h);return await i._def.returns._def.type.parseAsync(k,a).catch(w=>{throw d.addIssue(s(k,w)),d})})}else{const i=this;return Z(function(...u){const d=i._def.args.safeParse(u,a);if(!d.success)throw new S([n(u,d.error)]);const h=Reflect.apply(o,this,d.data),k=i._def.returns.safeParse(h,a);if(!k.success)throw new S([s(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new G({...this._def,args:I.create(e).rest(W.create())})}returns(e){return new G({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new G({args:e||I.create([]).rest(W.create()),returns:t||W.create(),typeName:_.ZodFunction,...v(n)})}}class fe extends g{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}fe.create=(r,e)=>new fe({getter:r,typeName:_.ZodLazy,...v(e)});class he extends g{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}he.create=(r,e)=>new he({value:r,typeName:_.ZodLiteral,...v(e)});function Xe(r,e){return new U({values:r,typeName:_.ZodEnum,...v(e)})}class U extends g{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{expected:x.joinValues(n),received:t.parsedType,code:c.invalid_type}),y}if(ke(this,re)||Je(this,re,new Set(this._def.values)),!ke(this,re).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:n}),y}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}re=new WeakMap;U.create=Xe;class pe extends g{constructor(){super(...arguments),ne.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const s=x.objectValues(t);return l(n,{expected:x.joinValues(s),received:n.parsedType,code:c.invalid_type}),y}if(ke(this,ne)||Je(this,ne,new Set(x.getValidEnumValues(this._def.values))),!ke(this,ne).has(e.data)){const s=x.objectValues(t);return l(n,{received:n.data,code:c.invalid_enum_value,options:s}),y}return Z(e.data)}get enum(){return this._def.values}}ne=new WeakMap;pe.create=(r,e)=>new pe({values:r,typeName:_.ZodNativeEnum,...v(e)});class Q extends g{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),y;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Z(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Q.create=(r,e)=>new Q({type:r,typeName:_.ZodPromise,...v(e)});class C extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{l(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async i=>{if(t.value==="aborted")return y;const u=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return u.status==="aborted"?y:u.status==="dirty"||t.value==="dirty"?H(u.value):u});{if(t.value==="aborted")return y;const i=this._def.schema._parseSync({data:o,path:n.path,parent:n});return i.status==="aborted"?y:i.status==="dirty"||t.value==="dirty"?H(i.value):i}}if(s.type==="refinement"){const o=i=>{const u=s.refinement(i,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value).then(()=>({status:t.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!se(o))return o;const i=s.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>se(o)?Promise.resolve(s.transform(o.value,a)).then(i=>({status:t.value,value:i})):o);x.assertNever(s)}}C.create=(r,e,t)=>new C({schema:r,typeName:_.ZodEffects,effect:e,...v(t)});C.createWithPreprocess=(r,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...v(t)});class N extends g{_parse(e){return this._getType(e)===f.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}N.create=(r,e)=>new N({innerType:r,typeName:_.ZodOptional,...v(e)});class z extends g{_parse(e){return this._getType(e)===f.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(r,e)=>new z({innerType:r,typeName:_.ZodNullable,...v(e)});class me extends g{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}me.create=(r,e)=>new me({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class _e extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ae(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new S(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}_e.create=(r,e)=>new _e({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class Se extends g{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}}Se.create=r=>new Se({typeName:_.ZodNaN,...v(r)});const Ct=Symbol("zod_brand");class Ue extends g{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ve extends g{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),H(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ve({in:e,out:t,typeName:_.ZodPipeline})}}class ye extends g{_parse(e){const t=this._def.innerType._parse(e),n=s=>(se(s)&&(s.value=Object.freeze(s.value)),s);return ae(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ye.create=(r,e)=>new ye({innerType:r,typeName:_.ZodReadonly,...v(e)});function Ke(r,e={},t){return r?K.create().superRefine((n,s)=>{var a,o;if(!r(n)){const i=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(a=i.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,d=typeof i=="string"?{message:i}:i;s.addIssue({code:"custom",...d,fatal:u})}}):K.create()}const Nt={object:b.lazycreate};var _;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));const Rt=(r,e={message:`Input not instance of ${r.name}`})=>Ke(t=>t instanceof r,e),Qe=E.create,Fe=D.create,It=Se.create,At=L.create,et=ie.create,Mt=q.create,Pt=we.create,$t=oe.create,Vt=de.create,Dt=K.create,Lt=W.create,Ut=M.create,zt=Te.create,Bt=j.create,Wt=b.create,qt=b.strictCreate,Jt=ce.create,Yt=Oe.create,Ht=ue.create,Gt=I.create,Xt=le.create,Kt=Ze.create,Qt=J.create,Ft=G.create,er=fe.create,tr=he.create,rr=U.create,nr=pe.create,sr=Q.create,Be=C.create,ar=N.create,ir=z.create,or=C.createWithPreprocess,dr=ve.create,cr=()=>Qe().optional(),ur=()=>Fe().optional(),lr=()=>et().optional(),fr={string:r=>E.create({...r,coerce:!0}),number:r=>D.create({...r,coerce:!0}),boolean:r=>ie.create({...r,coerce:!0}),bigint:r=>L.create({...r,coerce:!0}),date:r=>q.create({...r,coerce:!0})},hr=y;var p=Object.freeze({__proto__:null,defaultErrorMap:X,setErrorMap:ht,getErrorMap:xe,makeIssue:be,EMPTY_PATH:pt,addIssueToContext:l,ParseStatus:T,INVALID:y,DIRTY:H,OK:Z,isAborted:Ve,isDirty:De,isValid:se,isAsync:ae,get util(){return x},get objectUtil(){return $e},ZodParsedType:f,getParsedType:V,ZodType:g,datetimeRegex:Ge,ZodString:E,ZodNumber:D,ZodBigInt:L,ZodBoolean:ie,ZodDate:q,ZodSymbol:we,ZodUndefined:oe,ZodNull:de,ZodAny:K,ZodUnknown:W,ZodNever:M,ZodVoid:Te,ZodArray:j,ZodObject:b,ZodUnion:ce,ZodDiscriminatedUnion:Oe,ZodIntersection:ue,ZodTuple:I,ZodRecord:le,ZodMap:Ze,ZodSet:J,ZodFunction:G,ZodLazy:fe,ZodLiteral:he,ZodEnum:U,ZodNativeEnum:pe,ZodPromise:Q,ZodEffects:C,ZodTransformer:C,ZodOptional:N,ZodNullable:z,ZodDefault:me,ZodCatch:_e,ZodNaN:Se,BRAND:Ct,ZodBranded:Ue,ZodPipeline:ve,ZodReadonly:ye,custom:Ke,Schema:g,ZodSchema:g,late:Nt,get ZodFirstPartyTypeKind(){return _},coerce:fr,any:Dt,array:Bt,bigint:At,boolean:et,date:Mt,discriminatedUnion:Yt,effect:Be,enum:rr,function:Ft,instanceof:Rt,intersection:Ht,lazy:er,literal:tr,map:Kt,nan:It,nativeEnum:nr,never:Ut,null:Vt,nullable:ir,number:Fe,object:Wt,oboolean:lr,onumber:ur,optional:ar,ostring:cr,pipeline:dr,preprocess:or,promise:sr,record:Xt,set:Qt,strictObject:qt,string:Qe,symbol:Pt,transformer:Be,tuple:Gt,undefined:$t,union:Jt,unknown:Lt,void:zt,NEVER:hr,ZodIssueCode:c,quotelessJson:ft,ZodError:S});lt(p);const We=p.object({code:p.number(),message:p.string()}),pr=p.object({message:p.string()}),mr=p.object({emails:p.array(p.string()),http_body:p.string(),http_url:p.string(),txt_name:p.string(),txt_value:p.string()}),_r=p.object({ciphers:p.array(p.string()),early_hints:p.string(),http2:p.string(),min_tls_version:p.string(),tls_1_3:p.string()}),yr=p.object({id:p.string(),bundle_method:p.string(),certificate_authority:p.string(),custom_certificate:p.string(),custom_csr_id:p.string(),custom_key:p.string(),expires_on:p.string(),hosts:p.array(p.string()),issuer:p.string(),method:p.string(),serial_number:p.string(),settings:_r,signature:p.string(),type:p.string(),uploaded_on:p.string(),validation_errors:p.array(pr),validation_records:p.array(mr),wildcard:p.boolean()}),vr=p.object({name:p.string(),type:p.string(),value:p.string()}),gr=p.object({http_body:p.string(),http_url:p.string()}),xr=p.object({id:p.string(),ssl:yr,custom_metadata:p.record(p.string()),custom_origin_server:p.string(),custom_origin_sni:p.string(),ownership_verification:vr,ownership_verification_http:gr,status:p.string(),verification_errors:p.array(p.string())}),br=p.object({errors:p.array(We),messages:p.array(We),success:p.boolean(),result:xr});function kr(r){return tt(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({"X-Auth-Email":r.authEmail,"X-Auth-Key":r.authKey,"Content-Type":"application/json"}).middlewares([dt(),at()])}function wr(r){return{create:async(e,t)=>{const{result:n,errors:s,success:a}=br.parse(await kr(r).post({hostname:t.domain,ssl:{method:"http",type:"dv"}},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(s));return{custom_domain_id:n.id,tenant_id:e,domain:n.ssl.hosts[0],primary:!1,status:n.status==="active"?"ready":"pending",type:"auth0_managed_certs"}},get:async(e,t)=>{throw console.log("get",e,t),new Error("Not implemented")},list:async e=>{throw console.log("list",e),new Error("Not implemented")},remove:async(e,t)=>{throw console.log("remove",e,t),new Error("Not implemented")},update:async(e,t)=>{throw console.log("update",e,t),new Error("Not implemented")}}}function Tr(r){return{customDomains:wr(r)}}module.exports=Tr;
|
|
@@ -1,13 +1,115 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { z } from '@hono/zod-openapi';
|
|
4
|
+
|
|
5
|
+
declare const customDomainInsertSchema: z.ZodObject<{
|
|
6
|
+
domain: z.ZodString;
|
|
7
|
+
type: z.ZodEnum<[
|
|
8
|
+
"auth0_managed_certs",
|
|
9
|
+
"self_managed_certs"
|
|
10
|
+
]>;
|
|
11
|
+
verification_method: z.ZodOptional<z.ZodEnum<[
|
|
12
|
+
"txt"
|
|
13
|
+
]>>;
|
|
14
|
+
tls_policy: z.ZodOptional<z.ZodEnum<[
|
|
15
|
+
"recommended"
|
|
16
|
+
]>>;
|
|
17
|
+
custom_client_ip_header: z.ZodOptional<z.ZodEnum<[
|
|
18
|
+
"true-client-ip",
|
|
19
|
+
"cf-connecting-ip",
|
|
20
|
+
"x-forwarded-for",
|
|
21
|
+
"x-azure-clientip",
|
|
22
|
+
"null"
|
|
23
|
+
]>>;
|
|
24
|
+
domain_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
type: "auth0_managed_certs" | "self_managed_certs";
|
|
27
|
+
domain: string;
|
|
28
|
+
verification_method?: "txt" | undefined;
|
|
29
|
+
tls_policy?: "recommended" | undefined;
|
|
30
|
+
custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
|
|
31
|
+
domain_metadata?: Record<string, string> | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
type: "auth0_managed_certs" | "self_managed_certs";
|
|
34
|
+
domain: string;
|
|
35
|
+
verification_method?: "txt" | undefined;
|
|
36
|
+
tls_policy?: "recommended" | undefined;
|
|
37
|
+
custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
|
|
38
|
+
domain_metadata?: Record<string, string> | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export type CustomDomainInsert = z.infer<typeof customDomainInsertSchema>;
|
|
41
|
+
declare const customDomainSchema: z.ZodObject<{
|
|
42
|
+
custom_domain_id: z.ZodString;
|
|
43
|
+
primary: z.ZodBoolean;
|
|
44
|
+
status: z.ZodEnum<[
|
|
45
|
+
"disabled",
|
|
46
|
+
"pending",
|
|
47
|
+
"pending_verification",
|
|
48
|
+
"ready"
|
|
49
|
+
]>;
|
|
50
|
+
origin_domain_name: z.ZodOptional<z.ZodString>;
|
|
51
|
+
verification: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
52
|
+
tls_policy: z.ZodOptional<z.ZodString>;
|
|
53
|
+
domain: z.ZodString;
|
|
54
|
+
type: z.ZodEnum<[
|
|
55
|
+
"auth0_managed_certs",
|
|
56
|
+
"self_managed_certs"
|
|
57
|
+
]>;
|
|
58
|
+
verification_method: z.ZodOptional<z.ZodEnum<[
|
|
59
|
+
"txt"
|
|
60
|
+
]>>;
|
|
61
|
+
custom_client_ip_header: z.ZodOptional<z.ZodEnum<[
|
|
62
|
+
"true-client-ip",
|
|
63
|
+
"cf-connecting-ip",
|
|
64
|
+
"x-forwarded-for",
|
|
65
|
+
"x-azure-clientip",
|
|
66
|
+
"null"
|
|
67
|
+
]>>;
|
|
68
|
+
domain_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
type: "auth0_managed_certs" | "self_managed_certs";
|
|
71
|
+
status: "disabled" | "pending" | "pending_verification" | "ready";
|
|
72
|
+
primary: boolean;
|
|
8
73
|
domain: string;
|
|
74
|
+
custom_domain_id: string;
|
|
75
|
+
verification_method?: "txt" | undefined;
|
|
76
|
+
tls_policy?: string | undefined;
|
|
77
|
+
custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
|
|
78
|
+
domain_metadata?: Record<string, string> | undefined;
|
|
79
|
+
origin_domain_name?: string | undefined;
|
|
80
|
+
verification?: {} | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
type: "auth0_managed_certs" | "self_managed_certs";
|
|
83
|
+
status: "disabled" | "pending" | "pending_verification" | "ready";
|
|
84
|
+
primary: boolean;
|
|
85
|
+
domain: string;
|
|
86
|
+
custom_domain_id: string;
|
|
87
|
+
verification_method?: "txt" | undefined;
|
|
88
|
+
tls_policy?: string | undefined;
|
|
89
|
+
custom_client_ip_header?: "null" | "true-client-ip" | "cf-connecting-ip" | "x-forwarded-for" | "x-azure-clientip" | undefined;
|
|
90
|
+
domain_metadata?: Record<string, string> | undefined;
|
|
91
|
+
origin_domain_name?: string | undefined;
|
|
92
|
+
verification?: {} | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
export type CustomDomain = z.infer<typeof customDomainSchema>;
|
|
95
|
+
export interface CustomDomainsAdapter {
|
|
96
|
+
create: (tenant_id: string, custom_domain: CustomDomainInsert) => Promise<CustomDomain>;
|
|
97
|
+
get: (tenant_id: string, id: string) => Promise<CustomDomain | null>;
|
|
98
|
+
list: (tenant_id: string) => Promise<CustomDomain[]>;
|
|
99
|
+
remove: (tenant_id: string, id: string) => Promise<boolean>;
|
|
100
|
+
update: (tenant_id: string, id: string, custom_domain: Partial<CustomDomain>) => Promise<boolean>;
|
|
101
|
+
}
|
|
102
|
+
export interface CloudflareConfig {
|
|
103
|
+
zoneId: string;
|
|
104
|
+
authKey: string;
|
|
105
|
+
authEmail: string;
|
|
9
106
|
}
|
|
10
|
-
|
|
11
|
-
|
|
107
|
+
declare function createAdapters(config: CloudflareConfig): {
|
|
108
|
+
customDomains: CustomDomainsAdapter;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
createAdapters as default,
|
|
113
|
+
};
|
|
12
114
|
|
|
13
115
|
export {};
|