@onvo-ai/react
Version:
The react SDK for Onvo AI dashboard builder
1 lines • 2.05 MB
JavaScript
"use strict";var e=require("react"),t=require("react/jsx-runtime"),n=require("react-dom");function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var r=o(e),a=o(n);function i(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function s(e,t){var n;return(null===(n=null==e?void 0:e._def)||void 0===n?void 0:n.typeName)===t}function l(e,t){const n=e.ZodType.prototype[t];e.ZodType.prototype[t]=function(...e){const t=n.apply(this,e);return t._def.openapi=this._def.openapi,t}}function c(e){if(void 0!==e.ZodType.prototype.openapi)return;e.ZodType.prototype.openapi=function(e,t){var n,o,r,a,l,c;const u="string"==typeof e?t:e,d=null!=u?u:{},{param:h}=d,p=i(d,["param"]),f=Object.assign(Object.assign({},null===(n=this._def.openapi)||void 0===n?void 0:n._internal),"string"==typeof e?{refId:e}:void 0),m=Object.assign(Object.assign(Object.assign({},null===(o=this._def.openapi)||void 0===o?void 0:o.metadata),p),(null===(a=null===(r=this._def.openapi)||void 0===r?void 0:r.metadata)||void 0===a?void 0:a.param)||h?{param:Object.assign(Object.assign({},null===(c=null===(l=this._def.openapi)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.param),h)}:void 0),g=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(f).length>0?{_internal:f}:void 0),Object.keys(m).length>0?{metadata:m}:void 0)}));if(s(this,"ZodObject")){const e=this.extend;g.extend=function(...t){var n,o,r,a,i,s,l;const c=e.apply(this,t);return c._def.openapi={_internal:{extendedFrom:(null===(o=null===(n=this._def.openapi)||void 0===n?void 0:n._internal)||void 0===o?void 0:o.refId)?{refId:null===(a=null===(r=this._def.openapi)||void 0===r?void 0:r._internal)||void 0===a?void 0:a.refId,schema:this}:null===(s=null===(i=this._def.openapi)||void 0===i?void 0:i._internal)||void 0===s?void 0:s.extendedFrom},metadata:null===(l=c._def.openapi)||void 0===l?void 0:l.metadata},c}}return g},l(e,"optional"),l(e,"nullable"),l(e,"default"),l(e,"transform"),l(e,"refine");const t=e.ZodObject.prototype.deepPartial;e.ZodObject.prototype.deepPartial=function(){const e=this._def.shape(),n=t.apply(this),o=n._def.shape();return Object.entries(o).forEach(([t,n])=>{var o,r;n._def.openapi=null===(r=null===(o=e[t])||void 0===o?void 0:o._def)||void 0===r?void 0:r.openapi}),n._def.openapi=void 0,n};const n=e.ZodObject.prototype.pick;e.ZodObject.prototype.pick=function(...e){const t=n.apply(this,e);return t._def.openapi=void 0,t};const o=e.ZodObject.prototype.omit;e.ZodObject.prototype.omit=function(...e){const t=o.apply(this,e);return t._def.openapi=void 0,t}}function u(e,t){if(null==e||null==t)return e===t;if(e===t||e.valueOf()===t.valueOf())return!0;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1}if(!(e instanceof Object&&t instanceof Object))return!1;const n=Object.keys(e);return Object.keys(t).every(e=>-1!==n.indexOf(e))&&n.every(n=>u(e[n],t[n]))}"function"==typeof SuppressedError&&SuppressedError;class d{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n)return void this.buckets.set(t,[e]);const o=n.some(t=>u(t,e));o||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return!!n&&n.some(t=>u(t,e))}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const o of this.buckets.values())e+=1,t+=o.length,o.length>1&&(n+=1);return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:e/t}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if("string"==typeof e){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if("number"==typeof e)return e;if("object"==typeof e)for(const[n,o]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(null!=o?o:"");return t}}function h(e){return void 0===e}function p(e,t){const n={};return Object.entries(e).forEach(([e,o])=>{n[e]=t(o)}),n}function f(e,t){const n={};return Object.entries(e).forEach(([e,o])=>{t(o,e)||(n[e]=o)}),n}function m(e){return e.filter(e=>!h(e))}const g=u;function v(e){return"string"==typeof e}class b{constructor(e){this.message=e}}class y extends b{constructor(e,t){super(e),this.data=t}}class w extends b{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function x(e,t){try{return e()}catch(e){if(e instanceof w)throw new w(Object.assign(Object.assign({},e.data),t));throw e}}class E extends b{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class k{static getMetadata(e){var t;const n=this.unwrapChained(e),o=e._def.openapi?e._def.openapi:n._def.openapi,r=null!==(t=e.description)&&void 0!==t?t:n.description;return{_internal:null==o?void 0:o._internal,metadata:Object.assign({description:r},null==o?void 0:o.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return null==n?void 0:n._internal}static getParamMetadata(e){var t,n;const o=this.unwrapChained(e),r=e._def.openapi?e._def.openapi:o._def.openapi,a=null!==(t=e.description)&&void 0!==t?t:o.description;return{_internal:null==r?void 0:r._internal,metadata:Object.assign(Object.assign({},null==r?void 0:r.metadata),{param:Object.assign({description:a},null===(n=null==r?void 0:r.metadata)||void 0===n?void 0:n.param)})}}static buildSchemaMetadata(e){return f(function(e,t){const n={};return Object.entries(e).forEach(([e,o])=>{t.some(t=>t===e)||(n[e]=o)}),n}(e,["param"]),h)}static buildParameterMetadata(e){return f(e,h)}static applySchemaMetadata(e,t){return f(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),h)}static getRefId(e){var t;return null===(t=this.getInternalMetadata(e))||void 0===t?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return null==t?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&s(e,t)?e:s(e,"ZodOptional")||s(e,"ZodNullable")||s(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):s(e,"ZodDefault")||s(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):s(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):s(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return e.isOptional()}}class S{transform(e,t,n){var o,r;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:null===(o=e._def.minLength)||void 0===o?void 0:o.value,maxItems:null===(r=e._def.maxLength)||void 0===r?void 0:r.value})}}class _{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class C{transform(e,t,n,o,r){const a=[...e.options.values()],i=a.map(o);return t?{oneOf:n(i,t)}:{oneOf:i,discriminator:this.mapDiscriminator(a,e.discriminator,r)}}mapDiscriminator(e,t,n){if(e.some(e=>void 0===k.getRefId(e)))return;const o={};return e.forEach(e=>{var r;const a=k.getRefId(e),i=null===(r=e.shape)||void 0===r?void 0:r[t];if(s(i,"ZodEnum")||s(i,"ZodNativeEnum")){return void Object.values(i.enum).filter(v).forEach(e=>{o[e]=n(a)})}const l=null==i?void 0:i._def.value;if("string"!=typeof l)throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);o[l]=n(a)}),{propertyName:t,mapping:o}}}class O{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class D{transform(e,t,n,o){const r={allOf:this.flattenIntersectionTypes(e).map(o)};return t?{anyOf:n([r],t)}:r}flattenIntersectionTypes(e){if(!s(e,"ZodIntersection"))return[e];return[...this.flattenIntersectionTypes(e._def.left),...this.flattenIntersectionTypes(e._def.right)]}}class M{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}class N{transform(e,t){const{type:n,values:o}=function(e){const t=Object.keys(e).filter(t=>"number"!=typeof e[e[t]]).map(t=>e[t]),n=t.filter(e=>"number"==typeof e).length;return{values:t,type:0===n?"string":n===t.length?"numeric":"mixed"}}(e._def.values);if("mixed"===n)throw new b("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t("numeric"===n?"integer":"string")),{enum:o})}}class P{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class T{transform(e,t,n,o){var r;const a=null===(r=k.getInternalMetadata(e))||void 0===r?void 0:r.extendedFrom,i=this.requiredKeysOf(e),s=p(e._def.shape(),o);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:s,default:t}),i.length>0?{required:i}:{}),this.generateAdditionalProperties(e,o));const l=a.schema;o(l);const c=this.requiredKeysOf(l),u=p(null==l?void 0:l._def.shape(),o),d=Object.fromEntries(Object.entries(s).filter(([e,t])=>!g(u[e],t))),h=i.filter(e=>!c.includes(e)),f=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:d}),h.length>0?{required:h}:{}),this.generateAdditionalProperties(e,o));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},f]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,o=e._def.catchall;return s(o,"ZodNever")?"strict"===n?{additionalProperties:!1}:{}:{additionalProperties:t(o)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([e,t])=>!k.isOptionalSchema(t)).map(([e,t])=>e)}}class I{transform(e,t,n){const o=e._def.valueType,r=e._def.keyType,a=n(o);if(s(r,"ZodEnum")||s(r,"ZodNativeEnum")){const e=Object.values(r.enum).filter(v).reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:e})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class L{transform(e,t){var n,o,r;const a=this.getZodStringCheck(e,"regex"),i=null===(n=this.getZodStringCheck(e,"length"))||void 0===n?void 0:n.value,s=Number.isFinite(e.minLength)&&null!==(o=e.minLength)&&void 0!==o?o:void 0,l=Number.isFinite(e.maxLength)&&null!==(r=e.maxLength)&&void 0!==r?r:void 0;return Object.assign(Object.assign({},t("string")),{minLength:null!=i?i:s,maxLength:null!=i?i:l,format:this.mapStringFormat(e),pattern:null==a?void 0:a.regex.source})}mapStringFormat(e){return e.isUUID?"uuid":e.isEmail?"email":e.isURL?"uri":e.isDate?"date":e.isDatetime?"date-time":e.isCUID?"cuid":e.isCUID2?"cuid2":e.isULID?"ulid":e.isIP?"ip":e.isEmoji?"emoji":void 0}getZodStringCheck(e,t){return e._def.checks.find(e=>e.kind===t)}}class A{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:o}=e._def,r=o.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(r))}}class R{transform(e,t,n){return{anyOf:t(this.flattenUnionTypes(e).map(e=>{const t=this.unwrapNullable(e);return n(t)}))}}flattenUnionTypes(e){if(!s(e,"ZodUnion"))return[e];return e._def.options.flatMap(e=>this.flattenUnionTypes(e))}unwrapNullable(e){return s(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class j{constructor(e){this.versionSpecifics=e,this.objectTransformer=new T,this.stringTransformer=new L,this.numberTransformer=new P,this.bigIntTransformer=new _,this.literalTransformer=new M,this.enumTransformer=new O,this.nativeEnumTransformer=new N,this.arrayTransformer=new S,this.unionTransformer=new R,this.discriminatedUnionTransformer=new C,this.intersectionTransformer=new D,this.recordTransformer=new I,this.tupleTransformer=new A(e)}transform(e,t,n,o,r){if(s(e,"ZodNull"))return this.versionSpecifics.nullType;if(s(e,"ZodUnknown")||s(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(s(e,"ZodObject"))return this.objectTransformer.transform(e,r,e=>this.versionSpecifics.mapNullableType(e,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,o);return Object.assign(Object.assign({},a),{default:r})}transformSchemaWithoutDefault(e,t,n,o){if(s(e,"ZodUnknown")||s(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(s(e,"ZodString"))return this.stringTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t));if(s(e,"ZodNumber"))return this.numberTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t),e=>this.versionSpecifics.getNumberChecks(e));if(s(e,"ZodBigInt"))return this.bigIntTransformer.transform(e=>this.versionSpecifics.mapNullableType(e,t));if(s(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(s(e,"ZodLiteral"))return this.literalTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t));if(s(e,"ZodEnum"))return this.enumTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t));if(s(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t));if(s(e,"ZodArray"))return this.arrayTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t),n);if(s(e,"ZodTuple"))return this.tupleTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t),n);if(s(e,"ZodUnion"))return this.unionTransformer.transform(e,e=>this.versionSpecifics.mapNullableOfArray(e,t),n);if(s(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,e=>this.versionSpecifics.mapNullableOfArray(e,t),n,o);if(s(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,e=>this.versionSpecifics.mapNullableOfArray(e,t),n);if(s(e,"ZodRecord"))return this.recordTransformer.transform(e,e=>this.versionSpecifics.mapNullableType(e,t),n);if(s(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const r=k.getRefId(e);throw new E({currentSchema:e._def,schemaName:r})}}class z{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new j(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:e,name:t,component:o})=>{var r;null!==(r=n[e])&&void 0!==r||(n[e]={}),n[e][t]=o}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},null!==(e=n.schemas)&&void 0!==e?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},null!==(t=n.parameters)&&void 0!==t?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const o=e.findIndex(e=>e===t.type),r=e.findIndex(e=>e===n.type);return o-r})}generateSingle(e){if("type"in e)switch(e.type){case"parameter":return void this.generateParameterDefinition(e.schema);case"schema":return void this.generateSchemaWithRef(e.schema);case"route":return void this.generateSingleRoute(e.route);case"component":return void this.rawComponents.push(e)}else this.generateSchemaWithRef(e)}generateParameterDefinition(e){const t=k.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,o,r,a,i;const s=null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.param,l=(null===(o=null==e?void 0:e._internal)||void 0===o?void 0:o.refId)?this.paramRefs[null===(r=e._internal)||void 0===r?void 0:r.refId]:void 0;if((null===(a=null==e?void 0:e._internal)||void 0===a?void 0:a.refId)&&l){if(s&&l.in!==s.in||(null==t?void 0:t.in)&&l.in!==t.in)throw new y(`Conflicting location for parameter ${l.name}`,{key:"in",values:m([l.in,null==t?void 0:t.in,null==s?void 0:s.in])});if(s&&l.name!==s.name||(null==t?void 0:t.name)&&l.name!==(null==t?void 0:t.name))throw new y("Conflicting names for parameter",{key:"name",values:m([l.name,null==t?void 0:t.name,null==s?void 0:s.name])});return{$ref:`#/components/parameters/${null===(i=e._internal)||void 0===i?void 0:i.refId}`}}}generateInlineParameters(e,t){var n;const o=k.getMetadata(e),r=null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.param,a=this.getParameterRef(o,{in:t});if(a)return[a];if(s(e,"ZodObject")){const n=e._def.shape(),o=Object.entries(n).map(([e,n])=>{var o,r;const a=k.getMetadata(n),i=this.getParameterRef(a,{in:t,name:e});if(i)return i;const s=null===(o=null==a?void 0:a.metadata)||void 0===o?void 0:o.param;if((null==s?void 0:s.name)&&s.name!==e)throw new y("Conflicting names for parameter",{key:"name",values:[e,s.name]});if((null==s?void 0:s.in)&&s.in!==t)throw new y(`Conflicting location for parameter ${null!==(r=s.name)&&void 0!==r?r:e}`,{key:"in",values:[t,s.in]});return this.generateParameter(n.openapi({param:{name:e,in:t}}))});return o}if((null==r?void 0:r.in)&&r.in!==t)throw new y(`Conflicting location for parameter ${r.name}`,{key:"in",values:[t,r.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=k.getParamMetadata(e),o=null===(t=null==n?void 0:n.metadata)||void 0===t?void 0:t.param,r=!k.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:r},o?k.buildParameterMetadata(o):{})}generateParameter(e){var t;const n=k.getMetadata(e),o=null===(t=null==n?void 0:n.metadata)||void 0===t?void 0:t.param,r=null==o?void 0:o.name,a=null==o?void 0:o.in;if(!r)throw new w({missingField:"name"});if(!a)throw new w({missingField:"in",paramName:r});const i=this.generateSimpleParameter(e);return Object.assign(Object.assign({},i),{in:a,name:r})}generateSchemaWithMetadata(e){var t;const n=k.unwrapChained(e),o=k.getMetadata(e),r=k.getDefaultValue(e),a=(null===(t=null==o?void 0:o.metadata)||void 0===t?void 0:t.type)?{type:null==o?void 0:o.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),r);return(null==o?void 0:o.metadata)?k.applySchemaMetadata(a,o.metadata):f(a,h)}constructReferencedOpenAPISchema(e){var t;const n=k.getMetadata(e),o=k.unwrapChained(e),r=k.getDefaultValue(e),a=e.isNullable();return(null===(t=null==n?void 0:n.metadata)||void 0===t?void 0:t.type)?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(o,a,r)}generateSimpleSchema(e){var t;const n=k.getMetadata(e),o=k.getRefId(e);if(!o||!this.schemaRefs[o])return this.generateSchemaWithMetadata(e);const r=this.schemaRefs[o],a={$ref:this.generateSchemaRef(o)},i=f(k.buildSchemaMetadata(null!==(t=null==n?void 0:n.metadata)&&void 0!==t?t:{}),(e,t)=>void 0===e||g(e,r[t]));if(i.type)return{allOf:[a,i]};const s=f(this.constructReferencedOpenAPISchema(e),(e,t)=>void 0===e||g(e,r[t])),l=k.applySchemaMetadata(s,i);return Object.keys(l).length>0?{allOf:[a,l]}:a}generateSchemaWithRef(e){const t=k.getRefId(e),n=this.generateSimpleSchema(e);return t&&void 0===this.schemaRefs[t]?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=i(e,["content"]),o=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:o})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),o=this.cleanParameter(e.params),r=this.cleanParameter(e.cookies),a=x(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),i=x(()=>o?this.generateInlineParameters(o,"path"):[],{location:"path"}),s=x(()=>r?this.generateInlineParameters(r,"cookie"):[],{location:"cookie"});return[...i,...a,...x(()=>{if(Array.isArray(t))return t.flatMap(e=>this.generateInlineParameters(e,"header"));const e=this.cleanParameter(t);return e?this.generateInlineParameters(e,"header"):[]},{location:"header"}),...s]}cleanParameter(e){if(e)return s(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:o,responses:r}=e,a=i(e,["method","path","request","responses"]),s=p(r,e=>this.getResponse(e)),l=x(()=>this.getParameters(o),{route:`${t} ${n}`}),c=this.getRequestBody(null==o?void 0:o.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),l.length>0?{parameters:[...a.parameters||[],...l]}:{}),c?{requestBody:c}:{}),{responses:s})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){if(this.isReferenceObject(e))return e;const{content:t,headers:n}=e,o=i(e,["content","headers"]),r=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},o),r);const a=s(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},o),{headers:a}),r)}isReferenceObject(e){return"$ref"in e}getResponseHeaders(e){const t=p(e._def.shape(),e=>this.generateSimpleParameter(e));return t}getBodyContent(e){return p(e,e=>{if(!e||!function(e){return"_def"in e}(e.schema))return e;const{schema:t}=e,n=i(e,["schema"]),o=this.generateSchemaWithRef(t);return Object.assign({schema:o},n)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,e=>this.generateSchemaWithRef(e),e=>this.generateSchemaRef(e),n)}}class F{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=function(e){const t=new d;return e.forEach(e=>t.put(e)),[...t.values()]}(e);return{items:1===t.length?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(e=>{switch(e.kind){case"min":return e.inclusive?{minimum:Number(e.value)}:{minimum:Number(e.value),exclusiveMinimum:!0};case"max":return e.inclusive?{maximum:Number(e.value)}:{maximum:Number(e.value),exclusiveMaximum:!0};default:return{}}}))}}var B,$;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),o={};for(const e of n)o[e]=t[e];return e.objectValues(o)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(B||(B={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}($||($={}));const V=B.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W=e=>{switch(typeof e){case"undefined":return V.undefined;case"string":return V.string;case"number":return Number.isNaN(e)?V.nan:V.number;case"boolean":return V.boolean;case"function":return V.function;case"bigint":return V.bigint;case"symbol":return V.symbol;case"object":return Array.isArray(e)?V.array:null===e?V.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?V.promise:"undefined"!=typeof Map&&e instanceof Map?V.map:"undefined"!=typeof Set&&e instanceof Set?V.set:"undefined"!=typeof Date&&e instanceof Date?V.date:V.object;default:return V.unknown}},H=B.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"]);class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},o=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(o);else if("invalid_return_type"===r.code)o(r.returnTypeError);else if("invalid_arguments"===r.code)o(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,o=0;for(;o<r.path.length;){const n=r.path[o];o===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(this),n}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];t[n]=t[n]||[],t[n].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=e=>new U(e);const Z=(e,t)=>{let n;switch(e.code){case H.invalid_type:n=e.received===V.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case H.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,B.jsonStringifyReplacer)}`;break;case H.unrecognized_keys:n=`Unrecognized key(s) in object: ${B.joinValues(e.keys,", ")}`;break;case H.invalid_union:n="Invalid input";break;case H.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${B.joinValues(e.options)}`;break;case H.invalid_enum_value:n=`Invalid enum value. Expected ${B.joinValues(e.options)}, received '${e.received}'`;break;case H.invalid_arguments:n="Invalid function arguments";break;case H.invalid_return_type:n="Invalid function return type";break;case H.invalid_date:n="Invalid date";break;case H.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:B.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case H.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case H.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case H.custom:n="Invalid input";break;case H.invalid_intersection_types:n="Intersection results could not be merged";break;case H.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case H.not_finite:n="Number must be finite";break;default:n=t.defaultError,B.assertNever(e)}return{message:n}};let q=Z;function Y(){return q}const G=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(void 0!==r.message)return{...r,path:a,message:r.message};let s="";const l=o.filter(e=>!!e).slice().reverse();for(const e of l)s=e(i,{data:t,defaultError:s}).message;return{...r,path:a,message:s}};function K(e,t){const n=Y(),o=G({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Z?void 0:Z].filter(e=>!!e)});e.common.issues.push(o)}class X{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const o of t){if("aborted"===o.status)return J;"dirty"===o.status&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,o=await e.value;n.push({key:t,value:o})}return X.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const o of t){const{key:t,value:r}=o;if("aborted"===t.status)return J;if("aborted"===r.status)return J;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!o.alwaysSet||(n[t.value]=r.value)}return{status:e.value,value:n}}}const J=Object.freeze({status:"aborted"}),Q=e=>({status:"dirty",value:e}),ee=e=>({status:"valid",value:e}),te=e=>"aborted"===e.status,ne=e=>"dirty"===e.status,oe=e=>"valid"===e.status,re=e=>"undefined"!=typeof Promise&&e instanceof Promise;var ae;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(ae||(ae={}));class ie{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const se=(e,t)=>{if(oe(t))return{success:!0,data:t.value};if(!e.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 U(e.common.issues);return this._error=t,this._error}}};function le(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:a}=e;return"invalid_enum_value"===t.code?{message:a??r.defaultError}:void 0===r.data?{message:a??o??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:a??n??r.defaultError}},description:r}}class ce{get description(){return this._def.description}_getType(e){return W(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(re(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){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},o=this._parseSync({data:e,path:n.path,parent:n});return se(n,o)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return oe(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>oe(e)?{value:e.value}:{issues:t.common.issues})}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?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},o=this._parse({data:e,path:n.path,parent:n}),r=await(re(o)?o:Promise.resolve(o));return se(n,r)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,o)=>{const r=e(t),a=()=>o.addIssue({code:H.custom,...n(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(a(),!1)):!!r||(a(),!1)})}refinement(e,t){return this._refinement((n,o)=>!!e(n)||(o.addIssue("function"==typeof t?t(n,o):t),!1))}_refinement(e){return new dt({schema:this,typeName:St.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return ht.create(this,this._def)}nullable(){return pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ze.create(this)}promise(){return ut.create(this,this._def)}or(e){return Ge.create([this,e],this._def)}and(e){return Qe.create(this,e,this._def)}transform(e){return new dt({...le(this._def),schema:this,typeName:St.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ft({...le(this._def),innerType:this,defaultValue:t,typeName:St.ZodDefault})}brand(){return new bt({typeName:St.ZodBranded,type:this,...le(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new mt({...le(this._def),innerType:this,catchValue:t,typeName:St.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return yt.create(this,e)}readonly(){return wt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ue=/^c[^\s-]{8,}$/i,de=/^[0-9a-z]+$/,he=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pe=/^[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,fe=/^[a-z0-9_-]{21}$/i,me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ge=/^[-+]?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)?)??$/,ve=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let be;const ye=/^(?:(?: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])$/,we=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,xe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ee=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ke=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Se=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_e="((\\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])))",Ce=new RegExp(`^${_e}$`);function Oe(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function De(e){return new RegExp(`^${Oe(e)}$`)}function Me(e){let t=`${_e}T${Oe(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ne(e,t){return!("v4"!==t&&t||!ye.test(e))||!("v6"!==t&&t||!xe.test(e))}function Pe(e,t){if(!me.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function Te(e,t){return!("v4"!==t&&t||!we.test(e))||!("v6"!==t&&t||!Ee.test(e))}class Ie extends ce{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==V.string){const t=this._getOrReturnCtx(e);return K(t,{code:H.invalid_type,expected:V.string,received:t.parsedType}),J}const t=new X;let n;for(const o of this._def.checks)if("min"===o.kind)e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:H.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if("max"===o.kind)e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:H.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if("length"===o.kind){const r=e.data.length>o.value,a=e.data.length<o.value;(r||a)&&(n=this._getOrReturnCtx(e,n),r?K(n,{code:H.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&K(n,{code:H.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),t.dirty())}else if("email"===o.kind)ve.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"email",code:H.invalid_string,message:o.message}),t.dirty());else if("emoji"===o.kind)be||(be=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),be.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"emoji",code:H.invalid_string,message:o.message}),t.dirty());else if("uuid"===o.kind)pe.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"uuid",code:H.invalid_string,message:o.message}),t.dirty());else if("nanoid"===o.kind)fe.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"nanoid",code:H.invalid_string,message:o.message}),t.dirty());else if("cuid"===o.kind)ue.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid",code:H.invalid_string,message:o.message}),t.dirty());else if("cuid2"===o.kind)de.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid2",code:H.invalid_string,message:o.message}),t.dirty());else if("ulid"===o.kind)he.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ulid",code:H.invalid_string,message:o.message}),t.dirty());else if("url"===o.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),K(n,{validation:"url",code:H.invalid_string,message:o.message}),t.dirty()}else if("regex"===o.kind){o.regex.lastIndex=0;o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"regex",code:H.invalid_string,message:o.message}),t.dirty())}else if("trim"===o.kind)e.data=e.data.trim();else if("includes"===o.kind)e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),t.dirty());else if("toLowerCase"===o.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===o.kind)e.data=e.data.toUpperCase();else if("startsWith"===o.kind)e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:{startsWith:o.value},message:o.message}),t.dirty());else if("endsWith"===o.kind)e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:{endsWith:o.value},message:o.message}),t.dirty());else if("datetime"===o.kind){Me(o).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:"datetime",message:o.message}),t.dirty())}else if("date"===o.kind){Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:"date",message:o.message}),t.dirty())}else if("time"===o.kind){De(o).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:H.invalid_string,validation:"time",message:o.message}),t.dirty())}else"duration"===o.kind?ge.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"duration",code:H.invalid_string,message:o.message}),t.dirty()):"ip"===o.kind?Ne(e.data,o.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ip",code:H.invalid_string,message:o.message}),t.dirty()):"jwt"===o.kind?Pe(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"jwt",code:H.invalid_string,message:o.message}),t.dirty()):"cidr"===o.kind?Te(e.data,o.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cidr",code:H.invalid_string,message:o.message}),t.dirty()):"base64"===o.kind?ke.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64",code:H.invalid_string,message:o.message}),t.dirty()):"base64url"===o.kind?Se.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64url",code:H.invalid_string,message:o.message}),t.dirty()):B.assertNever(o);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:H.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ae.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ae.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ae.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...ae.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...ae.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Ie({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ie({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ie({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Le(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}Ie.create=e=>new Ie({checks:[],typeName:St.ZodString,coerce:e?.coerce??!1,...le(e)});class Ae extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==V.number){const t=this._getOrReturnCtx(e);return K(t,{code:H.invalid_type,expected:V.number,received:t.parsedType}),J}let t;const n=new X;for(const o of this._def.checks)if("int"===o.kind)B.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),K(t,{code:H.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty());else if("min"===o.kind){(o.inclusive?e.data<o.value:e.data<=o.value)&&(t=this._getOrReturnCtx(e,t),K(t,{code:H.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty())}else if("max"===o.kind){(o.inclusive?e.data>o.value:e.data>=o.value)&&(t=this._getOrReturnCtx(e,t),K(t,{code:H.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty())}else"multipleOf"===o.kind?0!==Le(e.data,o.value)&&(t=this._getOrReturnCtx(e,t),K(t,{code:H.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):"finite"===o.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),K(t,{code:H.not_finite,message:o.message}),n.dirty()):B.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,o){return new Ae({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(o)}]})}_addCheck(e){return new Ae({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,valu