2 lines
68 KiB
JavaScript
2 lines
68 KiB
JavaScript
function e(e,t,n,a){return new(n||(n=Promise))((function(s,i){function r(e){try{d(a.next(e))}catch(e){i(e)}}function o(e){try{d(a.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,o)}d((a=a.apply(e,t||[])).next())}))}function t(e,t,n,a){if("a"===n&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?a:"a"===n?a.call(e):a?a.value:t.get(e)}function n(e,t,n,a,s){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?s.call(e,n):s?s.value=n:t.set(e,n),n}var a,s;"function"==typeof SuppressedError&&SuppressedError,function(e){e.assertEqual=e=>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]])),a={};for(const e of n)a[e]=t[e];return e.objectValues(a)},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&&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}(a||(a={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(s||(s={}));const i=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=e=>{switch(typeof e){case"undefined":return i.undefined;case"string":return i.string;case"number":return isNaN(e)?i.nan:i.number;case"boolean":return i.boolean;case"function":return i.function;case"bigint":return i.bigint;case"symbol":return i.symbol;case"object":return Array.isArray(e)?i.array:null===e?i.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?i.promise:"undefined"!=typeof Map&&e instanceof Map?i.map:"undefined"!=typeof Set&&e instanceof Set?i.set:"undefined"!=typeof Date&&e instanceof Date?i.date:i.object;default:return i.unknown}},o=a.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 d extends Error{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}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},a=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(a);else if("invalid_return_type"===s.code)a(s.returnTypeError);else if("invalid_arguments"===s.code)a(s.argumentsError);else if(0===s.path.length)n._errors.push(t(s));else{let e=n,a=0;for(;a<s.path.length;){const n=s.path[a];a===s.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(s))):e[n]=e[n]||{_errors:[]},e=e[n],a++}}};return a(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}d.create=e=>new d(e);const c=(e,t)=>{let n;switch(e.code){case o.invalid_type:n=e.received===i.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,a.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:n=`Unrecognized key(s) in object: ${a.joinValues(e.keys,", ")}`;break;case o.invalid_union:n="Invalid input";break;case o.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${a.joinValues(e.options)}`;break;case o.invalid_enum_value:n=`Invalid enum value. Expected ${a.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:n="Invalid function arguments";break;case o.invalid_return_type:n="Invalid function return type";break;case o.invalid_date:n="Invalid date";break;case o.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}"`:a.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.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?`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 o.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 o.custom:n="Invalid input";break;case o.invalid_intersection_types:n="Intersection results could not be merged";break;case o.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:n="Number must be finite";break;default:n=t.defaultError,a.assertNever(e)}return{message:n}};let l=c;function u(){return l}const h=e=>{const{data:t,path:n,errorMaps:a,issueData:s}=e,i=[...n,...s.path||[]],r={...s,path:i};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(r,{data:t,defaultError:o}).message;return{...s,path:i,message:s.message||o}};function p(e,t){const n=h({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,u(),c].filter((e=>!!e))});e.common.issues.push(n)}class f{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 a of t){if("aborted"===a.status)return m;"dirty"===a.status&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t)n.push({key:await e.key,value:await e.value});return f.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const a of t){const{key:t,value:s}=a;if("aborted"===t.status)return m;if("aborted"===s.status)return m;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!a.alwaysSet||(n[t.value]=s.value)}return{status:e.value,value:n}}}const m=Object.freeze({status:"aborted"}),v=e=>({status:"dirty",value:e}),g=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,_=e=>"dirty"===e.status,b=e=>"valid"===e.status,w=e=>"undefined"!=typeof Promise&&e instanceof Promise;var k;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(k||(k={}));class x{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}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 Z=(e,t)=>{if(b(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 d(e.common.issues);return this._error=t,this._error}}};function E(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:a,description:s}=e;if(t&&(n||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:s};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=a?a:t.defaultError}:{message:null!=n?n:t.defaultError},description:s}}class T{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new f,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(w(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const a={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},s=this._parseSync({data:e,path:a.path,parent:a});return Z(a,s)}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:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},a=this._parse({data:e,path:n.path,parent:n}),s=await(w(a)?a:Promise.resolve(a));return Z(n,s)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const s=e(t),i=()=>a.addIssue({code:o.custom,...n(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then((e=>!!e||(i(),!1))):!!s||(i(),!1)}))}refinement(e,t){return this._refinement(((n,a)=>!!e(n)||(a.addIssue("function"==typeof t?t(n,a):t),!1)))}_refinement(e){return new pe({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return fe.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this,this._def)}promise(){return he.create(this,this._def)}or(e){return H.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new pe({...E(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ve({...E(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new be({typeName:Ee.ZodBranded,type:this,...E(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ge({...E(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return we.create(this,e)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const N=/^c[^\s-]{8,}$/i,O=/^[a-z][a-z0-9]*$/,C=/[0-9A-HJKMNP-TV-Z]{26}/,S=/^[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,R=/^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,I=/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u,j=/^(((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=/^(([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})))$/;class P extends T{constructor(){super(...arguments),this._regex=(e,t,n)=>this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,...k.errToObj(n)}),this.nonempty=e=>this.min(1,k.errToObj(e)),this.trim=()=>new P({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new P({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new P({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==i.string){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.string,received:t.parsedType}),m}const t=new f;let n;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:o.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:o.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?p(n,{code:o.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&p(n,{code:o.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)R.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"email",code:o.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)I.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"emoji",code:o.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)S.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"uuid",code:o.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)N.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid",code:o.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)O.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid2",code:o.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)C.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ulid",code:o.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(a){n=this._getOrReturnCtx(e,n),p(n,{validation:"url",code:o.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"regex",code:o.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),p(n,{code:o.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:o.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:o.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){((d=i).precision?d.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${d.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${d.precision}}Z$`):0===d.precision?d.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$"):d.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$")).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:o.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else"ip"===i.kind?(s=e.data,("v4"!==(r=i.version)&&r||!j.test(s))&&("v6"!==r&&r||!A.test(s))&&(n=this._getOrReturnCtx(e,n),p(n,{validation:"ip",code:o.invalid_string,message:i.message}),t.dirty())):a.assertNever(i);var s,r,d;return{status:t.value,value:e.data}}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}datetime(e){var t;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,...k.errToObj(null==e?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...k.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===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 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 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 M(e,t){const n=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,s=n>a?n:a;return parseInt(e.toFixed(s).replace(".",""))%parseInt(t.toFixed(s).replace(".",""))/Math.pow(10,s)}P.create=e=>{var t;return new P({checks:[],typeName:Ee.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...E(e)})};class L extends T{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)!==i.number){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.number,received:t.parsedType}),m}let t;const n=new f;for(const s of this._def.checks)if("int"===s.kind)a.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:o.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty());else if("min"===s.kind){(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty())}else if("max"===s.kind){(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty())}else"multipleOf"===s.kind?0!==M(e.data,s.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_finite,message:s.message}),n.dirty()):a.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,n,a){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(a)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&a.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}L.create=e=>new L({checks:[],typeName:Ee.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...E(e)});class D extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==i.bigint){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.bigint,received:t.parsedType}),m}let t;const n=new f;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty())}else if("max"===s.kind){(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty())}else"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),p(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):a.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,n,a){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:k.toString(a)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}D.create=e=>{var t;return new D({checks:[],typeName:Ee.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...E(e)})};class $ extends T{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==i.boolean){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.boolean,received:t.parsedType}),m}return g(e.data)}}$.create=e=>new $({typeName:Ee.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...E(e)});class U extends T{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==i.date){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.date,received:t.parsedType}),m}if(isNaN(e.data.getTime())){return p(this._getOrReturnCtx(e),{code:o.invalid_date}),m}const t=new f;let n;for(const s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:o.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:o.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):a.assertNever(s);return{status:t.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:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}U.create=e=>new U({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ee.ZodDate,...E(e)});class V extends T{_parse(e){if(this._getType(e)!==i.symbol){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.symbol,received:t.parsedType}),m}return g(e.data)}}V.create=e=>new V({typeName:Ee.ZodSymbol,...E(e)});class z extends T{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.undefined,received:t.parsedType}),m}return g(e.data)}}z.create=e=>new z({typeName:Ee.ZodUndefined,...E(e)});class W extends T{_parse(e){if(this._getType(e)!==i.null){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.null,received:t.parsedType}),m}return g(e.data)}}W.create=e=>new W({typeName:Ee.ZodNull,...E(e)});class B extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return g(e.data)}}B.create=e=>new B({typeName:Ee.ZodAny,...E(e)});class K extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return g(e.data)}}K.create=e=>new K({typeName:Ee.ZodUnknown,...E(e)});class F extends T{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.never,received:t.parsedType}),m}}F.create=e=>new F({typeName:Ee.ZodNever,...E(e)});class q extends T{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.void,received:t.parsedType}),m}return g(e.data)}}q.create=e=>new q({typeName:Ee.ZodVoid,...E(e)});class J extends T{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==i.array)return p(t,{code:o.invalid_type,expected:i.array,received:t.parsedType}),m;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,s=t.data.length<a.exactLength.value;(e||s)&&(p(t,{code:e?o.too_big:o.too_small,minimum:s?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(p(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(p(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>a.type._parseAsync(new x(t,e,t.path,n))))).then((e=>f.mergeArray(n,e)));const s=[...t.data].map(((e,n)=>a.type._parseSync(new x(t,e,t.path,n))));return f.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new J({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new J({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new J({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}function G(e){if(e instanceof Y){const t={};for(const n in e.shape){const a=e.shape[n];t[n]=fe.create(G(a))}return new Y({...e._def,shape:()=>t})}return e instanceof J?new J({...e._def,type:G(e.element)}):e instanceof fe?fe.create(G(e.unwrap())):e instanceof me?me.create(G(e.unwrap())):e instanceof ne?ne.create(e.items.map((e=>G(e)))):e}J.create=(e,t)=>new J({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...E(t)});class Y extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=a.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==i.object){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.object,received:t.parsedType}),m}const{status:t,ctx:n}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),r=[];if(!(this._def.catchall instanceof F&&"strip"===this._def.unknownKeys))for(const e in n.data)s.includes(e)||r.push(e);const d=[];for(const e of s){const t=a[e],s=n.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new x(n,s,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof F){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)d.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)r.length>0&&(p(n,{code:o.unrecognized_keys,keys:r}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of r){const a=n.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new x(n,a,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const n=await t.key;e.push({key:n,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>f.mergeObjectSync(t,e))):f.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new Y({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var a,s,i,r;const o=null!==(i=null===(s=(a=this._def).errorMap)||void 0===s?void 0:s.call(a,t,n).message)&&void 0!==i?i:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(r=k.errToObj(e).message)&&void 0!==r?r:o}:{message:o}}}:{}})}strip(){return new Y({...this._def,unknownKeys:"strip"})}passthrough(){return new Y({...this._def,unknownKeys:"passthrough"})}extend(e){return new Y({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Y({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Y({...this._def,catchall:e})}pick(e){const t={};return a.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new Y({...this._def,shape:()=>t})}omit(e){const t={};return a.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new Y({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return a.objectKeys(this.shape).forEach((n=>{const a=this.shape[n];e&&!e[n]?t[n]=a:t[n]=a.optional()})),new Y({...this._def,shape:()=>t})}required(e){const t={};return a.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof fe;)e=e._def.innerType;t[n]=e}})),new Y({...this._def,shape:()=>t})}keyof(){return ce(a.objectKeys(this.shape))}}Y.create=(e,t)=>new Y({shape:()=>e,unknownKeys:"strip",catchall:F.create(),typeName:Ee.ZodObject,...E(t)}),Y.strictCreate=(e,t)=>new Y({shape:()=>e,unknownKeys:"strict",catchall:F.create(),typeName:Ee.ZodObject,...E(t)}),Y.lazycreate=(e,t)=>new Y({shape:e,unknownKeys:"strip",catchall:F.create(),typeName:Ee.ZodObject,...E(t)});class H extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map((e=>new d(e.ctx.common.issues)));return p(t,{code:o.invalid_union,unionErrors:n}),m}));{let e;const a=[];for(const s of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&a.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=a.map((e=>new d(e)));return p(t,{code:o.invalid_union,unionErrors:s}),m}}get options(){return this._def.options}}H.create=(e,t)=>new H({options:e,typeName:Ee.ZodUnion,...E(t)});const X=e=>e instanceof oe?X(e.schema):e instanceof pe?X(e.innerType()):e instanceof de?[e.value]:e instanceof le?e.options:e instanceof ue?Object.keys(e.enum):e instanceof ve?X(e._def.innerType):e instanceof z?[void 0]:e instanceof W?[null]:null;class Q extends T{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.object)return p(t,{code:o.invalid_type,expected:i.object,received:t.parsedType}),m;const n=this.discriminator,a=t.data[n],s=this.optionsMap.get(a);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const a=new Map;for(const n of t){const t=X(n.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of t){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,n)}}return new Q({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...E(n)})}}function ee(e,t){const n=r(e),s=r(t);if(e===t)return{valid:!0,data:e};if(n===i.object&&s===i.object){const n=a.objectKeys(t),s=a.objectKeys(e).filter((e=>-1!==n.indexOf(e))),i={...e,...t};for(const n of s){const a=ee(e[n],t[n]);if(!a.valid)return{valid:!1};i[n]=a.data}return{valid:!0,data:i}}if(n===i.array&&s===i.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let a=0;a<e.length;a++){const s=ee(e[a],t[a]);if(!s.valid)return{valid:!1};n.push(s.data)}return{valid:!0,data:n}}return n===i.date&&s===i.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class te extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=(e,a)=>{if(y(e)||y(a))return m;const s=ee(e.value,a.value);return s.valid?((_(e)||_(a))&&t.dirty(),{status:t.value,value:s.data}):(p(n,{code:o.invalid_intersection_types}),m)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}te.create=(e,t,n)=>new te({left:e,right:t,typeName:Ee.ZodIntersection,...E(n)});class ne extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.array)return p(n,{code:o.invalid_type,expected:i.array,received:n.parsedType}),m;if(n.data.length<this._def.items.length)return p(n,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new x(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(a).then((e=>f.mergeArray(t,e))):f.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ne({...this._def,rest:e})}}ne.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ne({items:e,typeName:Ee.ZodTuple,rest:null,...E(t)})};class ae extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.object)return p(n,{code:o.invalid_type,expected:i.object,received:n.parsedType}),m;const a=[],s=this._def.keyType,r=this._def.valueType;for(const e in n.data)a.push({key:s._parse(new x(n,e,n.path,e)),value:r._parse(new x(n,n.data[e],n.path,e))});return n.common.async?f.mergeObjectAsync(t,a):f.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,n){return new ae(t instanceof T?{keyType:e,valueType:t,typeName:Ee.ZodRecord,...E(n)}:{keyType:P.create(),valueType:e,typeName:Ee.ZodRecord,...E(t)})}}class se extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.map)return p(n,{code:o.invalid_type,expected:i.map,received:n.parsedType}),m;const a=this._def.keyType,s=this._def.valueType,r=[...n.data.entries()].map((([e,t],i)=>({key:a._parse(new x(n,e,n.path,[i,"key"])),value:s._parse(new x(n,t,n.path,[i,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of r){const a=await n.key,s=await n.value;if("aborted"===a.status||"aborted"===s.status)return m;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of r){const a=n.key,s=n.value;if("aborted"===a.status||"aborted"===s.status)return m;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}}}se.create=(e,t,n)=>new se({valueType:t,keyType:e,typeName:Ee.ZodMap,...E(n)});class ie extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.set)return p(n,{code:o.invalid_type,expected:i.set,received:n.parsedType}),m;const a=this._def;null!==a.minSize&&n.data.size<a.minSize.value&&(p(n,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&n.data.size>a.maxSize.value&&(p(n,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const s=this._def.valueType;function r(e){const n=new Set;for(const a of e){if("aborted"===a.status)return m;"dirty"===a.status&&t.dirty(),n.add(a.value)}return{status:t.value,value:n}}const d=[...n.data.values()].map(((e,t)=>s._parse(new x(n,e,n.path,t))));return n.common.async?Promise.all(d).then((e=>r(e))):r(d)}min(e,t){return new ie({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ie({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ie.create=(e,t)=>new ie({valueType:e,minSize:null,maxSize:null,typeName:Ee.ZodSet,...E(t)});class re extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.function)return p(t,{code:o.invalid_type,expected:i.function,received:t.parsedType}),m;function n(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,u(),c].filter((e=>!!e)),issueData:{code:o.invalid_arguments,argumentsError:n}})}function a(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,u(),c].filter((e=>!!e)),issueData:{code:o.invalid_return_type,returnTypeError:n}})}const s={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof he){const e=this;return g((async function(...t){const i=new d([]),o=await e._def.args.parseAsync(t,s).catch((e=>{throw i.addIssue(n(t,e)),i})),c=await Reflect.apply(r,this,o);return await e._def.returns._def.type.parseAsync(c,s).catch((e=>{throw i.addIssue(a(c,e)),i}))}))}{const e=this;return g((function(...t){const i=e._def.args.safeParse(t,s);if(!i.success)throw new d([n(t,i.error)]);const o=Reflect.apply(r,this,i.data),c=e._def.returns.safeParse(o,s);if(!c.success)throw new d([a(o,c.error)]);return c.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new re({...this._def,args:ne.create(e).rest(K.create())})}returns(e){return new re({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new re({args:e||ne.create([]).rest(K.create()),returns:t||K.create(),typeName:Ee.ZodFunction,...E(n)})}}class oe extends T{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})}}oe.create=(e,t)=>new oe({getter:e,typeName:Ee.ZodLazy,...E(t)});class de extends T{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ce(e,t){return new le({values:e,typeName:Ee.ZodEnum,...E(t)})}de.create=(e,t)=>new de({value:e,typeName:Ee.ZodLiteral,...E(t)});class le extends T{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:a.joinValues(n),received:t.parsedType,code:o.invalid_type}),m}if(-1===this._def.values.indexOf(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:o.invalid_enum_value,options:n}),m}return g(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 le.create(e)}exclude(e){return le.create(this.options.filter((t=>!e.includes(t))))}}le.create=ce;class ue extends T{_parse(e){const t=a.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==i.string&&n.parsedType!==i.number){const e=a.objectValues(t);return p(n,{expected:a.joinValues(e),received:n.parsedType,code:o.invalid_type}),m}if(-1===t.indexOf(e.data)){const e=a.objectValues(t);return p(n,{received:n.data,code:o.invalid_enum_value,options:e}),m}return g(e.data)}get enum(){return this._def.values}}ue.create=(e,t)=>new ue({values:e,typeName:Ee.ZodNativeEnum,...E(t)});class he extends T{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.promise&&!1===t.common.async)return p(t,{code:o.invalid_type,expected:i.promise,received:t.parsedType}),m;const n=t.parsedType===i.promise?t.data:Promise.resolve(t.data);return g(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}he.create=(e,t)=>new he({type:e,typeName:Ee.ZodPromise,...E(t)});class pe extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:e=>{p(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===s.type){const e=s.transform(n.data,i);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:n.path,parent:n}))):this._def.schema._parseSync({data:e,path:n.path,parent:n})}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===a.status?m:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?m:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===s.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!b(e))return e;const a=s.transform(e.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>b(e)?Promise.resolve(s.transform(e.value,i)).then((e=>({status:t.value,value:e}))):e))}a.assertNever(s)}}pe.create=(e,t,n)=>new pe({schema:e,typeName:Ee.ZodEffects,effect:t,...E(n)}),pe.createWithPreprocess=(e,t,n)=>new pe({schema:t,effect:{type:"preprocess",transform:e},typeName:Ee.ZodEffects,...E(n)});class fe extends T{_parse(e){return this._getType(e)===i.undefined?g(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fe.create=(e,t)=>new fe({innerType:e,typeName:Ee.ZodOptional,...E(t)});class me extends T{_parse(e){return this._getType(e)===i.null?g(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(e,t)=>new me({innerType:e,typeName:Ee.ZodNullable,...E(t)});class ve extends T{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===i.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ve.create=(e,t)=>new ve({innerType:e,typeName:Ee.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...E(t)});class ge extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return w(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new d(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new d(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ge.create=(e,t)=>new ge({innerType:e,typeName:Ee.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...E(t)});class ye extends T{_parse(e){if(this._getType(e)!==i.nan){const t=this._getOrReturnCtx(e);return p(t,{code:o.invalid_type,expected:i.nan,received:t.parsedType}),m}return{status:"valid",value:e.data}}}ye.create=e=>new ye({typeName:Ee.ZodNaN,...E(e)});const _e=Symbol("zod_brand");class be extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class we extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),v(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new we({in:e,out:t,typeName:Ee.ZodPipeline})}}class ke extends T{_parse(e){const t=this._def.innerType._parse(e);return b(t)&&(t.value=Object.freeze(t.value)),t}}ke.create=(e,t)=>new ke({innerType:e,typeName:Ee.ZodReadonly,...E(t)});const xe=(e,t={},n)=>e?B.create().superRefine(((a,s)=>{var i,r;if(!e(a)){const e="function"==typeof t?t(a):"string"==typeof t?{message:t}:t,o=null===(r=null!==(i=e.fatal)&&void 0!==i?i:n)||void 0===r||r,d="string"==typeof e?{message:e}:e;s.addIssue({code:"custom",...d,fatal:o})}})):B.create(),Ze={object:Y.lazycreate};var Ee;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ee||(Ee={}));const Te=P.create,Ne=L.create,Oe=ye.create,Ce=D.create,Se=$.create,Re=U.create,Ie=V.create,je=z.create,Ae=W.create,Pe=B.create,Me=K.create,Le=F.create,De=q.create,$e=J.create,Ue=Y.create,Ve=Y.strictCreate,ze=H.create,We=Q.create,Be=te.create,Ke=ne.create,Fe=ae.create,qe=se.create,Je=ie.create,Ge=re.create,Ye=oe.create,He=de.create,Xe=le.create,Qe=ue.create,et=he.create,tt=pe.create,nt=fe.create,at=me.create,st=pe.createWithPreprocess,it=we.create,rt={string:e=>P.create({...e,coerce:!0}),number:e=>L.create({...e,coerce:!0}),boolean:e=>$.create({...e,coerce:!0}),bigint:e=>D.create({...e,coerce:!0}),date:e=>U.create({...e,coerce:!0})},ot=m;var dt,ct,lt,ut,ht,pt,ft,mt,vt,gt,yt,_t,bt,wt,kt,xt,Zt,Et,Tt,Nt,Ot,Ct,St,Rt,It,jt,At,Pt,Mt,Lt=Object.freeze({__proto__:null,defaultErrorMap:c,setErrorMap:function(e){l=e},getErrorMap:u,makeIssue:h,EMPTY_PATH:[],addIssueToContext:p,ParseStatus:f,INVALID:m,DIRTY:v,OK:g,isAborted:y,isDirty:_,isValid:b,isAsync:w,get util(){return a},get objectUtil(){return s},ZodParsedType:i,getParsedType:r,ZodType:T,ZodString:P,ZodNumber:L,ZodBigInt:D,ZodBoolean:$,ZodDate:U,ZodSymbol:V,ZodUndefined:z,ZodNull:W,ZodAny:B,ZodUnknown:K,ZodNever:F,ZodVoid:q,ZodArray:J,ZodObject:Y,ZodUnion:H,ZodDiscriminatedUnion:Q,ZodIntersection:te,ZodTuple:ne,ZodRecord:ae,ZodMap:se,ZodSet:ie,ZodFunction:re,ZodLazy:oe,ZodLiteral:de,ZodEnum:le,ZodNativeEnum:ue,ZodPromise:he,ZodEffects:pe,ZodTransformer:pe,ZodOptional:fe,ZodNullable:me,ZodDefault:ve,ZodCatch:ge,ZodNaN:ye,BRAND:_e,ZodBranded:be,ZodPipeline:we,ZodReadonly:ke,custom:xe,Schema:T,ZodSchema:T,late:Ze,get ZodFirstPartyTypeKind(){return Ee},coerce:rt,any:Pe,array:$e,bigint:Ce,boolean:Se,date:Re,discriminatedUnion:We,effect:tt,enum:Xe,function:Ge,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>xe((t=>t instanceof e),t),intersection:Be,lazy:Ye,literal:He,map:qe,nan:Oe,nativeEnum:Qe,never:Le,null:Ae,nullable:at,number:Ne,object:Ue,oboolean:()=>Se().optional(),onumber:()=>Ne().optional(),optional:nt,ostring:()=>Te().optional(),pipeline:it,preprocess:st,promise:et,record:Fe,set:Je,strictObject:Ve,string:Te,symbol:Ie,transformer:tt,tuple:Ke,undefined:je,union:ze,unknown:Me,void:De,NEVER:ot,ZodIssueCode:o,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:d});console.info("%c↔️ Swipe navigation ↔️ - v1.13.2","color: #2980b9; font-weight: 700;");const Dt=["ha-tabs","hui-map-card",".ha-scrollbar","ha-sidebar","ha-slider","input[type=range]","#slider","better-thermostat-ui-card","big-slider-card","floor3d-card","gallery-card","#graph-wrapper svg.apexcharts-svg","history-explorer-card",".horizontal-buttons-stack-container","my-slider","my-slider-v2","mwc-tab-bar","#plotly g.draglayer",".range-slider","round-slider","sankey-chart","slider-button-card","swipe-card",".swiper","toucharea","xiaomi-vacuum-map-card","mushroom-slider","ha-bar-slider"].join(","),$t="↔️ Swipe navigation:";var Ut;function Vt(e){Kt(e,Ut.VERBOSE)}function zt(e){Kt(e,Ut.DEBUG)}function Wt(e){Kt(e,Ut.INFO)}function Bt(e){Kt(e,Ut.ERROR)}function Kt(e,t){if(t>=qt.current().getLoggerLevel()){let n;switch(t){case Ut.VERBOSE:n="[V]";break;case Ut.DEBUG:n="[D]";break;case Ut.INFO:n="[I]";break;case Ut.WARN:n="[W]";break;case Ut.ERROR:n="[E]";break;default:throw new Error(`Unhandled case: ${t}`)}const a=$t+" "+n+" "+e;t<Ut.ERROR?console.log(a):console.error(a)}}!function(e){e[e._ALL=0]="_ALL",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(Ut||(Ut={}));const Ft=Lt.object({animate:Lt.union([Lt.literal("none"),Lt.literal("swipe"),Lt.literal("fade"),Lt.literal("flip")]).optional(),animate_duration:Lt.number().optional(),enable:Lt.boolean().optional(),enable_mouse_swipe:Lt.boolean().optional(),logger_level:Lt.union([Lt.literal("verbose"),Lt.literal("debug"),Lt.literal("info"),Lt.literal("warn"),Lt.literal("error")]).optional(),prevent_default:Lt.boolean().optional(),skip_hidden:Lt.boolean().optional(),skip_tabs:Lt.coerce.string().optional(),swipe_amount:Lt.number().optional(),wrap:Lt.boolean().optional()});class qt{constructor(){this.animate="none",this.animate_duration=200,this.enable=!0,this.enable_mouse_swipe=!1,this.logger_level=Ut.WARN,this.prevent_default=!1,this.skip_hidden=!0,this.skip_tabs=[],this.swipe_amount=.15,this.wrap=!0}static current(){return qt.currentConfig}static readAndMonitorConfig(){return e(this,void 0,void 0,(function*(){Gt.huiRoot.watchChanges({onDomNodeRefreshedCallback:()=>{qt.readConfig()},onDomNodeRemovedCallback:null}),yield qt.readConfig()}))}static registerConfigObserver(e){qt.configObservers.push(e)}static unregisterConfigObserver(e){const t=qt.configObservers.indexOf(e);t>-1?qt.configObservers.splice(t,1):Bt("Internal error while unregistering a configObserver: not found.")}getAnimate(){return this.animate}getAnimateDuration(){return this.animate_duration}getEnable(){return this.enable}getEnableMouseSwipe(){return this.enable_mouse_swipe}getLoggerLevel(){return this.logger_level}getPreventDefault(){return this.prevent_default}getSkipHidden(){return this.skip_hidden}getSkipTabs(){return this.skip_tabs}getSwipeAmount(){return this.swipe_amount}getWrap(){return this.wrap}static readConfig(){return e(this,void 0,void 0,(function*(){zt("Attempting to read config...");const e=yield qt.getRawConfigOrNull();if(JSON.stringify(e)==JSON.stringify(qt.rawConfig))return void zt("Config is identical.");qt.rawConfig=e;const t=qt.parseConfig(e);null!=t&&(JSON.stringify(t)!=JSON.stringify(qt.currentConfig)?(qt.currentConfig=t,Wt("New configuration loaded."),qt.configObservers.forEach((e=>{e.callback()}))):zt("Config is equivalent."))}))}static parseConfig(e){if(t=e,!Ft.safeParse(t).success)return Bt("Found invalid configuration."),null;var t;const n=new qt;switch(null!=e.animate&&(n.animate=e.animate),null!=e.animate_duration&&(n.animate_duration=e.animate_duration),null!=e.enable&&(n.enable=e.enable),null!=e.enable_mouse_swipe&&(n.enable_mouse_swipe=e.enable_mouse_swipe),e.logger_level){case"verbose":n.logger_level=Ut.VERBOSE;break;case"debug":n.logger_level=Ut.DEBUG;break;case"info":n.logger_level=Ut.INFO;break;case"warn":n.logger_level=Ut.WARN;break;case"error":n.logger_level=Ut.ERROR;break;case null:case void 0:break;default:{const t=e.logger_level;throw new Error(`Unhandled case: ${t}`)}}return null!=e.prevent_default&&(n.prevent_default=e.prevent_default),null!=e.skip_hidden&&(n.skip_hidden=e.skip_hidden),null!=e.skip_tabs&&(n.skip_tabs=String(e.skip_tabs).replace(/\s+/g,"").split(",").map((e=>parseInt(e)))),null!=e.swipe_amount&&(n.swipe_amount=e.swipe_amount/100),null!=e.wrap&&(n.wrap=e.wrap),n}static getRawConfigOrNull(){var t,n,a,s;return e(this,void 0,void 0,(function*(){const e=new Date(Date.now()+15e3);let i=null;for(;null==i&&Date.now()<e.getTime();)null!=Gt.haPanelLovelace.getDomNode()&&(i=null!==(a=null===(n=null===(t=Gt.haPanelLovelace.getDomNode())||void 0===t?void 0:t.lovelace)||void 0===n?void 0:n.config)&&void 0!==a?a:null),null==i&&(yield new Promise((e=>setTimeout(e,1e3))));let r=null;return null!=i?r=null!==(s=i.swipe_nav)&&void 0!==s?s:{}:Bt("Can't find dashboard configuration"),r}))}}qt.currentConfig=new qt,qt.rawConfig=null,qt.configObservers=[];class Jt{constructor(e,t,a){dt.add(this),ct.set(this,null),lt.set(this,void 0),ut.set(this,void 0),ht.set(this,void 0),pt.set(this,!1),ft.set(this,null),mt.set(this,null),vt.set(this,new Map),n(this,lt,e,"f"),n(this,ut,t,"f"),n(this,ht,a,"f")}invalidateDomNode(){t(this,dt,"m",Zt).call(this),null!=t(this,mt,"f")&&t(this,mt,"f").call(this),n(this,ct,null,"f")}watchChanges(e){t(this,dt,"m",gt).call(this),n(this,ft,e.onDomNodeRefreshedCallback,"f"),n(this,mt,e.onDomNodeRemovedCallback,"f")}getDomNode(){return null==t(this,ct,"f")?t(this,dt,"m",wt).call(this):t(this,dt,"m",bt).call(this)&&(zt('Stale object in cache: "'+t(this,ct,"f").nodeName.toLowerCase()+'". Invalidating...'),this.invalidateDomNode(),this.getDomNode()),t(this,ct,"f")}getParentNode(){let e=t(this,lt,"f")instanceof Jt?t(this,lt,"f").getDomNode():t(this,lt,"f");return null!=e&&t(this,ht,"f")&&("shadowRoot"in e?e=e.shadowRoot:(Bt(e.nodeName+" is expected to have a shadowRoot, but it is missing."),e=null)),e}}ct=new WeakMap,lt=new WeakMap,ut=new WeakMap,ht=new WeakMap,pt=new WeakMap,ft=new WeakMap,mt=new WeakMap,vt=new WeakMap,dt=new WeakSet,gt=function(){t(this,pt,"f")||(n(this,pt,!0,"f"),t(this,dt,"m",yt).call(this))},yt=function(){var e;t(this,pt,"f")&&null!=t(this,lt,"f")&&t(this,lt,"f")instanceof Jt&&t(e=t(this,lt,"f"),dt,"m",_t).call(e,this)},_t=function(e){t(this,vt,"f").has(e)||(t(this,vt,"f").set(e,new MutationObserver((n=>{var a,s,i;for(const r of n)r.addedNodes.length>0&&(Vt(r.addedNodes.length+' new element(s) appeared under "'+(null!==(i=null===(s=null===(a=t(this,ct,"f"))||void 0===a?void 0:a.nodeName)||void 0===s?void 0:s.toLowerCase())&&void 0!==i?i:"unknown")+'". Checking...'),e.getDomNode())}))),t(this,dt,"m",gt).call(this),t(this,dt,"m",xt).call(this,e))},bt=function(){var e,n;return!(null!==(n=null===(e=t(this,ct,"f"))||void 0===e?void 0:e.isConnected)&&void 0!==n&&n)},wt=function(){var e,a,s;const i=this.getParentNode();n(this,ct,null==i?null:(()=>{for(const e of t(this,ut,"f")){const t=i.querySelector(e);if(null!=t&&t instanceof HTMLElement)return t}return null})(),"f"),null!=t(this,ct,"f")&&(zt('Object refreshed: "'+(null!==(s=null===(a=null===(e=t(this,ct,"f"))||void 0===e?void 0:e.nodeName)||void 0===a?void 0:a.toLowerCase())&&void 0!==s?s:"unknown")+'".'),t(this,dt,"m",yt).call(this),t(this,dt,"m",kt).call(this),null!=t(this,ft,"f")&&t(this,ft,"f").call(this))},kt=function(){var e,n,a;null!=t(this,ct,"f")&&t(this,vt,"f").size>0&&(Vt("Reconnecting "+t(this,vt,"f").size+" observers to "+(null!==(a=null===(n=null===(e=t(this,ct,"f"))||void 0===e?void 0:e.nodeName)||void 0===n?void 0:n.toLowerCase())&&void 0!==a?a:"unknown")),t(this,vt,"f").forEach(((e,n)=>{t(this,dt,"m",xt).call(this,n)})))},xt=function(e){if(null!=t(this,ct,"f")){const n=t(this,vt,"f").get(e),a=e.getParentNode();null==n?Bt("Illegal state: observer is not defined when connecting a child observer."):null==a?Bt("Illegal state: parent is not defined when connecting a child observer."):n.observe(a,{childList:!0}),e.getDomNode()}},Zt=function(){var e,n,a;t(this,vt,"f").size>0&&(Vt("Disconnecting "+t(this,vt,"f").size+' observers from "'+(null!==(a=null===(n=null===(e=t(this,ct,"f"))||void 0===e?void 0:e.nodeName)||void 0===n?void 0:n.toLowerCase())&&void 0!==a?a:"unknown")+'"'),t(this,vt,"f").forEach((e=>{e.disconnect()})))};class Gt{}Gt.ha=new Jt(document,["home-assistant"],!1),Gt.haMain=new Jt(Gt.ha,["home-assistant-main"],!0),Gt.partialPanelResolver=new Jt(Gt.haMain,["partial-panel-resolver"],!0),Gt.haPanelLovelace=new Jt(Gt.partialPanelResolver,["ha-panel-lovelace"],!1),Gt.huiRoot=new Jt(Gt.haPanelLovelace,["hui-root"],!0),Gt.haAppLayout=new Jt(Gt.huiRoot,[function(){var e,t,n;const a=(null===(n=null===(t=null===(e=document.getElementsByTagName("home-assistant")[0])||void 0===e?void 0:e.hass)||void 0===t?void 0:t.config)||void 0===n?void 0:n.version)||null;return null!=a&&function(e,t){const n=e.split("."),a=t.split(".");for(let e=0;e<a.length;e++){const t=~~a[e],s=~~n[e];if(t>s)return!0;if(t<s)return!1}return!1}(a,"2023.4")}()?"ha-app-layout":"div"],!0),Gt.haAppLayoutView=new Jt(Gt.haAppLayout,['[id="view"]'],!1),Gt.tabsContainer=new Jt(Gt.haAppLayout,["paper-tabs","ha-tabs"],!1);class Yt{static init(){var e;null===(e=t(this,Et,"f",St))||void 0===e||e.abort(),n(this,Et,new AbortController,"f",St),Gt.haAppLayout.watchChanges({onDomNodeRefreshedCallback:()=>{Yt.init()},onDomNodeRemovedCallback:null});const a=Gt.haAppLayout.getDomNode();null!=a&&(zt("Initializing SwipeManger..."),a.addEventListener("touchstart",(e=>{t(this,Et,"m",Rt).call(this,e)}),{signal:t(this,Et,"f",St).signal,passive:!0}),a.addEventListener("touchmove",(e=>{t(this,Et,"m",It).call(this,e)}),{signal:t(this,Et,"f",St).signal,passive:!1}),a.addEventListener("touchend",(()=>{t(this,Et,"m",jt).call(this)}),{signal:t(this,Et,"f",St).signal,passive:!0}),a.addEventListener("mousedown",(e=>{t(this,Et,"m",Rt).call(this,e)}),{signal:t(this,Et,"f",St).signal,passive:!0}),qt.current().getEnableMouseSwipe()&&(a.addEventListener("mousemove",(e=>{t(this,Et,"m",It).call(this,e)}),{signal:t(this,Et,"f",St).signal,passive:!1}),a.addEventListener("mouseup",(()=>{t(this,Et,"m",jt).call(this)}),{signal:t(this,Et,"f",St).signal,passive:!0})))}}Et=Yt,Rt=function(e){let t;if(null!=window.TouchEvent&&e instanceof TouchEvent)t="touch";else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}t="click"}if(0!=qt.current().getEnable()){if(null!=window.TouchEvent&&e instanceof TouchEvent&&e.touches.length>1)return n(this,Et,null,"f",Tt),n(this,Et,null,"f",Nt),void zt("Ignoring "+t+": multiple touchpoints detected.");if(e instanceof MouseEvent&&!qt.current().getEnableMouseSwipe())return n(this,Et,null,"f",Tt),n(this,Et,null,"f",Nt),void zt("Ignoring "+t+": swiping via mouse is disabled.");if("object"==typeof e.composedPath())for(const n of e.composedPath())if(n instanceof Element){if("HUI-VIEW"==n.nodeName)break;if(n.matches&&n.matches(Dt))return void zt("Ignoring "+t+' on "'+(null!=n.nodeName?n.nodeName.toLowerCase():"unknown")+'".')}if(null!=window.TouchEvent&&e instanceof TouchEvent)n(this,Et,e.touches[0].clientX,"f",Tt),n(this,Et,e.touches[0].clientY,"f",Nt);else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}n(this,Et,e.clientX,"f",Tt),n(this,Et,e.clientY,"f",Nt)}}else zt("Ignoring "+t+": Swipe navigation is disabled in the config.")},It=function(e){if(t(this,Et,"f",Tt)&&t(this,Et,"f",Nt)){if(null!=window.TouchEvent&&e instanceof TouchEvent)n(this,Et,t(this,Et,"f",Tt)-e.touches[0].clientX,"f",Ot),n(this,Et,t(this,Et,"f",Nt)-e.touches[0].clientY,"f",Ct);else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}n(this,Et,t(this,Et,"f",Tt)-e.clientX,"f",Ot),n(this,Et,t(this,Et,"f",Nt)-e.clientY,"f",Ct)}Math.abs(t(this,Et,"f",Ot))>Math.abs(t(this,Et,"f",Ct))&&qt.current().getPreventDefault()&&e.preventDefault()}},jt=function(){var e;if(null!=t(this,Et,"f",Ot)&&null!=t(this,Et,"f",Ct))if(Math.abs(t(this,Et,"f",Ot))<Math.abs(t(this,Et,"f",Ct)))zt("Swipe ignored, vertical movement.");else if(Math.abs(t(this,Et,"f",Ot))<Math.abs(screen.width*qt.current().getSwipeAmount()))zt("Swipe ignored, too short.");else{const n=t(this,Et,"f",Ot)<0;Wt("Swipe detected, changing tab to the "+(n?"left":"right")+".");const a="rtl"==(null===(e=Gt.ha.getDomNode())||void 0===e?void 0:e.style.direction),s=t(this,Et,"m",Pt).call(this,a?!n:n);s>=0&&t(this,Et,"m",Mt).call(this,s,n)}n(this,Et,n(this,Et,n(this,Et,n(this,Et,null,"f",Ct),"f",Ot),"f",Nt),"f",Tt)},At=function(){var e,t;return Array.from(null!==(t=null===(e=Gt.tabsContainer.getDomNode())||void 0===e?void 0:e.querySelectorAll("paper-tab"))&&void 0!==t?t:[])},Pt=function(e){var n;const a=t(this,Et,"m",At).call(this),s=null===(n=Gt.tabsContainer.getDomNode())||void 0===n?void 0:n.querySelector(".iron-selected"),i=null!=s?a.indexOf(s):-1;let r=i,o=null;if(-1==i)o="Can't determine the active tab";else{const t=e?-1:1;do{r+=t,-1==r?r=qt.current().getWrap()?a.length-1:-1:r==a.length&&(r=qt.current().getWrap()?0:-1),r==i?o="Error, no viable tabs found for swiping.":-1==r&&(o="Edge has been reached and wrap is disabled.")}while(null==o&&(qt.current().getSkipTabs().includes(r)||qt.current().getSkipHidden()&&"none"==getComputedStyle(a[r],null).display))}return null!=o?(Kt(o,Ut.WARN),-1):r},Mt=function(e,n){if(e<0)Bt("Invalid tab index: "+e+".");else{const a=Gt.haAppLayoutView.getDomNode(),s=t(this,Et,"m",At).call(this);if(null==a)Bt("view is null when attempting to change tab.");else{const t=qt.current().getAnimate();if("none"==t)s[e].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!0}));else{const i=qt.current().getAnimateDuration();if(a.style.transition=`transform ${i}ms ease-in, opacity ${i}ms ease-in`,"swipe"==t){const t=Gt.haAppLayout.getDomNode();null!=t&&(t.style.overflow="hidden");const r=n?screen.width/2+"px":`-${screen.width/2}px`,o=n?`-${screen.width/2}px`:screen.width/2+"px";a.style.opacity="0",a.style.transform=`translate(${r}, 0)`,setTimeout((function(){a.style.transition="",a.style.transform=`translate(${o}, 0)`,s[e].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!0}))}),i+10)}else if("fade"==t)a.style.opacity="0",setTimeout((function(){a.style.transition="",s[e].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!0})),a.style.opacity="0"}),i+10);else{if("flip"!=t){throw new Error(`Unhandled case: ${t}`)}a.style.transform="rotatey(90deg)",a.style.opacity="0.25",setTimeout((function(){a.style.transition="",s[e].dispatchEvent(new MouseEvent("click",{bubbles:!1,cancelable:!0}))}),i+10)}setTimeout((function(){a.style.transition=`transform ${i}ms ease-out, opacity ${i}ms ease-out`,a.style.opacity="1",a.style.transform=""}),i+50),"swipe"==t&&setTimeout((function(){const e=Gt.haAppLayout.getDomNode();null!=e&&(e.style.overflow="")}),2*i+100)}}}},Tt={value:void 0},Nt={value:void 0},Ot={value:void 0},Ct={value:void 0},St={value:null},function(){e(this,void 0,void 0,(function*(){yield qt.readAndMonitorConfig(),Yt.init()}))}();
|