@deconz-community/ddf-validator 0.1.1 → 0.2.1
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/ddf-validator.cjs +1 -1
- package/dist/ddf-validator.mjs +207 -2903
- package/package.json +4 -4
- package/dist/ddf-validator.iife.js +0 -1
package/dist/ddf-validator.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.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},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var ge;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(ge||(ge={}));const l=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=n=>{switch(typeof n){case"undefined":return l.undefined;case"string":return l.string;case"number":return isNaN(n)?l.nan:l.number;case"boolean":return l.boolean;case"function":return l.function;case"bigint":return l.bigint;case"symbol":return l.symbol;case"object":return Array.isArray(n)?l.array:n===null?l.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?l.promise:typeof Map<"u"&&n instanceof Map?l.map:typeof Set<"u"&&n instanceof Set?l.set:typeof Date<"u"&&n instanceof Date?l.date:l.object;default:return l.unknown}},d=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"]),Le=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class S extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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},r={_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)r._errors.push(t(o));else{let c=r,p=0;for(;p<o.path.length;){const f=o.path[p];p===o.path.length-1?(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(o))):c[f]=c[f]||{_errors:[]},c=c[f],p++}}};return s(this),r}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={},r=[];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))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=n=>new S(n);const J=(n,e)=>{let t;switch(n.code){case d.invalid_type:n.received===l.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(n.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(n.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:x.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case d.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case d.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(n)}return{message:t}};let Oe=J;function Me(n){Oe=n}function ce(){return Oe}const de=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};let c="";const p=r.filter(f=>!!f).slice().reverse();for(const f of p)c=f(o,{data:e,defaultError:c}).message;return{...s,path:a,message:s.message||c}},De=[];function u(n,e){const t=de({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ce(),J].filter(r=>!!r)});n.common.issues.push(t)}class k{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t)r.push({key:await s.key,value:await s.value});return k.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};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(),(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const y=Object.freeze({status:"aborted"}),Se=n=>({status:"dirty",value:n}),w=n=>({status:"valid",value:n}),be=n=>n.status==="aborted",xe=n=>n.status==="dirty",le=n=>n.status==="valid",ue=n=>typeof Promise<"u"&&n instanceof Promise;var h;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class C{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,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 we=(n,e)=>{if(le(e))return{success:!0,data:e.value};if(!n.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(n.common.issues);return this._error=t,this._error}}};function v(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))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,c)=>o.code!=="invalid_type"?{message:c.defaultError}:typeof c.data>"u"?{message:r??c.defaultError}:{message:t??c.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.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ue(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parseSync({data:e,path:s.path,parent:s});return we(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:$(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(ue(s)?s:Promise.resolve(s));return we(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(p=>p?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new N({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return A.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this,this._def)}promise(){return q.create(this,this._def)}or(e){return F.create([this,e],this._def)}and(e){return ee.create(this,e,this._def)}transform(e){return new N({...v(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ae({...v(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new Ne({typeName:m.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new me({...v(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ie.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ve=/^c[^\s-]{8,}$/i,Ue=/^[a-z][a-z0-9]*$/,ze=/[0-9A-HJKMNP-TV-Z]{26}/,Ye=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,Be=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((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}))\])|(\[IPv6:(([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})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,He=/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u,We=/^(((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}))$/,Ge=/^(([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})))$/,qe=n=>n.precision?n.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${n.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${n.precision}}Z$`):n.precision===0?n.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):n.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Je(n,e){return!!((e==="v4"||!e)&&We.test(n)||(e==="v6"||!e)&&Ge.test(n))}class O extends g{constructor(){super(...arguments),this._regex=(e,t,r)=>this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...h.errToObj(r)}),this.nonempty=e=>this.min(1,h.errToObj(e)),this.trim=()=>new O({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new O({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new O({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==l.string){const a=this._getOrReturnCtx(e);return u(a,{code:d.invalid_type,expected:l.string,received:a.parsedType}),y}const r=new k;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?u(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&u(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Be.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"email",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")He.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"emoji",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Ye.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"uuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ve.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Ue.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")ze.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ulid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),u(s,{validation:"url",code:d.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"regex",code:d.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.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),u(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?qe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="ip"?Je(e.data,a.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ip",code:d.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_addCheck(e){return new O({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!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,...h.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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}}O.create=n=>{var e;return new O({checks:[],typeName:m.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...v(n)})};function Ke(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class L 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)!==l.number){const a=this._getOrReturnCtx(e);return u(a,{code:d.invalid_type,expected:l.number,received:a.parsedType}),y}let r;const s=new k;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),u(r,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.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)&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Ke(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),u(r,{code:d.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,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.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 r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}L.create=n=>new L({checks:[],typeName:m.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...v(n)});class M 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)!==l.bigint){const a=this._getOrReturnCtx(e);return u(a,{code:d.invalid_type,expected:l.bigint,received:a.parsedType}),y}let r;const s=new k;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.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)&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),u(r,{code:d.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,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,s){return new M({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(s)}]})}_addCheck(e){return new M({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.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}}M.create=n=>{var e;return new M({checks:[],typeName:m.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...v(n)})};class K extends g{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==l.boolean){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.boolean,received:r.parsedType}),y}return w(e.data)}}K.create=n=>new K({typeName:m.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...v(n)});class U extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==l.date){const a=this._getOrReturnCtx(e);return u(a,{code:d.invalid_type,expected:l.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return u(a,{code:d.invalid_date}),y}const r=new k;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.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}}U.create=n=>new U({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:m.ZodDate,...v(n)});class fe extends g{_parse(e){if(this._getType(e)!==l.symbol){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.symbol,received:r.parsedType}),y}return w(e.data)}}fe.create=n=>new fe({typeName:m.ZodSymbol,...v(n)});class X extends g{_parse(e){if(this._getType(e)!==l.undefined){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.undefined,received:r.parsedType}),y}return w(e.data)}}X.create=n=>new X({typeName:m.ZodUndefined,...v(n)});class Q extends g{_parse(e){if(this._getType(e)!==l.null){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.null,received:r.parsedType}),y}return w(e.data)}}Q.create=n=>new Q({typeName:m.ZodNull,...v(n)});class G extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}}G.create=n=>new G({typeName:m.ZodAny,...v(n)});class V extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}}V.create=n=>new V({typeName:m.ZodUnknown,...v(n)});class P extends g{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:l.never,received:t.parsedType}),y}}P.create=n=>new P({typeName:m.ZodNever,...v(n)});class pe extends g{_parse(e){if(this._getType(e)!==l.undefined){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.void,received:r.parsedType}),y}return w(e.data)}}pe.create=n=>new pe({typeName:m.ZodVoid,...v(n)});class Z extends g{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==l.array)return u(t,{code:d.invalid_type,expected:l.array,received:t.parsedType}),y;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(u(t,{code:o?d.too_big:d.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(u(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(u(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new C(t,o,t.path,c)))).then(o=>k.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new C(t,o,t.path,c)));return k.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new Z({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new Z({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new Z({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}Z.create=(n,e)=>new Z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...v(e)});function H(n){if(n instanceof T){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=A.create(H(r))}return new T({...n._def,shape:()=>e})}else return n instanceof Z?new Z({...n._def,type:H(n.element)}):n instanceof A?A.create(H(n.unwrap())):n instanceof Y?Y.create(H(n.unwrap())):n instanceof I?I.create(n.items.map(e=>H(e))):n}class T 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)!==l.object){const f=this._getOrReturnCtx(e);return u(f,{code:d.invalid_type,expected:l.object,received:f.parsedType}),y}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(const f in s.data)o.includes(f)||c.push(f);const p=[];for(const f of o){const b=a[f],B=s.data[f];p.push({key:{status:"valid",value:f},value:b._parse(new C(s,B,s.path,f)),alwaysSet:f in s.data})}if(this._def.catchall instanceof P){const f=this._def.unknownKeys;if(f==="passthrough")for(const b of c)p.push({key:{status:"valid",value:b},value:{status:"valid",value:s.data[b]}});else if(f==="strict")c.length>0&&(u(s,{code:d.unrecognized_keys,keys:c}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const b of c){const B=s.data[b];p.push({key:{status:"valid",value:b},value:f._parse(new C(s,B,s.path,b)),alwaysSet:b in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const f=[];for(const b of p){const B=await b.key;f.push({key:B,value:await b.value,alwaysSet:b.alwaysSet})}return f}).then(f=>k.mergeObjectSync(r,f)):k.mergeObjectSync(r,p)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new T({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const p=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=h.errToObj(e).message)!==null&&c!==void 0?c:p}:{message:p}}}:{}})}strip(){return new T({...this._def,unknownKeys:"strip"})}passthrough(){return new T({...this._def,unknownKeys:"passthrough"})}extend(e){return new T({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new T({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new T({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new T({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new T({...this._def,shape:()=>t})}deepPartial(){return H(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new T({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof A;)a=a._def.innerType;t[r]=a}}),new T({...this._def,shape:()=>t})}keyof(){return Ze(x.objectKeys(this.shape))}}T.create=(n,e)=>new T({shape:()=>n,unknownKeys:"strip",catchall:P.create(),typeName:m.ZodObject,...v(e)});T.strictCreate=(n,e)=>new T({shape:()=>n,unknownKeys:"strict",catchall:P.create(),typeName:m.ZodObject,...v(e)});T.lazycreate=(n,e)=>new T({shape:n,unknownKeys:"strip",catchall:P.create(),typeName:m.ZodObject,...v(e)});class F extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new S(c.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:o}),y}if(t.common.async)return Promise.all(r.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 p of r){const f={...t,common:{...t.common,issues:[]},parent:null},b=p._parseSync({data:t.data,path:t.path,parent:f});if(b.status==="valid")return b;b.status==="dirty"&&!a&&(a={result:b,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(p=>new S(p));return u(t,{code:d.invalid_union,unionErrors:c}),y}}get options(){return this._def.options}}F.create=(n,e)=>new F({options:n,typeName:m.ZodUnion,...v(e)});const oe=n=>n instanceof ne?oe(n.schema):n instanceof N?oe(n.innerType()):n instanceof re?[n.value]:n instanceof D?n.options:n instanceof se?Object.keys(n.enum):n instanceof ae?oe(n._def.innerType):n instanceof X?[void 0]:n instanceof Q?[null]:null;class _e extends g{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.object)return u(t,{code:d.invalid_type,expected:l.object,received:t.parsedType}),y;const r=this.discriminator,s=t.data[r],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}):(u(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=oe(a.shape[e]);if(!o)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new _e({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(r)})}}function Te(n,e){const t=$(n),r=$(e);if(n===e)return{valid:!0,data:n};if(t===l.object&&r===l.object){const s=x.objectKeys(e),a=x.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const p=Te(n[c],e[c]);if(!p.valid)return{valid:!1};o[c]=p.data}return{valid:!0,data:o}}else if(t===l.array&&r===l.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],p=Te(o,c);if(!p.valid)return{valid:!1};s.push(p.data)}return{valid:!0,data:s}}else return t===l.date&&r===l.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class ee extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(be(a)||be(o))return y;const c=Te(a.value,o.value);return c.valid?((xe(a)||xe(o))&&t.dirty(),{status:t.value,value:c.data}):(u(r,{code:d.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ee.create=(n,e,t)=>new ee({left:n,right:e,typeName:m.ZodIntersection,...v(t)});class I extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.array)return u(r,{code:d.invalid_type,expected:l.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return u(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(u(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,c)=>{const p=this._def.items[c]||this._def.rest;return p?p._parse(new C(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>k.mergeArray(t,o)):k.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:n,typeName:m.ZodTuple,rest:null,...v(e)})};class te extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.object)return u(r,{code:d.invalid_type,expected:l.object,received:r.parsedType}),y;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new C(r,c,r.path,c)),value:o._parse(new C(r,r.data[c],r.path,c))});return r.common.async?k.mergeObjectAsync(t,s):k.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof g?new te({keyType:e,valueType:t,typeName:m.ZodRecord,...v(r)}):new te({keyType:O.create(),valueType:e,typeName:m.ZodRecord,...v(t)})}}class he extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.map)return u(r,{code:d.invalid_type,expected:l.map,received:r.parsedType}),y;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,p],f)=>({key:s._parse(new C(r,c,r.path,[f,"key"])),value:a._parse(new C(r,p,r.path,[f,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const p of o){const f=await p.key,b=await p.value;if(f.status==="aborted"||b.status==="aborted")return y;(f.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(f.value,b.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const p of o){const f=p.key,b=p.value;if(f.status==="aborted"||b.status==="aborted")return y;(f.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(f.value,b.value)}return{status:t.value,value:c}}}}he.create=(n,e,t)=>new he({valueType:e,keyType:n,typeName:m.ZodMap,...v(t)});class z extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.set)return u(r,{code:d.invalid_type,expected:l.set,received:r.parsedType}),y;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(u(r,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(u(r,{code:d.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(p){const f=new Set;for(const b of p){if(b.status==="aborted")return y;b.status==="dirty"&&t.dirty(),f.add(b.value)}return{status:t.value,value:f}}const c=[...r.data.values()].map((p,f)=>a._parse(new C(r,p,r.path,f)));return r.common.async?Promise.all(c).then(p=>o(p)):o(c)}min(e,t){return new z({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({valueType:n,minSize:null,maxSize:null,typeName:m.ZodSet,...v(e)});class W extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.function)return u(t,{code:d.invalid_type,expected:l.function,received:t.parsedType}),y;function r(c,p){return de({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ce(),J].filter(f=>!!f),issueData:{code:d.invalid_arguments,argumentsError:p}})}function s(c,p){return de({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ce(),J].filter(f=>!!f),issueData:{code:d.invalid_return_type,returnTypeError:p}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;return this._def.returns instanceof q?w(async(...c)=>{const p=new S([]),f=await this._def.args.parseAsync(c,a).catch(ve=>{throw p.addIssue(r(c,ve)),p}),b=await o(...f);return await this._def.returns._def.type.parseAsync(b,a).catch(ve=>{throw p.addIssue(s(b,ve)),p})}):w((...c)=>{const p=this._def.args.safeParse(c,a);if(!p.success)throw new S([r(c,p.error)]);const f=o(...p.data),b=this._def.returns.safeParse(f,a);if(!b.success)throw new S([s(f,b.error)]);return b.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new W({...this._def,args:I.create(e).rest(V.create())})}returns(e){return new W({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new W({args:e||I.create([]).rest(V.create()),returns:t||V.create(),typeName:m.ZodFunction,...v(r)})}}class ne 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})}}ne.create=(n,e)=>new ne({getter:n,typeName:m.ZodLazy,...v(e)});class re extends g{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}re.create=(n,e)=>new re({value:n,typeName:m.ZodLiteral,...v(e)});function Ze(n,e){return new D({values:n,typeName:m.ZodEnum,...v(e)})}class D extends g{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return u(t,{expected:x.joinValues(r),received:t.parsedType,code:d.invalid_type}),y}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),r=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:r}),y}return w(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){return D.create(e)}exclude(e){return D.create(this.options.filter(t=>!e.includes(t)))}}D.create=Ze;class se extends g{_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==l.string&&r.parsedType!==l.number){const s=x.objectValues(t);return u(r,{expected:x.joinValues(s),received:r.parsedType,code:d.invalid_type}),y}if(t.indexOf(e.data)===-1){const s=x.objectValues(t);return u(r,{received:r.data,code:d.invalid_enum_value,options:s}),y}return w(e.data)}get enum(){return this._def.values}}se.create=(n,e)=>new se({values:n,typeName:m.ZodNativeEnum,...v(e)});class q extends g{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:l.promise,received:t.parsedType}),y;const r=t.parsedType===l.promise?t.data:Promise.resolve(t.data);return w(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}q.create=(n,e)=>new q({type:n,typeName:m.ZodPromise,...v(e)});class N extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){const o=s.transform(r.data);return r.common.async?Promise.resolve(o).then(c=>this._def.schema._parseAsync({data:c,path:r.path,parent:r})):this._def.schema._parseSync({data:o,path:r.path,parent:r})}const a={addIssue:o=>{u(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="refinement"){const o=c=>{const p=s.refinement(c,a);if(r.common.async)return Promise.resolve(p);if(p instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?y:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?y:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!le(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>le(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);x.assertNever(s)}}N.create=(n,e,t)=>new N({schema:n,typeName:m.ZodEffects,effect:e,...v(t)});N.createWithPreprocess=(n,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:n},typeName:m.ZodEffects,...v(t)});class A extends g{_parse(e){return this._getType(e)===l.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}A.create=(n,e)=>new A({innerType:n,typeName:m.ZodOptional,...v(e)});class Y extends g{_parse(e){return this._getType(e)===l.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:m.ZodNullable,...v(e)});class ae extends g{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===l.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ae.create=(n,e)=>new ae({innerType:n,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class me extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ue(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new S(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class ye extends g{_parse(e){if(this._getType(e)!==l.nan){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:l.nan,received:r.parsedType}),y}return{status:"valid",value:e.data}}}ye.create=n=>new ye({typeName:m.ZodNaN,...v(n)});const Xe=Symbol("zod_brand");class Ne extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ie extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),Se(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ie({in:e,out:t,typeName:m.ZodPipeline})}}const Re=(n,e={},t)=>n?G.create().superRefine((r,s)=>{var a,o;if(!n(r)){const c=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,p=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,f=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...f,fatal:p})}}):G.create(),Qe={object:T.lazycreate};var m;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline"})(m||(m={}));const Fe=(n,e={message:`Input not instance of ${n.name}`})=>Re(t=>t instanceof n,e),Ce=O.create,Ie=L.create,et=ye.create,tt=M.create,Ae=K.create,nt=U.create,rt=fe.create,st=X.create,at=Q.create,it=G.create,ot=V.create,ct=P.create,dt=pe.create,lt=Z.create,ut=T.create,ft=T.strictCreate,pt=F.create,ht=_e.create,mt=ee.create,yt=I.create,_t=te.create,vt=he.create,gt=z.create,bt=W.create,xt=ne.create,Tt=re.create,kt=D.create,wt=se.create,Et=q.create,Ee=N.create,Ot=A.create,St=Y.create,Zt=N.createWithPreprocess,Nt=ie.create,Rt=()=>Ce().optional(),Ct=()=>Ie().optional(),It=()=>Ae().optional(),At={string:n=>O.create({...n,coerce:!0}),number:n=>L.create({...n,coerce:!0}),boolean:n=>K.create({...n,coerce:!0}),bigint:n=>M.create({...n,coerce:!0}),date:n=>U.create({...n,coerce:!0})},Pt=y;var i=Object.freeze({__proto__:null,defaultErrorMap:J,setErrorMap:Me,getErrorMap:ce,makeIssue:de,EMPTY_PATH:De,addIssueToContext:u,ParseStatus:k,INVALID:y,DIRTY:Se,OK:w,isAborted:be,isDirty:xe,isValid:le,isAsync:ue,get util(){return x},get objectUtil(){return ge},ZodParsedType:l,getParsedType:$,ZodType:g,ZodString:O,ZodNumber:L,ZodBigInt:M,ZodBoolean:K,ZodDate:U,ZodSymbol:fe,ZodUndefined:X,ZodNull:Q,ZodAny:G,ZodUnknown:V,ZodNever:P,ZodVoid:pe,ZodArray:Z,ZodObject:T,ZodUnion:F,ZodDiscriminatedUnion:_e,ZodIntersection:ee,ZodTuple:I,ZodRecord:te,ZodMap:he,ZodSet:z,ZodFunction:W,ZodLazy:ne,ZodLiteral:re,ZodEnum:D,ZodNativeEnum:se,ZodPromise:q,ZodEffects:N,ZodTransformer:N,ZodOptional:A,ZodNullable:Y,ZodDefault:ae,ZodCatch:me,ZodNaN:ye,BRAND:Xe,ZodBranded:Ne,ZodPipeline:ie,custom:Re,Schema:g,ZodSchema:g,late:Qe,get ZodFirstPartyTypeKind(){return m},coerce:At,any:it,array:lt,bigint:tt,boolean:Ae,date:nt,discriminatedUnion:ht,effect:Ee,enum:kt,function:bt,instanceof:Fe,intersection:mt,lazy:xt,literal:Tt,map:vt,nan:et,nativeEnum:wt,never:ct,null:at,nullable:St,number:Ie,object:ut,oboolean:It,onumber:Ct,optional:Ot,ostring:Rt,pipeline:Nt,preprocess:Zt,promise:Et,record:_t,set:gt,strictObject:ft,string:Ce,symbol:rt,transformer:Ee,tuple:yt,undefined:st,union:pt,unknown:ot,void:dt,NEVER:Pt,ZodIssueCode:d,quotelessJson:Le,ZodError:S});const jt=["$TYPE_AIR_PURIFIER","$TYPE_AIR_QUALITY_SENSOR","$TYPE_ALARM_SENSOR","$TYPE_BATTERY_SENSOR","$TYPE_COLOR_DIMMABLE_LIGHT","$TYPE_COLOR_LIGHT","$TYPE_COLOR_TEMPERATURE_LIGHT","$TYPE_CONSUMPTION_SENSOR","$TYPE_DIMMABLE_LIGHT","$TYPE_DIMMABLE_PLUGIN_UNIT","$TYPE_DIMMER_SWITCH","$TYPE_DOOR_LOCK_CONTROLLER","$TYPE_DOOR_LOCK","$TYPE_EXTENDED_COLOR_LIGHT","$TYPE_FIRE_SENSOR","$TYPE_HUMIDITY_SENSOR","$TYPE_LIGHT_LEVEL_SENSOR","$TYPE_ON_OFF_LIGHT","$TYPE_ON_OFF_OUTPUT","$TYPE_ON_OFF_PLUGIN_UNIT","$TYPE_OPEN_CLOSE_SENSOR","$TYPE_POWER_SENSOR","$TYPE_PRESENCE_SENSOR","$TYPE_PRESSURE_SENSOR","$TYPE_RANGE_EXTENDER","$TYPE_RELATIVE_ROTARY","$TYPE_SMART_PLUG","$TYPE_SPECTRAL_SENSOR","$TYPE_SWITCH","$TYPE_TEMPERATURE_SENSOR","$TYPE_THERMOSTAT","$TYPE_VIBRATION_SENSOR","$TYPE_WARNING_DEVICE","$TYPE_WATER_LEAK_SENSOR","$TYPE_WINDOW_COVERING_DEVICE","$TYPE_ZGP_SWITCH","ZHAAirPurifier","ZHAAirQuality","ZHAAlarm","ZHABattery","Color dimmable light","Color light","Color temperature light","ZHAConsumption","Dimmable light","Dimmable plug-in unit","Dimmer switch","Door lock controller","Door Lock","Extended color light","ZHAFire","ZHAHumidity","ZHALightLevel","On/Off light","On/Off output","On/Off plug-in unit","ZHAOpenClose","ZHAPower","ZHAPresence","ZHAPressure","Range extender","ZHARelativeRotary","Smart plug","ZHASpectral","ZHASwitch","ZHATemperature","ZHAThermostat","ZHAVibration","Warning device","ZHAWater","Window covering device","ZGPSwitch","ZHAAncillaryControl","ZHATime","ZHACarbonMonoxide","ZHADoorLock"];function _(n=void 0){return n===void 0?i.string():i.string().length(2+n)}function R(){return i.string()}function $t(){return i.string()}function E(){return i.union([_(2),i.number().min(0).max(255)])}function j(){return i.string()}function Lt(){return i.custom(n=>{if(!Array.isArray(n)||n.length%2!==0)return!1;for(let e=0;e<n.length;e+=2){const t=n[e],r=n[e+1];if(typeof t!="number"||typeof r!="string")return!1}return!0},"The value must be an array with an even number of values and alternating between number and string.")}function Mt(n){return ke().parse(n)}function Dt(){return i.discriminatedUnion("schema",[ke().innerType()])}function ke(){return i.strictObject({schema:i.literal("devcap1.schema.json"),"doc:path":i.optional(i.string()),"doc:hdr":i.optional(i.string()),"md:known_issues":i.optional(i.array(i.string())),manufacturername:i.string().or(i.array(i.string())),modelid:i.string().or(i.array(i.string())),vendor:i.optional(i.string()),comment:i.optional(i.string()),matchexpr:i.optional(R()),path:i.optional(j()),product:i.optional(i.string()),sleeper:i.optional(i.boolean()),supportsMgmtBind:i.optional(i.boolean()),status:i.enum(["Draft","Bronze","Silver","Gold"]),subdevices:i.array(Pe()),bindings:i.optional(i.array($e()))}).refine(n=>typeof n.manufacturername=="string"&&typeof n.modelid=="string"||Array.isArray(n.manufacturername)&&Array.isArray(n.modelid)&&n.manufacturername.length===n.modelid.length,{message:"manufacturername and modelid should be both strings or arrays with the same length.",path:["manufacturername","modelid"]})}function Pe(){return i.strictObject({type:i.enum(jt),restapi:i.enum(["/lights","/sensors"]),uuid:i.union([i.tuple([i.literal("$address.ext"),_(2)]),i.tuple([i.literal("$address.ext"),_(2),_(4)])]),fingerprint:i.optional(i.strictObject({profile:_(4),device:_(4),endpoint:E(),in:i.optional(i.array(_(4))),out:i.optional(i.array(_(4)))})),meta:i.optional(i.strictObject({values:i.any(),"group.endpoints":i.optional(i.array(i.number()))})),buttons:i.optional(i.any()),buttonevents:i.optional(i.any()),items:i.array(je()),example:i.optional(i.unknown())})}function je(){return i.strictObject({name:i.string(),description:i.optional(i.string()),comment:i.optional(i.string()),public:i.optional(i.boolean()),static:i.optional(i.union([i.string(),i.number(),i.boolean()])),range:i.optional(i.tuple([i.number(),i.number()])),deprecated:i.optional($t()),access:i.optional(i.literal("R")),read:i.optional(i.discriminatedUnion("fn",[i.strictObject({fn:i.literal("none")}),i.strictObject({fn:i.undefined(),at:i.optional(_(4).or(i.array(_(4)))),cl:_(4),ep:i.optional(E()),mf:i.optional(_(4)),eval:i.optional(R())}),i.strictObject({fn:i.literal("zcl"),at:i.optional(_(4).or(i.array(_(4)))),cl:_(4),ep:i.optional(E()),mf:i.optional(_(4)),eval:i.optional(R())}),i.strictObject({fn:i.literal("tuya")})])),parse:i.optional(i.discriminatedUnion("fn",[i.strictObject({fn:i.undefined(),at:i.optional(_(4)),cl:_(4),ep:i.optional(E()),cmd:i.optional(_(2)),mf:i.optional(_(4)),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),i.strictObject({fn:i.literal("zcl"),at:i.optional(_(4)),cl:_(4),ep:i.optional(E()),cmd:i.optional(_(2)),mf:i.optional(_(4)),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),i.strictObject({fn:i.literal("ias:zonestatus"),mask:i.enum(["alarm1","alarm2"])}),i.strictObject({fn:i.literal("numtostr"),srcitem:i.enum(["state/airqualityppb","state/pm2_5"]),op:i.literal("le"),to:Lt()}),i.strictObject({fn:i.literal("xiaomi:special"),ep:i.optional(E()),at:i.optional(_(4)),idx:_(2),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),i.strictObject({fn:i.literal("tuya"),dpid:i.number(),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType()])),write:i.optional(i.discriminatedUnion("fn",[i.strictObject({fn:i.literal("none")}),i.strictObject({fn:i.undefined(),at:i.optional(_(4).or(i.array(_(4)))),"state.timeout":i.optional(i.number()),"change.timeout":i.optional(i.number()),cl:_(4),dt:_(2),ep:i.optional(E()),mf:i.optional(_(4)),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),i.strictObject({fn:i.literal("zcl"),at:i.optional(_(4).or(i.array(_(4)))),"state.timeout":i.optional(i.number()),"change.timeout":i.optional(i.number()),cl:_(4),dt:_(2),ep:i.optional(E()),mf:i.optional(_(4)),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),i.strictObject({fn:i.literal("tuya"),dpid:i.number(),dt:_(2),eval:i.optional(R()),script:i.optional(j())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType()])),awake:i.optional(i.boolean()),default:i.optional(i.unknown()),values:i.optional(i.unknown()),"refresh.interval":i.optional(i.number())})}function $e(){return i.discriminatedUnion("bind",[i.strictObject({bind:i.literal("unicast"),"src.ep":E(),"dst.ep":i.optional(E()),cl:_(4),report:i.optional(i.array(i.strictObject({at:_(4),dt:_(2),mf:i.optional(_(4)),min:i.number(),max:i.number(),change:i.optional(_().or(i.number()))})))}),i.strictObject({bind:i.literal("groupcast"),"src.ep":E(),cl:_(4),"config.group":i.number()})])}exports.ddfSchema=ke;exports.mainSchema=Dt;exports.subBindingSchema=$e;exports.subDeviceItemSchema=je;exports.subDeviceSchema=Pe;exports.validate=Mt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),m=["$TYPE_AIR_PURIFIER","$TYPE_AIR_QUALITY_SENSOR","$TYPE_ALARM_SENSOR","$TYPE_BATTERY_SENSOR","$TYPE_COLOR_DIMMABLE_LIGHT","$TYPE_COLOR_LIGHT","$TYPE_COLOR_TEMPERATURE_LIGHT","$TYPE_CONSUMPTION_SENSOR","$TYPE_DIMMABLE_LIGHT","$TYPE_DIMMABLE_PLUGIN_UNIT","$TYPE_DIMMER_SWITCH","$TYPE_DOOR_LOCK_CONTROLLER","$TYPE_DOOR_LOCK","$TYPE_EXTENDED_COLOR_LIGHT","$TYPE_FIRE_SENSOR","$TYPE_HUMIDITY_SENSOR","$TYPE_LIGHT_LEVEL_SENSOR","$TYPE_ON_OFF_LIGHT","$TYPE_ON_OFF_OUTPUT","$TYPE_ON_OFF_PLUGIN_UNIT","$TYPE_OPEN_CLOSE_SENSOR","$TYPE_POWER_SENSOR","$TYPE_PRESENCE_SENSOR","$TYPE_PRESSURE_SENSOR","$TYPE_RANGE_EXTENDER","$TYPE_RELATIVE_ROTARY","$TYPE_SMART_PLUG","$TYPE_SPECTRAL_SENSOR","$TYPE_SWITCH","$TYPE_TEMPERATURE_SENSOR","$TYPE_THERMOSTAT","$TYPE_VIBRATION_SENSOR","$TYPE_WARNING_DEVICE","$TYPE_WATER_LEAK_SENSOR","$TYPE_WINDOW_COVERING_DEVICE","$TYPE_ZGP_SWITCH","ZHAAirPurifier","ZHAAirQuality","ZHAAlarm","ZHABattery","Color dimmable light","Color light","Color temperature light","ZHAConsumption","Dimmable light","Dimmable plug-in unit","Dimmer switch","Door lock controller","Door Lock","Extended color light","ZHAFire","ZHAHumidity","ZHALightLevel","On/Off light","On/Off output","On/Off plug-in unit","ZHAOpenClose","ZHAPower","ZHAPresence","ZHAPressure","Range extender","ZHARelativeRotary","Smart plug","ZHASpectral","ZHASwitch","ZHATemperature","ZHAThermostat","ZHAVibration","Warning device","ZHAWater","Window covering device","ZGPSwitch","ZHAAncillaryControl","ZHATime","ZHACarbonMonoxide","ZHADoorLock"];function e(n=void 0){return n===void 0?t.z.string():t.z.string().length(2+n)}function o(){return t.z.string()}function d(){return t.z.string()}function i(){return t.z.union([e(2),t.z.number().min(0).max(255)])}function r(){return t.z.string()}function E(){return t.z.custom(n=>{if(!Array.isArray(n)||n.length%2!==0)return!1;for(let a=0;a<n.length;a+=2){const c=n[a],u=n[a+1];if(typeof c!="number"||typeof u!="string")return!1}return!0},"The value must be an array with an even number of values and alternating between number and string.")}function b(n){return l().parse(n)}function T(){return t.z.discriminatedUnion("schema",[l().innerType()])}function l(){return t.z.strictObject({schema:t.z.literal("devcap1.schema.json"),"doc:path":t.z.optional(t.z.string()),"doc:hdr":t.z.optional(t.z.string()),"md:known_issues":t.z.optional(t.z.array(t.z.string())),manufacturername:t.z.string().or(t.z.array(t.z.string())),modelid:t.z.string().or(t.z.array(t.z.string())),vendor:t.z.optional(t.z.string()),comment:t.z.optional(t.z.string()),matchexpr:t.z.optional(o()),path:t.z.optional(r()),product:t.z.optional(t.z.string()),sleeper:t.z.optional(t.z.boolean()),supportsMgmtBind:t.z.optional(t.z.boolean()),status:t.z.enum(["Draft","Bronze","Silver","Gold"]),subdevices:t.z.array(z()),bindings:t.z.optional(t.z.array(p()))}).refine(n=>typeof n.manufacturername=="string"&&typeof n.modelid=="string"||Array.isArray(n.manufacturername)&&Array.isArray(n.modelid)&&n.manufacturername.length===n.modelid.length,{message:"manufacturername and modelid should be both strings or arrays with the same length.",path:["manufacturername","modelid"]})}function z(){return t.z.strictObject({type:t.z.enum(m),restapi:t.z.enum(["/lights","/sensors"]),uuid:t.z.union([t.z.tuple([t.z.literal("$address.ext"),e(2)]),t.z.tuple([t.z.literal("$address.ext"),e(2),e(4)])]),fingerprint:t.z.optional(t.z.strictObject({profile:e(4),device:e(4),endpoint:i(),in:t.z.optional(t.z.array(e(4))),out:t.z.optional(t.z.array(e(4)))})),meta:t.z.optional(t.z.strictObject({values:t.z.any(),"group.endpoints":t.z.optional(t.z.array(t.z.number()))})),buttons:t.z.optional(t.z.any()),buttonevents:t.z.optional(t.z.any()),items:t.z.array(s()),example:t.z.optional(t.z.unknown())})}function s(){return t.z.strictObject({name:t.z.string(),description:t.z.optional(t.z.string()),comment:t.z.optional(t.z.string()),public:t.z.optional(t.z.boolean()),static:t.z.optional(t.z.union([t.z.string(),t.z.number(),t.z.boolean()])),range:t.z.optional(t.z.tuple([t.z.number(),t.z.number()])),deprecated:t.z.optional(d()),access:t.z.optional(t.z.literal("R")),read:t.z.optional(t.z.discriminatedUnion("fn",[t.z.strictObject({fn:t.z.literal("none")}),t.z.strictObject({fn:t.z.undefined(),at:t.z.optional(e(4).or(t.z.array(e(4)))),cl:e(4),ep:t.z.optional(i()),mf:t.z.optional(e(4)),eval:t.z.optional(o())}),t.z.strictObject({fn:t.z.literal("zcl"),at:t.z.optional(e(4).or(t.z.array(e(4)))),cl:e(4),ep:t.z.optional(i()),mf:t.z.optional(e(4)),eval:t.z.optional(o())}),t.z.strictObject({fn:t.z.literal("tuya")})])),parse:t.z.optional(t.z.discriminatedUnion("fn",[t.z.strictObject({fn:t.z.undefined(),at:t.z.optional(e(4)),cl:e(4),ep:t.z.optional(i()),cmd:t.z.optional(e(2)),mf:t.z.optional(e(4)),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),t.z.strictObject({fn:t.z.literal("zcl"),at:t.z.optional(e(4)),cl:e(4),ep:t.z.optional(i()),cmd:t.z.optional(e(2)),mf:t.z.optional(e(4)),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),t.z.strictObject({fn:t.z.literal("ias:zonestatus"),mask:t.z.enum(["alarm1","alarm2"])}),t.z.strictObject({fn:t.z.literal("numtostr"),srcitem:t.z.enum(["state/airqualityppb","state/pm2_5"]),op:t.z.literal("le"),to:E()}),t.z.strictObject({fn:t.z.literal("xiaomi:special"),ep:t.z.optional(i()),at:t.z.optional(e(4)),idx:e(2),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),t.z.strictObject({fn:t.z.literal("tuya"),dpid:t.z.number(),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType()])),write:t.z.optional(t.z.discriminatedUnion("fn",[t.z.strictObject({fn:t.z.literal("none")}),t.z.strictObject({fn:t.z.undefined(),at:t.z.optional(e(4).or(t.z.array(e(4)))),"state.timeout":t.z.optional(t.z.number()),"change.timeout":t.z.optional(t.z.number()),cl:e(4),dt:e(2),ep:t.z.optional(i()),mf:t.z.optional(e(4)),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),t.z.strictObject({fn:t.z.literal("zcl"),at:t.z.optional(e(4).or(t.z.array(e(4)))),"state.timeout":t.z.optional(t.z.number()),"change.timeout":t.z.optional(t.z.number()),cl:e(4),dt:e(2),ep:t.z.optional(i()),mf:t.z.optional(e(4)),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType(),t.z.strictObject({fn:t.z.literal("tuya"),dpid:t.z.number(),dt:e(2),eval:t.z.optional(o()),script:t.z.optional(r())}).refine(n=>!("eval"in n&&"script"in n),{message:"eval and script should not both be present"}).innerType()])),awake:t.z.optional(t.z.boolean()),default:t.z.optional(t.z.unknown()),values:t.z.optional(t.z.unknown()),"refresh.interval":t.z.optional(t.z.number())})}function p(){return t.z.discriminatedUnion("bind",[t.z.strictObject({bind:t.z.literal("unicast"),"src.ep":i(),"dst.ep":t.z.optional(i()),cl:e(4),report:t.z.optional(t.z.array(t.z.strictObject({at:e(4),dt:e(2),mf:t.z.optional(e(4)),min:t.z.number(),max:t.z.number(),change:t.z.optional(e().or(t.z.number()))})))}),t.z.strictObject({bind:t.z.literal("groupcast"),"src.ep":i(),cl:e(4),"config.group":t.z.number()})])}exports.ddfSchema=l;exports.mainSchema=T;exports.subBindingSchema=p;exports.subDeviceItemSchema=s;exports.subDeviceSchema=z;exports.validate=b;
|