2 lines
81 KiB
JavaScript
2 lines
81 KiB
JavaScript
function e(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((o=o.apply(e,t||[])).next())})}function t(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function n(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}var o;"function"==typeof SuppressedError&&SuppressedError,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"}(o||(o={}));class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}static setLoggerLevel(e){i.loggerLevel=e}static getLoggerLevel(){return i.loggerLevel}static logv(e,t){i.log(e,t,o.VERBOSE)}static logd(e,t){i.log(e,t,o.DEBUG)}static logi(e,t){i.log(e,t,o.INFO)}static logw(e,t){i.log(e,t,o.WARN)}static loge(e,t){i.log(e,t,o.ERROR)}static log(e,t,n){if(n>=this.loggerLevel){let i;switch(n){case o.VERBOSE:i="[V]";break;case o.DEBUG:i="[D]";break;case o.INFO:i="[I]";break;case o.WARN:i="[W]";break;case o.ERROR:i="[E]";break;default:throw new Error(`Unhandled case: ${n}`)}const r=e+" "+i+" "+t;n<o.ERROR?console.log(r):console.error(r)}}}i.loggerLevel=o._ALL;const r="↔️ Swipe navigation:";function s(e,t,n){function o(n,o){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:o,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,o);const i=s.prototype,r=Object.keys(i);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class r extends i{}function s(e){var t;const i=n?.Parent?new r:this;o(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const e of i._zod.deferred)e();return i}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class c extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const u={};function l(e){return u}function d(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function f(e,t){return"bigint"==typeof t?t.toString():t}function p(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function h(e){return null==e}function m(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const g=Symbol("evaluating");function v(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==g)return void 0===o&&(o=g,o=n()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function _(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function y(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function w(e){return JSON.stringify(e)}const b="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function z(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const k=p(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function $(e){if(!1===z(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==z(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function O(e){return $(e)?{...e}:Array.isArray(e)?[...e]:e}const S=new Set(["string","number","symbol"]);function N(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E(e,t,n){const o=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(o._zod.parent=e),o}function x(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const T={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function P(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function I(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function A(e){return"string"==typeof e?e:e?.message}function Z(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const i=A(e.inst?._zod.def?.error?.(e))??A(t?.error?.(e))??A(n.customError?.(e))??A(n.localeError?.(e))??"Invalid input";o.message=i}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function C(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function j(...e){const[t,n,o]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:o}:{...t}}const R=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,f,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},D=s("$ZodError",R),F=s("$ZodError",R,{Parent:Error});const L=e=>(t,n,o,i)=>{const r=o?Object.assign(o,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new a;if(s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>Z(e,r,l())));throw b(t,i?.callee),t}return s.value},M=e=>async(t,n,o,i)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>Z(e,r,l())));throw b(t,i?.callee),t}return s.value},J=e=>(t,n,o)=>{const i=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},i);if(r instanceof Promise)throw new a;return r.issues.length?{success:!1,error:new(e??D)(r.issues.map(e=>Z(e,i,l())))}:{success:!0,data:r.value}},U=J(F),V=e=>async(t,n,o)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>Z(e,i,l())))}:{success:!0,data:r.value}},W=V(F),B=e=>(t,n,o)=>{const i=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return L(e)(t,n,i)},G=e=>(t,n,o)=>L(e)(t,n,o),Y=e=>async(t,n,o)=>{const i=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return M(e)(t,n,i)},H=e=>async(t,n,o)=>M(e)(t,n,o),X=e=>(t,n,o)=>{const i=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return J(e)(t,n,i)},K=e=>(t,n,o)=>J(e)(t,n,o),q=e=>async(t,n,o)=>{const i=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return V(e)(t,n,i)},Q=e=>async(t,n,o)=>V(e)(t,n,o),ee=/^[cC][^\s-]{8,}$/,te=/^[0-9a-z]+$/,ne=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,oe=/^[0-9a-vA-V]{20}$/,ie=/^[A-Za-z0-9]{27}$/,re=/^[a-zA-Z0-9_-]{21}$/,se=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ae=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ce=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ue=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const le=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,de=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,fe=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,pe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,he=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,me=/^[A-Za-z0-9_-]*$/,ge=/^\+[1-9]\d{6,14}$/,ve="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",_e=new RegExp(`^${ve}$`);function ye(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const we=/^-?\d+$/,be=/^-?\d+(?:\.\d+)?$/,ze=/^(?:true|false)$/i,ke=/^[^A-Z]*$/,$e=/^[^a-z]*$/,Oe=s("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Se={number:"number",bigint:"bigint",object:"date"},Ne=s("$ZodCheckLessThan",(e,t)=>{Oe.init(e,t);const n=Se[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ee=s("$ZodCheckGreaterThan",(e,t)=>{Oe.init(e,t);const n=Se[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xe=s("$ZodCheckMultipleOf",(e,t)=>{Oe.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let i=(o.split(".")[1]||"").length;if(0===i&&/\d?e-\d?/.test(o)){const e=o.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}const r=n>i?n:i;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Te=s("$ZodCheckNumberFormat",(e,t)=>{Oe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[i,r]=T[t.format];e._zod.onattach.push(e=>{const o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=r,n&&(o.pattern=we)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>r&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Pe=s("$ZodCheckMaxLength",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!h(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=C(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ie=s("$ZodCheckMinLength",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!h(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=C(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ae=s("$ZodCheckLengthEquals",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!h(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const r=C(o),s=i>t.length;n.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ze=s("$ZodCheckStringFormat",(e,t)=>{var n,o;Oe.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Ce=s("$ZodCheckRegex",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),je=s("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ke),Ze.init(e,t)}),Re=s("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$e),Ze.init(e,t)}),De=s("$ZodCheckIncludes",(e,t)=>{Oe.init(e,t);const n=N(t.includes),o=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Fe=s("$ZodCheckStartsWith",(e,t)=>{Oe.init(e,t);const n=new RegExp(`^${N(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Le=s("$ZodCheckEndsWith",(e,t)=>{Oe.init(e,t);const n=new RegExp(`.*${N(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Me=s("$ZodCheckOverwrite",(e,t)=>{Oe.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Je{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),o=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of o)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Ue={major:4,minor:3,patch:6},Ve=s("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ue;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const t of o)for(const n of t._zod.onattach)n(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let o,i=P(e);for(const r of t){if(r._zod.def.when){if(!r._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,s=r._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new a;if(o||s instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await s;e.issues.length!==t&&(i||(i=P(e,t)))});else{if(e.issues.length===t)continue;i||(i=P(e,t))}}return o?o.then(()=>e):e},n=(n,i,r)=>{if(P(n))return n.aborted=!0,n;const s=t(i,o,r);if(s instanceof Promise){if(!1===r.async)throw new a;return s.then(t=>e._zod.parse(t,r))}return e._zod.parse(s,r)};e._zod.run=(i,r)=>{if(r.skipChecks)return e._zod.parse(i,r);if("backward"===r.direction){const t=e._zod.parse({value:i.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,r)):n(t,i,r)}const s=e._zod.parse(i,r);if(s instanceof Promise){if(!1===r.async)throw new a;return s.then(e=>t(e,o,r))}return t(s,o,r)}}v(e,"~standard",()=>({validate:t=>{try{const n=U(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return W(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),We=s("$ZodString",(e,t)=>{var n;Ve.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Be=s("$ZodStringFormat",(e,t)=>{Ze.init(e,t),We.init(e,t)}),Ge=s("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ae),Be.init(e,t)}),Ye=s("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ce(e))}else t.pattern??(t.pattern=ce());Be.init(e,t)}),He=s("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ue),Be.init(e,t)}),Xe=s("$ZodURL",(e,t)=>{Be.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),i=new URL(o);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=o)}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ke=s("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Be.init(e,t)}),qe=s("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=re),Be.init(e,t)}),Qe=s("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ee),Be.init(e,t)}),et=s("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=te),Be.init(e,t)}),tt=s("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ne),Be.init(e,t)}),nt=s("$ZodXID",(e,t)=>{t.pattern??(t.pattern=oe),Be.init(e,t)}),ot=s("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ie),Be.init(e,t)}),it=s("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=ye({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${ve}T(?:${o})$`)}(t)),Be.init(e,t)}),rt=s("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=_e),Be.init(e,t)}),st=s("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ye(t)}$`)),Be.init(e,t)}),at=s("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=se),Be.init(e,t)}),ct=s("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=le),Be.init(e,t),e._zod.bag.format="ipv4"}),ut=s("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=de),Be.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),lt=s("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=fe),Be.init(e,t)}),dt=s("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=pe),Be.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(2!==o.length)throw new Error;const[e,t]=o;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ft(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const pt=s("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=he),Be.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ft(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ht=s("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=me),Be.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!me.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return ft(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),mt=s("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ge),Be.init(e,t)});const gt=s("$ZodJWT",(e,t)=>{Be.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[o]=n;if(!o)return!1;const i=JSON.parse(atob(o));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vt=s("$ZodNumber",(e,t)=>{Ve.init(e,t),e._zod.pattern=e._zod.bag.pattern??be,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const r="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...r?{received:r}:{}}),n}}),_t=s("$ZodNumberFormat",(e,t)=>{Te.init(e,t),vt.init(e,t)}),yt=s("$ZodBoolean",(e,t)=>{Ve.init(e,t),e._zod.pattern=ze,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),wt=s("$ZodUnknown",(e,t)=>{Ve.init(e,t),e._zod.parse=e=>e}),bt=s("$ZodNever",(e,t)=>{Ve.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function zt(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}const kt=s("$ZodArray",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const r=[];for(let e=0;e<i.length;e++){const s=i[e],a=t.element._zod.run({value:s,issues:[]},o);a instanceof Promise?r.push(a.then(t=>zt(t,n,e))):zt(a,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function $t(e,t,n,o,i){if(e.issues.length){if(i&&!(n in o))return;t.issues.push(...I(n,e.issues))}void 0===e.value?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Ot(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(o=e.shape,Object.keys(o).filter(e=>"optional"===o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function St(e,t,n,o,i,r){const s=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,l="optional"===c.optout;for(const i in t){if(a.has(i))continue;if("never"===u){s.push(i);continue}const r=c.run({value:t[i],issues:[]},o);r instanceof Promise?e.push(r.then(e=>$t(e,n,i,t,l))):$t(r,n,i,t,l)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}const Nt=s("$ZodObject",(e,t)=>{Ve.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const o=p(()=>Ot(t));v(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const o=e[t]._zod;if(o.values){n[t]??(n[t]=new Set);for(const e of o.values)n[t].add(e)}}return n});const i=z,r=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=o.value);const a=t.value;if(!i(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const o=u[e],i="optional"===o._zod.optout,r=o._zod.run({value:a[e],issues:[]},n);r instanceof Promise?c.push(r.then(n=>$t(n,t,e,a,i))):$t(r,t,e,a,i)}return r?St(c,a,t,n,o.value,e):c.length?Promise.all(c).then(()=>t):t}}),Et=s("$ZodObjectJIT",(e,t)=>{Nt.init(e,t);const n=e._zod.parse,o=p(()=>Ot(t));let i;const r=z,s=!u.jitless,a=s&&k.value,c=t.catchall;let l;e._zod.parse=(u,d)=>{l??(l=o.value);const f=u.value;return r(f)?s&&a&&!1===d?.async&&!0!==d.jitless?(i||(i=(e=>{const t=new Je(["shape","payload","ctx"]),n=o.value,i=e=>{const t=w(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let s=0;for(const e of n.keys)r[e]="key_"+s++;t.write("const newResult = {};");for(const o of n.keys){const n=r[o],s=w(o),a=e[o],c="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(o)};`),c?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),u=i(u,d),c?St([],f,u,d,l,e):u):n(u,d):(u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u)}});function xt(e,t,n,o){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const i=e.filter(e=>!P(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Z(e,o,l())))}),t)}const Tt=s("$ZodUnion",(e,t)=>{Ve.init(e,t),v(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),v(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),v(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),v(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>m(e.source)).join("|")})$`)}});const n=1===t.options.length,o=t.options[0]._zod.run;e._zod.parse=(i,r)=>{if(n)return o(i,r);let s=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:i.value,issues:[]},r);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>xt(t,i,e,r)):xt(a,i,e,r)}}),Pt=s("$ZodIntersection",(e,t)=>{Ve.init(e,t),e._zod.parse=(e,n)=>{const o=e.value,i=t.left._zod.run({value:o,issues:[]},n),r=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||r instanceof Promise?Promise.all([i,r]).then(([t,n])=>At(e,t,n)):At(e,i,r)}});function It(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if($(e)&&$(t)){const n=Object.keys(t),o=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const n of o){const o=It(e[n],t[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};i[n]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const i=It(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function At(e,t,n){const o=new Map;let i;for(const n of t.issues)if("unrecognized_keys"===n.code){i??(i=n);for(const e of n.keys)o.has(e)||o.set(e,{}),o.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)o.has(e)||o.set(e,{}),o.get(e).r=!0;else e.issues.push(t);const r=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&i&&e.issues.push({...i,keys:r}),P(e))return e;const s=It(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const Zt=s("$ZodEnum",(e,t)=>{Ve.init(e,t);const n=d(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(e=>S.has(typeof e)).map(e=>"string"==typeof e?N(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const r=t.value;return o.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),Ct=s("$ZodLiteral",(e,t)=>{if(Ve.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?N(e):e?N(e.toString()):String(e)).join("|")})$`),e._zod.parse=(o,i)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),jt=s("$ZodTransform",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new c(e.constructor.name);const i=t.transform(n.value,n);if(o.async){return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n))}if(i instanceof Promise)throw new a;return n.value=i,n}});function Rt(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Dt=s("$ZodOptional",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",e._zod.optout="optional",v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),v(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${m(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(t=>Rt(t,e.value)):Rt(o,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ft=s("$ZodExactOptional",(e,t)=>{Dt.init(e,t),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Lt=s("$ZodNullable",(e,t)=>{Ve.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${m(e.source)}|null)$`):void 0}),v(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Mt=s("$ZodDefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>Jt(e,t)):Jt(o,t)}});function Jt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Ut=s("$ZodPrefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Vt=s("$ZodNonOptional",(e,t)=>{Ve.init(e,t),v(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,o)=>{const i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then(t=>Wt(t,e)):Wt(i,e)}});function Wt(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Bt=s("$ZodCatch",(e,t)=>{Ve.init(e,t),v(e._zod,"optin",()=>t.innerType._zod.optin),v(e._zod,"optout",()=>t.innerType._zod.optout),v(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>Z(e,n,l()))},input:e.value}),e.issues=[]),e)):(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(e=>Z(e,n,l()))},input:e.value}),e.issues=[]),e)}}),Gt=s("$ZodPipe",(e,t)=>{Ve.init(e,t),v(e._zod,"values",()=>t.in._zod.values),v(e._zod,"optin",()=>t.in._zod.optin),v(e._zod,"optout",()=>t.out._zod.optout),v(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const o=t.out._zod.run(e,n);return o instanceof Promise?o.then(e=>Yt(e,t.in,n)):Yt(o,t.in,n)}const o=t.in._zod.run(e,n);return o instanceof Promise?o.then(e=>Yt(e,t.out,n)):Yt(o,t.out,n)}});function Yt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ht=s("$ZodReadonly",(e,t)=>{Ve.init(e,t),v(e._zod,"propValues",()=>t.innerType._zod.propValues),v(e._zod,"values",()=>t.innerType._zod.values),v(e._zod,"optin",()=>t.innerType?._zod?.optin),v(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(Xt):Xt(o)}});function Xt(e){return e.value=Object.freeze(e.value),e}const Kt=s("$ZodCustom",(e,t)=>{Oe.init(e,t),Ve.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const o=n.value,i=t.fn(o);if(i instanceof Promise)return i.then(t=>qt(t,n,o,e));qt(i,n,o,e)}});function qt(e,t,n,o){if(!e){const e={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),t.issues.push(j(e))}}var Qt;class en{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Qt=globalThis).__zod_globalRegistry??(Qt.__zod_globalRegistry=new en);const tn=globalThis.__zod_globalRegistry;function nn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function on(e,t){return new Ne({check:"less_than",...x(t),value:e,inclusive:!1})}function rn(e,t){return new Ne({check:"less_than",...x(t),value:e,inclusive:!0})}function sn(e,t){return new Ee({check:"greater_than",...x(t),value:e,inclusive:!1})}function an(e,t){return new Ee({check:"greater_than",...x(t),value:e,inclusive:!0})}function cn(e,t){return new xe({check:"multiple_of",...x(t),value:e})}function un(e,t){return new Pe({check:"max_length",...x(t),maximum:e})}function ln(e,t){return new Ie({check:"min_length",...x(t),minimum:e})}function dn(e,t){return new Ae({check:"length_equals",...x(t),length:e})}function fn(e){return new Me({check:"overwrite",tx:e})}function pn(e){const t=function(e,t){const n=new Oe({check:"custom",...x(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(j(e,n.value,t._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(j(o))}},e(n.value,n)));return t}function hn(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??tn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function mn(e,t,n={path:[],schemaPath:[]}){var o;const i=e._zod.def,r=t.seen.get(e);if(r){r.count++;return n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const o={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,o);else{const n=s.schema,r=t.processors[i.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);r(e,t,n,o)}const r=e._zod.parent;r&&(s.ref||(s.ref=r),mn(r,t,o),t.seen.get(r).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&_n(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&s.schema._prefault&&((o=s.schema).default??(o.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function gn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=o.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(n,t[0])}}const i=t=>{if(t[1].schema.$ref)return;const o=t[1],{ref:i,defId:r}=(t=>{const o="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${i("__shared")}#/${o}/${r}`}}if(t[1]===n)return{ref:"#"};const i=`#/${o}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:i+r}})(t);o.def={...o.schema},r&&(o.defId=r);const s=o.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const o=n[1];if(t===n[0]){i(n);continue}if(e.external){const o=e.external.registry.get(n[0])?.id;if(t!==n[0]&&o){i(n);continue}}const r=e.metadataRegistry.get(n[0])?.id;r?i(n):(o.cycle||o.count>1&&"ref"===e.reused)&&i(n)}}function vn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,r={...i},s=n.ref;if(n.ref=null,s){o(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,r);if(t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in r||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){o(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(const t of[...e.seen.entries()].reverse())o(t[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const r=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(r[e.defId]=e.def)}e.external||Object.keys(r).length>0&&("draft-2020-12"===e.target?i.$defs=r:i.definitions=r);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:yn(t,"input",e.processors),output:yn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function _n(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if("transform"===o.type)return!0;if("array"===o.type)return _n(o.element,n);if("set"===o.type)return _n(o.valueType,n);if("lazy"===o.type)return _n(o.getter(),n);if("promise"===o.type||"optional"===o.type||"nonoptional"===o.type||"nullable"===o.type||"readonly"===o.type||"default"===o.type||"prefault"===o.type)return _n(o.innerType,n);if("intersection"===o.type)return _n(o.left,n)||_n(o.right,n);if("record"===o.type||"map"===o.type)return _n(o.keyType,n)||_n(o.valueType,n);if("pipe"===o.type)return _n(o.in,n)||_n(o.out,n);if("object"===o.type){for(const e in o.shape)if(_n(o.shape[e],n))return!0;return!1}if("union"===o.type){for(const e of o.options)if(_n(e,n))return!0;return!1}if("tuple"===o.type){for(const e of o.items)if(_n(e,n))return!0;return!(!o.rest||!_n(o.rest,n))}return!1}const yn=(e,t,n={})=>o=>{const{libraryOptions:i,target:r}=o??{},s=hn({...i??{},target:r,io:t,processors:n});return mn(e,s),gn(s,e),vn(s,e)},wn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bn=(e,t,n,o)=>{const i=e._zod.def;mn(i.innerType,t,o);t.seen.get(e).ref=i.innerType},zn=s("ZodISODateTime",(e,t)=>{it.init(e,t),Bn.init(e,t)});function kn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}(zn,e)}const $n=s("ZodISODate",(e,t)=>{rt.init(e,t),Bn.init(e,t)});function On(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}($n,e)}const Sn=s("ZodISOTime",(e,t)=>{st.init(e,t),Bn.init(e,t)});function Nn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}(Sn,e)}const En=s("ZodISODuration",(e,t)=>{at.init(e,t),Bn.init(e,t)});function xn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}(En,e)}const Tn=s("ZodError",(e,t)=>{D.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},o=e=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>o({issues:e}));else if("invalid_key"===i.code)o({issues:i.issues});else if("invalid_element"===i.code)o({issues:i.issues});else if(0===i.path.length)n._errors.push(t(i));else{let e=n,o=0;for(;o<i.path.length;){const n=i.path[o];o===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):o.push(t(i));return{formErrors:o,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,f,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,f,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),Pn=L(Tn),In=M(Tn),An=J(Tn),Zn=V(Tn),Cn=B(Tn),jn=G(Tn),Rn=Y(Tn),Dn=H(Tn),Fn=X(Tn),Ln=K(Tn),Mn=q(Tn),Jn=Q(Tn),Un=s("ZodType",(e,t)=>(Ve.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:yn(e,"input"),output:yn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const o=hn({...n,processors:t});return mn(e,o),gn(o,e),vn(o,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(y(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>E(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>Pn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>An(e,t,n),e.parseAsync=async(t,n)=>In(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zn(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Cn(e,t,n),e.decode=(t,n)=>jn(e,t,n),e.encodeAsync=async(t,n)=>Rn(e,t,n),e.decodeAsync=async(t,n)=>Dn(e,t,n),e.safeEncode=(t,n)=>Fn(e,t,n),e.safeDecode=(t,n)=>Ln(e,t,n),e.safeEncodeAsync=async(t,n)=>Mn(e,t,n),e.safeDecodeAsync=async(t,n)=>Jn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}(Vo,e,t)}(t,n)),e.superRefine=t=>e.check(pn(t)),e.overwrite=t=>e.check(fn(t)),e.optional=()=>Ao(e),e.exactOptional=()=>new Zo({type:"optional",innerType:e}),e.nullable=()=>jo(e),e.nullish=()=>Ao(jo(e)),e.nonoptional=t=>function(e,t){return new Fo({type:"nonoptional",innerType:e,...x(t)})}(e,t),e.array=()=>{return function(e,t,n){return new e({type:"array",element:t,...x(n)})}(ko,e,t);var t},e.or=t=>So([e,t]),e.and=t=>new No({type:"intersection",left:e,right:t}),e.transform=t=>Jo(e,new Po({type:"transform",transform:t})),e.default=t=>{return n=t,new Ro({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():O(n)}});var n},e.prefault=t=>{return n=t,new Do({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():O(n)}});var n},e.catch=t=>{return new Lo({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Jo(e,t),e.readonly=()=>new Uo({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return tn.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>tn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return tn.get(e);const n=e.clone();return tn.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Vn=s("_ZodString",(e,t)=>{We.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n;o.type="string";const{minimum:i,maximum:r,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof r&&(o.maxLength=r),s&&(o.format=wn[s]??s,""===o.format&&delete o.format,"time"===s&&delete o.format),c&&(o.contentEncoding=c),a&&a.size>0){const e=[...a];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Ce({check:"string_format",format:"regex",...x(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new De({check:"string_format",format:"includes",...x(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Fe({check:"string_format",format:"starts_with",...x(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Le({check:"string_format",format:"ends_with",...x(t),suffix:e})}(...t)),e.min=(...t)=>e.check(ln(...t)),e.max=(...t)=>e.check(un(...t)),e.length=(...t)=>e.check(dn(...t)),e.nonempty=(...t)=>e.check(ln(1,...t)),e.lowercase=t=>e.check(function(e){return new je({check:"string_format",format:"lowercase",...x(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Re({check:"string_format",format:"uppercase",...x(e)})}(t)),e.trim=()=>e.check(fn(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return fn(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(fn(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(fn(e=>e.toUpperCase())),e.slugify=()=>e.check(fn(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),Wn=s("ZodString",(e,t)=>{We.init(e,t),Vn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}(Gn,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}(Xn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}(fo,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}(Kn,t)),e.guid=t=>e.check(nn(Yn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}(Hn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}(Hn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}(Hn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}(Hn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}(qn,t)),e.guid=t=>e.check(nn(Yn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}(Qn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}(eo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}(to,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}(co,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}(uo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}(no,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}(oo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}(io,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}(ro,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}(so,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}(ao,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}(lo,t)),e.datetime=t=>e.check(kn(t)),e.date=t=>e.check(On(t)),e.time=t=>e.check(Nn(t)),e.duration=t=>e.check(xn(t))}),Bn=s("ZodStringFormat",(e,t)=>{Be.init(e,t),Vn.init(e,t)}),Gn=s("ZodEmail",(e,t)=>{He.init(e,t),Bn.init(e,t)}),Yn=s("ZodGUID",(e,t)=>{Ge.init(e,t),Bn.init(e,t)}),Hn=s("ZodUUID",(e,t)=>{Ye.init(e,t),Bn.init(e,t)}),Xn=s("ZodURL",(e,t)=>{Xe.init(e,t),Bn.init(e,t)}),Kn=s("ZodEmoji",(e,t)=>{Ke.init(e,t),Bn.init(e,t)}),qn=s("ZodNanoID",(e,t)=>{qe.init(e,t),Bn.init(e,t)}),Qn=s("ZodCUID",(e,t)=>{Qe.init(e,t),Bn.init(e,t)}),eo=s("ZodCUID2",(e,t)=>{et.init(e,t),Bn.init(e,t)}),to=s("ZodULID",(e,t)=>{tt.init(e,t),Bn.init(e,t)}),no=s("ZodXID",(e,t)=>{nt.init(e,t),Bn.init(e,t)}),oo=s("ZodKSUID",(e,t)=>{ot.init(e,t),Bn.init(e,t)}),io=s("ZodIPv4",(e,t)=>{ct.init(e,t),Bn.init(e,t)}),ro=s("ZodIPv6",(e,t)=>{ut.init(e,t),Bn.init(e,t)}),so=s("ZodCIDRv4",(e,t)=>{lt.init(e,t),Bn.init(e,t)}),ao=s("ZodCIDRv6",(e,t)=>{dt.init(e,t),Bn.init(e,t)}),co=s("ZodBase64",(e,t)=>{pt.init(e,t),Bn.init(e,t)}),uo=s("ZodBase64URL",(e,t)=>{ht.init(e,t),Bn.init(e,t)}),lo=s("ZodE164",(e,t)=>{mt.init(e,t),Bn.init(e,t)}),fo=s("ZodJWT",(e,t)=>{gt.init(e,t),Bn.init(e,t)}),po=s("ZodNumber",(e,t)=>{vt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=n,{minimum:i,maximum:r,format:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;"string"==typeof s&&s.includes("int")?o.type="integer":o.type="number","number"==typeof u&&("draft-04"===t.target||"openapi-3.0"===t.target?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u),"number"==typeof i&&(o.minimum=i,"number"==typeof u&&"draft-04"!==t.target&&(u>=i?delete o.minimum:delete o.exclusiveMinimum)),"number"==typeof c&&("draft-04"===t.target||"openapi-3.0"===t.target?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c),"number"==typeof r&&(o.maximum=r,"number"==typeof c&&"draft-04"!==t.target&&(c<=r?delete o.maximum:delete o.exclusiveMaximum)),"number"==typeof a&&(o.multipleOf=a)})(e,t,n),e.gt=(t,n)=>e.check(sn(t,n)),e.gte=(t,n)=>e.check(an(t,n)),e.min=(t,n)=>e.check(an(t,n)),e.lt=(t,n)=>e.check(on(t,n)),e.lte=(t,n)=>e.check(rn(t,n)),e.max=(t,n)=>e.check(rn(t,n)),e.int=t=>e.check(go(t)),e.safe=t=>e.check(go(t)),e.positive=t=>e.check(sn(0,t)),e.nonnegative=t=>e.check(an(0,t)),e.negative=t=>e.check(on(0,t)),e.nonpositive=t=>e.check(rn(0,t)),e.multipleOf=(t,n)=>e.check(cn(t,n)),e.step=(t,n)=>e.check(cn(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ho(e){return function(e,t){return new e({type:"number",checks:[],...x(t)})}(po,e)}const mo=s("ZodNumberFormat",(e,t)=>{_t.init(e,t),po.init(e,t)});function go(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}(mo,e)}const vo=s("ZodBoolean",(e,t)=>{yt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function _o(e){return function(e,t){return new e({type:"boolean",...x(t)})}(vo,e)}const yo=s("ZodUnknown",(e,t)=>{wt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function wo(){return new yo({type:"unknown"})}const bo=s("ZodNever",(e,t)=>{bt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function zo(e){return function(e,t){return new e({type:"never",...x(t)})}(bo,e)}const ko=s("ZodArray",(e,t)=>{kt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=mn(r.element,t,{...o,path:[...o.path,"items"]})})(e,t,n,o),e.element=t.element,e.min=(t,n)=>e.check(ln(t,n)),e.nonempty=t=>e.check(ln(1,t)),e.max=(t,n)=>e.check(un(t,n)),e.length=(t,n)=>e.check(dn(t,n)),e.unwrap=()=>e.element});const $o=s("ZodObject",(e,t)=>{Et.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=n,r=e._zod.def;i.type="object",i.properties={};const s=r.shape;for(const e in s)i.properties[e]=mn(s[e],t,{...o,path:[...o.path,"properties",e]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(i.required=Array.from(c)),"never"===r.catchall?._zod.def.type?i.additionalProperties=!1:r.catchall?r.catchall&&(i.additionalProperties=mn(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,o),v(e,"shape",()=>t.shape),e.keyof=()=>function(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Eo({type:"enum",entries:n,...x(t)})}(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:wo()}),e.loose=()=>e.clone({...e._zod.def,catchall:wo()}),e.strict=()=>e.clone({...e._zod.def,catchall:zo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!$(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=y(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return _(this,"shape",n),n}});return E(e,o)}(e,t),e.safeExtend=t=>function(e,t){if(!$(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=y(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return _(this,"shape",n),n}});return E(e,n)}(e,t),e.merge=t=>function(e,t){const n=y(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return _(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return E(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return E(e,y(e._zod.def,{get shape(){const e={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(e[o]=n.shape[o])}return _(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=y(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete o[e]}return _(this,"shape",o),o},checks:[]});return E(e,i)}(e,t),e.partial=(...t)=>function(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=y(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return _(this,"shape",i),i},checks:[]});return E(t,i)}(Io,e,t[0]),e.required=(...t)=>function(e,t,n){const o=y(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:"nonoptional",innerType:o[t]}))}else for(const t in o)i[t]=new e({type:"nonoptional",innerType:o[t]});return _(this,"shape",i),i}});return E(t,o)}(Fo,e,t[0])});const Oo=s("ZodUnion",(e,t)=>{Tt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=!1===i.inclusive,s=i.options.map((e,n)=>mn(e,t,{...o,path:[...o.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=s:n.anyOf=s})(e,t,n,o),e.options=t.options});function So(e,t){return new Oo({type:"union",options:e,...x(t)})}const No=s("ZodIntersection",(e,t)=>{Pt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=mn(i.left,t,{...o,path:[...o.path,"allOf",0]}),s=mn(i.right,t,{...o,path:[...o.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(r)?r.allOf:[r],...a(s)?s.allOf:[s]];n.allOf=c})(e,t,n,o)});const Eo=s("ZodEnum",(e,t)=>{Zt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=d(e._zod.def.entries);o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=o})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const o of e){if(!n.has(o))throw new Error(`Key ${o} not found in enum`);i[o]=t.entries[o]}return new Eo({...t,checks:[],...x(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Eo({...t,checks:[],...x(o),entries:i})}});const xo=s("ZodLiteral",(e,t)=>{Ct.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n)=>{const o=e._zod.def,i=[];for(const e of o.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(e))}else i.push(e);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function To(e,t){return new xo({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const Po=s("ZodTransform",(e,t)=>{jt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new c(e.constructor.name);n.addIssue=o=>{if("string"==typeof o)n.issues.push(j(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(j(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});const Io=s("ZodOptional",(e,t)=>{Dt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>bn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});function Ao(e){return new Io({type:"optional",innerType:e})}const Zo=s("ZodExactOptional",(e,t)=>{Ft.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>bn(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});const Co=s("ZodNullable",(e,t)=>{Lt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r=mn(i.innerType,t,o),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});function jo(e){return new Co({type:"nullable",innerType:e})}const Ro=s("ZodDefault",(e,t)=>{Mt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;mn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Do=s("ZodPrefault",(e,t)=>{Ut.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;mn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});const Fo=s("ZodNonOptional",(e,t)=>{Vt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;mn(i.innerType,t,o),t.seen.get(e).ref=i.innerType})(e,t,0,o),e.unwrap=()=>e._zod.def.innerType});const Lo=s("ZodCatch",(e,t)=>{Bt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;let r;mn(i.innerType,t,o),t.seen.get(e).ref=i.innerType;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Mo=s("ZodPipe",(e,t)=>{Gt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def,r="input"===t.io?"transform"===i.in._zod.def.type?i.out:i.in:i.out;mn(r,t,o),t.seen.get(e).ref=r})(e,t,0,o),e.in=t.in,e.out=t.out});function Jo(e,t){return new Mo({type:"pipe",in:e,out:t})}const Uo=s("ZodReadonly",(e,t)=>{Ht.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(t,n,o)=>((e,t,n,o)=>{const i=e._zod.def;mn(i.innerType,t,o),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,o),e.unwrap=()=>e._zod.def.innerType});const Vo=s("ZodCustom",(e,t)=>{Kt.init(e,t),Un.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});class Wo{constructor(){this.animate="none",this.animate_duration=200,this.enable=!0,this.enable_mouse_swipe=!1,this.enable_on_subviews=!0,this.logger_level=o.WARN,this.prevent_default=!1,this.skip_hidden=!0,this.skip_subviews=!0,this.skip_tabs=[],this.swipe_amount=.15,this.wrap=!0}getAnimate(){return this.animate}getAnimateDuration(){return this.animate_duration}getEnable(){return this.enable}getEnableMouseSwipe(){return this.enable_mouse_swipe}getEnableOnSubviews(){return this.enable_on_subviews}getLoggerLevel(){return this.logger_level}getPreventDefault(){return this.prevent_default}getSkipHidden(){return this.skip_hidden}getSkipSubviews(){return this.skip_subviews}getSkipTabs(){return this.skip_tabs}getSwipeAmount(){return this.swipe_amount}getWrap(){return this.wrap}static parseConfig(e){if(t=e,!Bo.safeParse(t).success)return i.loge(r,"Found invalid configuration."),null;var t;const n=new Wo;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),null!=e.enable_on_subviews&&(n.enable_on_subviews=e.enable_on_subviews),e.logger_level){case"verbose":n.logger_level=o.VERBOSE;break;case"debug":n.logger_level=o.DEBUG;break;case"info":n.logger_level=o.INFO;break;case"warn":n.logger_level=o.WARN;break;case"error":n.logger_level=o.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_subviews&&(n.skip_subviews=e.skip_subviews),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}}const Bo=function(e,t){const n={type:"object",shape:e??{},...x(t)};return new $o(n)}({animate:So([To("none"),To("swipe"),To("fade"),To("flip")]).optional(),animate_duration:ho().optional(),enable:_o().optional(),enable_mouse_swipe:_o().optional(),enable_on_subviews:_o().optional(),logger_level:So([To("verbose"),To("debug"),To("info"),To("warn"),To("error")]).optional(),prevent_default:_o().optional(),skip_hidden:_o().optional(),skip_subviews:_o().optional(),skip_tabs:function(e,t){return new e({type:"string",coerce:!0,...x(t)})}(Wn,Go).optional(),swipe_amount:ho().optional(),wrap:_o().optional()});var Go;class Yo{constructor(e){this.domNodes=[],this.observers=[],this.domNodeAddedCallbacks=[],this.domNodeRemovedCallbacks=[],this.selectorPaths=e,this.domNodes=new Array(this.selectorPaths.length),this.observers=new Array(this.selectorPaths.length)}addDomNodeAddedCallback(e){i.logv(r,'Adding callback to PageObject: "'+this.selectorPaths[this.selectorPaths.length-1]+'".'),0==this.domNodeAddedCallbacks.length&&0==this.domNodeRemovedCallbacks.length&&this.createNodeObserversFrom(0),this.domNodeAddedCallbacks.push(e)}toString(){return this.selectorPaths.join("→")}getDomNode(){const e=this.domNodes.length-1;return i.logv(r,"Getting DOM node "+this.toString()+"."),this.getDomNodeAt(e)}getSelectorPaths(){return this.selectorPaths.slice()}getDomNodeAt(e){var t;const n=this.domNodes[e];if(1==(null==n?void 0:n.isConnected))return n;i.logv(r,"Recursively Getting DOM node "+e+" "+this.selectorPaths[e]+" in "+this.toString()+".");const o=0==e?document:this.getDomNodeAt(e-1);return"$"==this.selectorPaths[e]?this.domNodes[e]=o instanceof HTMLElement&&o.shadowRoot?o.shadowRoot:null:this.domNodes[e]=null!==(t=null==o?void 0:o.querySelector(this.selectorPaths[e]))&&void 0!==t?t:null,this.domNodes[e]}createNodeObserversFrom(e){var t;i.logv(r,"Creating observer for "+e+" "+this.selectorPaths[e]+" in "+this.toString()+".");const n=0==e?document:this.getDomNodeAt(e-1);if(null!=n)if(this.observers[e]=new MutationObserver(t=>{for(const n of t){for(const t of n.addedNodes)t instanceof HTMLElement&&("$"==this.selectorPaths[e]||t.matches(this.selectorPaths[e]))&&(i.logd(r,'DOM node added: "'+t.nodeName.toLowerCase()+'".'),this.domNodes[e]=t,e==this.selectorPaths.length-1?this.invokeDomNodeAddedCallbacks(t):this.createNodeObserversFrom(e+1));for(const t of n.removedNodes)t instanceof HTMLElement&&("$"==this.selectorPaths[e]||t.matches(this.selectorPaths[e]))&&(i.logd(r,'DOM node removed: "'+t.nodeName.toLowerCase()+'".'),this.domNodes[e]=null,e<this.selectorPaths.length-1&&(this.destroyNodeObserversFrom(e+1),this.invalidateDomNodesFrom(e+1)),this.invokeDomNodeRemovedCallbacks())}}),null===(t=this.observers[e])||void 0===t||t.observe(n,{childList:!0,subtree:!1}),e<this.observers.length-1)this.createNodeObserversFrom(e+1);else{const t=this.getDomNodeAt(e);null!=t&&this.invokeDomNodeAddedCallbacks(t)}}destroyNodeObserversFrom(e){var t;null!=this.observers[e]&&(null===(t=this.observers[e])||void 0===t||t.disconnect(),this.observers[e]=null),e<this.observers.length-1&&this.destroyNodeObserversFrom(e+1)}invalidateDomNodesFrom(e){this.domNodes[e]=null,e<this.domNodes.length-1&&this.invalidateDomNodesFrom(e+1)}invokeDomNodeAddedCallbacks(e){for(const t of this.domNodeAddedCallbacks)t(e)}invokeDomNodeRemovedCallbacks(){for(const e of this.domNodeRemovedCallbacks)e()}}class Ho{}Ho.ha=new Yo(["home-assistant"]),Ho.haMain=new Yo([...Ho.ha.getSelectorPaths(),"$","home-assistant-main"]),Ho.partialPanelResolver=new Yo([...Ho.haMain.getSelectorPaths(),"$","partial-panel-resolver"]),Ho.haPanelLovelace=new Yo([...Ho.partialPanelResolver.getSelectorPaths(),"ha-panel-lovelace"]),Ho.huiRoot=new Yo([...Ho.haPanelLovelace.getSelectorPaths(),"$","hui-root"]),Ho.haAppLayout=new Yo([...Ho.huiRoot.getSelectorPaths(),"$",function(){const e=function(){var e,t,n;return(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!=e&&function(e,t){const n=e.split("."),o=t.split(".");for(let e=0;e<o.length;e++){const t=~~o[e],i=~~n[e];if(t>i)return!0;if(t<i)return!1}return!1}(e,"2023.4")}()?"ha-app-layout":"div"]),Ho.haAppLayoutView=new Yo([...Ho.huiRoot.getSelectorPaths(),"$",'[id="view"]']);class Xo{static getCurrentConfig(){return Xo.currentConfig}static getPanel(){return Xo.panel}static getViews(){var e,t;const n=Ho.haPanelLovelace.getDomNode(),o=null===(t=null===(e=null==n?void 0:n.lovelace)||void 0===e?void 0:e.config)||void 0===t?void 0:t.views;return null!=o&&(Xo.views=o),Xo.views}static getCurrentViewName(){var e,t,n;const o=Ho.haPanelLovelace.getDomNode();return null!==(n=null===(t=null===(e=null==o?void 0:o.route)||void 0===e?void 0:e.path)||void 0===t?void 0:t.replace("/",""))&&void 0!==n?n:null}static getCurrentViewIndex(){const e=Xo.views,t=Xo.getCurrentViewName();if(null==e||null==t)return null;for(let n=0;n<e.length;n++){const o=e[n].path;if(String(n)==t)return n;if(o==t)return n}return null}static isViewVisible(e,t){const n=e[t].visible;if(null==n||1==n)return!0;if(0==n)return!1;if(n instanceof Array){for(const e of n)if(e.user==Xo.currentUserId)return!0;return!1}throw new Error(`Unhandled case: ${n}`)}static isViewHidden(e,t){return!Xo.isViewVisible(e,t)}static readAndMonitorConfig(){return e(this,void 0,void 0,function*(){Ho.huiRoot.addDomNodeAddedCallback(()=>{Xo.readConfig()}),yield Xo.readConfig()})}static registerConfigObserver(e){Xo.configObservers.push(e)}static unregisterConfigObserver(e){const t=Xo.configObservers.indexOf(e);t>-1?Xo.configObservers.splice(t,1):i.loge(r,"Internal error while unregistering a configObserver: not found.")}static readConfig(){return e(this,void 0,void 0,function*(){var e,t,n,o,s,a,c,u;i.logd(r,"Attempting to read config...");const l=Ho.haPanelLovelace.getDomNode(),d=null!==(n=null===(t=null===(e=null==l?void 0:l.lovelace)||void 0===e?void 0:e.config)||void 0===t?void 0:t.swipe_nav)&&void 0!==n?n:{};JSON.stringify(d)!=JSON.stringify(Xo.rawConfig)&&Xo.saveConfig(d);const f=null===(o=null==l?void 0:l.route)||void 0===o?void 0:o.prefix;null!=f&&(Xo.panel=f.replace("/",""));const p=null===(a=null===(s=null==l?void 0:l.lovelace)||void 0===s?void 0:s.config)||void 0===a?void 0:a.views;null!=p&&(Xo.views=p);const h=null===(u=null===(c=null==l?void 0:l.hass)||void 0===c?void 0:c.user)||void 0===u?void 0:u.id;null!=h&&(Xo.currentUserId=h)})}static saveConfig(e){Xo.rawConfig=e;const t=Wo.parseConfig(e);null!=t&&(JSON.stringify(t)!=JSON.stringify(Xo.currentConfig)?(Xo.currentConfig=t,Xo.configObservers.forEach(e=>{e.callback()})):i.logd(r,"Config is equivalent."))}}Xo.currentConfig=new Wo,Xo.panel=null,Xo.views=null,Xo.currentUserId=null,Xo.rawConfig=null,Xo.configObservers=[];class Ko{constructor(e){this.callback=e}}const qo=[".badges-scroll","ha-tabs","paper-tabs","sl-tab-group","ha-tab-group","hui-badge-edit-mode","hui-card-edit-mode",".section-actions .handle","hui-map-card","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","map-card","my-slider","my-slider-v2","mwc-tab-bar","#plotly g.draglayer",".range-slider",".bubble-button-slider-container",".bubble-pop-up","remote-touchpad","round-slider","sankey-chart",".slide-confirm","simple-swipe-card","slider-button-card","swipe-card",".swiper","#swiper","todo-swipe-card","toucharea",".circlepad","vehicle-info-card","vehicle-status-card","xiaomi-vacuum-map-card","css-swipe-card"].join(","),Qo=[{host:"weather-forecast-extended-card",selectors:".forecast.daily, .forecast.hourly, .header-pages"}],ei=Qo.map(e=>e.selectors).join(", "),ti=[".ha-scrollbar"].join(",");var ni,oi,ii,ri,si,ai,ci,ui,li,di;class fi{static init(){var e;null===(e=t(this,ni,"f",ai))||void 0===e||e.abort(),n(this,ni,new AbortController,"f",ai);const o=Ho.haAppLayout.getDomNode();null!=o&&(i.logd(r,"Initializing SwipeManger..."),o.addEventListener("touchstart",e=>{t(this,ni,"m",ci).call(this,e)},{signal:t(this,ni,"f",ai).signal,passive:!0}),o.addEventListener("touchmove",e=>{t(this,ni,"m",ui).call(this,e)},{signal:t(this,ni,"f",ai).signal,passive:!1}),o.addEventListener("touchend",()=>{t(this,ni,"m",li).call(this)},{signal:t(this,ni,"f",ai).signal,passive:!0}),o.addEventListener("mousedown",e=>{t(this,ni,"m",ci).call(this,e)},{signal:t(this,ni,"f",ai).signal,passive:!0}),Xo.getCurrentConfig().getEnableMouseSwipe()&&(o.addEventListener("mousemove",e=>{t(this,ni,"m",ui).call(this,e)},{signal:t(this,ni,"f",ai).signal,passive:!1}),o.addEventListener("mouseup",()=>{t(this,ni,"m",li).call(this)},{signal:t(this,ni,"f",ai).signal,passive:!0})))}static animatedNavigateTo(e,t){const n=Ho.haAppLayoutView.getDomNode();if(null==n)i.loge(r,"view is null when attempting to change tab.");else{const o=Xo.getCurrentConfig().getAnimate();if("none"==o)ni.navigateTo(e);else{const i=Xo.getCurrentConfig().getAnimateDuration();if(n.style.transition=`transform ${i}ms ease-in, opacity ${i}ms ease-in`,"swipe"==o){const o=Ho.haAppLayout.getDomNode();null!=o&&(o.style.overflow="hidden");const r=t?screen.width/2+"px":`-${screen.width/2}px`,s=t?`-${screen.width/2}px`:screen.width/2+"px";n.style.opacity="0",n.style.transform=`translate(${r}, 0)`,setTimeout(function(){n.style.transition="",n.style.transform=`translate(${s}, 0)`,ni.navigateTo(e)},i+10)}else if("fade"==o)n.style.opacity="0",setTimeout(function(){n.style.transition="",ni.navigateTo(e),n.style.opacity="0"},i+10);else{if("flip"!=o){throw new Error(`Unhandled case: ${o}`)}n.style.transform="rotatey(90deg)",n.style.opacity="0.25",setTimeout(function(){n.style.transition="",ni.navigateTo(e)},i+10)}setTimeout(function(){n.style.transition=`transform ${i}ms ease-out, opacity ${i}ms ease-out`,n.style.opacity="1",n.style.transform=""},i+50),"swipe"==o&&setTimeout(function(){const e=Ho.haAppLayout.getDomNode();null!=e&&(e.style.overflow="")},2*i+100)}}}static navigateTo(e){const t=window.location.search,n=window.location.hash,o="/"+Xo.getPanel()+"/"+e+t+n;window.location.pathname+window.location.search+window.location.hash!==o&&(window.history.pushState(null,"",o),window.dispatchEvent(new CustomEvent("location-changed")))}}ni=fi,ci=function(e){var t,o;let s;if(null!=window.TouchEvent&&e instanceof TouchEvent)s="touch";else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}s="click"}if(0!=Xo.getCurrentConfig().getEnable()){if(0==Xo.getCurrentConfig().getEnableOnSubviews()){const e=Xo.getViews(),t=Xo.getCurrentViewIndex();if(null!=e&&null!=t&&e[t].subview)return void i.logd(r,"Ignoring "+s+": Swipe navigation on subviews is disabled in the config.")}if(null!=window.TouchEvent&&e instanceof TouchEvent&&e.touches.length>1)return n(this,ni,null,"f",oi),n(this,ni,null,"f",ii),void i.logd(r,"Ignoring "+s+": multiple touchpoints detected.");if(e instanceof MouseEvent&&!Xo.getCurrentConfig().getEnableMouseSwipe())return n(this,ni,null,"f",oi),n(this,ni,null,"f",ii),void i.logd(r,"Ignoring "+s+": 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(qo))return void i.logd(r,"Ignoring "+s+' on "'+(null!=n.nodeName?n.nodeName.toLowerCase():"unknown")+'".');if((null===(t=n.matches)||void 0===t?void 0:t.call(n,ti))&&(n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth))return void i.logd(r,"Ignoring "+s+' on scrollable "'+(null!=n.nodeName?n.nodeName.toLowerCase():"unknown")+'".');if(ei&&(null===(o=n.matches)||void 0===o?void 0:o.call(n,ei))){const e=n.getRootNode();if(e instanceof ShadowRoot)for(const t of Qo)if(e.host.matches(t.host)&&n.matches(t.selectors))return void i.logd(r,"Ignoring "+s+' on scoped exception "'+t.host+" >> "+t.selectors+'".')}}if(null!=window.TouchEvent&&e instanceof TouchEvent)n(this,ni,e.touches[0].clientX,"f",oi),n(this,ni,e.touches[0].clientY,"f",ii);else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}n(this,ni,e.clientX,"f",oi),n(this,ni,e.clientY,"f",ii)}}else i.logd(r,"Ignoring "+s+": Swipe navigation is disabled in the config.")},ui=function(e){if(t(this,ni,"f",oi)&&t(this,ni,"f",ii)){if(null!=window.TouchEvent&&e instanceof TouchEvent)n(this,ni,t(this,ni,"f",oi)-e.touches[0].clientX,"f",ri),n(this,ni,t(this,ni,"f",ii)-e.touches[0].clientY,"f",si);else{if(!(e instanceof MouseEvent)){throw new Error(`Unhandled case: ${e}`)}n(this,ni,t(this,ni,"f",oi)-e.clientX,"f",ri),n(this,ni,t(this,ni,"f",ii)-e.clientY,"f",si)}Math.abs(t(this,ni,"f",ri))>Math.abs(t(this,ni,"f",si))&&Xo.getCurrentConfig().getPreventDefault()&&e.preventDefault()}},li=function(){var e;if(null!=t(this,ni,"f",ri)&&null!=t(this,ni,"f",si))if(Math.abs(t(this,ni,"f",ri))<Math.abs(t(this,ni,"f",si)))i.logd(r,"Swipe ignored, vertical movement.");else if(Math.abs(t(this,ni,"f",ri))<Math.abs(screen.width*Xo.getCurrentConfig().getSwipeAmount()))i.logd(r,"Swipe ignored, too short.");else{const n=t(this,ni,"f",ri)<0;i.logi(r,"Swipe detected, changing tab to the "+(n?"left":"right")+".");const o="rtl"==(null===(e=Ho.ha.getDomNode())||void 0===e?void 0:e.style.direction),s=t(this,ni,"m",di).call(this,o?!n:n);null!=s&&this.animatedNavigateTo(s,n)}n(this,ni,n(this,ni,n(this,ni,n(this,ni,null,"f",si),"f",ri),"f",ii),"f",oi)},di=function(e){const t=Xo.getViews(),n=Xo.getCurrentViewIndex();if(null==t||null==n)return i.loge(r,"Can't determine the active tab."),null;let o=n,s=null;const a=e?-1:1;let c=!1;for(;!c;){if(o+=a,-1==o||o==t.length){if(!Xo.getCurrentConfig().getWrap()){c=!0,o=-1,s="Edge has been reached and wrap is disabled.";break}o=(o+t.length)%t.length}if(o==n){c=!0,o=-1,s="Error, no viable tabs found for swiping.";break}Xo.getCurrentConfig().getSkipTabs().includes(o)||(Xo.getCurrentConfig().getSkipHidden()&&Xo.isViewHidden(t,o)||Xo.getCurrentConfig().getSkipSubviews()&&1==t[o].subview||(c=!0))}if(null!=s)return i.logw(r,s),null;{const e=t[o].path;return null==e||""==e.trim()?String(o):e}},oi={value:void 0},ii={value:void 0},ri={value:void 0},si={value:void 0},ai={value:null},console.info("%c↔️ Swipe navigation ↔️ - v1.16.0","color: #2980b9; font-weight: 700;"),function(){e(this,void 0,void 0,function*(){i.setLoggerLevel(Xo.getCurrentConfig().getLoggerLevel()),Xo.registerConfigObserver(new Ko(()=>{i.setLoggerLevel(Xo.getCurrentConfig().getLoggerLevel()),i.logi(r,"New configuration loaded.")})),yield Xo.readAndMonitorConfig(),Ho.haAppLayout.addDomNodeAddedCallback(()=>{fi.init()}),fi.init()})}();
|