scordi-extension 1.14.8 → 1.14.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var tr=Object.defineProperty;var nr=(r,e,n)=>e in r?tr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var fe=(r,e,n)=>nr(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class At extends Error{constructor(e,n,i){super(e),this.code=n,this.details=i,this.name="EightGError"}static extensionNotInstalled(){return new At("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new At(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new At(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(){return new At("Request timeout - Extension did not respond within 30 seconds","REQUEST_TIMEOUT")}}function rr(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}class ar{constructor(){}async checkExtension(){return new Promise((e,n)=>{const i=setTimeout(()=>{n(At.extensionNotInstalled())},5e3),s=u=>{rr(u.data)&&(clearTimeout(i),window.removeEventListener("message",s),e(u.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((n,i)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,u=setTimeout(()=>{i(At.requestTimeout())},6e4),f=v=>{var C,S,V,j;if(((C=v.data)==null?void 0:C.type)==="8G_COLLECT_RESPONSE"&&v.data.requestId===s){clearTimeout(u),window.removeEventListener("message",f);const x=v.data,E=((S=x==null?void 0:x.result)==null?void 0:S.steps)??((j=(V=x==null?void 0:x.result)==null?void 0:V.result)==null?void 0:j.steps)??[];n({success:x.success,steps:E,error:x.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}}var ye;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function n(s){throw new Error}r.assertNever=n,r.arrayToEnum=s=>{const u={};for(const f of s)u[f]=f;return u},r.getValidEnumValues=s=>{const u=r.objectKeys(s).filter(v=>typeof s[s[v]]!="number"),f={};for(const v of u)f[v]=s[v];return r.objectValues(f)},r.objectValues=s=>r.objectKeys(s).map(function(u){return s[u]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const u=[];for(const f in s)Object.prototype.hasOwnProperty.call(s,f)&&u.push(f);return u},r.find=(s,u)=>{for(const f of s)if(u(f))return f},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function i(s,u=" | "){return s.map(f=>typeof f=="string"?`'${f}'`:f).join(u)}r.joinValues=i,r.jsonStringifyReplacer=(s,u)=>typeof u=="bigint"?u.toString():u})(ye||(ye={}));var Cn;(function(r){r.mergeShapes=(e,n)=>({...e,...n})})(Cn||(Cn={}));const $=ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=r=>{switch(typeof r){case"undefined":return $.undefined;case"string":return $.string;case"number":return Number.isNaN(r)?$.nan:$.number;case"boolean":return $.boolean;case"function":return $.function;case"bigint":return $.bigint;case"symbol":return $.symbol;case"object":return Array.isArray(r)?$.array:r===null?$.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?$.promise:typeof Map<"u"&&r instanceof Map?$.map:typeof Set<"u"&&r instanceof Set?$.set:typeof Date<"u"&&r instanceof Date?$.date:$.object;default:return $.unknown}},O=ye.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"]),ir=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class rt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(u){return u.message},i={_errors:[]},s=u=>{for(const f of u.issues)if(f.code==="invalid_union")f.unionErrors.map(s);else if(f.code==="invalid_return_type")s(f.returnTypeError);else if(f.code==="invalid_arguments")s(f.argumentsError);else if(f.path.length===0)i._errors.push(n(f));else{let v=i,C=0;for(;C<f.path.length;){const S=f.path[C];C===f.path.length-1?(v[S]=v[S]||{_errors:[]},v[S]._errors.push(n(f))):v[S]=v[S]||{_errors:[]},v=v[S],C++}}};return s(this),i}static assert(e){if(!(e instanceof rt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ye.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},i=[];for(const s of this.issues)if(s.path.length>0){const u=s.path[0];n[u]=n[u]||[],n[u].push(e(s))}else i.push(e(s));return{formErrors:i,fieldErrors:n}}get formErrors(){return this.flatten()}}rt.create=r=>new rt(r);const Vt=(r,e)=>{let n;switch(r.code){case O.invalid_type:r.received===$.undefined?n="Required":n=`Expected ${r.expected}, received ${r.received}`;break;case O.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(r.expected,ye.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:n=`Unrecognized key(s) in object: ${ye.joinValues(r.keys,", ")}`;break;case O.invalid_union:n="Invalid input";break;case O.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ye.joinValues(r.options)}`;break;case O.invalid_enum_value:n=`Invalid enum value. Expected ${ye.joinValues(r.options)}, received '${r.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:typeof r.validation=="object"?"includes"in r.validation?(n=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?n=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?n=`Invalid input: must end with "${r.validation.endsWith}"`:ye.assertNever(r.validation):r.validation!=="regex"?n=`Invalid ${r.validation}`:n="Invalid";break;case O.too_small:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:n="Invalid input";break;case O.too_big:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?n=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:n="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 ${r.multipleOf}`;break;case O.not_finite:n="Number must be finite";break;default:n=e.defaultError,ye.assertNever(r)}return{message:n}};let Bn=Vt;function sr(r){Bn=r}function gn(){return Bn}const bn=r=>{const{data:e,path:n,errorMaps:i,issueData:s}=r,u=[...n,...s.path||[]],f={...s,path:u};if(s.message!==void 0)return{...s,path:u,message:s.message};let v="";const C=i.filter(S=>!!S).slice().reverse();for(const S of C)v=S(f,{data:e,defaultError:v}).message;return{...s,path:u,message:v}},or=[];function F(r,e){const n=gn(),i=bn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,n,n===Vt?void 0:Vt].filter(s=>!!s)});r.common.issues.push(i)}class He{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const i=[];for(const s of n){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),i.push(s.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,n){const i=[];for(const s of n){const u=await s.key,f=await s.value;i.push({key:u,value:f})}return He.mergeObjectSync(e,i)}static mergeObjectSync(e,n){const i={};for(const s of n){const{key:u,value:f}=s;if(u.status==="aborted"||f.status==="aborted")return ee;u.status==="dirty"&&e.dirty(),f.status==="dirty"&&e.dirty(),u.value!=="__proto__"&&(typeof f.value<"u"||s.alwaysSet)&&(i[u.value]=f.value)}return{status:e.value,value:i}}}const ee=Object.freeze({status:"aborted"}),Lt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Dn=r=>r.status==="aborted",Pn=r=>r.status==="dirty",jt=r=>r.status==="valid",Jt=r=>typeof Promise<"u"&&r instanceof Promise;var G;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(G||(G={}));class mt{constructor(e,n,i,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=i,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Zn=(r,e)=>{if(jt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new rt(r.common.issues);return this._error=n,this._error}}};function ie(r){if(!r)return{};const{errorMap:e,invalid_type_error:n,required_error:i,description:s}=r;if(e&&(n||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(f,v)=>{const{message:C}=r;return f.code==="invalid_enum_value"?{message:C??v.defaultError}:typeof v.data>"u"?{message:C??i??v.defaultError}:f.code!=="invalid_type"?{message:v.defaultError}:{message:C??n??v.defaultError}},description:s}}class oe{get description(){return this._def.description}_getType(e){return wt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new He,ctx:{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Jt(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const i=this.safeParse(e,n);if(i.success)return i.data;throw i.error}safeParse(e,n){const i={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Zn(i,s)}"~validate"(e){var i,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)};if(!this["~standard"].async)try{const u=this._parseSync({data:e,path:[],parent:n});return jt(u)?{value:u.value}:{issues:n.common.issues}}catch(u){(s=(i=u==null?void 0:u.message)==null?void 0:i.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(u=>jt(u)?{value:u.value}:{issues:n.common.issues})}async parseAsync(e,n){const i=await this.safeParseAsync(e,n);if(i.success)return i.data;throw i.error}async safeParseAsync(e,n){const i={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parse({data:e,path:i.path,parent:i}),u=await(Jt(s)?s:Promise.resolve(s));return Zn(i,u)}refine(e,n){const i=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,u)=>{const f=e(s),v=()=>u.addIssue({code:O.custom,...i(s)});return typeof Promise<"u"&&f instanceof Promise?f.then(C=>C?!0:(v(),!1)):f?!0:(v(),!1)})}refinement(e,n){return this._refinement((i,s)=>e(i)?!0:(s.addIssue(typeof n=="function"?n(i,s):n),!1))}_refinement(e){return new lt({schema:this,typeName:ne.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return pt.create(this,this._def)}nullable(){return Ct.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ft.create(this)}promise(){return Wt.create(this,this._def)}or(e){return en.create([this,e],this._def)}and(e){return tn.create(this,e,this._def)}transform(e){return new lt({...ie(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new on({...ie(this._def),innerType:this,defaultValue:n,typeName:ne.ZodDefault})}brand(){return new Rn({typeName:ne.ZodBranded,type:this,...ie(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new un({...ie(this._def),innerType:this,catchValue:n,typeName:ne.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return fn.create(this,e)}readonly(){return cn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ur=/^c[^\s-]{8,}$/i,cr=/^[0-9a-z]+$/,fr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,lr=/^[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,dr=/^[a-z0-9_-]{21}$/i,hr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Sn;const vr=/^(?:(?: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])$/,gr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,br=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_r=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wn="((\\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])))",xr=new RegExp(`^${Wn}$`);function qn(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const n=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Tr(r){return new RegExp(`^${qn(r)}$`)}function Yn(r){let e=`${Wn}T${qn(r)}`;const n=[];return n.push(r.local?"Z?":"Z"),r.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Ar(r,e){return!!((e==="v4"||!e)&&vr.test(r)||(e==="v6"||!e)&&br.test(r))}function Er(r,e){if(!hr.test(r))return!1;try{const[n]=r.split(".");if(!n)return!1;const i=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(i));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Sr(r,e){return!!((e==="v4"||!e)&&gr.test(r)||(e==="v6"||!e)&&wr.test(r))}class ct extends oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==$.string){const u=this._getOrReturnCtx(e);return F(u,{code:O.invalid_type,expected:$.string,received:u.parsedType}),ee}const i=new He;let s;for(const u of this._def.checks)if(u.kind==="min")e.data.length<u.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:O.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),i.dirty());else if(u.kind==="max")e.data.length>u.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:O.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),i.dirty());else if(u.kind==="length"){const f=e.data.length>u.value,v=e.data.length<u.value;(f||v)&&(s=this._getOrReturnCtx(e,s),f?F(s,{code:O.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}):v&&F(s,{code:O.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}),i.dirty())}else if(u.kind==="email")mr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"email",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="emoji")Sn||(Sn=new RegExp(yr,"u")),Sn.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"emoji",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="uuid")lr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"uuid",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="nanoid")dr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"nanoid",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="cuid")ur.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="cuid2")cr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid2",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="ulid")fr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ulid",code:O.invalid_string,message:u.message}),i.dirty());else if(u.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),F(s,{validation:"url",code:O.invalid_string,message:u.message}),i.dirty()}else u.kind==="regex"?(u.regex.lastIndex=0,u.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"regex",code:O.invalid_string,message:u.message}),i.dirty())):u.kind==="trim"?e.data=e.data.trim():u.kind==="includes"?e.data.includes(u.value,u.position)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:{includes:u.value,position:u.position},message:u.message}),i.dirty()):u.kind==="toLowerCase"?e.data=e.data.toLowerCase():u.kind==="toUpperCase"?e.data=e.data.toUpperCase():u.kind==="startsWith"?e.data.startsWith(u.value)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:{startsWith:u.value},message:u.message}),i.dirty()):u.kind==="endsWith"?e.data.endsWith(u.value)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:{endsWith:u.value},message:u.message}),i.dirty()):u.kind==="datetime"?Yn(u).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:"datetime",message:u.message}),i.dirty()):u.kind==="date"?xr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:"date",message:u.message}),i.dirty()):u.kind==="time"?Tr(u).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:O.invalid_string,validation:"time",message:u.message}),i.dirty()):u.kind==="duration"?pr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"duration",code:O.invalid_string,message:u.message}),i.dirty()):u.kind==="ip"?Ar(e.data,u.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ip",code:O.invalid_string,message:u.message}),i.dirty()):u.kind==="jwt"?Er(e.data,u.alg)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"jwt",code:O.invalid_string,message:u.message}),i.dirty()):u.kind==="cidr"?Sr(e.data,u.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cidr",code:O.invalid_string,message:u.message}),i.dirty()):u.kind==="base64"?kr.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64",code:O.invalid_string,message:u.message}),i.dirty()):u.kind==="base64url"?_r.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64url",code:O.invalid_string,message:u.message}),i.dirty()):ye.assertNever(u);return{status:i.value,value:e.data}}_regex(e,n,i){return this.refinement(s=>e.test(s),{validation:n,code:O.invalid_string,...G.errToObj(i)})}_addCheck(e){return new ct({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...G.errToObj(e)})}url(e){return this._addCheck({kind:"url",...G.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...G.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...G.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...G.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...G.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...G.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...G.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...G.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...G.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...G.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...G.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...G.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...G.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...G.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...G.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...G.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...G.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...G.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...G.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...G.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...G.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...G.errToObj(n)})}nonempty(e){return this.min(1,G.errToObj(e))}trim(){return new ct({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ct({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ct({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ct.create=r=>new ct({checks:[],typeName:ne.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function Or(r,e){const n=(r.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,s=n>i?n:i,u=Number.parseInt(r.toFixed(s).replace(".","")),f=Number.parseInt(e.toFixed(s).replace(".",""));return u%f/10**s}class Et extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==$.number){const u=this._getOrReturnCtx(e);return F(u,{code:O.invalid_type,expected:$.number,received:u.parsedType}),ee}let i;const s=new He;for(const u of this._def.checks)u.kind==="int"?ye.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:O.invalid_type,expected:"integer",received:"float",message:u.message}),s.dirty()):u.kind==="min"?(u.inclusive?e.data<u.value:e.data<=u.value)&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.too_small,minimum:u.value,type:"number",inclusive:u.inclusive,exact:!1,message:u.message}),s.dirty()):u.kind==="max"?(u.inclusive?e.data>u.value:e.data>=u.value)&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.too_big,maximum:u.value,type:"number",inclusive:u.inclusive,exact:!1,message:u.message}),s.dirty()):u.kind==="multipleOf"?Or(e.data,u.value)!==0&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.not_multiple_of,multipleOf:u.value,message:u.message}),s.dirty()):u.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),F(i,{code:O.not_finite,message:u.message}),s.dirty()):ye.assertNever(u);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,G.toString(n))}gt(e,n){return this.setLimit("min",e,!1,G.toString(n))}lte(e,n){return this.setLimit("max",e,!0,G.toString(n))}lt(e,n){return this.setLimit("max",e,!1,G.toString(n))}setLimit(e,n,i,s){return new Et({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:i,message:G.toString(s)}]})}_addCheck(e){return new Et({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:G.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:G.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:G.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:G.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:G.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ye.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(n===null||i.value>n)&&(n=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Et.create=r=>new Et({checks:[],typeName:ne.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class St extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==$.bigint)return this._getInvalidInput(e);let i;const s=new He;for(const u of this._def.checks)u.kind==="min"?(u.inclusive?e.data<u.value:e.data<=u.value)&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.too_small,type:"bigint",minimum:u.value,inclusive:u.inclusive,message:u.message}),s.dirty()):u.kind==="max"?(u.inclusive?e.data>u.value:e.data>=u.value)&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.too_big,type:"bigint",maximum:u.value,inclusive:u.inclusive,message:u.message}),s.dirty()):u.kind==="multipleOf"?e.data%u.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),F(i,{code:O.not_multiple_of,multipleOf:u.value,message:u.message}),s.dirty()):ye.assertNever(u);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return F(n,{code:O.invalid_type,expected:$.bigint,received:n.parsedType}),ee}gte(e,n){return this.setLimit("min",e,!0,G.toString(n))}gt(e,n){return this.setLimit("min",e,!1,G.toString(n))}lte(e,n){return this.setLimit("max",e,!0,G.toString(n))}lt(e,n){return this.setLimit("max",e,!1,G.toString(n))}setLimit(e,n,i,s){return new St({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:i,message:G.toString(s)}]})}_addCheck(e){return new St({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:G.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}St.create=r=>new St({checks:[],typeName:ne.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class Xt extends oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==$.boolean){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.boolean,received:i.parsedType}),ee}return Je(e.data)}}Xt.create=r=>new Xt({typeName:ne.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Rt extends oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==$.date){const u=this._getOrReturnCtx(e);return F(u,{code:O.invalid_type,expected:$.date,received:u.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const u=this._getOrReturnCtx(e);return F(u,{code:O.invalid_date}),ee}const i=new He;let s;for(const u of this._def.checks)u.kind==="min"?e.data.getTime()<u.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:O.too_small,message:u.message,inclusive:!0,exact:!1,minimum:u.value,type:"date"}),i.dirty()):u.kind==="max"?e.data.getTime()>u.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:O.too_big,message:u.message,inclusive:!0,exact:!1,maximum:u.value,type:"date"}),i.dirty()):ye.assertNever(u);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Rt({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:G.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:G.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Rt.create=r=>new Rt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ne.ZodDate,...ie(r)});class wn extends oe{_parse(e){if(this._getType(e)!==$.symbol){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.symbol,received:i.parsedType}),ee}return Je(e.data)}}wn.create=r=>new wn({typeName:ne.ZodSymbol,...ie(r)});class Qt extends oe{_parse(e){if(this._getType(e)!==$.undefined){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.undefined,received:i.parsedType}),ee}return Je(e.data)}}Qt.create=r=>new Qt({typeName:ne.ZodUndefined,...ie(r)});class Kt extends oe{_parse(e){if(this._getType(e)!==$.null){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.null,received:i.parsedType}),ee}return Je(e.data)}}Kt.create=r=>new Kt({typeName:ne.ZodNull,...ie(r)});class Bt extends oe{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Bt.create=r=>new Bt({typeName:ne.ZodAny,...ie(r)});class Nt extends oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}Nt.create=r=>new Nt({typeName:ne.ZodUnknown,...ie(r)});class kt extends oe{_parse(e){const n=this._getOrReturnCtx(e);return F(n,{code:O.invalid_type,expected:$.never,received:n.parsedType}),ee}}kt.create=r=>new kt({typeName:ne.ZodNever,...ie(r)});class kn extends oe{_parse(e){if(this._getType(e)!==$.undefined){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.void,received:i.parsedType}),ee}return Je(e.data)}}kn.create=r=>new kn({typeName:ne.ZodVoid,...ie(r)});class ft extends oe{_parse(e){const{ctx:n,status:i}=this._processInputParams(e),s=this._def;if(n.parsedType!==$.array)return F(n,{code:O.invalid_type,expected:$.array,received:n.parsedType}),ee;if(s.exactLength!==null){const f=n.data.length>s.exactLength.value,v=n.data.length<s.exactLength.value;(f||v)&&(F(n,{code:f?O.too_big:O.too_small,minimum:v?s.exactLength.value:void 0,maximum:f?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),i.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(F(n,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(F(n,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),n.common.async)return Promise.all([...n.data].map((f,v)=>s.type._parseAsync(new mt(n,f,n.path,v)))).then(f=>He.mergeArray(i,f));const u=[...n.data].map((f,v)=>s.type._parseSync(new mt(n,f,n.path,v)));return He.mergeArray(i,u)}get element(){return this._def.type}min(e,n){return new ft({...this._def,minLength:{value:e,message:G.toString(n)}})}max(e,n){return new ft({...this._def,maxLength:{value:e,message:G.toString(n)}})}length(e,n){return new ft({...this._def,exactLength:{value:e,message:G.toString(n)}})}nonempty(e){return this.min(1,e)}}ft.create=(r,e)=>new ft({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray,...ie(e)});function $t(r){if(r instanceof Me){const e={};for(const n in r.shape){const i=r.shape[n];e[n]=pt.create($t(i))}return new Me({...r._def,shape:()=>e})}else return r instanceof ft?new ft({...r._def,type:$t(r.element)}):r instanceof pt?pt.create($t(r.unwrap())):r instanceof Ct?Ct.create($t(r.unwrap())):r instanceof yt?yt.create(r.items.map(e=>$t(e))):r}class Me extends oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=ye.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==$.object){const S=this._getOrReturnCtx(e);return F(S,{code:O.invalid_type,expected:$.object,received:S.parsedType}),ee}const{status:i,ctx:s}=this._processInputParams(e),{shape:u,keys:f}=this._getCached(),v=[];if(!(this._def.catchall instanceof kt&&this._def.unknownKeys==="strip"))for(const S in s.data)f.includes(S)||v.push(S);const C=[];for(const S of f){const V=u[S],j=s.data[S];C.push({key:{status:"valid",value:S},value:V._parse(new mt(s,j,s.path,S)),alwaysSet:S in s.data})}if(this._def.catchall instanceof kt){const S=this._def.unknownKeys;if(S==="passthrough")for(const V of v)C.push({key:{status:"valid",value:V},value:{status:"valid",value:s.data[V]}});else if(S==="strict")v.length>0&&(F(s,{code:O.unrecognized_keys,keys:v}),i.dirty());else if(S!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const S=this._def.catchall;for(const V of v){const j=s.data[V];C.push({key:{status:"valid",value:V},value:S._parse(new mt(s,j,s.path,V)),alwaysSet:V in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const S=[];for(const V of C){const j=await V.key,x=await V.value;S.push({key:j,value:x,alwaysSet:V.alwaysSet})}return S}).then(S=>He.mergeObjectSync(i,S)):He.mergeObjectSync(i,C)}get shape(){return this._def.shape()}strict(e){return G.errToObj,new Me({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,i)=>{var u,f;const s=((f=(u=this._def).errorMap)==null?void 0:f.call(u,n,i).message)??i.defaultError;return n.code==="unrecognized_keys"?{message:G.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Me({...this._def,unknownKeys:"strip"})}passthrough(){return new Me({...this._def,unknownKeys:"passthrough"})}extend(e){return new Me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Me({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ne.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Me({...this._def,catchall:e})}pick(e){const n={};for(const i of ye.objectKeys(e))e[i]&&this.shape[i]&&(n[i]=this.shape[i]);return new Me({...this._def,shape:()=>n})}omit(e){const n={};for(const i of ye.objectKeys(this.shape))e[i]||(n[i]=this.shape[i]);return new Me({...this._def,shape:()=>n})}deepPartial(){return $t(this)}partial(e){const n={};for(const i of ye.objectKeys(this.shape)){const s=this.shape[i];e&&!e[i]?n[i]=s:n[i]=s.optional()}return new Me({...this._def,shape:()=>n})}required(e){const n={};for(const i of ye.objectKeys(this.shape))if(e&&!e[i])n[i]=this.shape[i];else{let u=this.shape[i];for(;u instanceof pt;)u=u._def.innerType;n[i]=u}return new Me({...this._def,shape:()=>n})}keyof(){return Gn(ye.objectKeys(this.shape))}}Me.create=(r,e)=>new Me({shape:()=>r,unknownKeys:"strip",catchall:kt.create(),typeName:ne.ZodObject,...ie(e)});Me.strictCreate=(r,e)=>new Me({shape:()=>r,unknownKeys:"strict",catchall:kt.create(),typeName:ne.ZodObject,...ie(e)});Me.lazycreate=(r,e)=>new Me({shape:r,unknownKeys:"strip",catchall:kt.create(),typeName:ne.ZodObject,...ie(e)});class en extends oe{_parse(e){const{ctx:n}=this._processInputParams(e),i=this._def.options;function s(u){for(const v of u)if(v.result.status==="valid")return v.result;for(const v of u)if(v.result.status==="dirty")return n.common.issues.push(...v.ctx.common.issues),v.result;const f=u.map(v=>new rt(v.ctx.common.issues));return F(n,{code:O.invalid_union,unionErrors:f}),ee}if(n.common.async)return Promise.all(i.map(async u=>{const f={...n,common:{...n.common,issues:[]},parent:null};return{result:await u._parseAsync({data:n.data,path:n.path,parent:f}),ctx:f}})).then(s);{let u;const f=[];for(const C of i){const S={...n,common:{...n.common,issues:[]},parent:null},V=C._parseSync({data:n.data,path:n.path,parent:S});if(V.status==="valid")return V;V.status==="dirty"&&!u&&(u={result:V,ctx:S}),S.common.issues.length&&f.push(S.common.issues)}if(u)return n.common.issues.push(...u.ctx.common.issues),u.result;const v=f.map(C=>new rt(C));return F(n,{code:O.invalid_union,unionErrors:v}),ee}}get options(){return this._def.options}}en.create=(r,e)=>new en({options:r,typeName:ne.ZodUnion,...ie(e)});const bt=r=>r instanceof rn?bt(r.schema):r instanceof lt?bt(r.innerType()):r instanceof an?[r.value]:r instanceof Ot?r.options:r instanceof sn?ye.objectValues(r.enum):r instanceof on?bt(r._def.innerType):r instanceof Qt?[void 0]:r instanceof Kt?[null]:r instanceof pt?[void 0,...bt(r.unwrap())]:r instanceof Ct?[null,...bt(r.unwrap())]:r instanceof Rn||r instanceof cn?bt(r.unwrap()):r instanceof un?bt(r._def.innerType):[];class En extends oe{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==$.object)return F(n,{code:O.invalid_type,expected:$.object,received:n.parsedType}),ee;const i=this.discriminator,s=n.data[i],u=this.optionsMap.get(s);return u?n.common.async?u._parseAsync({data:n.data,path:n.path,parent:n}):u._parseSync({data:n.data,path:n.path,parent:n}):(F(n,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,i){const s=new Map;for(const u of n){const f=bt(u.shape[e]);if(!f.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const v of f){if(s.has(v))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(v)}`);s.set(v,u)}}return new En({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...ie(i)})}}function Nn(r,e){const n=wt(r),i=wt(e);if(r===e)return{valid:!0,data:r};if(n===$.object&&i===$.object){const s=ye.objectKeys(e),u=ye.objectKeys(r).filter(v=>s.indexOf(v)!==-1),f={...r,...e};for(const v of u){const C=Nn(r[v],e[v]);if(!C.valid)return{valid:!1};f[v]=C.data}return{valid:!0,data:f}}else if(n===$.array&&i===$.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let u=0;u<r.length;u++){const f=r[u],v=e[u],C=Nn(f,v);if(!C.valid)return{valid:!1};s.push(C.data)}return{valid:!0,data:s}}else return n===$.date&&i===$.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class tn extends oe{_parse(e){const{status:n,ctx:i}=this._processInputParams(e),s=(u,f)=>{if(Dn(u)||Dn(f))return ee;const v=Nn(u.value,f.value);return v.valid?((Pn(u)||Pn(f))&&n.dirty(),{status:n.value,value:v.data}):(F(i,{code:O.invalid_intersection_types}),ee)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([u,f])=>s(u,f)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}tn.create=(r,e,n)=>new tn({left:r,right:e,typeName:ne.ZodIntersection,...ie(n)});class yt extends oe{_parse(e){const{status:n,ctx:i}=this._processInputParams(e);if(i.parsedType!==$.array)return F(i,{code:O.invalid_type,expected:$.array,received:i.parsedType}),ee;if(i.data.length<this._def.items.length)return F(i,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&i.data.length>this._def.items.length&&(F(i,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const u=[...i.data].map((f,v)=>{const C=this._def.items[v]||this._def.rest;return C?C._parse(new mt(i,f,i.path,v)):null}).filter(f=>!!f);return i.common.async?Promise.all(u).then(f=>He.mergeArray(n,f)):He.mergeArray(n,u)}get items(){return this._def.items}rest(e){return new yt({...this._def,rest:e})}}yt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new yt({items:r,typeName:ne.ZodTuple,rest:null,...ie(e)})};class nn extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:i}=this._processInputParams(e);if(i.parsedType!==$.object)return F(i,{code:O.invalid_type,expected:$.object,received:i.parsedType}),ee;const s=[],u=this._def.keyType,f=this._def.valueType;for(const v in i.data)s.push({key:u._parse(new mt(i,v,i.path,v)),value:f._parse(new mt(i,i.data[v],i.path,v)),alwaysSet:v in i.data});return i.common.async?He.mergeObjectAsync(n,s):He.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,i){return n instanceof oe?new nn({keyType:e,valueType:n,typeName:ne.ZodRecord,...ie(i)}):new nn({keyType:ct.create(),valueType:e,typeName:ne.ZodRecord,...ie(n)})}}class _n extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:i}=this._processInputParams(e);if(i.parsedType!==$.map)return F(i,{code:O.invalid_type,expected:$.map,received:i.parsedType}),ee;const s=this._def.keyType,u=this._def.valueType,f=[...i.data.entries()].map(([v,C],S)=>({key:s._parse(new mt(i,v,i.path,[S,"key"])),value:u._parse(new mt(i,C,i.path,[S,"value"]))}));if(i.common.async){const v=new Map;return Promise.resolve().then(async()=>{for(const C of f){const S=await C.key,V=await C.value;if(S.status==="aborted"||V.status==="aborted")return ee;(S.status==="dirty"||V.status==="dirty")&&n.dirty(),v.set(S.value,V.value)}return{status:n.value,value:v}})}else{const v=new Map;for(const C of f){const S=C.key,V=C.value;if(S.status==="aborted"||V.status==="aborted")return ee;(S.status==="dirty"||V.status==="dirty")&&n.dirty(),v.set(S.value,V.value)}return{status:n.value,value:v}}}}_n.create=(r,e,n)=>new _n({valueType:e,keyType:r,typeName:ne.ZodMap,...ie(n)});class Mt extends oe{_parse(e){const{status:n,ctx:i}=this._processInputParams(e);if(i.parsedType!==$.set)return F(i,{code:O.invalid_type,expected:$.set,received:i.parsedType}),ee;const s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(F(i,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(F(i,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const u=this._def.valueType;function f(C){const S=new Set;for(const V of C){if(V.status==="aborted")return ee;V.status==="dirty"&&n.dirty(),S.add(V.value)}return{status:n.value,value:S}}const v=[...i.data.values()].map((C,S)=>u._parse(new mt(i,C,i.path,S)));return i.common.async?Promise.all(v).then(C=>f(C)):f(v)}min(e,n){return new Mt({...this._def,minSize:{value:e,message:G.toString(n)}})}max(e,n){return new Mt({...this._def,maxSize:{value:e,message:G.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Mt.create=(r,e)=>new Mt({valueType:r,minSize:null,maxSize:null,typeName:ne.ZodSet,...ie(e)});class zt extends oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==$.function)return F(n,{code:O.invalid_type,expected:$.function,received:n.parsedType}),ee;function i(v,C){return bn({data:v,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gn(),Vt].filter(S=>!!S),issueData:{code:O.invalid_arguments,argumentsError:C}})}function s(v,C){return bn({data:v,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gn(),Vt].filter(S=>!!S),issueData:{code:O.invalid_return_type,returnTypeError:C}})}const u={errorMap:n.common.contextualErrorMap},f=n.data;if(this._def.returns instanceof Wt){const v=this;return Je(async function(...C){const S=new rt([]),V=await v._def.args.parseAsync(C,u).catch(E=>{throw S.addIssue(i(C,E)),S}),j=await Reflect.apply(f,this,V);return await v._def.returns._def.type.parseAsync(j,u).catch(E=>{throw S.addIssue(s(j,E)),S})})}else{const v=this;return Je(function(...C){const S=v._def.args.safeParse(C,u);if(!S.success)throw new rt([i(C,S.error)]);const V=Reflect.apply(f,this,S.data),j=v._def.returns.safeParse(V,u);if(!j.success)throw new rt([s(V,j.error)]);return j.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new zt({...this._def,args:yt.create(e).rest(Nt.create())})}returns(e){return new zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,i){return new zt({args:e||yt.create([]).rest(Nt.create()),returns:n||Nt.create(),typeName:ne.ZodFunction,...ie(i)})}}class rn extends oe{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}rn.create=(r,e)=>new rn({getter:r,typeName:ne.ZodLazy,...ie(e)});class an extends oe{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return F(n,{received:n.data,code:O.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}an.create=(r,e)=>new an({value:r,typeName:ne.ZodLiteral,...ie(e)});function Gn(r,e){return new Ot({values:r,typeName:ne.ZodEnum,...ie(e)})}class Ot extends oe{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),i=this._def.values;return F(n,{expected:ye.joinValues(i),received:n.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),i=this._def.values;return F(n,{received:n.data,code:O.invalid_enum_value,options:i}),ee}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return Ot.create(e,{...this._def,...n})}exclude(e,n=this._def){return Ot.create(this.options.filter(i=>!e.includes(i)),{...this._def,...n})}}Ot.create=Gn;class sn extends oe{_parse(e){const n=ye.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==$.string&&i.parsedType!==$.number){const s=ye.objectValues(n);return F(i,{expected:ye.joinValues(s),received:i.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(ye.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=ye.objectValues(n);return F(i,{received:i.data,code:O.invalid_enum_value,options:s}),ee}return Je(e.data)}get enum(){return this._def.values}}sn.create=(r,e)=>new sn({values:r,typeName:ne.ZodNativeEnum,...ie(e)});class Wt extends oe{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==$.promise&&n.common.async===!1)return F(n,{code:O.invalid_type,expected:$.promise,received:n.parsedType}),ee;const i=n.parsedType===$.promise?n.data:Promise.resolve(n.data);return Je(i.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Wt.create=(r,e)=>new Wt({type:r,typeName:ne.ZodPromise,...ie(e)});class lt extends oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:i}=this._processInputParams(e),s=this._def.effect||null,u={addIssue:f=>{F(i,f),f.fatal?n.abort():n.dirty()},get path(){return i.path}};if(u.addIssue=u.addIssue.bind(u),s.type==="preprocess"){const f=s.transform(i.data,u);if(i.common.async)return Promise.resolve(f).then(async v=>{if(n.value==="aborted")return ee;const C=await this._def.schema._parseAsync({data:v,path:i.path,parent:i});return C.status==="aborted"?ee:C.status==="dirty"||n.value==="dirty"?Lt(C.value):C});{if(n.value==="aborted")return ee;const v=this._def.schema._parseSync({data:f,path:i.path,parent:i});return v.status==="aborted"?ee:v.status==="dirty"||n.value==="dirty"?Lt(v.value):v}}if(s.type==="refinement"){const f=v=>{const C=s.refinement(v,u);if(i.common.async)return Promise.resolve(C);if(C instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return v};if(i.common.async===!1){const v=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return v.status==="aborted"?ee:(v.status==="dirty"&&n.dirty(),f(v.value),{status:n.value,value:v.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(v=>v.status==="aborted"?ee:(v.status==="dirty"&&n.dirty(),f(v.value).then(()=>({status:n.value,value:v.value}))))}if(s.type==="transform")if(i.common.async===!1){const f=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!jt(f))return ee;const v=s.transform(f.value,u);if(v instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:v}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(f=>jt(f)?Promise.resolve(s.transform(f.value,u)).then(v=>({status:n.value,value:v})):ee);ye.assertNever(s)}}lt.create=(r,e,n)=>new lt({schema:r,typeName:ne.ZodEffects,effect:e,...ie(n)});lt.createWithPreprocess=(r,e,n)=>new lt({schema:e,effect:{type:"preprocess",transform:r},typeName:ne.ZodEffects,...ie(n)});class pt extends oe{_parse(e){return this._getType(e)===$.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pt.create=(r,e)=>new pt({innerType:r,typeName:ne.ZodOptional,...ie(e)});class Ct extends oe{_parse(e){return this._getType(e)===$.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ct.create=(r,e)=>new Ct({innerType:r,typeName:ne.ZodNullable,...ie(e)});class on extends oe{_parse(e){const{ctx:n}=this._processInputParams(e);let i=n.data;return n.parsedType===$.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}on.create=(r,e)=>new on({innerType:r,typeName:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class un extends oe{_parse(e){const{ctx:n}=this._processInputParams(e),i={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Jt(s)?s.then(u=>({status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new rt(i.common.issues)},input:i.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new rt(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}un.create=(r,e)=>new un({innerType:r,typeName:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class xn extends oe{_parse(e){if(this._getType(e)!==$.nan){const i=this._getOrReturnCtx(e);return F(i,{code:O.invalid_type,expected:$.nan,received:i.parsedType}),ee}return{status:"valid",value:e.data}}}xn.create=r=>new xn({typeName:ne.ZodNaN,...ie(r)});const Cr=Symbol("zod_brand");class Rn extends oe{_parse(e){const{ctx:n}=this._processInputParams(e),i=n.data;return this._def.type._parse({data:i,path:n.path,parent:n})}unwrap(){return this._def.type}}class fn extends oe{_parse(e){const{status:n,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const u=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return u.status==="aborted"?ee:u.status==="dirty"?(n.dirty(),Lt(u.value)):this._def.out._parseAsync({data:u.value,path:i.path,parent:i})})();{const s=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?ee:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:i.path,parent:i})}}static create(e,n){return new fn({in:e,out:n,typeName:ne.ZodPipeline})}}class cn extends oe{_parse(e){const n=this._def.innerType._parse(e),i=s=>(jt(s)&&(s.value=Object.freeze(s.value)),s);return Jt(n)?n.then(s=>i(s)):i(n)}unwrap(){return this._def.innerType}}cn.create=(r,e)=>new cn({innerType:r,typeName:ne.ZodReadonly,...ie(e)});function $n(r,e){const n=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof n=="string"?{message:n}:n}function Hn(r,e={},n){return r?Bt.create().superRefine((i,s)=>{const u=r(i);if(u instanceof Promise)return u.then(f=>{if(!f){const v=$n(e,i),C=v.fatal??n??!0;s.addIssue({code:"custom",...v,fatal:C})}});if(!u){const f=$n(e,i),v=f.fatal??n??!0;s.addIssue({code:"custom",...f,fatal:v})}}):Bt.create()}const Dr={object:Me.lazycreate};var ne;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(ne||(ne={}));const Pr=(r,e={message:`Input not instance of ${r.name}`})=>Hn(n=>n instanceof r,e),Tn=ct.create,Mn=Et.create,Nr=xn.create,jr=St.create,An=Xt.create,Rr=Rt.create,Mr=wn.create,Ir=Qt.create,Fr=Kt.create,Ur=Bt.create,Zr=Nt.create,$r=kt.create,Lr=kn.create,zr=ft.create,jn=Me.create,Vr=Me.strictCreate,Br=en.create,Wr=En.create,qr=tn.create,Yr=yt.create,Gr=nn.create,Hr=_n.create,Jr=Mt.create,Xr=zt.create,Qr=rn.create,Kr=an.create,Jn=Ot.create,ea=sn.create,ta=Wt.create,Ln=lt.create,na=pt.create,ra=Ct.create,aa=lt.createWithPreprocess,ia=fn.create,sa=()=>Tn().optional(),oa=()=>Mn().optional(),ua=()=>An().optional(),ca={string:(r=>ct.create({...r,coerce:!0})),number:(r=>Et.create({...r,coerce:!0})),boolean:(r=>Xt.create({...r,coerce:!0})),bigint:(r=>St.create({...r,coerce:!0})),date:(r=>Rt.create({...r,coerce:!0}))},fa=ee,A=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Cr,DIRTY:Lt,EMPTY_PATH:or,INVALID:ee,NEVER:fa,OK:Je,ParseStatus:He,Schema:oe,ZodAny:Bt,ZodArray:ft,ZodBigInt:St,ZodBoolean:Xt,ZodBranded:Rn,ZodCatch:un,ZodDate:Rt,ZodDefault:on,ZodDiscriminatedUnion:En,ZodEffects:lt,ZodEnum:Ot,ZodError:rt,get ZodFirstPartyTypeKind(){return ne},ZodFunction:zt,ZodIntersection:tn,ZodIssueCode:O,ZodLazy:rn,ZodLiteral:an,ZodMap:_n,ZodNaN:xn,ZodNativeEnum:sn,ZodNever:kt,ZodNull:Kt,ZodNullable:Ct,ZodNumber:Et,ZodObject:Me,ZodOptional:pt,ZodParsedType:$,ZodPipeline:fn,ZodPromise:Wt,ZodReadonly:cn,ZodRecord:nn,ZodSchema:oe,ZodSet:Mt,ZodString:ct,ZodSymbol:wn,ZodTransformer:lt,ZodTuple:yt,ZodType:oe,ZodUndefined:Qt,ZodUnion:en,ZodUnknown:Nt,ZodVoid:kn,addIssueToContext:F,any:Ur,array:zr,bigint:jr,boolean:An,coerce:ca,custom:Hn,date:Rr,datetimeRegex:Yn,defaultErrorMap:Vt,discriminatedUnion:Wr,effect:Ln,enum:Jn,function:Xr,getErrorMap:gn,getParsedType:wt,instanceof:Pr,intersection:qr,isAborted:Dn,isAsync:Jt,isDirty:Pn,isValid:jt,late:Dr,lazy:Qr,literal:Kr,makeIssue:bn,map:Hr,nan:Nr,nativeEnum:ea,never:$r,null:Fr,nullable:ra,number:Mn,object:jn,get objectUtil(){return Cn},oboolean:ua,onumber:oa,optional:na,ostring:sa,pipeline:ia,preprocess:aa,promise:ta,quotelessJson:ir,record:Gr,set:Jr,setErrorMap:sr,strictObject:Vr,string:Tn,symbol:Mr,transformer:Ln,tuple:Yr,undefined:Ir,union:Br,unknown:Zr,get util(){return ye},void:Lr},Symbol.toStringTag,{value:"Module"})),la=A.object({type:A.literal("object"),shape:A.record(A.string(),A.any())}),da=A.object({type:A.literal("array"),items:A.any()}),ha=A.discriminatedUnion("type",[la,da]),pa=A.object({name:A.literal("ai-parse-data"),sourceData:A.any().optional(),schemaDefinition:ha,prompt:A.string().optional(),model:A.string().optional(),apiKey:A.string().min(1,"OpenAI API key is required")}),ma=dt.extend({name:A.literal("get-text"),includeTags:A.boolean().optional(),useTextContent:A.boolean().optional(),regex:A.string().optional(),prefixText:A.string().optional(),suffixText:A.string().optional(),filterEmpty:A.boolean().optional(),scrollToCollect:A.boolean().optional(),scrollDistance:A.number().optional(),scrollWaitMs:A.number().optional(),maxScrollAttempts:A.number().optional()}),ya=dt.extend({name:A.literal("attribute-value"),attributeName:A.string()}),va=dt.extend({name:A.literal("get-value-form"),type:A.enum(["text-field","select","checkbox"]).optional()}),ga=dt.extend({name:A.literal("set-value-form"),setValue:A.string(),type:A.enum(["text-field","select","checkbox"]).optional()}),ba=dt.extend({name:A.literal("clear-value-form"),type:A.enum(["text-field","select","checkbox"]).optional()}),wa=dt.extend({name:A.literal("element-exists")}),ka=dt.extend({name:A.literal("event-click"),textFilter:A.object({text:A.union([A.string(),A.array(A.string())]),mode:A.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()}),_a=A.object({name:A.literal("keypress"),key:A.string(),code:A.string().optional(),keyCode:A.number().optional(),modifiers:A.array(A.enum(["Alt","Control","Meta","Shift"])).optional()}),xa=A.object({name:A.literal("wait"),duration:A.number().min(0)}),Ta=A.object({name:A.literal("wait-for-condition"),conditions:A.object({urlPattern:A.string().optional(),elementExists:A.object({selector:A.string(),findBy:A.enum(["cssSelector","xpath"])}).optional(),cookieExists:A.string().optional(),storageKey:A.object({type:A.enum(["localStorage","sessionStorage"]),key:A.string()}).optional(),userConfirmation:A.boolean().optional(),message:A.string().optional(),buttonText:A.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:A.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:A.number().min(100).optional(),timeoutMs:A.number().min(1e3).optional(),position:A.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()}),Aa=dt.extend({name:A.literal("save-assets")}),Ea=dt.extend({name:A.literal("get-element-data"),includeText:A.boolean().optional(),includeTags:A.boolean().optional(),useTextContent:A.boolean().optional(),regex:A.string().optional(),prefixText:A.string().optional(),suffixText:A.string().optional(),attributes:A.array(A.string()).optional(),includeSelector:A.boolean().optional(),includeXPath:A.boolean().optional()}),Sa=dt.extend({name:A.literal("scroll"),scrollType:A.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:A.number().optional(),behavior:A.enum(["auto","smooth"]).optional(),maxScrolls:A.number().optional(),waitAfterScroll:A.number().optional()}),Oa=A.object({name:A.literal("fetch-api"),url:A.string(),method:A.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:A.record(A.string(),A.string()).optional(),body:A.record(A.string(),A.any()).optional(),timeout:A.number().min(0).optional(),parseJson:A.boolean().optional(),returnHeaders:A.boolean().optional()});var zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vn(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var On={exports:{}},Vn;function Ca(){return Vn||(Vn=1,(function(r,e){(function(n){r.exports=n()})(function(){return(function(){function n(i,s,u){function f(S,V){if(!s[S]){if(!i[S]){var j=typeof vn=="function"&&vn;if(!V&&j)return j(S,!0);if(v)return v(S,!0);var x=new Error("Cannot find module '"+S+"'");throw x.code="MODULE_NOT_FOUND",x}var E=s[S]={exports:{}};i[S][0].call(E.exports,function(q){var be=i[S][1][q];return f(be||q)},E,E.exports,n,i,s,u)}return s[S].exports}for(var v=typeof vn=="function"&&vn,C=0;C<u.length;C++)f(u[C]);return f}return n})()({1:[function(n,i,s){const u=n("./utils"),f=(function(){const v=u.stringToArray,C=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],S=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],V=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],j=["Thousand","Million","Billion","Trillion"];function x(g,_){var b=function(I,R,T){var M="";if(I<=19)M=(R?" and ":"")+(T?S[I]:C[I]);else if(I<100){const pe=Math.floor(I/10),ve=I%10;M=(R?" and ":"")+V[pe-2],ve>0?M+="-"+b(ve,!1,T):T&&(M=M.substring(0,M.length-1)+"ieth")}else if(I<1e3){const pe=Math.floor(I/100),ve=I%100;M=(R?", ":"")+C[pe]+" Hundred",ve>0?M+=b(ve,!0,T):T&&(M+="th")}else{var J=Math.floor(Math.log10(I)/3);J>j.length&&(J=j.length);const pe=Math.pow(10,J*3),ve=Math.floor(I/pe),H=I-ve*pe;M=(R?", ":"")+b(ve,!1,!1)+" "+j[J-1],H>0?M+=b(H,!0,T):T&&(M+="th")}return M},D=b(g,!1,_);return D}const E={};C.forEach(function(g,_){E[g.toLowerCase()]=_}),S.forEach(function(g,_){E[g.toLowerCase()]=_}),V.forEach(function(g,_){const b=g.toLowerCase();E[b]=(_+2)*10,E[b.substring(0,g.length-1)+"ieth"]=E[b]}),E.hundredth=100,j.forEach(function(g,_){const b=g.toLowerCase(),D=Math.pow(10,(_+1)*3);E[b]=D,E[b+"th"]=D});function q(g){const b=g.split(/,\s|\sand\s|[\s\\-]/).map(R=>E[R]);let D=[0];return b.forEach(R=>{if(R<100){let T=D.pop();T>=1e3&&(D.push(T),T=0),D.push(T+R)}else D.push(D.pop()*R)}),D.reduce((R,T)=>R+T,0)}const be=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Pe={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function Ce(g){for(var _=0;_<be.length;_++){const b=be[_];if(g>=b[0])return b[1]+Ce(g-b[0])}return""}function Q(g){for(var _=0,b=1,D=g.length-1;D>=0;D--){const I=g[D],R=Pe[I];R<b?_-=R:(b=R,_+=R)}return _}function P(g,_){for(var b=[],D=_.charCodeAt(0);g>0;)b.unshift(String.fromCharCode((g-1)%26+D)),g=Math.floor((g-1)/26);return b.join("")}function ae(g,_){for(var b=_.charCodeAt(0),D=0,I=0;I<g.length;I++)D+=(g.charCodeAt(g.length-I-1)-b+1)*Math.pow(26,I);return D}function L(g,_){if(typeof g>"u")return;g=Math.floor(g);const b=we(_);return B(g,b)}const k={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},U={UPPER:"upper",LOWER:"lower",TITLE:"title"};function B(g,_){let b;const D=g<0;switch(g=Math.abs(g),_.primary){case k.LETTERS:b=P(g,_.case===U.UPPER?"A":"a");break;case k.ROMAN:b=Ce(g),_.case===U.UPPER&&(b=b.toUpperCase());break;case k.WORDS:b=x(g,_.ordinal),_.case===U.UPPER?b=b.toUpperCase():_.case===U.LOWER&&(b=b.toLowerCase());break;case k.DECIMAL:b=""+g;var I=_.mandatoryDigits-b.length;if(I>0){var R=new Array(I+1).join("0");b=R+b}if(_.zeroCode!==48&&(b=v(b).map(pe=>String.fromCodePoint(pe.codePointAt(0)+_.zeroCode-48)).join("")),_.regular){const pe=Math.floor((b.length-1)/_.groupingSeparators.position);for(let ve=pe;ve>0;ve--){const H=b.length-ve*_.groupingSeparators.position;b=b.substr(0,H)+_.groupingSeparators.character+b.substr(H)}}else _.groupingSeparators.reverse().forEach(pe=>{const ve=b.length-pe.position;b=b.substr(0,ve)+pe.character+b.substr(ve)});if(_.ordinal){var T={1:"st",2:"nd",3:"rd"},M=b[b.length-1],J=T[M];(!J||b.length>1&&b[b.length-2]==="1")&&(J="th"),b=b+J}break;case k.SEQUENCE:throw{code:"D3130",value:_.token}}return D&&(b="-"+b),b}const le=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function we(g){const _={type:"integer",primary:k.DECIMAL,case:U.LOWER,ordinal:!1};let b,D;const I=g.lastIndexOf(";");switch(I===-1?b=g:(b=g.substring(0,I),D=g.substring(I+1),D[0]==="o"&&(_.ordinal=!0)),b){case"A":_.case=U.UPPER;case"a":_.primary=k.LETTERS;break;case"I":_.case=U.UPPER;case"i":_.primary=k.ROMAN;break;case"W":_.case=U.UPPER,_.primary=k.WORDS;break;case"Ww":_.case=U.TITLE,_.primary=k.WORDS;break;case"w":_.primary=k.WORDS;break;default:{let R=null,T=0,M=0,J=[],pe=0;if(v(b).map(H=>H.codePointAt(0)).reverse().forEach(H=>{let K=!1;for(let de=0;de<le.length;de++){const Y=le[de];if(H>=Y&&H<=Y+9){if(K=!0,T++,pe++,R===null)R=Y;else if(Y!==R)throw{code:"D3131"};break}}K||(H===35?(pe++,M++):J.push({position:pe,character:String.fromCodePoint(H)}))}),T>0){_.primary=k.DECIMAL,_.zeroCode=R,_.mandatoryDigits=T,_.optionalDigits=M;const K=function(de){if(de.length===0)return 0;const Y=de[0].character;for(let Ze=1;Ze<de.length;Ze++)if(de[Ze].character!==Y)return 0;const Le=de.map(Ze=>Ze.position),it=function(Ze,qe){return qe===0?Ze:it(qe,Ze%qe)},We=Le.reduce(it);for(let Ze=1;Ze<=Le.length;Ze++)if(Le.indexOf(Ze*We)===-1)return 0;return We}(J);K>0?(_.regular=!0,_.groupingSeparators={position:K,character:J[0].character}):(_.regular=!1,_.groupingSeparators=J)}else _.primary=k.SEQUENCE,_.token=b}}return _}const xe={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Te(g){var _=[];const b={type:"datetime",parts:_},D=function(K,de){if(de>K){let Y=g.substring(K,de);Y=Y.split("]]").join("]"),_.push({type:"literal",value:Y})}};for(var I=0,R=0;R<g.length;){if(g.charAt(R)==="["){if(g.charAt(R+1)==="["){D(I,R),_.push({type:"literal",value:"["}),R+=2,I=R;continue}if(D(I,R),I=R,R=g.indexOf("]",I),R===-1)throw{code:"D3135"};let K=g.substring(I+1,R);K=K.split(/\s+/).join("");var T={type:"marker",component:K.charAt(0)},M=K.lastIndexOf(","),J;if(M!==-1){const de=K.substring(M+1),Y=de.indexOf("-");let Le,it;const We=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};Y===-1?Le=de:(Le=de.substring(0,Y),it=de.substring(Y+1));const Ze={min:We(Le),max:We(it)};T.width=Ze,J=K.substring(1,M)}else J=K.substring(1);if(J.length===1)T.presentation1=J;else if(J.length>1){var pe=J.charAt(J.length-1);"atco".indexOf(pe)!==-1?(T.presentation2=pe,pe==="o"&&(T.ordinal=!0),T.presentation1=J.substring(0,J.length-1)):T.presentation1=J}else T.presentation1=xe[T.component];if(typeof T.presentation1>"u")throw{code:"D3132",value:T.component};if(T.presentation1[0]==="n")T.names=U.LOWER;else if(T.presentation1[0]==="N")T.presentation1[1]==="n"?T.names=U.TITLE:T.names=U.UPPER;else if("YMDdFWwXxHhmsf".indexOf(T.component)!==-1){var ve=T.presentation1;if(T.presentation2&&(ve+=";"+T.presentation2),T.integerFormat=we(ve),T.width&&T.width.min!==void 0&&T.integerFormat.mandatoryDigits<T.width.min&&(T.integerFormat.mandatoryDigits=T.width.min),T.component==="Y")if(T.n=-1,T.width&&T.width.max!==void 0)T.n=T.width.max,T.integerFormat.mandatoryDigits=T.n;else{var H=T.integerFormat.mandatoryDigits+T.integerFormat.optionalDigits;H>=2&&(T.n=H)}const de=_[_.length-1];de&&de.integerFormat&&(de.integerFormat.parseWidth=de.integerFormat.mandatoryDigits)}(T.component==="Z"||T.component==="z")&&(T.integerFormat=we(T.presentation1)),_.push(T),I=R+1}R++}return D(I,R),b}const me=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],je=["January","February","March","April","May","June","July","August","September","October","November","December"],Ke=1e3*60*60*24,ke=function(g){const _=Date.UTC(g.year,g.month);var b=new Date(_).getUTCDay();return b===0&&(b=7),b>4?_+(8-b)*Ke:_-(b-1)*Ke},ue=function(g,_){return{year:g,month:_,nextMonth:function(){return _===11?ue(g+1,0):ue(g,_+1)},previousMonth:function(){return _===0?ue(g-1,11):ue(g,_-1)},nextYear:function(){return ue(g+1,_)},previousYear:function(){return ue(g-1,_)}}},et=function(g,_){return(_-g)/(Ke*7)+1},re=(g,_)=>{let b;switch(_){case"Y":b=g.getUTCFullYear();break;case"M":b=g.getUTCMonth()+1;break;case"D":b=g.getUTCDate();break;case"d":{const D=Date.UTC(g.getUTCFullYear(),g.getUTCMonth(),g.getUTCDate()),I=Date.UTC(g.getUTCFullYear(),0);b=(D-I)/Ke+1;break}case"F":b=g.getUTCDay(),b===0&&(b=7);break;case"W":{const D=ue(g.getUTCFullYear(),0),I=ke(D),R=Date.UTC(D.year,g.getUTCMonth(),g.getUTCDate());let T=et(I,R);if(T>52){const M=ke(D.nextYear());R>=M&&(T=1)}else if(T<1){const M=ke(D.previousYear());T=et(M,R)}b=Math.floor(T);break}case"w":{const D=ue(g.getUTCFullYear(),g.getUTCMonth()),I=ke(D),R=Date.UTC(D.year,D.month,g.getUTCDate());let T=et(I,R);if(T>4){const M=ke(D.nextMonth());R>=M&&(T=1)}else if(T<1){const M=ke(D.previousMonth());T=et(M,R)}b=Math.floor(T);break}case"X":{const D=ue(g.getUTCFullYear(),0),I=ke(D),R=ke(D.nextYear()),T=g.getTime();T<I?b=D.year-1:T>=R?b=D.year+1:b=D.year;break}case"x":{const D=ue(g.getUTCFullYear(),g.getUTCMonth()),I=ke(D),R=D.nextMonth(),T=ke(R),M=g.getTime();M<I?b=D.previousMonth().month+1:M>=T?b=R.month+1:b=D.month+1;break}case"H":b=g.getUTCHours();break;case"h":b=g.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=g.getUTCHours()>=12?"pm":"am";break;case"m":b=g.getUTCMinutes();break;case"s":b=g.getUTCSeconds();break;case"f":b=g.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Fe=null;function at(g,_,b){var D=0,I=0;if(typeof b<"u"){const ve=parseInt(b);D=Math.floor(ve/100),I=ve%100}var R=function(ve,H){var K=re(ve,H.component);if("YMDdFWwXxHhms".indexOf(H.component)!==-1)if(H.component==="Y"&&H.n!==-1&&(K=K%Math.pow(10,H.n)),H.names){if(H.component==="M"||H.component==="x")K=je[K-1];else if(H.component==="F")K=me[K];else throw{code:"D3133",value:H.component};H.names===U.UPPER?K=K.toUpperCase():H.names===U.LOWER&&(K=K.toLowerCase()),H.width&&K.length>H.width.max&&(K=K.substring(0,H.width.max))}else K=B(K,H.integerFormat);else if(H.component==="f")K=B(K,H.integerFormat);else if(H.component==="Z"||H.component==="z"){const de=D*100+I;if(H.integerFormat.regular)K=B(de,H.integerFormat);else{const Y=H.integerFormat.mandatoryDigits;if(Y===1||Y===2)K=B(D,H.integerFormat),I!==0&&(K+=":"+L(I,"00"));else if(Y===3||Y===4)K=B(de,H.integerFormat);else throw{code:"D3134",value:Y}}de>=0&&(K="+"+K),H.component==="z"&&(K="GMT"+K),de===0&&H.presentation2==="t"&&(K="Z")}else H.component==="P"&&H.names===U.UPPER&&(K=K.toUpperCase());return K};let T;typeof _>"u"?(Fe===null&&(Fe=Te("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),T=Fe):T=Te(_);const M=(60*D+I)*60*1e3,J=new Date(g+M);let pe="";return T.parts.forEach(function(ve){ve.type==="literal"?pe+=ve.value:pe+=R(J,ve)}),pe}function l(g){var _={};if(g.type==="datetime")_.type="datetime",_.parts=g.parts.map(function(b){var D={};if(b.type==="literal")D.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let R;Array.isArray(b.integerFormat.groupingSeparators)||(R=b.integerFormat.groupingSeparators),D.regex="",b.component==="z"&&(D.regex="GMT"),D.regex+="[-+][0-9]+",R&&(D.regex+=R.character+"[0-9]+"),D.parse=function(T){b.component==="z"&&(T=T.substring(3));let M=0,J=0;return R?(M=Number.parseInt(T.substring(0,T.indexOf(R.character))),J=Number.parseInt(T.substring(T.indexOf(R.character)+1))):T.length-1<=2?M=Number.parseInt(T):(M=Number.parseInt(T.substring(0,3)),J=Number.parseInt(T.substring(3))),M*60+J}}else if(b.integerFormat)D=l(b.integerFormat);else{D.regex="[a-zA-Z]+";var I={};if(b.component==="M"||b.component==="x")je.forEach(function(R,T){b.width&&b.width.max?I[R.substring(0,b.width.max)]=T+1:I[R]=T+1});else if(b.component==="F")me.forEach(function(R,T){T>0&&(b.width&&b.width.max?I[R.substring(0,b.width.max)]=T:I[R]=T)});else if(b.component==="P")I={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};D.parse=function(R){return I[R]}}return D.component=b.component,D});else{_.type="integer";const b=g.case===U.UPPER;switch(g.primary){case k.LETTERS:_.regex=b?"[A-Z]+":"[a-z]+",_.parse=function(D){return ae(D,b?"A":"a")};break;case k.ROMAN:_.regex=b?"[MDCLXVI]+":"[mdclxvi]+",_.parse=function(D){return Q(b?D:D.toUpperCase())};break;case k.WORDS:_.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",_.parse=function(D){return q(D.toLowerCase())};break;case k.DECIMAL:_.regex="[0-9]",g.parseWidth?_.regex+=`{${g.parseWidth}}`:_.regex+="+",g.ordinal&&(_.regex+="(?:th|st|nd|rd)"),_.parse=function(D){let I=D;return g.ordinal&&(I=D.substring(0,D.length-2)),g.regular?I=I.split(",").join(""):g.groupingSeparators.forEach(R=>{I=I.split(R.character).join("")}),g.zeroCode!==48&&(I=I.split("").map(R=>String.fromCodePoint(R.codePointAt(0)-g.zeroCode+48)).join("")),parseInt(I)};break;case k.SEQUENCE:throw{code:"D3130",value:g.token}}}return _}function p(g,_){if(typeof g>"u")return;const b=we(_);return l(b).parse(g)}function z(g,_){const b=Te(_),D=l(b),I="^"+D.parts.map(J=>"("+J.regex+")").join("")+"$";var T=new RegExp(I,"i").exec(g);if(T!==null){const Y={};for(let Ee=1;Ee<T.length;Ee++){const o=D.parts[Ee-1];o.parse&&(Y[o.component]=o.parse(T[Ee]))}if(Object.getOwnPropertyNames(Y).length===0)return;let Le=0;const it=Ee=>{Le<<=1,Le+=Ee?1:0},We=Ee=>!(~Ee&Le)&&!!(Ee&Le);"YXMxWwdD".split("").forEach(Ee=>it(Y[Ee]));const qe=!We(161)&&We(130),vt=We(84),_t=!vt&&We(72);Le=0,"PHhmsf".split("").forEach(Ee=>it(Y[Ee]));const xt=!We(23)&&We(47),qt=(qe?"YD":vt?"XxwF":_t?"XWF":"YMD")+(xt?"Phmsf":"Hmsf"),ot=this.environment.timestamp;let It=!1,ht=!1;if(qt.split("").forEach(Ee=>{if(typeof Y[Ee]>"u")It?(Y[Ee]="MDd".indexOf(Ee)!==-1?1:0,ht=!0):Y[Ee]=re(ot,Ee);else if(It=!0,ht)throw{code:"D3136"}}),Y.M>0?Y.M-=1:Y.M=0,qe){const Ee=Date.UTC(Y.Y,0),o=(Y.d-1)*1e3*60*60*24,d=new Date(Ee+o);Y.M=d.getUTCMonth(),Y.D=d.getUTCDate()}if(vt)throw{code:"D3136"};if(_t)throw{code:"D3136"};xt&&(Y.H=Y.h===12?0:Y.h,Y.P===1&&(Y.H+=12));var M=Date.UTC(Y.Y,Y.M,Y.D,Y.H,Y.m,Y.s,Y.f);return(Y.Z||Y.z)&&(M-=(Y.Z||Y.z)*60*1e3),M}}var ce=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function Oe(g,_){if(!(typeof g>"u"))if(typeof _>"u"){if(!ce.test(g))throw{stack:new Error().stack,code:"D3110",value:g};return Date.parse(g)}else return z.call(this,g,_)}function _e(g,_,b){if(!(typeof g>"u"))return at.call(this,g,_,b)}return{formatInteger:L,parseInteger:p,fromMillis:_e,toMillis:Oe}})();i.exports=f},{"./utils":6}],2:[function(n,i,s){(function(u){(function(){var f=n("./utils");const v=(()=>{var C=f.isNumeric,S=f.isArrayOfStrings,V=f.isArrayOfNumbers,j=f.createSequence,x=f.isSequence,E=f.isFunction,q=f.isLambda,be=f.isPromise,Pe=f.getFunctionArity,Ce=f.isDeepEqual,Q=f.stringToArray;function P(t){if(!(typeof t>"u")){var a=0;return t.forEach(function(c){a+=c}),a}}function ae(t){return typeof t>"u"?0:t.length}function L(t){if(!(typeof t>"u"||t.length===0))return Math.max.apply(Math,t)}function k(t){if(!(typeof t>"u"||t.length===0))return Math.min.apply(Math,t)}function U(t){if(!(typeof t>"u"||t.length===0)){var a=0;return t.forEach(function(c){a+=c}),a/t.length}}function B(t,a=!1){if(!(typeof t>"u")){var c;if(typeof t=="string")c=t;else if(E(t))c="";else{if(typeof t=="number"&&!isFinite(t))throw{code:"D3001",value:t,stack:new Error().stack};var y=a?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),c=JSON.stringify(t,function(h,w){return typeof w<"u"&&w!==null&&w.toPrecision&&C(w)?Number(w.toPrecision(15)):w&&E(w)?"":w},y)}return c}}function le(t,a,c){if(!(typeof t>"u")){var y=Q(t),h=y.length;if(h+a<0&&(a=0),typeof c<"u"){if(c<=0)return"";var w=a>=0?a+c:h+a+c;return y.slice(a,w).join("")}return y.slice(a).join("")}}function we(t,a){if(!(typeof t>"u")){var c=t.indexOf(a);return c>-1?t.substr(0,c):t}}function xe(t,a){if(!(typeof t>"u")){var c=t.indexOf(a);return c>-1?t.substr(c+a.length):t}}function Te(t){if(!(typeof t>"u"))return t.toLowerCase()}function me(t){if(!(typeof t>"u"))return t.toUpperCase()}function je(t){if(!(typeof t>"u"))return Q(t).length}function Ke(t){if(!(typeof t>"u")){var a=t.replace(/[ \t\n\r]+/gm," ");return a.charAt(0)===" "&&(a=a.substring(1)),a.charAt(a.length-1)===" "&&(a=a.substring(0,a.length-1)),a}}function ke(t,a,c){if(!(typeof t>"u")){(typeof c>"u"||c.length===0)&&(c=" ");var y;a=Math.trunc(a);var h=Math.abs(a)-je(t);if(h>0){var w=new Array(h+1).join(c);c.length>1&&(w=le(w,0,h)),a>0?y=t+w:y=w+t}else y=t;return y}}async function ue(t,a){var c=t.apply(this,[a]);if(be(c)&&(c=await c),c&&!(typeof c.start=="number"||c.end==="number"||Array.isArray(c.groups)||E(c.next)))throw{code:"T1010",stack:new Error().stack};return c}async function et(t,a){if(!(typeof t>"u")){var c;if(typeof a=="string")c=t.indexOf(a)!==-1;else{var y=await ue(a,t);c=typeof y<"u"}return c}}async function re(t,a,c){if(!(typeof t>"u")){if(c<0)throw{stack:new Error().stack,value:c,code:"D3040",index:3};var y=j();if(typeof c>"u"||c>0){var h=0,w=await ue(a,t);if(typeof w<"u")for(;typeof w<"u"&&(typeof c>"u"||h<c);)y.push({match:w.match,index:w.start,groups:w.groups}),w=await ue(w.next),h++}return y}}async function Fe(t,a,c,y){if(!(typeof t>"u")){var h=this;if(a==="")throw{code:"D3010",stack:new Error().stack,value:a,index:2};if(y<0)throw{code:"D3011",stack:new Error().stack,value:y,index:4};var w;typeof c=="string"?w=function(Ae){for(var ze="",ge=0,Ie=c.indexOf("$",ge);Ie!==-1&&ge<c.length;){ze+=c.substring(ge,Ie),ge=Ie+1;var st=c.charAt(ge);if(st==="$")ze+="$",ge++;else if(st==="0")ze+=Ae.match,ge++;else{var Ve;if(Ae.groups.length===0?Ve=1:Ve=Math.floor(Math.log(Ae.groups.length)*Math.LOG10E)+1,Ie=parseInt(c.substring(ge,ge+Ve),10),Ve>1&&Ie>Ae.groups.length&&(Ie=parseInt(c.substring(ge,ge+Ve-1),10)),isNaN(Ie))ze+="$";else{if(Ae.groups.length>0){var Ft=Ae.groups[Ie-1];typeof Ft<"u"&&(ze+=Ft)}ge+=Ie.toString().length}}Ie=c.indexOf("$",ge)}return ze+=c.substring(ge),ze}:w=c;var N="",W=0;if(typeof y>"u"||y>0){var X=0;if(typeof a=="string"){for(var Se=t.indexOf(a,W);Se!==-1&&(typeof y>"u"||X<y);)N+=t.substring(W,Se),N+=c,W=Se+a.length,X++,Se=t.indexOf(a,W);N+=t.substring(W)}else{var he=await ue(a,t);if(typeof he<"u"){for(;typeof he<"u"&&(typeof y>"u"||X<y);){N+=t.substring(W,he.start);var De=w.apply(h,[he]);if(be(De)&&(De=await De),typeof De=="string")N+=De;else throw{code:"D3012",stack:new Error().stack,value:De};W=he.start+he.match.length,X++,he=await ue(he.next)}N+=t.substring(W)}else N=t}}else N=t;return N}}function at(t){if(!(typeof t>"u")){var a=typeof window<"u"?window.btoa:function(c){return new u.Buffer.from(c,"binary").toString("base64")};return a(t)}}function l(t){if(!(typeof t>"u")){var a=typeof window<"u"?window.atob:function(c){return new u.Buffer.from(c,"base64").toString("binary")};return a(t)}}function p(t){if(!(typeof t>"u")){var a;try{a=encodeURIComponent(t)}catch{throw{code:"D3140",stack:new Error().stack,value:t,functionName:"encodeUrlComponent"}}return a}}function z(t){if(!(typeof t>"u")){var a;try{a=encodeURI(t)}catch{throw{code:"D3140",stack:new Error().stack,value:t,functionName:"encodeUrl"}}return a}}function ce(t){if(!(typeof t>"u")){var a;try{a=decodeURIComponent(t)}catch{throw{code:"D3140",stack:new Error().stack,value:t,functionName:"decodeUrlComponent"}}return a}}function Oe(t){if(!(typeof t>"u")){var a;try{a=decodeURI(t)}catch{throw{code:"D3140",stack:new Error().stack,value:t,functionName:"decodeUrl"}}return a}}async function _e(t,a,c){if(!(typeof t>"u")){if(c<0)throw{code:"D3020",stack:new Error().stack,value:c,index:3};var y=[];if(typeof c>"u"||c>0)if(typeof a=="string")y=t.split(a,c);else{var h=0,w=await ue(a,t);if(typeof w<"u"){for(var N=0;typeof w<"u"&&(typeof c>"u"||h<c);)y.push(t.substring(N,w.start)),N=w.end,w=await ue(w.next),h++;(typeof c>"u"||h<c)&&y.push(t.substring(N))}else y.push(t)}return y}}function g(t,a){if(!(typeof t>"u"))return typeof a>"u"&&(a=""),t.join(a)}function _(t,a,c){if(!(typeof t>"u")){var y={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},h=y;typeof c<"u"&&Object.keys(c).forEach(function(te){h[te]=c[te]});for(var w=[],N=h["zero-digit"].charCodeAt(0),W=N;W<N+10;W++)w.push(String.fromCharCode(W));var X=w.concat([h["decimal-separator"],h["exponent-separator"],h["grouping-separator"],h.digit,h["pattern-separator"]]),Se=a.split(h["pattern-separator"]);if(Se.length>2)throw{code:"D3080",stack:new Error().stack};var he=function(te){var Re=(function(){for(var $e,nt=0;nt<te.length;nt++)if($e=te.charAt(nt),X.indexOf($e)!==-1&&$e!==h["exponent-separator"])return te.substring(0,nt)})(),Ge=(function(){for(var $e,nt=te.length-1;nt>=0;nt--)if($e=te.charAt(nt),X.indexOf($e)!==-1&&$e!==h["exponent-separator"])return te.substring(nt+1)})(),Ne=te.substring(Re.length,te.length-Ge.length),Xe,Tt,Qe,Pt,tt=te.indexOf(h["exponent-separator"],Re.length);tt===-1||tt>te.length-Ge.length?(Xe=Ne,Tt=void 0):(Xe=Ne.substring(0,tt),Tt=Ne.substring(tt+1));var ut=Xe.indexOf(h["decimal-separator"]);return ut===-1?(Qe=Xe,Pt=Ge):(Qe=Xe.substring(0,ut),Pt=Xe.substring(ut+1)),{prefix:Re,suffix:Ge,activePart:Ne,mantissaPart:Xe,exponentPart:Tt,integerPart:Qe,fractionalPart:Pt,subpicture:te}},De=function(te){var Re,Ge,Ne=te.subpicture,Xe=Ne.indexOf(h["decimal-separator"]);Xe!==Ne.lastIndexOf(h["decimal-separator"])&&(Re="D3081"),Ne.indexOf(h.percent)!==Ne.lastIndexOf(h.percent)&&(Re="D3082"),Ne.indexOf(h["per-mille"])!==Ne.lastIndexOf(h["per-mille"])&&(Re="D3083"),Ne.indexOf(h.percent)!==-1&&Ne.indexOf(h["per-mille"])!==-1&&(Re="D3084");var Tt=!1;for(Ge=0;Ge<te.mantissaPart.length;Ge++){var Qe=te.mantissaPart.charAt(Ge);if(w.indexOf(Qe)!==-1||Qe===h.digit){Tt=!0;break}}Tt||(Re="D3085");var Pt=te.activePart.split("").map(function($e){return X.indexOf($e)===-1?"p":"a"}).join("");Pt.indexOf("p")!==-1&&(Re="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===h["grouping-separator"]||Ne.charAt(Xe+1)===h["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===h["grouping-separator"]&&(Re="D3088"),Ne.indexOf(h["grouping-separator"]+h["grouping-separator"])!==-1&&(Re="D3089");var tt=te.integerPart.indexOf(h.digit);tt!==-1&&te.integerPart.substring(0,tt).split("").filter(function($e){return w.indexOf($e)>-1}).length>0&&(Re="D3090"),tt=te.fractionalPart.lastIndexOf(h.digit),tt!==-1&&te.fractionalPart.substring(tt).split("").filter(function($e){return w.indexOf($e)>-1}).length>0&&(Re="D3091");var ut=typeof te.exponentPart=="string";if(ut&&te.exponentPart.length>0&&(Ne.indexOf(h.percent)!==-1||Ne.indexOf(h["per-mille"])!==-1)&&(Re="D3092"),ut&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function($e){return w.indexOf($e)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Ae=function(te){var Re=function(Be,mn){for(var Ht=[],gt=Be.indexOf(h["grouping-separator"]);gt!==-1;){var yn=(mn?Be.substring(0,gt):Be.substring(gt)).split("").filter(function(Zt){return w.indexOf(Zt)!==-1||Zt===h.digit}).length;Ht.push(yn),gt=te.integerPart.indexOf(h["grouping-separator"],gt+1)}return Ht},Ge=Re(te.integerPart),Ne=function(Be){if(Be.length===0)return 0;for(var mn=function(yn,Zt){return Zt===0?yn:mn(Zt,yn%Zt)},Ht=Be.reduce(mn),gt=1;gt<=Be.length;gt++)if(Be.indexOf(gt*Ht)===-1)return 0;return Ht},Xe=Ne(Ge),Tt=Re(te.fractionalPart,!0),Qe=te.integerPart.split("").filter(function(Be){return w.indexOf(Be)!==-1}).length,Pt=Qe,tt=te.fractionalPart.split(""),ut=tt.filter(function(Be){return w.indexOf(Be)!==-1}).length,$e=tt.filter(function(Be){return w.indexOf(Be)!==-1||Be===h.digit}).length,nt=typeof te.exponentPart=="string";Qe===0&&$e===0&&(nt?(ut=1,$e=1):Qe=1),nt&&Qe===0&&te.integerPart.indexOf(h.digit)!==-1&&(Qe=1),Qe===0&&ut===0&&(ut=1);var Un=0;return nt&&(Un=te.exponentPart.split("").filter(function(Be){return w.indexOf(Be)!==-1}).length),{integerPartGroupingPositions:Ge,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Pt,prefix:te.prefix,fractionalPartGroupingPositions:Tt,minimumFactionalPartSize:ut,maximumFactionalPartSize:$e,minimumExponentSize:Un,suffix:te.suffix,picture:te.subpicture}},ze=Se.map(he);ze.forEach(De);var ge=ze.map(Ae),Ie=h["minus-sign"],st=h["zero-digit"],Ve=h["decimal-separator"],Ft=h["grouping-separator"];ge.length===1&&(ge.push(JSON.parse(JSON.stringify(ge[0]))),ge[1].prefix=Ie+ge[1].prefix);var Ue;t>=0?Ue=ge[0]:Ue=ge[1];var Yt;Ue.picture.indexOf(h.percent)!==-1?Yt=t*100:Ue.picture.indexOf(h["per-mille"])!==-1?Yt=t*1e3:Yt=t;var Dt,Ut;if(Ue.minimumExponentSize===0)Dt=Yt;else{var Xn=Math.pow(10,Ue.scalingFactor),Qn=Math.pow(10,Ue.scalingFactor-1);for(Dt=Yt,Ut=0;Dt<Qn;)Dt*=10,Ut-=1;for(;Dt>Xn;)Dt/=10,Ut+=1}var Kn=M(Dt,Ue.maximumFactionalPartSize),In=function(te,Re){var Ge=Math.abs(te).toFixed(Re);return st!=="0"&&(Ge=Ge.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?w[Ne.charCodeAt(0)-48]:Ne}).join("")),Ge},se=In(Kn,Ue.maximumFactionalPartSize),Ye=se.indexOf(".");for(Ye===-1?se=se+Ve:se=se.replace(".",Ve);se.charAt(0)===st;)se=se.substring(1);for(;se.charAt(se.length-1)===st;)se=se.substring(0,se.length-1);Ye=se.indexOf(Ve);var Gt=Ue.minimumIntegerPartSize-Ye,Fn=Ue.minimumFactionalPartSize-(se.length-Ye-1);if(se=(Gt>0?new Array(Gt+1).join(st):"")+se,se=se+(Fn>0?new Array(Fn+1).join(st):""),Ye=se.indexOf(Ve),Ue.regularGrouping>0)for(var er=Math.floor((Ye-1)/Ue.regularGrouping),hn=1;hn<=er;hn++)se=[se.slice(0,Ye-hn*Ue.regularGrouping),Ft,se.slice(Ye-hn*Ue.regularGrouping)].join("");else Ue.integerPartGroupingPositions.forEach(function(te){se=[se.slice(0,Ye-te),Ft,se.slice(Ye-te)].join(""),Ye++});if(Ye=se.indexOf(Ve),Ue.fractionalPartGroupingPositions.forEach(function(te){se=[se.slice(0,te+Ye+1),Ft,se.slice(te+Ye+1)].join("")}),Ye=se.indexOf(Ve),(Ue.picture.indexOf(Ve)===-1||Ye===se.length-1)&&(se=se.substring(0,se.length-1)),typeof Ut<"u"){var pn=In(Ut,0);Gt=Ue.minimumExponentSize-pn.length,Gt>0&&(pn=new Array(Gt+1).join(st)+pn),se=se+h["exponent-separator"]+(Ut<0?Ie:"")+pn}return se=Ue.prefix+se+Ue.suffix,se}}function b(t,a){if(!(typeof t>"u")){if(t=M(t),typeof a>"u"?a=10:a=M(a),a<2||a>36)throw{code:"D3100",stack:new Error().stack,value:a};var c=t.toString(a);return c}}function D(t){var a;if(!(typeof t>"u")){if(typeof t=="number")a=t;else if(typeof t=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))a=parseFloat(t);else if(typeof t=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(t))a=Number(t);else if(t===!0)a=1;else if(t===!1)a=0;else throw{code:"D3030",value:t,stack:new Error().stack,index:1};return a}}function I(t){var a;if(!(typeof t>"u"))return a=Math.abs(t),a}function R(t){var a;if(!(typeof t>"u"))return a=Math.floor(t),a}function T(t){var a;if(!(typeof t>"u"))return a=Math.ceil(t),a}function M(t,a){var c;if(!(typeof t>"u")){if(a){var y=t.toString().split("e");t=+(y[0]+"e"+(y[1]?+y[1]+a:a))}c=Math.round(t);var h=c-t;return Math.abs(h)===.5&&Math.abs(c%2)===1&&(c=c-1),a&&(y=c.toString().split("e"),c=+(y[0]+"e"+(y[1]?+y[1]-a:-a))),Object.is(c,-0)&&(c=0),c}}function J(t){var a;if(!(typeof t>"u")){if(t<0)throw{stack:new Error().stack,code:"D3060",index:1,value:t};return a=Math.sqrt(t),a}}function pe(t,a){var c;if(!(typeof t>"u")){if(c=Math.pow(t,a),!isFinite(c))throw{stack:new Error().stack,code:"D3061",index:1,value:t,exp:a};return c}}function ve(){return Math.random()}function H(t){if(!(typeof t>"u")){var a=!1;if(Array.isArray(t)){if(t.length===1)a=H(t[0]);else if(t.length>1){var c=t.filter(function(y){return H(y)});a=c.length>0}}else typeof t=="string"?t.length>0&&(a=!0):C(t)?t!==0&&(a=!0):t!==null&&typeof t=="object"&&!E(t)?Object.keys(t).length>0&&(a=!0):typeof t=="boolean"&&t===!0&&(a=!0);return a}}function K(t){if(!(typeof t>"u"))return!H(t)}function de(t,a,c,y){var h=[a],w=Pe(t);return w>=2&&h.push(c),w>=3&&h.push(y),h}async function Y(t,a){if(!(typeof t>"u")){for(var c=j(),y=0;y<t.length;y++){var h=de(a,t[y],y,t),w=await a.apply(this,h);typeof w<"u"&&c.push(w)}return c}}async function Le(t,a){if(!(typeof t>"u")){for(var c=j(),y=0;y<t.length;y++){var h=t[y],w=de(a,h,y,t),N=await a.apply(this,w);H(N)&&c.push(h)}return c}}async function it(t,a){if(!(typeof t>"u")){for(var c=!1,y,h=0;h<t.length;h++){var w=t[h],N=!0;if(typeof a<"u"){var W=de(a,w,h,t),X=await a.apply(this,W);N=H(X)}if(N)if(!c)y=w,c=!0;else throw{stack:new Error().stack,code:"D3138",index:h}}if(!c)throw{stack:new Error().stack,code:"D3139"};return y}}function We(){for(var t=[],a=Array.prototype.slice.call(arguments),c=Math.min.apply(Math,a.map(function(w){return Array.isArray(w)?w.length:0})),y=0;y<c;y++){var h=a.map(w=>w[y]);t.push(h)}return t}async function Ze(t,a,c){if(!(typeof t>"u")){var y,h=Pe(a);if(h<2)throw{stack:new Error().stack,code:"D3050",index:1};var w;for(typeof c>"u"&&t.length>0?(y=t[0],w=1):(y=c,w=0);w<t.length;){var N=[y,t[w]];h>=3&&N.push(w),h>=4&&N.push(t),y=await a.apply(this,N),w++}return y}}function qe(t){var a=j();if(Array.isArray(t)){var c={};t.forEach(function(y){var h=qe(y);h.forEach(function(w){c[w]=!0})}),a=qe(c)}else t!==null&&typeof t=="object"&&!E(t)&&Object.keys(t).forEach(y=>a.push(y));return a}function vt(t,a){var c;if(Array.isArray(t)){c=j();for(var y=0;y<t.length;y++){var h=vt(t[y],a);typeof h<"u"&&(Array.isArray(h)?h.forEach(w=>c.push(w)):c.push(h))}}else t!==null&&typeof t=="object"&&!E(t)&&(c=t[a]);return c}function _t(t,a){return typeof t>"u"?a:typeof a>"u"?t:(Array.isArray(t)||(t=j(t)),Array.isArray(a)||(a=[a]),t.concat(a))}function ln(t){return!(typeof t>"u")}function xt(t){var a=j();if(Array.isArray(t))t.forEach(function(h){a=_t(a,xt(h))});else if(t!==null&&typeof t=="object"&&!q(t))for(var c in t){var y={};y[c]=t[c],a.push(y)}else a=t;return a}function Z(t){if(!(typeof t>"u")){var a={};return t.forEach(function(c){for(var y in c)a[y]=c[y]}),a}}function dn(t){if(!(typeof t>"u")){if(t.length<=1)return t;for(var a=t.length,c=new Array(a),y=0;y<a;y++)c[a-y-1]=t[y];return c}}async function qt(t,a){var c=j();for(var y in t){var h=de(a,t[y],y,t),w=await a.apply(this,h);typeof w<"u"&&c.push(w)}return c}function ot(t){throw{code:"D3137",stack:new Error().stack,message:t||"$error() function evaluated"}}function It(t,a){if(!t)throw{code:"D3141",stack:new Error().stack,message:a||"$assert() statement failed"}}function ht(t){if(t!==void 0)return t===null?"null":C(t)?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":Array.isArray(t)?"array":E(t)?"function":"object"}async function Ee(t,a){if(!(typeof t>"u")){if(t.length<=1)return t;var c;if(typeof a>"u"){if(!V(t)&&!S(t))throw{stack:new Error().stack,code:"D3070",index:1};c=async function(N,W){return N>W}}else c=a;var y=async function(N,W){var X=async function(he,De,Ae){De.length===0?Array.prototype.push.apply(he,Ae):Ae.length===0?Array.prototype.push.apply(he,De):await c(De[0],Ae[0])?(he.push(Ae[0]),await X(he,De,Ae.slice(1))):(he.push(De[0]),await X(he,De.slice(1),Ae))},Se=[];return await X(Se,N,W),Se},h=async function(N){if(!Array.isArray(N)||N.length<=1)return N;var W=Math.floor(N.length/2),X=N.slice(0,W),Se=N.slice(W);return X=await h(X),Se=await h(Se),await y(X,Se)},w=await h(t);return w}}function o(t){if(!(typeof t>"u")){if(t.length<=1)return t;for(var a=new Array(t.length),c=0;c<t.length;c++){var y=Math.floor(Math.random()*(c+1));c!==y&&(a[c]=a[y]),a[y]=t[c]}return a}}function d(t){if(!(typeof t>"u")){if(!Array.isArray(t)||t.length<=1)return t;for(var a=x(t)?j():[],c=0;c<t.length;c++){for(var y=t[c],h=!1,w=0;w<a.length;w++)if(Ce(y,a[w])){h=!0;break}h||a.push(y)}return a}}async function m(t,a){var c={};for(var y in t){var h=t[y],w=de(a,h,y,t),N=await a.apply(this,w);H(N)&&(c[y]=h)}return Object.keys(c).length===0&&(c=void 0),c}return{sum:P,count:ae,max:L,min:k,average:U,string:B,substring:le,substringBefore:we,substringAfter:xe,lowercase:Te,uppercase:me,length:je,trim:Ke,pad:ke,match:re,contains:et,replace:Fe,split:_e,join:g,formatNumber:_,formatBase:b,number:D,floor:R,ceil:T,round:M,abs:I,sqrt:J,power:pe,random:ve,boolean:H,not:K,map:Y,zip:We,filter:Le,single:it,foldLeft:Ze,sift:m,keys:qe,lookup:vt,append:_t,exists:ln,spread:xt,merge:Z,reverse:dn,each:qt,error:ot,assert:It,type:ht,sort:Ee,shuffle:o,distinct:d,base64encode:at,base64decode:l,encodeUrlComponent:p,encodeUrl:z,decodeUrlComponent:ce,decodeUrl:Oe}})();i.exports=v}).call(this)}).call(this,typeof zn<"u"?zn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(n,i,s){var u=n("./datetime"),f=n("./functions"),v=n("./utils"),C=n("./parser"),S=n("./signature"),V=(function(){var j=v.isNumeric,x=v.isArrayOfStrings,E=v.isArrayOfNumbers,q=v.createSequence,be=v.isSequence,Pe=v.isFunction,Ce=v.isLambda,Q=v.isIterable,P=v.isPromise,ae=v.getFunctionArity,L=v.isDeepEqual,k=ot(null);async function U(o,d,m){var t,a=m.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(a&&await a(o,d,m),o.type){case"path":t=await B(o,d,m);break;case"binary":t=await je(o,d,m);break;case"unary":t=await Ke(o,d,m);break;case"name":t=ke(o,d);break;case"string":case"number":case"value":t=ue(o);break;case"wildcard":t=et(o,d);break;case"descendant":t=Fe(o,d);break;case"parent":t=m.lookup(o.slot.label);break;case"condition":t=await R(o,d,m);break;case"block":t=await T(o,d,m);break;case"bind":t=await I(o,d,m);break;case"regex":t=M(o);break;case"function":t=await de(o,d,m);break;case"variable":t=J(o,d,m);break;case"lambda":t=it(o,d,m);break;case"partial":t=await We(o,d,m);break;case"apply":t=await K(o,d,m);break;case"transform":t=ve(o,d,m);break}if(Object.prototype.hasOwnProperty.call(o,"predicate"))for(var c=0;c<o.predicate.length;c++)t=await me(o.predicate[c].expr,t,m);o.type!=="path"&&Object.prototype.hasOwnProperty.call(o,"group")&&(t=await _(o.group,t,m));var y=m.lookup(Symbol.for("jsonata.__evaluate_exit"));return y&&await y(o,d,m,t),t&&be(t)&&!t.tupleStream&&(o.keepArray&&(t.keepSingleton=!0),t.length===0?t=void 0:t.length===1&&(t=t.keepSingleton?t:t[0])),t}async function B(o,d,m){var t;Array.isArray(d)&&o.steps[0].type!=="variable"?t=d:t=q(d);for(var a,c=!1,y=void 0,h=0;h<o.steps.length;h++){var w=o.steps[h];if(w.tuple&&(c=!0),h===0&&w.consarray?a=await U(w,t,m):c?y=await Te(w,t,y,m):a=await we(w,t,m,h===o.steps.length-1),!c&&(typeof a>"u"||a.length===0))break;typeof w.focus>"u"&&(t=a)}if(c)if(o.tuple)a=y;else for(a=q(),h=0;h<y.length;h++)a.push(y[h]["@"]);return o.keepSingletonArray&&(Array.isArray(a)&&a.cons&&!a.sequence&&(a=q(a)),a.keepSingleton=!0),o.hasOwnProperty("group")&&(a=await _(o.group,c?y:a,m)),a}function le(o,d){var m=ot(o);for(const t in d)m.bind(t,d[t]);return m}async function we(o,d,m,t){var a;if(o.type==="sort")return a=await pe(o,d,m),o.stages&&(a=await xe(o.stages,a,m)),a;a=q();for(var c=0;c<d.length;c++){var y=await U(o,d[c],m);if(o.stages)for(var h=0;h<o.stages.length;h++)y=await me(o.stages[h].expr,y,m);typeof y<"u"&&a.push(y)}var w=q();return t&&a.length===1&&Array.isArray(a[0])&&!be(a[0])?w=a[0]:a.forEach(function(N){!Array.isArray(N)||N.cons?w.push(N):N.forEach(W=>w.push(W))}),w}async function xe(o,d,m){for(var t=d,a=0;a<o.length;a++){var c=o[a];switch(c.type){case"filter":t=await me(c.expr,t,m);break;case"index":for(var y=0;y<t.length;y++){var h=t[y];h[c.value]=y}break}}return t}async function Te(o,d,m,t){var a;if(o.type==="sort"){if(m)a=await pe(o,m,t);else{var c=await pe(o,d,t);a=q(),a.tupleStream=!0;for(var y=0;y<c.length;y++){var h={"@":c[y]};h[o.index]=y,a.push(h)}}return o.stages&&(a=await xe(o.stages,a,t)),a}a=q(),a.tupleStream=!0;var w=t;m===void 0&&(m=d.map(Se=>({"@":Se})));for(var N=0;N<m.length;N++){w=le(t,m[N]);var W=await U(o,m[N]["@"],w);if(typeof W<"u"){Array.isArray(W)||(W=[W]);for(var X=0;X<W.length;X++)h={},Object.assign(h,m[N]),W.tupleStream?Object.assign(h,W[X]):(o.focus?(h[o.focus]=W[X],h["@"]=m[N]["@"]):h["@"]=W[X],o.index&&(h[o.index]=X),o.ancestor&&(h[o.ancestor.label]=m[N]["@"])),a.push(h)}}return o.stages&&(a=await xe(o.stages,a,t)),a}async function me(o,d,m){var t=q();if(d&&d.tupleStream&&(t.tupleStream=!0),Array.isArray(d)||(d=q(d)),o.type==="number"){var a=Math.floor(o.value);a<0&&(a=d.length+a);var c=await d[a];typeof c<"u"&&(Array.isArray(c)?t=c:t.push(c))}else for(a=0;a<d.length;a++){var c=d[a],y=c,h=m;d.tupleStream&&(y=c["@"],h=le(m,c));var w=await U(o,y,h);j(w)&&(w=[w]),E(w)?w.forEach(function(W){var X=Math.floor(W);X<0&&(X=d.length+X),X===a&&t.push(c)}):f.boolean(w)&&t.push(c)}return t}async function je(o,d,m){var t,a=await U(o.lhs,d,m),c=o.value,y=async()=>await U(o.rhs,d,m);if(c==="and"||c==="or")try{return await Oe(a,y,c)}catch(w){throw w.position=o.position,w.token=c,w}var h=await y();try{switch(c){case"+":case"-":case"*":case"/":case"%":t=l(a,h,c);break;case"=":case"!=":t=p(a,h,c);break;case"<":case"<=":case">":case">=":t=z(a,h,c);break;case"&":t=g(a,h);break;case"..":t=D(a,h);break;case"in":t=ce(a,h);break}}catch(w){throw w.position=o.position,w.token=c,w}return t}async function Ke(o,d,m){var t;switch(o.value){case"-":if(t=await U(o.expression,d,m),typeof t>"u")t=void 0;else if(j(t))t=-t;else throw{code:"D1002",stack:new Error().stack,position:o.position,token:o.value,value:t};break;case"[":t=[];let y=await Promise.all(o.expressions.map(async(h,w)=>(m.isParallelCall=w>0,[h,await U(h,d,m)])));for(let h of y){var[a,c]=h;typeof c<"u"&&(a.value==="["?t.push(c):t=f.append(t,c))}o.consarray&&Object.defineProperty(t,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":t=await _(o,d,m);break}return t}function ke(o,d,m){return f.lookup(d,o.value)}function ue(o){return o.value}function et(o,d){var m=q();return Array.isArray(d)&&d.outerWrapper&&d.length>0&&(d=d[0]),d!==null&&typeof d=="object"&&Object.keys(d).forEach(function(t){var a=d[t];Array.isArray(a)?(a=re(a),m=f.append(m,a)):m.push(a)}),m}function re(o,d){return typeof d>"u"&&(d=[]),Array.isArray(o)?o.forEach(function(m){re(m,d)}):d.push(o),d}function Fe(o,d){var m,t=q();return typeof d<"u"&&(at(d,t),t.length===1?m=t[0]:m=t),m}function at(o,d){Array.isArray(o)||d.push(o),Array.isArray(o)?o.forEach(function(m){at(m,d)}):o!==null&&typeof o=="object"&&Object.keys(o).forEach(function(m){at(o[m],d)})}function l(o,d,m){var t;if(typeof o<"u"&&!j(o))throw{code:"T2001",stack:new Error().stack,value:o};if(typeof d<"u"&&!j(d))throw{code:"T2002",stack:new Error().stack,value:d};if(typeof o>"u"||typeof d>"u")return t;switch(m){case"+":t=o+d;break;case"-":t=o-d;break;case"*":t=o*d;break;case"/":t=o/d;break;case"%":t=o%d;break}return t}function p(o,d,m){var t,a=typeof o,c=typeof d;if(a==="undefined"||c==="undefined")return!1;switch(m){case"=":t=L(o,d);break;case"!=":t=!L(o,d);break}return t}function z(o,d,m){var t,a=typeof o,c=typeof d,y=a==="undefined"||a==="string"||a==="number",h=c==="undefined"||c==="string"||c==="number";if(!y||!h)throw{code:"T2010",stack:new Error().stack,value:a==="string"||a==="number"?d:o};if(!(a==="undefined"||c==="undefined")){if(a!==c)throw{code:"T2009",stack:new Error().stack,value:o,value2:d};switch(m){case"<":t=o<d;break;case"<=":t=o<=d;break;case">":t=o>d;break;case">=":t=o>=d;break}return t}}function ce(o,d){var m=!1;if(typeof o>"u"||typeof d>"u")return!1;Array.isArray(d)||(d=[d]);for(var t=0;t<d.length;t++)if(d[t]===o){m=!0;break}return m}async function Oe(o,d,m){var t,a=_e(o);switch(m){case"and":t=a&&_e(await d());break;case"or":t=a||_e(await d());break}return t}function _e(o){var d=f.boolean(o);return typeof d>"u"?!1:d}function g(o,d){var m,t="",a="";return typeof o<"u"&&(t=f.string(o)),typeof d<"u"&&(a=f.string(d)),m=t.concat(a),m}async function _(o,d,m){var t={},a={},c=!!(d&&d.tupleStream);Array.isArray(d)||(d=q(d)),d.length===0&&d.push(void 0);for(var y=0;y<d.length;y++)for(var h=d[y],w=c?le(m,h):m,N=0;N<o.lhs.length;N++){var W=o.lhs[N],X=await U(W[0],c?h["@"]:h,w);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:o.position,value:X};if(X!==void 0){var Se={data:h,exprIndex:N};if(a.hasOwnProperty(X)){if(a[X].exprIndex!==N)throw{code:"D1009",stack:new Error().stack,position:o.position,value:X};a[X].data=f.append(a[X].data,h)}else a[X]=Se}}let he=await Promise.all(Object.keys(a).map(async(Ae,ze)=>{let ge=a[Ae];var Ie=ge.data,st=m;if(c){var Ve=b(ge.data);Ie=Ve["@"],delete Ve["@"],st=le(m,Ve)}return m.isParallelCall=ze>0,[Ae,await U(o.lhs[ge.exprIndex][1],Ie,st)]}));for(let Ae of he){var[X,De]=await Ae;typeof De<"u"&&(t[X]=De)}return t}function b(o){if(!Array.isArray(o))return o;var d={};Object.assign(d,o[0]);for(var m=1;m<o.length;m++)for(const t in o[m])d[t]=f.append(d[t],o[m][t]);return d}function D(o,d){var m;if(typeof o<"u"&&!Number.isInteger(o))throw{code:"T2003",stack:new Error().stack,value:o};if(typeof d<"u"&&!Number.isInteger(d))throw{code:"T2004",stack:new Error().stack,value:d};if(typeof o>"u"||typeof d>"u"||o>d)return m;var t=d-o+1;if(t>1e7)throw{code:"D2014",stack:new Error().stack,value:t};m=new Array(t);for(var a=o,c=0;a<=d;a++,c++)m[c]=a;return m.sequence=!0,m}async function I(o,d,m){var t=await U(o.rhs,d,m);return m.bind(o.lhs.value,t),t}async function R(o,d,m){var t,a=await U(o.condition,d,m);return f.boolean(a)?t=await U(o.then,d,m):typeof o.else<"u"&&(t=await U(o.else,d,m)),t}async function T(o,d,m){for(var t,a=ot(m),c=0;c<o.expressions.length;c++)t=await U(o.expressions[c],d,a);return t}function M(o){var d=new Ee.RegexEngine(o.value),m=function(t,a){var c;d.lastIndex=a||0;var y=d.exec(t);if(y!==null){if(c={match:y[0],start:y.index,end:y.index+y[0].length,groups:[]},y.length>1)for(var h=1;h<y.length;h++)c.groups.push(y[h]);c.next=function(){if(!(d.lastIndex>=t.length)){var w=m(t,d.lastIndex);if(w&&w.match==="")throw{code:"D1004",stack:new Error().stack,position:o.position,value:o.value.source};return w}}}return c};return m}function J(o,d,m){var t;return o.value===""?t=d&&d.outerWrapper?d[0]:d:t=m.lookup(o.value),t}async function pe(o,d,m){var t,a=d,c=!!d.tupleStream,y=async function(w,N){for(var W=0,X=0;W===0&&X<o.terms.length;X++){var Se=o.terms[X],he=w,De=m;c&&(he=w["@"],De=le(m,w));var Ae=await U(Se.expression,he,De);he=N,De=m,c&&(he=N["@"],De=le(m,N));var ze=await U(Se.expression,he,De),ge=typeof Ae,Ie=typeof ze;if(ge==="undefined"){W=Ie==="undefined"?0:1;continue}if(Ie==="undefined"){W=-1;continue}if(!(ge==="string"||ge==="number")||!(Ie==="string"||Ie==="number"))throw{code:"T2008",stack:new Error().stack,position:o.position,value:ge==="string"||ge==="number"?ze:Ae};if(ge!==Ie)throw{code:"T2007",stack:new Error().stack,position:o.position,value:Ae,value2:ze};Ae!==ze&&(Ae<ze?W=-1:W=1,Se.descending===!0&&(W=-W))}return W===1},h={environment:m,input:d};return t=await f.sort.apply(h,[a,y]),t}function ve(o,d,m){var t=async function(a){if(!(typeof a>"u")){var c=m.lookup("clone");if(!Pe(c))throw{code:"T2013",stack:new Error().stack,position:o.position};var y=await Y(c,[a],null,m),h=await U(o.pattern,y,m);if(typeof h<"u"){Array.isArray(h)||(h=[h]);for(var w=0;w<h.length;w++){var N=h[w];if(N&&(N.isPrototypeOf(y)||N instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:o.position};var W=await U(o.update,N,m),X=typeof W;if(X!=="undefined"){if(X!=="object"||W===null||Array.isArray(W))throw{code:"T2011",stack:new Error().stack,position:o.update.position,value:W};for(var Se in W)N[Se]=W[Se]}if(typeof o.delete<"u"){var he=await U(o.delete,N,m);if(typeof he<"u"){var De=he;if(Array.isArray(he)||(he=[he]),!x(he))throw{code:"T2012",stack:new Error().stack,position:o.delete.position,value:De};for(var Ae=0;Ae<he.length;Ae++)typeof N=="object"&&N!==null&&delete N[he[Ae]]}}}}return y}};return Z(t,"<(oa):o>")}var H=C("function($f, $g) { function($x){ $g($f($x)) } }");async function K(o,d,m){var t,a=await U(o.lhs,d,m);if(o.rhs.type==="function")t=await de(o.rhs,d,m,{context:a});else{var c=await U(o.rhs,d,m);if(!Pe(c))throw{code:"T2006",stack:new Error().stack,position:o.position,value:c};if(Pe(a)){var y=await U(H,null,m);t=await Y(y,[a,c],null,m)}else t=await Y(c,[a],null,m)}return t}async function de(o,d,m,t){var a,c=await U(o.procedure,d,m);if(typeof c>"u"&&o.procedure.type==="path"&&m.lookup(o.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:o.position,token:o.procedure.steps[0].value};var y=[];typeof t<"u"&&y.push(t.context);for(var h=0;h<o.arguments.length;h++){const N=await U(o.arguments[h],d,m);if(Pe(N)){const W=async function(...X){return await Y(N,X,null,m)};W.arity=ae(N),y.push(W)}else y.push(N)}var w=o.procedure.type==="path"?o.procedure.steps[0].value:o.procedure.value;try{typeof c=="object"&&(c.token=w,c.position=o.position),a=await Y(c,y,d,m)}catch(N){throw N.position||(N.position=o.position),N.token||(N.token=w),N}return a}async function Y(o,d,m,t){var a;for(a=await Le(o,d,m,t);Ce(a)&&a.thunk===!0;){var c=await U(a.body.procedure,a.input,a.environment);a.body.procedure.type==="variable"&&(c.token=a.body.procedure.value),c.position=a.body.procedure.position;for(var y=[],h=0;h<a.body.arguments.length;h++)y.push(await U(a.body.arguments[h],a.input,a.environment));a=await Le(c,y,m,t)}return a}async function Le(o,d,m,t){var a;try{var c=d;if(o&&(c=Ze(o.signature,d,m)),Ce(o))a=await qe(o,c);else if(o&&o._jsonata_function===!0){var y={environment:t,input:m};a=o.implementation.apply(y,c),Q(a)&&(a=a.next().value),P(a)&&(a=await a)}else if(typeof o=="function")a=o.apply(m,c),P(a)&&(a=await a);else throw{code:"T1006",stack:new Error().stack}}catch(h){throw o&&(typeof h.token>"u"&&typeof o.token<"u"&&(h.token=o.token),h.position=o.position||h.position),h}return a}function it(o,d,m){var t={_jsonata_lambda:!0,input:d,environment:m,arguments:o.arguments,signature:o.signature,body:o.body};return o.thunk===!0&&(t.thunk=!0),t.apply=async function(a,c){return await Y(t,c,d,a?a.environment:m)},t}async function We(o,d,m){for(var t,a=[],c=0;c<o.arguments.length;c++){var y=o.arguments[c];y.type==="operator"&&y.value==="?"?a.push(y):a.push(await U(y,d,m))}var h=await U(o.procedure,d,m);if(typeof h>"u"&&o.procedure.type==="path"&&m.lookup(o.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:o.position,token:o.procedure.steps[0].value};if(Ce(h))t=vt(h,a);else if(h&&h._jsonata_function===!0)t=_t(h.implementation,a);else if(typeof h=="function")t=_t(h,a);else throw{code:"T1008",stack:new Error().stack,position:o.position,token:o.procedure.type==="path"?o.procedure.steps[0].value:o.procedure.value};return t}function Ze(o,d,m){if(typeof o>"u")return d;var t=o.validate(d,m);return t}async function qe(o,d){var m,t=ot(o.environment);return o.arguments.forEach(function(a,c){t.bind(a.value,d[c])}),typeof o.body=="function"?m=await ln(o.body,t):m=await U(o.body,o.input,t),m}function vt(o,d){var m=ot(o.environment),t=[];o.arguments.forEach(function(c,y){var h=d[y];h&&h.type==="operator"&&h.value==="?"?t.push(c):m.bind(c.value,h)});var a={_jsonata_lambda:!0,input:o.input,environment:m,arguments:t,body:o.body};return a}function _t(o,d){var m=xt(o);m=m.map(function(y){return"$"+y.trim()});var t="function("+m.join(", ")+"){ _ }",a=C(t);a.body=o;var c=vt(a,d);return c}async function ln(o,d){var m=xt(o),t=m.map(function(y){return d.lookup(y.trim())}),a={environment:d},c=o.apply(a,t);return P(c)&&(c=await c),c}function xt(o){var d=o.toString(),m=/\(([^)]*)\)/.exec(d)[1],t=m.split(",");return t}function Z(o,d){var m={_jsonata_function:!0,implementation:o};return typeof d<"u"&&(m.signature=S(d)),m}async function dn(o,d){if(!(typeof o>"u")){var m=this.input;typeof d<"u"&&(m=d,Array.isArray(m)&&!be(m)&&(m=q(m),m.outerWrapper=!0));try{var t=C(o,!1)}catch(c){throw ht(c),{stack:new Error().stack,code:"D3120",value:c.message,error:c}}try{var a=await U(t,m,this.environment)}catch(c){throw ht(c),{stack:new Error().stack,code:"D3121",value:c.message,error:c}}return a}}function qt(o){if(!(typeof o>"u"))return JSON.parse(f.string(o))}function ot(o){var d={};const m={bind:function(a,c){d[a]=c},lookup:function(a){var c;return d.hasOwnProperty(a)?c=d[a]:o&&(c=o.lookup(a)),c},timestamp:o?o.timestamp:null,async:o?o.async:!1,isParallelCall:o?o.isParallelCall:!1,global:o?o.global:{ancestry:[null]}};if(o){var t=o.lookup(Symbol.for("jsonata.__createFrame_push"));t&&t(o,m)}return m}k.bind("sum",Z(f.sum,"<a<n>:n>")),k.bind("count",Z(f.count,"<a:n>")),k.bind("max",Z(f.max,"<a<n>:n>")),k.bind("min",Z(f.min,"<a<n>:n>")),k.bind("average",Z(f.average,"<a<n>:n>")),k.bind("string",Z(f.string,"<x-b?:s>")),k.bind("substring",Z(f.substring,"<s-nn?:s>")),k.bind("substringBefore",Z(f.substringBefore,"<s-s:s>")),k.bind("substringAfter",Z(f.substringAfter,"<s-s:s>")),k.bind("lowercase",Z(f.lowercase,"<s-:s>")),k.bind("uppercase",Z(f.uppercase,"<s-:s>")),k.bind("length",Z(f.length,"<s-:n>")),k.bind("trim",Z(f.trim,"<s-:s>")),k.bind("pad",Z(f.pad,"<s-ns?:s>")),k.bind("match",Z(f.match,"<s-f<s:o>n?:a<o>>")),k.bind("contains",Z(f.contains,"<s-(sf):b>")),k.bind("replace",Z(f.replace,"<s-(sf)(sf)n?:s>")),k.bind("split",Z(f.split,"<s-(sf)n?:a<s>>")),k.bind("join",Z(f.join,"<a<s>s?:s>")),k.bind("formatNumber",Z(f.formatNumber,"<n-so?:s>")),k.bind("formatBase",Z(f.formatBase,"<n-n?:s>")),k.bind("formatInteger",Z(u.formatInteger,"<n-s:s>")),k.bind("parseInteger",Z(u.parseInteger,"<s-s:n>")),k.bind("number",Z(f.number,"<(nsb)-:n>")),k.bind("floor",Z(f.floor,"<n-:n>")),k.bind("ceil",Z(f.ceil,"<n-:n>")),k.bind("round",Z(f.round,"<n-n?:n>")),k.bind("abs",Z(f.abs,"<n-:n>")),k.bind("sqrt",Z(f.sqrt,"<n-:n>")),k.bind("power",Z(f.power,"<n-n:n>")),k.bind("random",Z(f.random,"<:n>")),k.bind("boolean",Z(f.boolean,"<x-:b>")),k.bind("not",Z(f.not,"<x-:b>")),k.bind("map",Z(f.map,"<af>")),k.bind("zip",Z(f.zip,"<a+>")),k.bind("filter",Z(f.filter,"<af>")),k.bind("single",Z(f.single,"<af?>")),k.bind("reduce",Z(f.foldLeft,"<afj?:j>")),k.bind("sift",Z(f.sift,"<o-f?:o>")),k.bind("keys",Z(f.keys,"<x-:a<s>>")),k.bind("lookup",Z(f.lookup,"<x-s:x>")),k.bind("append",Z(f.append,"<xx:a>")),k.bind("exists",Z(f.exists,"<x:b>")),k.bind("spread",Z(f.spread,"<x-:a<o>>")),k.bind("merge",Z(f.merge,"<a<o>:o>")),k.bind("reverse",Z(f.reverse,"<a:a>")),k.bind("each",Z(f.each,"<o-f:a>")),k.bind("error",Z(f.error,"<s?:x>")),k.bind("assert",Z(f.assert,"<bs?:x>")),k.bind("type",Z(f.type,"<x:s>")),k.bind("sort",Z(f.sort,"<af?:a>")),k.bind("shuffle",Z(f.shuffle,"<a:a>")),k.bind("distinct",Z(f.distinct,"<x:x>")),k.bind("base64encode",Z(f.base64encode,"<s-:s>")),k.bind("base64decode",Z(f.base64decode,"<s-:s>")),k.bind("encodeUrlComponent",Z(f.encodeUrlComponent,"<s-:s>")),k.bind("encodeUrl",Z(f.encodeUrl,"<s-:s>")),k.bind("decodeUrlComponent",Z(f.decodeUrlComponent,"<s-:s>")),k.bind("decodeUrl",Z(f.decodeUrl,"<s-:s>")),k.bind("eval",Z(dn,"<sx?:x>")),k.bind("toMillis",Z(u.toMillis,"<s-s?:n>")),k.bind("fromMillis",Z(u.fromMillis,"<n-s?s?:s>")),k.bind("clone",Z(qt,"<(oa)-:o>"));var It={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function ht(o){var d=It[o.code];if(typeof d<"u"){var m=d.replace(/\{\{\{([^}]+)}}}/g,function(){return o[arguments[1]]});m=m.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(o[arguments[1]])}),o.message=m}}function Ee(o,d){var m,t;try{m=C(o,d&&d.recover),t=m.errors,delete m.errors}catch(y){throw ht(y),y}var a=ot(k),c=new Date;return a.bind("now",Z(function(y,h){return u.fromMillis(c.getTime(),y,h)},"<s?s?:s>")),a.bind("millis",Z(function(){return c.getTime()},"<:n>")),d&&d.RegexEngine?Ee.RegexEngine=d.RegexEngine:Ee.RegexEngine=RegExp,{evaluate:async function(y,h,w){if(typeof t<"u"){var N={code:"S0500",position:0};throw ht(N),N}if(typeof h<"u"){var W;W=ot(a);for(var X in h)W.bind(X,h[X])}else W=a;W.bind("$",y),c=new Date,W.timestamp=c,Array.isArray(y)&&!be(y)&&(y=q(y),y.outerWrapper=!0);var Se;try{return Se=await U(m,y,W),typeof w=="function"&&w(null,Se),Se}catch(he){throw ht(he),he}},assign:function(y,h){a.bind(y,h)},registerFunction:function(y,h,w){var N=Z(h,w);a.bind(y,N)},ast:function(){return m},errors:function(){return t}}}return Ee.parser=C,Ee})();i.exports=V},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(n,i,s){var u=n("./signature");const f=(()=>{var v={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},C={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "},S=function(j){var x=0,E=j.length,q=function(Ce,Q){var P={type:Ce,value:Q,position:x};return P},be=function(){for(var Ce=x,Q=0,P,ae,L=function(U){if(j.charAt(U)==="/"&&Q===0){for(var B=0;j.charAt(U-(B+1))==="\\";)B++;if(B%2===0)return!0}return!1};x<E;){var k=j.charAt(x);if(L(x)){if(P=j.substring(Ce,x),P==="")throw{code:"S0301",stack:new Error().stack,position:x};for(x++,k=j.charAt(x),Ce=x;k==="i"||k==="m";)x++,k=j.charAt(x);return ae=j.substring(Ce,x)+"g",new RegExp(P,ae)}(k==="("||k==="["||k==="{")&&j.charAt(x-1)!=="\\"&&Q++,(k===")"||k==="]"||k==="}")&&j.charAt(x-1)!=="\\"&&Q--,x++}throw{code:"S0302",stack:new Error().stack,position:x}},Pe=function(Ce){if(x>=E)return null;for(var Q=j.charAt(x);x<E&&`
3
- \r\v`.indexOf(Q)>-1;)x++,Q=j.charAt(x);if(Q==="/"&&j.charAt(x+1)==="*"){var P=x;for(x+=2,Q=j.charAt(x);!(Q==="*"&&j.charAt(x+1)==="/");)if(Q=j.charAt(++x),x>=E)throw{code:"S0106",stack:new Error().stack,position:P};return x+=2,Q=j.charAt(x),Pe(Ce)}if(Ce!==!0&&Q==="/")return x++,q("regex",be());if(Q==="."&&j.charAt(x+1)===".")return x+=2,q("operator","..");if(Q===":"&&j.charAt(x+1)==="=")return x+=2,q("operator",":=");if(Q==="!"&&j.charAt(x+1)==="=")return x+=2,q("operator","!=");if(Q===">"&&j.charAt(x+1)==="=")return x+=2,q("operator",">=");if(Q==="<"&&j.charAt(x+1)==="=")return x+=2,q("operator","<=");if(Q==="*"&&j.charAt(x+1)==="*")return x+=2,q("operator","**");if(Q==="~"&&j.charAt(x+1)===">")return x+=2,q("operator","~>");if(Q==="?"&&j.charAt(x+1)===":")return x+=2,q("operator","?:");if(Q==="?"&&j.charAt(x+1)==="?")return x+=2,q("operator","??");if(Object.prototype.hasOwnProperty.call(v,Q))return x++,q("operator",Q);if(Q==='"'||Q==="'"){var ae=Q;x++;for(var L="";x<E;){if(Q=j.charAt(x),Q==="\\")if(x++,Q=j.charAt(x),Object.prototype.hasOwnProperty.call(C,Q))L+=C[Q];else if(Q==="u"){var k=j.substr(x+1,4);if(/^[0-9a-fA-F]+$/.test(k)){var U=parseInt(k,16);L+=String.fromCharCode(U),x+=4}else throw{code:"S0104",stack:new Error().stack,position:x}}else throw{code:"S0103",stack:new Error().stack,position:x,token:Q};else{if(Q===ae)return x++,q("string",L);L+=Q}x++}throw{code:"S0101",stack:new Error().stack,position:x}}var B=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,le=B.exec(j.substring(x));if(le!==null){var we=parseFloat(le[0]);if(!isNaN(we)&&isFinite(we))return x+=le[0].length,q("number",we);throw{code:"S0102",stack:new Error().stack,position:x,token:le[0]}}var xe;if(Q==="`"){x++;var Te=j.indexOf("`",x);if(Te!==-1)return xe=j.substring(x,Te),x=Te+1,q("name",xe);throw x=E,{code:"S0105",stack:new Error().stack,position:x}}for(var me=x,je;;)if(je=j.charAt(me),me===E||`
4
- \r\v`.indexOf(je)>-1||Object.prototype.hasOwnProperty.call(v,je)){if(j.charAt(x)==="$")return xe=j.substring(x+1,me),x=me,q("variable",xe);switch(xe=j.substring(x,me),x=me,xe){case"or":case"in":case"and":return q("operator",xe);case"true":return q("value",!0);case"false":return q("value",!1);case"null":return q("value",null);default:return x===E&&xe===""?null:q("name",xe)}}else me++};return Pe},V=function(j,x){var E,q,be={},Pe=[],Ce=function(){var l=[];E.id!=="(end)"&&l.push({type:E.type,value:E.value,position:E.position});for(var p=q();p!==null;)l.push(p),p=q();return l},Q={nud:function(){var l={code:"S0211",token:this.value,position:this.position};if(x)return l.remaining=Ce(),l.type="error",Pe.push(l),l;throw l.stack=new Error().stack,l}},P=function(l,p){var z=be[l];return p=p||0,z?p>=z.lbp&&(z.lbp=p):(z=Object.create(Q),z.id=z.value=l,z.lbp=p,be[l]=z),z},ae=function(l){if(x){l.remaining=Ce(),Pe.push(l);var p=be["(error)"];return E=Object.create(p),E.error=l,E.type="(error)",E}else throw l.stack=new Error().stack,l},L=function(l,p){if(l&&E.id!==l){var z;E.id==="(end)"?z="S0203":z="S0202";var ce={code:z,position:E.position,token:E.value,value:l};return ae(ce)}var Oe=q(p);if(Oe===null)return E=be["(end)"],E.position=j.length,E;var _e=Oe.value,g=Oe.type,_;switch(g){case"name":case"variable":_=be["(name)"];break;case"operator":if(_=be[_e],!_)return ae({code:"S0204",stack:new Error().stack,position:Oe.position,token:_e});break;case"string":case"number":case"value":_=be["(literal)"];break;case"regex":g="regex",_=be["(regex)"];break;default:return ae({code:"S0205",stack:new Error().stack,position:Oe.position,token:_e})}return E=Object.create(_),E.value=_e,E.type=g,E.position=Oe.position,E},k=function(l){var p,z=E;for(L(null,!0),p=z.nud();l<E.lbp;)z=E,L(),p=z.led(p);return p},U=function(l){var p=P(l,0);p.nud=function(){return this}},B=function(l,p,z){var ce=p||v[l],Oe=P(l,ce);return Oe.led=z||function(_e){return this.lhs=_e,this.rhs=k(ce),this.type="binary",this},Oe},le=function(l,p,z){var ce=P(l,p);return ce.led=z,ce},we=function(l,p){var z=P(l);return z.nud=p||function(){return this.expression=k(70),this.type="unary",this},z};U("(end)"),U("(name)"),U("(literal)"),U("(regex)"),P(":"),P(";"),P(","),P(")"),P("]"),P("}"),P(".."),B("."),B("+"),B("-"),B("*"),B("/"),B("%"),B("="),B("<"),B(">"),B("!="),B("<="),B(">="),B("&"),B("and"),B("or"),B("in"),U("and"),U("or"),U("in"),we("-"),B("~>"),B("??",v["??"],function(l){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[l]},this.then=l,this.else=k(0),this}),le("(error)",10,function(l){return this.lhs=l,this.error=E.error,this.remaining=Ce(),this.type="error",this}),we("*",function(){return this.type="wildcard",this}),we("**",function(){return this.type="descendant",this}),we("%",function(){return this.type="parent",this}),B("(",v["("],function(l){if(this.procedure=l,this.type="function",this.arguments=[],E.id!==")")for(;E.type==="operator"&&E.id==="?"?(this.type="partial",this.arguments.push(E),L("?")):this.arguments.push(k(0)),E.id===",";)L(",");if(L(")",!0),l.type==="name"&&(l.value==="function"||l.value==="λ")){if(this.arguments.forEach(function(_e,g){if(_e.type!=="variable")return ae({code:"S0208",stack:new Error().stack,position:_e.position,token:_e.value,value:g+1})}),this.type="lambda",E.id==="<"){for(var p=E.position,z=1,ce="<";z>0&&E.id!=="{"&&E.id!=="(end)";){var Oe=L();Oe.id===">"?z--:Oe.id==="<"&&z++,ce+=Oe.value}L(">");try{this.signature=u(ce)}catch(_e){return _e.position=p+_e.offset,ae(_e)}}L("{"),this.body=k(0),L("}")}return this}),we("(",function(){for(var l=[];E.id!==")"&&(l.push(k(0)),E.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=l,this}),we("[",function(){var l=[];if(E.id!=="]")for(;;){var p=k(0);if(E.id===".."){var z={type:"binary",value:"..",position:E.position,lhs:p};L(".."),z.rhs=k(0),p=z}if(l.push(p),E.id!==",")break;L(",")}return L("]",!0),this.expressions=l,this.type="unary",this}),B("[",v["["],function(l){if(E.id==="]"){for(var p=l;p&&p.type==="binary"&&p.value==="[";)p=p.lhs;return p.keepArray=!0,L("]"),l}else return this.lhs=l,this.rhs=k(v["]"]),this.type="binary",L("]",!0),this}),B("^",v["^"],function(l){L("(");for(var p=[];;){var z={descending:!1};if(E.id==="<"?L("<"):E.id===">"&&(z.descending=!0,L(">")),z.expression=k(0),p.push(z),E.id!==",")break;L(",")}return L(")"),this.lhs=l,this.rhs=p,this.type="binary",this});var xe=function(l){var p=[];if(E.id!=="}")for(;;){var z=k(0);L(":");var ce=k(0);if(p.push([z,ce]),E.id!==",")break;L(",")}return L("}",!0),typeof l>"u"?(this.lhs=p,this.type="unary"):(this.lhs=l,this.rhs=p,this.type="binary"),this};we("{",xe),B("{",v["{"],xe),le(":=",v[":="],function(l){return l.type!=="variable"?ae({code:"S0212",stack:new Error().stack,position:l.position,token:l.value}):(this.lhs=l,this.rhs=k(v[":="]-1),this.type="binary",this)}),B("@",v["@"],function(l){return this.lhs=l,this.rhs=k(v["@"]),this.rhs.type!=="variable"?ae({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),B("#",v["#"],function(l){return this.lhs=l,this.rhs=k(v["#"]),this.rhs.type!=="variable"?ae({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),B("?",v["?"],function(l){return this.type="condition",this.condition=l,this.then=k(0),E.id===":"&&(L(":"),this.else=k(0)),this}),B("?:",v["?:"],function(l){return this.type="condition",this.condition=l,this.then=l,this.else=k(0),this}),we("|",function(){return this.type="transform",this.pattern=k(0),L("|"),this.update=k(0),E.id===","&&(L(","),this.delete=k(0)),L("|"),this});var Te=function(l){var p;if(l.type==="function"&&!l.predicate){var z={type:"lambda",thunk:!0,arguments:[],position:l.position};z.body=l,p=z}else if(l.type==="condition")l.then=Te(l.then),typeof l.else<"u"&&(l.else=Te(l.else)),p=l;else if(l.type==="block"){var ce=l.expressions.length;ce>0&&(l.expressions[ce-1]=Te(l.expressions[ce-1])),p=l}else p=l;return p},me=0,je=0,Ke=[],ke=function(l,p){switch(l.type){case"name":case"wildcard":p.level--,p.level===0&&(typeof l.ancestor>"u"||(Ke[p.index].slot.label=l.ancestor.label),l.ancestor=p,l.tuple=!0);break;case"parent":p.level++;break;case"block":l.expressions.length>0&&(l.tuple=!0,p=ke(l.expressions[l.expressions.length-1],p));break;case"path":l.tuple=!0;var z=l.steps.length-1;for(p=ke(l.steps[z--],p);p.level>0&&z>=0;)p=ke(l.steps[z--],p);break;default:throw{code:"S0217",token:l.type,position:l.position}}return p},ue=function(l,p){if(typeof p.seekingParent<"u"||p.type==="parent"){var z=typeof p.seekingParent<"u"?p.seekingParent:[];p.type==="parent"&&z.push(p.slot),typeof l.seekingParent>"u"?l.seekingParent=z:Array.prototype.push.apply(l.seekingParent,z)}},et=function(l){var p=l.steps.length-1,z=l.steps[p],ce=typeof z.seekingParent<"u"?z.seekingParent:[];z.type==="parent"&&ce.push(z.slot);for(var Oe=0;Oe<ce.length;Oe++){var _e=ce[Oe];for(p=l.steps.length-2;_e.level>0;){if(p<0){typeof l.seekingParent>"u"?l.seekingParent=[_e]:l.seekingParent.push(_e);break}for(var g=l.steps[p--];p>=0&&g.focus&&l.steps[p].focus;)g=l.steps[p--];_e=ke(g,_e)}}},re=function(l){var p;switch(l.type){case"binary":switch(l.value){case".":var z=re(l.lhs);z.type==="path"?p=z:p={type:"path",steps:[z]},z.type==="parent"&&(p.seekingParent=[z.slot]);var ce=re(l.rhs);ce.type==="function"&&ce.procedure.type==="path"&&ce.procedure.steps.length===1&&ce.procedure.steps[0].type==="name"&&p.steps[p.steps.length-1].type==="function"&&(p.steps[p.steps.length-1].nextFunction=ce.procedure.steps[0].value),ce.type==="path"?Array.prototype.push.apply(p.steps,ce.steps):(typeof ce.predicate<"u"&&(ce.stages=ce.predicate,delete ce.predicate),p.steps.push(ce)),p.steps.filter(function(M){if(M.type==="number"||M.type==="value")throw{code:"S0213",stack:new Error().stack,position:M.position,value:M.value};return M.type==="string"}).forEach(function(M){M.type="name"}),p.steps.filter(function(M){return M.keepArray===!0}).length>0&&(p.keepSingletonArray=!0);var Oe=p.steps[0];Oe.type==="unary"&&Oe.value==="["&&(Oe.consarray=!0);var _e=p.steps[p.steps.length-1];_e.type==="unary"&&_e.value==="["&&(_e.consarray=!0),et(p);break;case"[":p=re(l.lhs);var g=p,_="predicate";if(p.type==="path"&&(g=p.steps[p.steps.length-1],_="stages"),typeof g.group<"u")throw{code:"S0209",stack:new Error().stack,position:l.position};typeof g[_]>"u"&&(g[_]=[]);var b=re(l.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(M=>{M.level===1?ke(g,M):M.level--}),ue(g,b)),g[_].push({type:"filter",expr:b,position:l.position});break;case"{":if(p=re(l.lhs),typeof p.group<"u")throw{code:"S0210",stack:new Error().stack,position:l.position};p.group={lhs:l.rhs.map(function(M){return[re(M[0]),re(M[1])]}),position:l.position};break;case"^":p=re(l.lhs),p.type!=="path"&&(p={type:"path",steps:[p]});var D={type:"sort",position:l.position};D.terms=l.rhs.map(function(M){var J=re(M.expression);return ue(D,J),{descending:M.descending,expression:J}}),p.steps.push(D),et(p);break;case":=":p={type:"bind",value:l.value,position:l.position},p.lhs=re(l.lhs),p.rhs=re(l.rhs),ue(p,p.rhs);break;case"@":if(p=re(l.lhs),g=p,p.type==="path"&&(g=p.steps[p.steps.length-1]),typeof g.stages<"u"||typeof g.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:l.position};if(g.type==="sort")throw{code:"S0216",stack:new Error().stack,position:l.position};l.keepArray&&(g.keepArray=!0),g.focus=l.rhs.value,g.tuple=!0;break;case"#":p=re(l.lhs),g=p,p.type==="path"?g=p.steps[p.steps.length-1]:(p={type:"path",steps:[p]},typeof g.predicate<"u"&&(g.stages=g.predicate,delete g.predicate)),typeof g.stages>"u"?g.index=l.rhs.value:g.stages.push({type:"index",value:l.rhs.value,position:l.position}),g.tuple=!0;break;case"~>":p={type:"apply",value:l.value,position:l.position},p.lhs=re(l.lhs),p.rhs=re(l.rhs),p.keepArray=p.lhs.keepArray||p.rhs.keepArray;break;default:p={type:l.type,value:l.value,position:l.position},p.lhs=re(l.lhs),p.rhs=re(l.rhs),ue(p,p.lhs),ue(p,p.rhs)}break;case"unary":p={type:l.type,value:l.value,position:l.position},l.value==="["?p.expressions=l.expressions.map(function(M){var J=re(M);return ue(p,J),J}):l.value==="{"?p.lhs=l.lhs.map(function(M){var J=re(M[0]);ue(p,J);var pe=re(M[1]);return ue(p,pe),[J,pe]}):(p.expression=re(l.expression),l.value==="-"&&p.expression.type==="number"?(p=p.expression,p.value=-p.value):ue(p,p.expression));break;case"function":case"partial":p={type:l.type,name:l.name,value:l.value,position:l.position},p.arguments=l.arguments.map(function(M){var J=re(M);return ue(p,J),J}),p.procedure=re(l.procedure);break;case"lambda":p={type:l.type,arguments:l.arguments,signature:l.signature,position:l.position};var I=re(l.body);p.body=Te(I);break;case"condition":p={type:l.type,position:l.position},p.condition=re(l.condition),ue(p,p.condition),p.then=re(l.then),ue(p,p.then),typeof l.else<"u"&&(p.else=re(l.else),ue(p,p.else));break;case"transform":p={type:l.type,position:l.position},p.pattern=re(l.pattern),p.update=re(l.update),typeof l.delete<"u"&&(p.delete=re(l.delete));break;case"block":p={type:l.type,position:l.position},p.expressions=l.expressions.map(function(M){var J=re(M);return ue(p,J),(J.consarray||J.type==="path"&&J.steps[0].consarray)&&(p.consarray=!0),J});break;case"name":p={type:"path",steps:[l]},l.keepArray&&(p.keepSingletonArray=!0);break;case"parent":p={type:"parent",slot:{label:"!"+me++,level:1,index:je++}},Ke.push(p);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":p=l;break;case"operator":if(l.value==="and"||l.value==="or"||l.value==="in")l.type="name",p=re(l);else if(l.value==="?")p=l;else throw{code:"S0201",stack:new Error().stack,position:l.position,token:l.value};break;case"error":p=l,l.lhs&&(p=re(l.lhs));break;default:var R="S0206";l.id==="(end)"&&(R="S0207");var T={code:R,position:l.position,token:l.value};if(x)return Pe.push(T),{type:"error",error:T};throw T.stack=new Error().stack,T}return l.keepArray&&(p.keepArray=!0),p};q=S(j),L();var Fe=k(0);if(E.id!=="(end)"){var at={code:"S0201",position:E.position,token:E.value};ae(at)}if(Fe=re(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return Pe.length>0&&(Fe.errors=Pe),Fe};return V})();i.exports=f},{"./signature":5}],5:[function(n,i,s){var u=n("./utils");const f=(()=>{var v={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function C(S){for(var V=1,j=[],x={},E=x;V<S.length;){var q=S.charAt(V);if(q===":")break;var be=function(){j.push(x),E=x,x={}},Pe=function(B,le,we,xe){for(var Te=1,me=le;me<B.length;)if(me++,q=B.charAt(me),q===xe){if(Te--,Te===0)break}else q===we&&Te++;return me};switch(q){case"s":case"n":case"b":case"l":case"o":x.regex="["+q+"m]",x.type=q,be();break;case"a":x.regex="[asnblfom]",x.type=q,x.array=!0,be();break;case"f":x.regex="f",x.type=q,be();break;case"j":x.regex="[asnblom]",x.type=q,be();break;case"x":x.regex="[asnblfom]",x.type=q,be();break;case"-":E.context=!0,E.contextRegex=new RegExp(E.regex),E.regex+="?";break;case"?":case"+":E.regex+=q;break;case"(":var Ce=Pe(S,V,"(",")"),Q=S.substring(V+1,Ce);if(Q.indexOf("<")===-1)x.regex="["+Q+"m]";else throw{code:"S0402",stack:new Error().stack,value:Q,offset:V};x.type="("+Q+")",V=Ce,be();break;case"<":if(E.type==="a"||E.type==="f"){var P=Pe(S,V,"<",">");E.subtype=S.substring(V+1,P),V=P}else throw{code:"S0401",stack:new Error().stack,value:E.type,offset:V};break}V++}var ae="^"+j.map(function(B){return"("+B.regex+")"}).join("")+"$",L=new RegExp(ae),k=function(B){var le;if(u.isFunction(B))le="f";else{var we=typeof B;switch(we){case"string":le="s";break;case"number":le="n";break;case"boolean":le="b";break;case"object":B===null?le="l":Array.isArray(B)?le="a":le="o";break;case"undefined":default:le="m"}}return le},U=function(B,le){for(var we="^",xe=0,Te=0;Te<j.length;Te++){we+=j[Te].regex;var me=le.match(we);if(me===null)throw{code:"T0410",stack:new Error().stack,value:B[xe],index:xe+1};xe=me[0].length}throw{code:"T0410",stack:new Error().stack,value:B[xe],index:xe+1}};return{definition:S,validate:function(B,le){var we="";B.forEach(function(je){we+=k(je)});var xe=L.exec(we);if(xe){var Te=[],me=0;return j.forEach(function(je,Ke){var ke=B[me],ue=xe[Ke+1];if(ue==="")if(je.context&&je.contextRegex){var et=k(le);if(je.contextRegex.test(et))Te.push(le);else throw{code:"T0411",stack:new Error().stack,value:le,index:me+1}}else Te.push(ke),me++;else ue.split("").forEach(function(re){if(je.type==="a"){if(re==="m")ke=void 0;else{ke=B[me];var Fe=!0;if(typeof je.subtype<"u"){if(re!=="a"&&ue!==je.subtype)Fe=!1;else if(re==="a"&&ke.length>0){var at=k(ke[0]);if(at!==je.subtype.charAt(0))Fe=!1;else{var l=ke.filter(function(p){return k(p)!==at});Fe=l.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:ke,index:me+1,type:v[je.subtype]};re!=="a"&&(ke=[ke])}Te.push(ke),me++}else Te.push(ke),me++})}),Te}U(B,we)}}}return C})();i.exports=f},{"./utils":6}],6:[function(n,i,s){const u=(()=>{function f(P){var ae=!1;if(typeof P=="number"&&(ae=!isNaN(P),ae&&!isFinite(P)))throw{code:"D1001",value:P,stack:new Error().stack};return ae}function v(P){var ae=!1;return Array.isArray(P)&&(ae=P.filter(function(L){return typeof L!="string"}).length===0),ae}function C(P){var ae=!1;return Array.isArray(P)&&(ae=P.filter(function(L){return!f(L)}).length===0),ae}function S(){var P=[];return P.sequence=!0,arguments.length===1&&P.push(arguments[0]),P}function V(P){return P.sequence===!0&&Array.isArray(P)}function j(P){return P&&(P._jsonata_function===!0||P._jsonata_lambda===!0)||typeof P=="function"}function x(P){var ae=typeof P.arity=="number"?P.arity:typeof P.implementation=="function"?P.implementation.length:typeof P.length=="number"?P.length:P.arguments.length;return ae}function E(P){return P&&P._jsonata_lambda===!0}var q=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function be(P){return typeof P=="object"&&P!==null&&q in P&&"next"in P&&typeof P.next=="function"}function Pe(P,ae){if(P===ae)return!0;if(typeof P=="object"&&typeof ae=="object"&&P!==null&&ae!==null){if(Array.isArray(P)&&Array.isArray(ae)){if(P.length!==ae.length)return!1;for(var L=0;L<P.length;L++)if(!Pe(P[L],ae[L]))return!1;return!0}var k=Object.getOwnPropertyNames(P),U=Object.getOwnPropertyNames(ae);if(k.length!==U.length)return!1;for(k=k.sort(),U=U.sort(),L=0;L<k.length;L++)if(k[L]!==U[L])return!1;for(L=0;L<k.length;L++){var B=k[L];if(!Pe(P[B],ae[B]))return!1}return!0}return!1}function Ce(P){return typeof P=="object"&&P!==null&&"then"in P&&typeof P.then=="function"}function Q(P){var ae=[];for(let L of P)ae.push(L);return ae}return{isNumeric:f,isArrayOfStrings:v,isArrayOfNumbers:C,createSequence:S,isSequence:V,isFunction:j,isLambda:E,isIterable:be,getFunctionArity:x,isDeepEqual:Pe,stringToArray:Q,isPromise:Ce}})();i.exports=u},{}]},{},[3])(3)})})(On)),On.exports}Ca();const Da=A.object({name:A.literal("data-extract"),code:A.string(),inputData:A.any().optional()}),Pa={"get-text":ma,"attribute-value":ya,"get-value-form":va,"set-value-form":ga,"clear-value-form":ba,"element-exists":wa,"event-click":ka,keypress:_a,wait:xa,"wait-for-condition":Ta,"save-assets":Aa,"get-element-data":Ea,scroll:Sa,"ai-parse-data":pa,"fetch-api":Oa,"data-extract":Da},dt=jn({name:Tn(),selector:Tn(),findBy:Jn(["cssSelector","xpath"]),option:jn({waitForSelector:An().optional(),waitSelectorTimeout:Mn().optional(),multiple:An().optional()})});class Na{constructor(){fe(this,"expr");fe(this,"json")}}class ja{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class Ra{constructor(){fe(this,"id");fe(this,"title");fe(this,"when");fe(this,"block");fe(this,"repeat");fe(this,"next");fe(this,"onSuccess");fe(this,"onFailure");fe(this,"switch");fe(this,"timeoutMs");fe(this,"retry");fe(this,"delayAfterMs")}}class Ma{constructor(){fe(this,"version");fe(this,"id");fe(this,"title");fe(this,"description");fe(this,"start");fe(this,"steps");fe(this,"vars");fe(this,"defaultDelayMs")}}class Ia{constructor(){fe(this,"stepId");fe(this,"skipped");fe(this,"success");fe(this,"message");fe(this,"result");fe(this,"startedAt");fe(this,"finishedAt");fe(this,"attempts")}}class Fa{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}exports.AllBlockSchemas=Pa;exports.BaseBlockSchema=dt;exports.Binding=ja;exports.CollectWorkflowResult=Fa;exports.Condition=Na;exports.EightGClient=ar;exports.EightGError=At;exports.Workflow=Ma;exports.WorkflowStep=Ra;exports.WorkflowStepRunResult=Ia;
1
+ "use strict";var xn=Object.defineProperty;var _n=(r,e,t)=>e in r?xn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>_n(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class At extends Error{constructor(e,t,a){super(e),this.code=t,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new At("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new At(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new At(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(){return new At("Request timeout - Extension did not respond within 30 seconds","REQUEST_TIMEOUT")}}function En(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}class Tn{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(At.extensionNotInstalled())},5e3),s=i=>{En(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((t,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=setTimeout(()=>{a(At.requestTimeout())},6e4),c=f=>{var k,_,R,S;if(((k=f.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&f.data.requestId===s){clearTimeout(i),window.removeEventListener("message",c);const w=f.data,A=((_=w==null?void 0:w.result)==null?void 0:_.steps)??((S=(R=w==null?void 0:w.result)==null?void 0:R.result)==null?void 0:S.steps)??[];t({success:w.success,steps:A,error:w.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",c),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}}var be;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},r.find=(s,i)=>{for(const c of s)if(i(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}r.joinValues=a,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Pr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pr||(Pr={}));const z=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),kt=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=be.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"]),An=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class nt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(t(c));else{let f=a,k=0;for(;k<c.path.length;){const _=c.path[k];k===c.path.length-1?(f[_]=f[_]||{_errors:[]},f[_]._errors.push(t(c))):f[_]=f[_]||{_errors:[]},f=f[_],k++}}};return s(this),a}static assert(e){if(!(e instanceof nt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];t[i]=t[i]||[],t[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}nt.create=r=>new nt(r);const Vt=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let ln=Vt;function Sn(r){ln=r}function vr(){return ln}const br=r=>{const{data:e,path:t,errorMaps:a,issueData:s}=r,i=[...t,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const k=a.filter(_=>!!_).slice().reverse();for(const _ of k)f=_(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Cn=[];function U(r,e){const t=vr(),a=br({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vt?void 0:Vt].filter(s=>!!s)});r.common.issues.push(a)}class Ye{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const s of t){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const s of t){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ye.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const s of t){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Zt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Nr=r=>r.status==="aborted",Mr=r=>r.status==="dirty",Rt=r=>r.status==="valid",Kt=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class yt{constructor(e,t,a,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const nn=(r,e)=>{if(Rt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new nt(r.common.issues);return this._error=t,this._error}}};function ie(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:a,description:s}=r;if(e&&(t||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:k}=r;return c.code==="invalid_enum_value"?{message:k??f.defaultError}:typeof f.data>"u"?{message:k??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:k??t??f.defaultError}},description:s}}class ce{get description(){return this._def.description}_getType(e){return kt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:kt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ye,ctx:{common:e.parent.common,data:e.data,parsedType:kt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Kt(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 a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)},s=this._parseSync({data:e,path:a.path,parent:a});return nn(a,s)}"~validate"(e){var a,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return Rt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>Rt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(Kt(s)?s:Promise.resolve(s));return nn(a,i)}refine(e,t){const a=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:D.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(k=>k?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,t){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof t=="function"?t(a,s):t),!1))}_refinement(e){return new ft({schema:this,typeName:re.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return mt.create(this,this._def)}nullable(){return Dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this)}promise(){return qt.create(this,this._def)}or(e){return tr.create([this,e],this._def)}and(e){return rr.create(this,e,this._def)}transform(e){return new ft({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new or({...ie(this._def),innerType:this,defaultValue:t,typeName:re.ZodDefault})}brand(){return new jr({typeName:re.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new cr({...ie(this._def),innerType:this,catchValue:t,typeName:re.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return lr.create(this,e)}readonly(){return ur.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const On=/^c[^\s-]{8,}$/i,Dn=/^[0-9a-z]+$/,Pn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Nn=/^[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,Mn=/^[a-z0-9_-]{21}$/i,Rn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,In=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cr;const $n=/^(?:(?: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])$/,Un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Bn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ln=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Zn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fn="((\\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])))",Vn=new RegExp(`^${fn}$`);function dn(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Wn(r){return new RegExp(`^${dn(r)}$`)}function hn(r){let e=`${fn}T${dn(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function qn(r,e){return!!((e==="v4"||!e)&&$n.test(r)||(e==="v6"||!e)&&Bn.test(r))}function Hn(r,e){if(!Rn.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Gn(r,e){return!!((e==="v4"||!e)&&Un.test(r)||(e==="v6"||!e)&&Ln.test(r))}class ut extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.string,received:i.parsedType}),ee}const a=new Ye;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?U(s,{code:D.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:D.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")jn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Cr||(Cr=new RegExp(Fn,"u")),Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")On.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Dn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Pn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:D.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"regex",code:D.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?hn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?Wn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?In.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?qn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?Hn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?Gn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:D.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,t,a){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ut({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ut({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ut({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ut({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ut.create=r=>new ut({checks:[],typeName:re.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function Yn(r,e){const t=(r.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=t>a?t:a,i=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class St extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.number,received:i.parsedType}),ee}let a;const s=new Ye;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:D.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Yn(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_finite,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new St({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new St({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(t===null||a.value>t)&&(t=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}St.create=r=>new St({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ct extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let a;const s=new Ye;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return U(t,{code:D.invalid_type,expected:z.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ct.create=r=>new Ct({checks:[],typeName:re.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class Xt extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.boolean,received:a.parsedType}),ee}return Je(e.data)}}Xt.create=r=>new Xt({typeName:re.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class It extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_date}),ee}const a=new Ye;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):be.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new It({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}It.create=r=>new It({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:re.ZodDate,...ie(r)});class wr extends ce{_parse(e){if(this._getType(e)!==z.symbol){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.symbol,received:a.parsedType}),ee}return Je(e.data)}}wr.create=r=>new wr({typeName:re.ZodSymbol,...ie(r)});class Qt extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.undefined,received:a.parsedType}),ee}return Je(e.data)}}Qt.create=r=>new Qt({typeName:re.ZodUndefined,...ie(r)});class er extends ce{_parse(e){if(this._getType(e)!==z.null){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.null,received:a.parsedType}),ee}return Je(e.data)}}er.create=r=>new er({typeName:re.ZodNull,...ie(r)});class Wt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Wt.create=r=>new Wt({typeName:re.ZodAny,...ie(r)});class Mt extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}Mt.create=r=>new Mt({typeName:re.ZodUnknown,...ie(r)});class xt extends ce{_parse(e){const t=this._getOrReturnCtx(e);return U(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),ee}}xt.create=r=>new xt({typeName:re.ZodNever,...ie(r)});class kr extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.void,received:a.parsedType}),ee}return Je(e.data)}}kr.create=r=>new kr({typeName:re.ZodVoid,...ie(r)});class lt extends ce{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return U(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),ee;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,f=t.data.length<s.exactLength.value;(c||f)&&(U(t,{code:c?D.too_big:D.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(U(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(U(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((c,f)=>s.type._parseAsync(new yt(t,c,t.path,f)))).then(c=>Ye.mergeArray(a,c));const i=[...t.data].map((c,f)=>s.type._parseSync(new yt(t,c,t.path,f)));return Ye.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new lt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new lt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new lt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}lt.create=(r,e)=>new lt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function Lt(r){if(r instanceof Ie){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=mt.create(Lt(a))}return new Ie({...r._def,shape:()=>e})}else return r instanceof lt?new lt({...r._def,type:Lt(r.element)}):r instanceof mt?mt.create(Lt(r.unwrap())):r instanceof Dt?Dt.create(Lt(r.unwrap())):r instanceof gt?gt.create(r.items.map(e=>Lt(e))):r}class Ie extends ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=be.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==z.object){const _=this._getOrReturnCtx(e);return U(_,{code:D.invalid_type,expected:z.object,received:_.parsedType}),ee}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof xt&&this._def.unknownKeys==="strip"))for(const _ in s.data)c.includes(_)||f.push(_);const k=[];for(const _ of c){const R=i[_],S=s.data[_];k.push({key:{status:"valid",value:_},value:R._parse(new yt(s,S,s.path,_)),alwaysSet:_ in s.data})}if(this._def.catchall instanceof xt){const _=this._def.unknownKeys;if(_==="passthrough")for(const R of f)k.push({key:{status:"valid",value:R},value:{status:"valid",value:s.data[R]}});else if(_==="strict")f.length>0&&(U(s,{code:D.unrecognized_keys,keys:f}),a.dirty());else if(_!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const _=this._def.catchall;for(const R of f){const S=s.data[R];k.push({key:{status:"valid",value:R},value:_._parse(new yt(s,S,s.path,R)),alwaysSet:R in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const _=[];for(const R of k){const S=await R.key,w=await R.value;_.push({key:S,value:w,alwaysSet:R.alwaysSet})}return _}).then(_=>Ye.mergeObjectSync(a,_)):Ye.mergeObjectSync(a,k)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Ie({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,t,a).message)??a.defaultError;return t.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ie({...this._def,unknownKeys:"strip"})}passthrough(){return new Ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ie({...this._def,catchall:e})}pick(e){const t={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of be.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}deepPartial(){return Lt(this)}partial(e){const t={};for(const a of be.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new Ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof mt;)i=i._def.innerType;t[a]=i}return new Ie({...this._def,shape:()=>t})}keyof(){return pn(be.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});class tr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return t.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new nt(f.ctx.common.issues));return U(t,{code:D.invalid_union,unionErrors:c}),ee}if(t.common.async)return Promise.all(a.map(async i=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const k of a){const _={...t,common:{...t.common,issues:[]},parent:null},R=k._parseSync({data:t.data,path:t.path,parent:_});if(R.status==="valid")return R;R.status==="dirty"&&!i&&(i={result:R,ctx:_}),_.common.issues.length&&c.push(_.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(k=>new nt(k));return U(t,{code:D.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}tr.create=(r,e)=>new tr({options:r,typeName:re.ZodUnion,...ie(e)});const wt=r=>r instanceof ar?wt(r.schema):r instanceof ft?wt(r.innerType()):r instanceof sr?[r.value]:r instanceof Ot?r.options:r instanceof ir?be.objectValues(r.enum):r instanceof or?wt(r._def.innerType):r instanceof Qt?[void 0]:r instanceof er?[null]:r instanceof mt?[void 0,...wt(r.unwrap())]:r instanceof Dt?[null,...wt(r.unwrap())]:r instanceof jr||r instanceof ur?wt(r.unwrap()):r instanceof cr?wt(r._def.innerType):[];class Ar extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return U(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),ee;const a=this.discriminator,s=t.data[a],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(U(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const s=new Map;for(const i of t){const c=wt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Ar({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ie(a)})}}function Rr(r,e){const t=kt(r),a=kt(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&a===z.object){const s=be.objectKeys(e),i=be.objectKeys(r).filter(f=>s.indexOf(f)!==-1),c={...r,...e};for(const f of i){const k=Rr(r[f],e[f]);if(!k.valid)return{valid:!1};c[f]=k.data}return{valid:!0,data:c}}else if(t===z.array&&a===z.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const c=r[i],f=e[i],k=Rr(c,f);if(!k.valid)return{valid:!1};s.push(k.data)}return{valid:!0,data:s}}else return t===z.date&&a===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class rr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Nr(i)||Nr(c))return ee;const f=Rr(i.value,c.value);return f.valid?((Mr(i)||Mr(c))&&t.dirty(),{status:t.value,value:f.data}):(U(a,{code:D.invalid_intersection_types}),ee)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}rr.create=(r,e,t)=>new rr({left:r,right:e,typeName:re.ZodIntersection,...ie(t)});class gt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.array)return U(a,{code:D.invalid_type,expected:z.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return U(a,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...a.data].map((c,f)=>{const k=this._def.items[f]||this._def.rest;return k?k._parse(new yt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ye.mergeArray(t,c)):Ye.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new gt({...this._def,rest:e})}}gt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gt({items:r,typeName:re.ZodTuple,rest:null,...ie(e)})};class nr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.object)return U(a,{code:D.invalid_type,expected:z.object,received:a.parsedType}),ee;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new yt(a,f,a.path,f)),value:c._parse(new yt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ye.mergeObjectAsync(t,s):Ye.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof ce?new nr({keyType:e,valueType:t,typeName:re.ZodRecord,...ie(a)}):new nr({keyType:ut.create(),valueType:e,typeName:re.ZodRecord,...ie(t)})}}class xr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.map)return U(a,{code:D.invalid_type,expected:z.map,received:a.parsedType}),ee;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,k],_)=>({key:s._parse(new yt(a,f,a.path,[_,"key"])),value:i._parse(new yt(a,k,a.path,[_,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const k of c){const _=await k.key,R=await k.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const k of c){const _=k.key,R=k.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}}}}xr.create=(r,e,t)=>new xr({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class jt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.set)return U(a,{code:D.invalid_type,expected:z.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(U(a,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function c(k){const _=new Set;for(const R of k){if(R.status==="aborted")return ee;R.status==="dirty"&&t.dirty(),_.add(R.value)}return{status:t.value,value:_}}const f=[...a.data.values()].map((k,_)=>i._parse(new yt(a,k,a.path,_)));return a.common.async?Promise.all(f).then(k=>c(k)):c(f)}min(e,t){return new jt({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new jt({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}jt.create=(r,e)=>new jt({valueType:r,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class zt extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return U(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),ee;function a(f,k){return br({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vr(),Vt].filter(_=>!!_),issueData:{code:D.invalid_arguments,argumentsError:k}})}function s(f,k){return br({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vr(),Vt].filter(_=>!!_),issueData:{code:D.invalid_return_type,returnTypeError:k}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof qt){const f=this;return Je(async function(...k){const _=new nt([]),R=await f._def.args.parseAsync(k,i).catch(A=>{throw _.addIssue(a(k,A)),_}),S=await Reflect.apply(c,this,R);return await f._def.returns._def.type.parseAsync(S,i).catch(A=>{throw _.addIssue(s(S,A)),_})})}else{const f=this;return Je(function(...k){const _=f._def.args.safeParse(k,i);if(!_.success)throw new nt([a(k,_.error)]);const R=Reflect.apply(c,this,_.data),S=f._def.returns.safeParse(R,i);if(!S.success)throw new nt([s(R,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new zt({...this._def,args:gt.create(e).rest(Mt.create())})}returns(e){return new zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new zt({args:e||gt.create([]).rest(Mt.create()),returns:t||Mt.create(),typeName:re.ZodFunction,...ie(a)})}}class ar extends ce{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})}}ar.create=(r,e)=>new ar({getter:r,typeName:re.ZodLazy,...ie(e)});class sr extends ce{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return U(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}sr.create=(r,e)=>new sr({value:r,typeName:re.ZodLiteral,...ie(e)});function pn(r,e){return new Ot({values:r,typeName:re.ZodEnum,...ie(e)})}class Ot extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{expected:be.joinValues(a),received:t.parsedType,code:D.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{received:t.data,code:D.invalid_enum_value,options:a}),ee}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ot.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ot.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ot.create=pn;class ir extends ce{_parse(e){const t=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==z.string&&a.parsedType!==z.number){const s=be.objectValues(t);return U(a,{expected:be.joinValues(s),received:a.parsedType,code:D.invalid_type}),ee}if(this._cache||(this._cache=new Set(be.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=be.objectValues(t);return U(a,{received:a.data,code:D.invalid_enum_value,options:s}),ee}return Je(e.data)}get enum(){return this._def.values}}ir.create=(r,e)=>new ir({values:r,typeName:re.ZodNativeEnum,...ie(e)});class qt extends ce{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return U(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),ee;const a=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qt.create=(r,e)=>new qt({type:r,typeName:re.ZodPromise,...ie(e)});class ft extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{U(a,c),c.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(t.value==="aborted")return ee;const k=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return k.status==="aborted"?ee:k.status==="dirty"||t.value==="dirty"?Zt(k.value):k});{if(t.value==="aborted")return ee;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?ee:f.status==="dirty"||t.value==="dirty"?Zt(f.value):f}}if(s.type==="refinement"){const c=f=>{const k=s.refinement(f,i);if(a.common.async)return Promise.resolve(k);if(k instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value),{status:t.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value).then(()=>({status:t.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Rt(c))return ee;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>Rt(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):ee);be.assertNever(s)}}ft.create=(r,e,t)=>new ft({schema:r,typeName:re.ZodEffects,effect:e,...ie(t)});ft.createWithPreprocess=(r,e,t)=>new ft({schema:e,effect:{type:"preprocess",transform:r},typeName:re.ZodEffects,...ie(t)});class mt extends ce{_parse(e){return this._getType(e)===z.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mt.create=(r,e)=>new mt({innerType:r,typeName:re.ZodOptional,...ie(e)});class Dt extends ce{_parse(e){return this._getType(e)===z.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Dt.create=(r,e)=>new Dt({innerType:r,typeName:re.ZodNullable,...ie(e)});class or extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===z.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}or.create=(r,e)=>new or({innerType:r,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class cr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Kt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new nt(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new nt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}cr.create=(r,e)=>new cr({innerType:r,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class _r extends ce{_parse(e){if(this._getType(e)!==z.nan){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}_r.create=r=>new _r({typeName:re.ZodNaN,...ie(r)});const Jn=Symbol("zod_brand");class jr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class lr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(t.dirty(),Zt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,t){return new lr({in:e,out:t,typeName:re.ZodPipeline})}}class ur extends ce{_parse(e){const t=this._def.innerType._parse(e),a=s=>(Rt(s)&&(s.value=Object.freeze(s.value)),s);return Kt(t)?t.then(s=>a(s)):a(t)}unwrap(){return this._def.innerType}}ur.create=(r,e)=>new ur({innerType:r,typeName:re.ZodReadonly,...ie(e)});function an(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function mn(r,e={},t){return r?Wt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=an(e,a),k=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:k})}});if(!i){const c=an(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Wt.create()}const Kn={object:Ie.lazycreate};var re;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(re||(re={}));const Xn=(r,e={message:`Input not instance of ${r.name}`})=>mn(t=>t instanceof r,e),Er=ut.create,Fr=St.create,Qn=_r.create,ea=Ct.create,Tr=Xt.create,ta=It.create,ra=wr.create,na=Qt.create,aa=er.create,sa=Wt.create,ia=Mt.create,oa=xt.create,ca=kr.create,ua=lt.create,Ir=Ie.create,la=Ie.strictCreate,fa=tr.create,da=Ar.create,ha=rr.create,pa=gt.create,ma=nr.create,ya=xr.create,ga=jt.create,va=zt.create,ba=ar.create,wa=sr.create,yn=Ot.create,ka=ir.create,xa=qt.create,sn=ft.create,_a=mt.create,Ea=Dt.create,Ta=ft.createWithPreprocess,Aa=lr.create,Sa=()=>Er().optional(),Ca=()=>Fr().optional(),Oa=()=>Tr().optional(),Da={string:(r=>ut.create({...r,coerce:!0})),number:(r=>St.create({...r,coerce:!0})),boolean:(r=>Xt.create({...r,coerce:!0})),bigint:(r=>Ct.create({...r,coerce:!0})),date:(r=>It.create({...r,coerce:!0}))},Pa=ee,O=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Jn,DIRTY:Zt,EMPTY_PATH:Cn,INVALID:ee,NEVER:Pa,OK:Je,ParseStatus:Ye,Schema:ce,ZodAny:Wt,ZodArray:lt,ZodBigInt:Ct,ZodBoolean:Xt,ZodBranded:jr,ZodCatch:cr,ZodDate:It,ZodDefault:or,ZodDiscriminatedUnion:Ar,ZodEffects:ft,ZodEnum:Ot,ZodError:nt,get ZodFirstPartyTypeKind(){return re},ZodFunction:zt,ZodIntersection:rr,ZodIssueCode:D,ZodLazy:ar,ZodLiteral:sr,ZodMap:xr,ZodNaN:_r,ZodNativeEnum:ir,ZodNever:xt,ZodNull:er,ZodNullable:Dt,ZodNumber:St,ZodObject:Ie,ZodOptional:mt,ZodParsedType:z,ZodPipeline:lr,ZodPromise:qt,ZodReadonly:ur,ZodRecord:nr,ZodSchema:ce,ZodSet:jt,ZodString:ut,ZodSymbol:wr,ZodTransformer:ft,ZodTuple:gt,ZodType:ce,ZodUndefined:Qt,ZodUnion:tr,ZodUnknown:Mt,ZodVoid:kr,addIssueToContext:U,any:sa,array:ua,bigint:ea,boolean:Tr,coerce:Da,custom:mn,date:ta,datetimeRegex:hn,defaultErrorMap:Vt,discriminatedUnion:da,effect:sn,enum:yn,function:va,getErrorMap:vr,getParsedType:kt,instanceof:Xn,intersection:ha,isAborted:Nr,isAsync:Kt,isDirty:Mr,isValid:Rt,late:Kn,lazy:ba,literal:wa,makeIssue:br,map:ya,nan:Qn,nativeEnum:ka,never:oa,null:aa,nullable:Ea,number:Fr,object:Ir,get objectUtil(){return Pr},oboolean:Oa,onumber:Ca,optional:_a,ostring:Sa,pipeline:Aa,preprocess:Ta,promise:xa,quotelessJson:An,record:ma,set:ga,setErrorMap:Sn,strictObject:la,string:Er,symbol:ra,transformer:sn,tuple:pa,undefined:na,union:fa,unknown:ia,get util(){return be},void:ca},Symbol.toStringTag,{value:"Module"})),dt=Ir({name:Er(),selector:Er(),findBy:yn(["cssSelector","xpath"]),option:Ir({waitForSelector:Tr().optional(),waitSelectorTimeout:Fr().optional(),multiple:Tr().optional()})}),Na=O.object({type:O.literal("object"),shape:O.record(O.string(),O.any())}),Ma=O.object({type:O.literal("array"),items:O.any()}),Ra=O.discriminatedUnion("type",[Na,Ma]),$r=O.object({name:O.literal("ai-parse-data"),sourceData:O.any().optional(),schemaDefinition:Ra,prompt:O.string().optional(),model:O.string().optional(),apiKey:O.string().min(1,"OpenAI API key is required")});function Ia(r){return $r.parse(r)}async function ja(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s="gpt-4o-mini",apiKey:i}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const c=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i}});if(c.$isError)throw new Error(c.message||"AI parsing failed");return{data:c.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function Fa(r){return{type:"object",shape:r}}function $a(r){return{type:"array",items:r}}const Ua={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e})};class Sr{async waitForElement(e,t,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,t);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class Ba extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,t);return i?Array.from(t.querySelectorAll(c)):t.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(k=>k.nodeType===Node.TEXT_NODE).map(k=>{var _;return((_=k.textContent)==null?void 0:_.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class La extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(_=>_.trim());if(c.length!==2)return null;const f=c[0],k=c[1];if(!f||!k)return null;try{const _=t.querySelector(f);if(!_||!_.contentDocument)return null;const R=_.contentDocument;return i?Array.from(R.querySelectorAll(k)):R.querySelector(k)}catch(_){return console.error("Iframe Selector error:",_),null}}}class Za extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(k=>k.trim());let f=t;try{for(let k=0;k<c.length;k++){const _=c[k],R=k===c.length-1;if(!_)return null;if(R&&i)return Array.from(f.querySelectorAll(_));const S=f.querySelector(_);if(!S)return null;if(R)return S;if(S.shadowRoot)f=S.shadowRoot;else return null}}catch(k){return console.error("Shadow DOM Selector error:",k),null}return null}}class za extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=t.evaluate(a,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let k=0;k<c.snapshotLength;k++){const _=c.snapshotItem(k);_&&_.nodeType===Node.ELEMENT_NODE&&f.push(_)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class Va{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${c})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function ht(r,e=document){const{selector:t,findBy:a="cssSelector",option:s}=r,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=Wa(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function Wa(r,e){return e==="xpath"?new za:r.includes(">>")?new Za:r.includes("|>")?new La:new Ba}const Ur=dt.extend({name:O.literal("get-text"),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),filterEmpty:O.boolean().optional(),scrollToCollect:O.boolean().optional(),scrollDistance:O.number().optional(),scrollWaitMs:O.number().optional(),maxScrollAttempts:O.number().optional()});function qa(r){return Ur.parse(r)}async function Ha(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:k,filterEmpty:_=!0,scrollToCollect:R=!1,scrollDistance:S=500,scrollWaitMs:w=300,maxScrollAttempts:A=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(R&&(k!=null&&k.multiple))return await Ga({selector:e,findBy:f,option:k,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:_,scrollDistance:S,scrollWaitMs:w,maxScrollAttempts:A});const I=await ht({selector:e,findBy:f,option:k});if(!I)return{data:""};const se=gn(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:_?me.filter(H=>H.trim()!==""):me}}else return{data:se(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function Ga(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:k,filterEmpty:_,scrollDistance:R,scrollWaitMs:S,maxScrollAttempts:w}=r,A=gn(s,i,c,f,k),I=new Set;let se=0,me=0;const ge=5;for(;se<w;){const H=await ht({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const L=I.size;if(H.forEach(B=>{const V=A(B);(!_||V.trim()!=="")&&I.add(V)}),I.size===L){if(me++,me>=ge)break}else me=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:R,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function gn(r,e,t,a="",s=""){return i=>{let c="";if(r?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",t){const f=new RegExp(t,"g"),k=c.match(f);c=k?k.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Br=dt.extend({name:O.literal("attribute-value"),attributeName:O.string()});function Ya(r){return Br.parse(r)}async function Ja(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:s}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await ht({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(t)).filter(f=>f!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Lr=dt.extend({name:O.literal("get-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function Ka(r){return Lr.parse(r)}async function Xa(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const s=await ht({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return{data:Qa(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function Qa(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Zr=dt.extend({name:O.literal("set-value-form"),setValue:O.string(),type:O.enum(["text-field","select","checkbox"]).optional()});function es(r){return Zr.parse(r)}async function ts(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:s="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await ht({selector:e,findBy:s,option:r.option});if(!i)throw new Error("Form element not found");return rs(i,t,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function rs(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const zr=dt.extend({name:O.literal("clear-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function ns(r){return zr.parse(r)}async function as(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await ht({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return ss(s,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ss(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Vr=dt.extend({name:O.literal("element-exists")});function is(r){return Vr.parse(r)}async function os(r){try{const{selector:e="",findBy:t="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await ht({selector:e,findBy:t,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Wr=dt.extend({name:O.literal("event-click"),textFilter:O.object({text:O.union([O.string(),O.array(O.string())]),mode:O.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function cs(r){return Wr.parse(r)}async function us(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:s}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await ht({selector:e,findBy:t,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=ls(i,s.text,s.mode);if(!f){const k=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${k}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await ds(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function ls(r,e,t){for(const a of r){const s=fs(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(t){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function fs(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const a=r.getAttribute("aria-label");return a?a.trim():""}async function ds(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),r.click&&r.click()}await new Promise(s=>setTimeout(s,50))}const qr=O.object({name:O.literal("keypress"),key:O.string(),code:O.string().optional(),keyCode:O.number().optional(),modifiers:O.array(O.enum(["Alt","Control","Meta","Shift"])).optional()});function hs(r){return qr.parse(r)}async function ps(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await ms(e,t,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function ms(r,e,t,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Or(r),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Or(r),bubbles:!0,cancelable:!0,...on(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Or(r),bubbles:!0,cancelable:!0,...on(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Or(r){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[r]||0}function on(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Hr=O.object({name:O.literal("wait"),duration:O.number().min(0)});function ys(r){return Hr.parse(r)}async function gs(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Gr=O.object({name:O.literal("wait-for-condition"),conditions:O.object({urlPattern:O.string().optional(),elementExists:O.object({selector:O.string(),findBy:O.enum(["cssSelector","xpath"])}).optional(),cookieExists:O.string().optional(),storageKey:O.object({type:O.enum(["localStorage","sessionStorage"]),key:O.string()}).optional(),userConfirmation:O.boolean().optional(),message:O.string().optional(),buttonText:O.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:O.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:O.number().min(100).optional(),timeoutMs:O.number().min(1e3).optional(),position:O.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function vs(r){return Gr.parse(r)}async function bs(r){try{const{conditions:e,mode:t="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=r;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",t,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let k=null,_=null;(t==="manual"||t==="auto-or-manual")&&f&&(k=new Promise(S=>{_=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:_}})));const R=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(S){console.warn("[WaitForCondition] Invalid URL pattern:",S)}if(e.elementExists){const{selector:S,findBy:w}=e.elementExists;let A=null;if(w==="cssSelector"?A=document.querySelector(S):w==="xpath"&&(A=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),A)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(A=>{const[I]=A.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:S,key:w}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(w)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${w}`}}return null};return new Promise(S=>{let w=null,A=!1;const I=()=>{w&&(clearInterval(w),w=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},se=ge=>{A||(A=!0,I(),console.log("[WaitForCondition] Resolved with:",ge),S({data:ge}))},me=setTimeout(()=>{se({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(w=setInterval(async()=>{const ge=await R();ge&&(clearTimeout(me),se(ge))},a)),(t==="manual"||t==="auto-or-manual")&&k&&k.then(()=>{clearTimeout(me),se({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const Yr=dt.extend({name:O.literal("save-assets")});function ws(r){return Yr.parse(r)}async function ks(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,s=await ht({selector:e,findBy:t,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class xs{static generate(e){var s;const t=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(k=>k.tagName===a.tagName);if(c.length>1){const k=c.indexOf(a)+1;i+=`[${k}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),t.unshift(i),a=a.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&t.push(`${s}="${i}"`)}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const Jr=dt.extend({name:O.literal("get-element-data"),includeText:O.boolean().optional(),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),attributes:O.array(O.string()).optional(),includeSelector:O.boolean().optional(),includeXPath:O.boolean().optional()});function _s(r){return Jr.parse(r)}async function Es(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:k=[],includeSelector:_=!1,includeXPath:R=!1,findBy:S="cssSelector",option:w}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&k.length===0)throw new Error("Either includeText must be true or attributes must be provided");const A=await ht({selector:e,findBy:S,option:w});if(!A)return{data:Array.isArray(A)?[]:{}};const I=Ts(t,a,s,i,c,f,k,_,R);return Array.isArray(A)?{data:A.map(I)}:{data:I(A)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Ts(r,e,t,a,s="",i="",c=[],f=!1,k=!1){return _=>{const R={};if(r){let S="";if(e?S=_.innerHTML:S=t?_.textContent||"":_.innerText||"",a){const w=new RegExp(a,"g"),A=S.match(w);S=A?A.join(" "):""}S.trim()&&(S=s+S.trim()+i),R.text=S}return c.length>0&&(R.attributes={},c.forEach(S=>{let w=_.getAttribute(S);if(w===null){const A=_.querySelector(`[${S}]`);A&&(w=A.getAttribute(S))}R.attributes[S]=w})),f&&(R.selector=Va.generate(_)),k&&(R.xpath=xs.generate(_)),R}}const Kr=dt.extend({name:O.literal("scroll"),scrollType:O.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:O.number().optional(),behavior:O.enum(["auto","smooth"]).optional(),maxScrolls:O.number().optional(),waitAfterScroll:O.number().optional()});function As(r){return Kr.parse(r)}async function Ss(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:k}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Cs(e,f,k,s);case"toBottom":return await Os(s,c);case"byDistance":return await Ds(a,s);case"untilLoaded":return await Ps(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Cs(r,e,t,a){const s=await ht({selector:r,findBy:e,option:t});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Os(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function Ds(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Ps(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(_=>setTimeout(_,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,k=window.innerHeight;if(f+k>=c-10&&c===i)break;i=c,s++}return{data:!0}}const Xr=O.object({name:O.literal("fetch-api"),url:O.string(),method:O.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:O.record(O.string(),O.string()).optional(),body:O.record(O.string(),O.any()).optional(),timeout:O.number().min(0).optional(),parseJson:O.boolean().optional(),returnHeaders:O.boolean().optional()});function Ns(r){return Xr.parse(r)}async function Ms(r){try{console.log("[FetchApiBlock] Sending API request to background:",r.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:r.url,method:r.method||"GET",headers:r.headers||{},body:r.body,timeout:r.timeout||3e4,parseJson:r.parseJson??!0,returnHeaders:r.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Rs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function gr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Dr={exports:{}},un;function Is(){return un||(un=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(_,R){if(!s[_]){if(!a[_]){var S=typeof gr=="function"&&gr;if(!R&&S)return S(_,!0);if(f)return f(_,!0);var w=new Error("Cannot find module '"+_+"'");throw w.code="MODULE_NOT_FOUND",w}var A=s[_]={exports:{}};a[_][0].call(A.exports,function(I){var se=a[_][1][I];return c(se||I)},A,A.exports,t,a,s,i)}return s[_].exports}for(var f=typeof gr=="function"&&gr,k=0;k<i.length;k++)c(i[k]);return c}return t})()({1:[function(t,a,s){const i=t("./utils"),c=(function(){const f=i.stringToArray,k=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],_=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],R=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function w(v,T){var b=function($,j,C){var F="";if($<=19)F=(j?" and ":"")+(C?_[$]:k[$]);else if($<100){const ye=Math.floor($/10),we=$%10;F=(j?" and ":"")+R[ye-2],we>0?F+="-"+b(we,!1,C):C&&(F=F.substring(0,F.length-1)+"ieth")}else if($<1e3){const ye=Math.floor($/100),we=$%100;F=(j?", ":"")+k[ye]+" Hundred",we>0?F+=b(we,!0,C):C&&(F+="th")}else{var K=Math.floor(Math.log10($)/3);K>S.length&&(K=S.length);const ye=Math.pow(10,K*3),we=Math.floor($/ye),J=$-we*ye;F=(j?", ":"")+b(we,!1,!1)+" "+S[K-1],J>0?F+=b(J,!0,C):C&&(F+="th")}return F},P=b(v,!1,T);return P}const A={};k.forEach(function(v,T){A[v.toLowerCase()]=T}),_.forEach(function(v,T){A[v.toLowerCase()]=T}),R.forEach(function(v,T){const b=v.toLowerCase();A[b]=(T+2)*10,A[b.substring(0,v.length-1)+"ieth"]=A[b]}),A.hundredth=100,S.forEach(function(v,T){const b=v.toLowerCase(),P=Math.pow(10,(T+1)*3);A[b]=P,A[b+"th"]=P});function I(v){const b=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>A[j]);let P=[0];return b.forEach(j=>{if(j<100){let C=P.pop();C>=1e3&&(P.push(C),C=0),P.push(C+j)}else P.push(P.pop()*j)}),P.reduce((j,C)=>j+C,0)}const se=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],me={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ge(v){for(var T=0;T<se.length;T++){const b=se[T];if(v>=b[0])return b[1]+ge(v-b[0])}return""}function H(v){for(var T=0,b=1,P=v.length-1;P>=0;P--){const $=v[P],j=me[$];j<b?T-=j:(b=j,T+=j)}return T}function N(v,T){for(var b=[],P=T.charCodeAt(0);v>0;)b.unshift(String.fromCharCode((v-1)%26+P)),v=Math.floor((v-1)/26);return b.join("")}function ne(v,T){for(var b=T.charCodeAt(0),P=0,$=0;$<v.length;$++)P+=(v.charCodeAt(v.length-$-1)-b+1)*Math.pow(26,$);return P}function L(v,T){if(typeof v>"u")return;v=Math.floor(v);const b=xe(T);return V(v,b)}const E={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},B={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(v,T){let b;const P=v<0;switch(v=Math.abs(v),T.primary){case E.LETTERS:b=N(v,T.case===B.UPPER?"A":"a");break;case E.ROMAN:b=ge(v),T.case===B.UPPER&&(b=b.toUpperCase());break;case E.WORDS:b=w(v,T.ordinal),T.case===B.UPPER?b=b.toUpperCase():T.case===B.LOWER&&(b=b.toLowerCase());break;case E.DECIMAL:b=""+v;var $=T.mandatoryDigits-b.length;if($>0){var j=new Array($+1).join("0");b=j+b}if(T.zeroCode!==48&&(b=f(b).map(ye=>String.fromCodePoint(ye.codePointAt(0)+T.zeroCode-48)).join("")),T.regular){const ye=Math.floor((b.length-1)/T.groupingSeparators.position);for(let we=ye;we>0;we--){const J=b.length-we*T.groupingSeparators.position;b=b.substr(0,J)+T.groupingSeparators.character+b.substr(J)}}else T.groupingSeparators.reverse().forEach(ye=>{const we=b.length-ye.position;b=b.substr(0,we)+ye.character+b.substr(we)});if(T.ordinal){var C={1:"st",2:"nd",3:"rd"},F=b[b.length-1],K=C[F];(!K||b.length>1&&b[b.length-2]==="1")&&(K="th"),b=b+K}break;case E.SEQUENCE:throw{code:"D3130",value:T.token}}return P&&(b="-"+b),b}const de=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(v){const T={type:"integer",primary:E.DECIMAL,case:B.LOWER,ordinal:!1};let b,P;const $=v.lastIndexOf(";");switch($===-1?b=v:(b=v.substring(0,$),P=v.substring($+1),P[0]==="o"&&(T.ordinal=!0)),b){case"A":T.case=B.UPPER;case"a":T.primary=E.LETTERS;break;case"I":T.case=B.UPPER;case"i":T.primary=E.ROMAN;break;case"W":T.case=B.UPPER,T.primary=E.WORDS;break;case"Ww":T.case=B.TITLE,T.primary=E.WORDS;break;case"w":T.primary=E.WORDS;break;default:{let j=null,C=0,F=0,K=[],ye=0;if(f(b).map(J=>J.codePointAt(0)).reverse().forEach(J=>{let Q=!1;for(let he=0;he<de.length;he++){const G=de[he];if(J>=G&&J<=G+9){if(Q=!0,C++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(J===35?(ye++,F++):K.push({position:ye,character:String.fromCodePoint(J)}))}),C>0){T.primary=E.DECIMAL,T.zeroCode=j,T.mandatoryDigits=C,T.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let Ue=1;Ue<he.length;Ue++)if(he[Ue].character!==G)return 0;const Le=he.map(Ue=>Ue.position),st=function(Ue,qe){return qe===0?Ue:st(qe,Ue%qe)},We=Le.reduce(st);for(let Ue=1;Ue<=Le.length;Ue++)if(Le.indexOf(Ue*We)===-1)return 0;return We}(K);Q>0?(T.regular=!0,T.groupingSeparators={position:Q,character:K[0].character}):(T.regular=!1,T.groupingSeparators=K)}else T.primary=E.SEQUENCE,T.token=b}}return T}const Te={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Ae(v){var T=[];const b={type:"datetime",parts:T},P=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),T.push({type:"literal",value:G})}};for(var $=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){P($,j),T.push({type:"literal",value:"["}),j+=2,$=j;continue}if(P($,j),$=j,j=v.indexOf("]",$),j===-1)throw{code:"D3135"};let Q=v.substring($+1,j);Q=Q.split(/\s+/).join("");var C={type:"marker",component:Q.charAt(0)},F=Q.lastIndexOf(","),K;if(F!==-1){const he=Q.substring(F+1),G=he.indexOf("-");let Le,st;const We=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Le=he:(Le=he.substring(0,G),st=he.substring(G+1));const Ue={min:We(Le),max:We(st)};C.width=Ue,K=Q.substring(1,F)}else K=Q.substring(1);if(K.length===1)C.presentation1=K;else if(K.length>1){var ye=K.charAt(K.length-1);"atco".indexOf(ye)!==-1?(C.presentation2=ye,ye==="o"&&(C.ordinal=!0),C.presentation1=K.substring(0,K.length-1)):C.presentation1=K}else C.presentation1=Te[C.component];if(typeof C.presentation1>"u")throw{code:"D3132",value:C.component};if(C.presentation1[0]==="n")C.names=B.LOWER;else if(C.presentation1[0]==="N")C.presentation1[1]==="n"?C.names=B.TITLE:C.names=B.UPPER;else if("YMDdFWwXxHhmsf".indexOf(C.component)!==-1){var we=C.presentation1;if(C.presentation2&&(we+=";"+C.presentation2),C.integerFormat=xe(we),C.width&&C.width.min!==void 0&&C.integerFormat.mandatoryDigits<C.width.min&&(C.integerFormat.mandatoryDigits=C.width.min),C.component==="Y")if(C.n=-1,C.width&&C.width.max!==void 0)C.n=C.width.max,C.integerFormat.mandatoryDigits=C.n;else{var J=C.integerFormat.mandatoryDigits+C.integerFormat.optionalDigits;J>=2&&(C.n=J)}const he=T[T.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(C.component==="Z"||C.component==="z")&&(C.integerFormat=xe(C.presentation1)),T.push(C),$=j+1}j++}return P($,j),b}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],Qe=1e3*60*60*24,_e=function(v){const T=Date.UTC(v.year,v.month);var b=new Date(T).getUTCDay();return b===0&&(b=7),b>4?T+(8-b)*Qe:T-(b-1)*Qe},ue=function(v,T){return{year:v,month:T,nextMonth:function(){return T===11?ue(v+1,0):ue(v,T+1)},previousMonth:function(){return T===0?ue(v-1,11):ue(v,T-1)},nextYear:function(){return ue(v+1,T)},previousYear:function(){return ue(v-1,T)}}},et=function(v,T){return(T-v)/(Qe*7)+1},ae=(v,T)=>{let b;switch(T){case"Y":b=v.getUTCFullYear();break;case"M":b=v.getUTCMonth()+1;break;case"D":b=v.getUTCDate();break;case"d":{const P=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),$=Date.UTC(v.getUTCFullYear(),0);b=(P-$)/Qe+1;break}case"F":b=v.getUTCDay(),b===0&&(b=7);break;case"W":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=Date.UTC(P.year,v.getUTCMonth(),v.getUTCDate());let C=et($,j);if(C>52){const F=_e(P.nextYear());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousYear());C=et(F,j)}b=Math.floor(C);break}case"w":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=Date.UTC(P.year,P.month,v.getUTCDate());let C=et($,j);if(C>4){const F=_e(P.nextMonth());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousMonth());C=et(F,j)}b=Math.floor(C);break}case"X":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=_e(P.nextYear()),C=v.getTime();C<$?b=P.year-1:C>=j?b=P.year+1:b=P.year;break}case"x":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=P.nextMonth(),C=_e(j),F=v.getTime();F<$?b=P.previousMonth().month+1:F>=C?b=j.month+1:b=P.month+1;break}case"H":b=v.getUTCHours();break;case"h":b=v.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=v.getUTCHours()>=12?"pm":"am";break;case"m":b=v.getUTCMinutes();break;case"s":b=v.getUTCSeconds();break;case"f":b=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Fe=null;function at(v,T,b){var P=0,$=0;if(typeof b<"u"){const we=parseInt(b);P=Math.floor(we/100),$=we%100}var j=function(we,J){var Q=ae(we,J.component);if("YMDdFWwXxHhms".indexOf(J.component)!==-1)if(J.component==="Y"&&J.n!==-1&&(Q=Q%Math.pow(10,J.n)),J.names){if(J.component==="M"||J.component==="x")Q=Me[Q-1];else if(J.component==="F")Q=ve[Q];else throw{code:"D3133",value:J.component};J.names===B.UPPER?Q=Q.toUpperCase():J.names===B.LOWER&&(Q=Q.toLowerCase()),J.width&&Q.length>J.width.max&&(Q=Q.substring(0,J.width.max))}else Q=V(Q,J.integerFormat);else if(J.component==="f")Q=V(Q,J.integerFormat);else if(J.component==="Z"||J.component==="z"){const he=P*100+$;if(J.integerFormat.regular)Q=V(he,J.integerFormat);else{const G=J.integerFormat.mandatoryDigits;if(G===1||G===2)Q=V(P,J.integerFormat),$!==0&&(Q+=":"+L($,"00"));else if(G===3||G===4)Q=V(he,J.integerFormat);else throw{code:"D3134",value:G}}he>=0&&(Q="+"+Q),J.component==="z"&&(Q="GMT"+Q),he===0&&J.presentation2==="t"&&(Q="Z")}else J.component==="P"&&J.names===B.UPPER&&(Q=Q.toUpperCase());return Q};let C;typeof T>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),C=Fe):C=Ae(T);const F=(60*P+$)*60*1e3,K=new Date(v+F);let ye="";return C.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(K,we)}),ye}function d(v){var T={};if(v.type==="datetime")T.type="datetime",T.parts=v.parts.map(function(b){var P={};if(b.type==="literal")P.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),P.regex="",b.component==="z"&&(P.regex="GMT"),P.regex+="[-+][0-9]+",j&&(P.regex+=j.character+"[0-9]+"),P.parse=function(C){b.component==="z"&&(C=C.substring(3));let F=0,K=0;return j?(F=Number.parseInt(C.substring(0,C.indexOf(j.character))),K=Number.parseInt(C.substring(C.indexOf(j.character)+1))):C.length-1<=2?F=Number.parseInt(C):(F=Number.parseInt(C.substring(0,3)),K=Number.parseInt(C.substring(3))),F*60+K}}else if(b.integerFormat)P=d(b.integerFormat);else{P.regex="[a-zA-Z]+";var $={};if(b.component==="M"||b.component==="x")Me.forEach(function(j,C){b.width&&b.width.max?$[j.substring(0,b.width.max)]=C+1:$[j]=C+1});else if(b.component==="F")ve.forEach(function(j,C){C>0&&(b.width&&b.width.max?$[j.substring(0,b.width.max)]=C:$[j]=C)});else if(b.component==="P")$={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};P.parse=function(j){return $[j]}}return P.component=b.component,P});else{T.type="integer";const b=v.case===B.UPPER;switch(v.primary){case E.LETTERS:T.regex=b?"[A-Z]+":"[a-z]+",T.parse=function(P){return ne(P,b?"A":"a")};break;case E.ROMAN:T.regex=b?"[MDCLXVI]+":"[mdclxvi]+",T.parse=function(P){return H(b?P:P.toUpperCase())};break;case E.WORDS:T.regex="(?:"+Object.keys(A).concat("and","[\\-, ]").join("|")+")+",T.parse=function(P){return I(P.toLowerCase())};break;case E.DECIMAL:T.regex="[0-9]",v.parseWidth?T.regex+=`{${v.parseWidth}}`:T.regex+="+",v.ordinal&&(T.regex+="(?:th|st|nd|rd)"),T.parse=function(P){let $=P;return v.ordinal&&($=P.substring(0,P.length-2)),v.regular?$=$.split(",").join(""):v.groupingSeparators.forEach(j=>{$=$.split(j.character).join("")}),v.zeroCode!==48&&($=$.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt($)};break;case E.SEQUENCE:throw{code:"D3130",value:v.token}}}return T}function m(v,T){if(typeof v>"u")return;const b=xe(T);return d(b).parse(v)}function W(v,T){const b=Ae(T),P=d(b),$="^"+P.parts.map(K=>"("+K.regex+")").join("")+"$";var C=new RegExp($,"i").exec(v);if(C!==null){const G={};for(let Ce=1;Ce<C.length;Ce++){const u=P.parts[Ce-1];u.parse&&(G[u.component]=u.parse(C[Ce]))}if(Object.getOwnPropertyNames(G).length===0)return;let Le=0;const st=Ce=>{Le<<=1,Le+=Ce?1:0},We=Ce=>!(~Ce&Le)&&!!(Ce&Le);"YXMxWwdD".split("").forEach(Ce=>st(G[Ce]));const qe=!We(161)&&We(130),vt=We(84),_t=!vt&&We(72);Le=0,"PHhmsf".split("").forEach(Ce=>st(G[Ce]));const Et=!We(23)&&We(47),Ht=(qe?"YD":vt?"XxwF":_t?"XWF":"YMD")+(Et?"Phmsf":"Hmsf"),ot=this.environment.timestamp;let Ft=!1,pt=!1;if(Ht.split("").forEach(Ce=>{if(typeof G[Ce]>"u")Ft?(G[Ce]="MDd".indexOf(Ce)!==-1?1:0,pt=!0):G[Ce]=ae(ot,Ce);else if(Ft=!0,pt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const Ce=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(Ce+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(vt)throw{code:"D3136"};if(_t)throw{code:"D3136"};Et&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var le=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function De(v,T){if(!(typeof v>"u"))if(typeof T>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return W.call(this,v,T)}function Ee(v,T,b){if(!(typeof v>"u"))return at.call(this,v,T,b)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:De}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var k=c.isNumeric,_=c.isArrayOfStrings,R=c.isArrayOfNumbers,S=c.createSequence,w=c.isSequence,A=c.isFunction,I=c.isLambda,se=c.isPromise,me=c.getFunctionArity,ge=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function ne(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function E(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function B(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function V(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(A(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,x){return typeof x<"u"&&x!==null&&x.toPrecision&&k(x)?Number(x.toPrecision(15)):x&&A(x)?"":x},g)}return l}}function de(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var x=o>=0?o+l:p+o+l;return g.slice(o,x).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Me(n){if(!(typeof n>"u"))return H(n).length}function Qe(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Me(n);if(p>0){var x=new Array(p+1).join(l);l.length>1&&(x=de(x,0,p)),o>0?g=n+x:g=x+n}else g=n;return g}}async function ue(n,o){var l=n.apply(this,[o]);if(se(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||A(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function et(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await ue(o,n);l=typeof g<"u"}return l}}async function ae(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=S();if(typeof l>"u"||l>0){var p=0,x=await ue(o,n);if(typeof x<"u")for(;typeof x<"u"&&(typeof l>"u"||p<l);)g.push({match:x.match,index:x.start,groups:x.groups}),x=await ue(x.next),p++}return g}}async function Fe(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var x;typeof l=="string"?x=function(Se){for(var Ze="",ke=0,je=l.indexOf("$",ke);je!==-1&&ke<l.length;){Ze+=l.substring(ke,je),ke=je+1;var it=l.charAt(ke);if(it==="$")Ze+="$",ke++;else if(it==="0")Ze+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(ke,ke+ze),10),ze>1&&je>Se.groups.length&&(je=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(je))Ze+="$";else{if(Se.groups.length>0){var $t=Se.groups[je-1];typeof $t<"u"&&(Ze+=$t)}ke+=je.toString().length}}je=l.indexOf("$",ke)}return Ze+=l.substring(ke),Ze}:x=l;var M="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,q);Oe!==-1&&(typeof g>"u"||X<g);)M+=n.substring(q,Oe),M+=l,q=Oe+o.length,X++,Oe=n.indexOf(o,q);M+=n.substring(q)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){M+=n.substring(q,pe.start);var Pe=x.apply(p,[pe]);if(se(Pe)&&(Pe=await Pe),typeof Pe=="string")M+=Pe;else throw{code:"D3012",stack:new Error().stack,value:Pe};q=pe.start+pe.match.length,X++,pe=await ue(pe.next)}M+=n.substring(q)}else M=n}}else M=n;return M}}function at(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function W(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function le(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function De(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,x=await ue(o,n);if(typeof x<"u"){for(var M=0;typeof x<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(M,x.start)),M=x.end,x=await ue(x.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(M))}else g.push(n)}return g}}function v(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function T(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(te){p[te]=l[te]});for(var x=[],M=p["zero-digit"].charCodeAt(0),q=M;q<M+10;q++)x.push(String.fromCharCode(q));var X=x.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Re=(function(){for(var Be,rt=0;rt<te.length;rt++)if(Be=te.charAt(rt),X.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(0,rt)})(),Ge=(function(){for(var Be,rt=te.length-1;rt>=0;rt--)if(Be=te.charAt(rt),X.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(rt+1)})(),Ne=te.substring(Re.length,te.length-Ge.length),Ke,Tt,Xe,Nt,tt=te.indexOf(p["exponent-separator"],Re.length);tt===-1||tt>te.length-Ge.length?(Ke=Ne,Tt=void 0):(Ke=Ne.substring(0,tt),Tt=Ne.substring(tt+1));var ct=Ke.indexOf(p["decimal-separator"]);return ct===-1?(Xe=Ke,Nt=Ge):(Xe=Ke.substring(0,ct),Nt=Ke.substring(ct+1)),{prefix:Re,suffix:Ge,activePart:Ne,mantissaPart:Ke,exponentPart:Tt,integerPart:Xe,fractionalPart:Nt,subpicture:te}},Pe=function(te){var Re,Ge,Ne=te.subpicture,Ke=Ne.indexOf(p["decimal-separator"]);Ke!==Ne.lastIndexOf(p["decimal-separator"])&&(Re="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Re="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Re="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Re="D3084");var Tt=!1;for(Ge=0;Ge<te.mantissaPart.length;Ge++){var Xe=te.mantissaPart.charAt(Ge);if(x.indexOf(Xe)!==-1||Xe===p.digit){Tt=!0;break}}Tt||(Re="D3085");var Nt=te.activePart.split("").map(function(Be){return X.indexOf(Be)===-1?"p":"a"}).join("");Nt.indexOf("p")!==-1&&(Re="D3086"),Ke!==-1?(Ne.charAt(Ke-1)===p["grouping-separator"]||Ne.charAt(Ke+1)===p["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Re="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Re="D3089");var tt=te.integerPart.indexOf(p.digit);tt!==-1&&te.integerPart.substring(0,tt).split("").filter(function(Be){return x.indexOf(Be)>-1}).length>0&&(Re="D3090"),tt=te.fractionalPart.lastIndexOf(p.digit),tt!==-1&&te.fractionalPart.substring(tt).split("").filter(function(Be){return x.indexOf(Be)>-1}).length>0&&(Re="D3091");var ct=typeof te.exponentPart=="string";if(ct&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Re="D3092"),ct&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Be){return x.indexOf(Be)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Se=function(te){var Re=function(Ve,mr){for(var Jt=[],bt=Ve.indexOf(p["grouping-separator"]);bt!==-1;){var yr=(mr?Ve.substring(0,bt):Ve.substring(bt)).split("").filter(function(Bt){return x.indexOf(Bt)!==-1||Bt===p.digit}).length;Jt.push(yr),bt=te.integerPart.indexOf(p["grouping-separator"],bt+1)}return Jt},Ge=Re(te.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var mr=function(yr,Bt){return Bt===0?yr:mr(Bt,yr%Bt)},Jt=Ve.reduce(mr),bt=1;bt<=Ve.length;bt++)if(Ve.indexOf(bt*Jt)===-1)return 0;return Jt},Ke=Ne(Ge),Tt=Re(te.fractionalPart,!0),Xe=te.integerPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Nt=Xe,tt=te.fractionalPart.split(""),ct=tt.filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Be=tt.filter(function(Ve){return x.indexOf(Ve)!==-1||Ve===p.digit}).length,rt=typeof te.exponentPart=="string";Xe===0&&Be===0&&(rt?(ct=1,Be=1):Xe=1),rt&&Xe===0&&te.integerPart.indexOf(p.digit)!==-1&&(Xe=1),Xe===0&&ct===0&&(ct=1);var rn=0;return rt&&(rn=te.exponentPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ge,regularGrouping:Ke,minimumIntegerPartSize:Xe,scalingFactor:Nt,prefix:te.prefix,fractionalPartGroupingPositions:Tt,minimumFactionalPartSize:ct,maximumFactionalPartSize:Be,minimumExponentSize:rn,suffix:te.suffix,picture:te.subpicture}},Ze=Oe.map(pe);Ze.forEach(Pe);var ke=Ze.map(Se),je=p["minus-sign"],it=p["zero-digit"],ze=p["decimal-separator"],$t=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=je+ke[1].prefix);var $e;n>=0?$e=ke[0]:$e=ke[1];var Gt;$e.picture.indexOf(p.percent)!==-1?Gt=n*100:$e.picture.indexOf(p["per-mille"])!==-1?Gt=n*1e3:Gt=n;var Pt,Ut;if($e.minimumExponentSize===0)Pt=Gt;else{var vn=Math.pow(10,$e.scalingFactor),bn=Math.pow(10,$e.scalingFactor-1);for(Pt=Gt,Ut=0;Pt<bn;)Pt*=10,Ut-=1;for(;Pt>vn;)Pt/=10,Ut+=1}var wn=F(Pt,$e.maximumFactionalPartSize),en=function(te,Re){var Ge=Math.abs(te).toFixed(Re);return it!=="0"&&(Ge=Ge.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?x[Ne.charCodeAt(0)-48]:Ne}).join("")),Ge},oe=en(wn,$e.maximumFactionalPartSize),He=oe.indexOf(".");for(He===-1?oe=oe+ze:oe=oe.replace(".",ze);oe.charAt(0)===it;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===it;)oe=oe.substring(0,oe.length-1);He=oe.indexOf(ze);var Yt=$e.minimumIntegerPartSize-He,tn=$e.minimumFactionalPartSize-(oe.length-He-1);if(oe=(Yt>0?new Array(Yt+1).join(it):"")+oe,oe=oe+(tn>0?new Array(tn+1).join(it):""),He=oe.indexOf(ze),$e.regularGrouping>0)for(var kn=Math.floor((He-1)/$e.regularGrouping),hr=1;hr<=kn;hr++)oe=[oe.slice(0,He-hr*$e.regularGrouping),$t,oe.slice(He-hr*$e.regularGrouping)].join("");else $e.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,He-te),$t,oe.slice(He-te)].join(""),He++});if(He=oe.indexOf(ze),$e.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+He+1),$t,oe.slice(te+He+1)].join("")}),He=oe.indexOf(ze),($e.picture.indexOf(ze)===-1||He===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Ut<"u"){var pr=en(Ut,0);Yt=$e.minimumExponentSize-pr.length,Yt>0&&(pr=new Array(Yt+1).join(it)+pr),oe=oe+p["exponent-separator"]+(Ut<0?je:"")+pr}return oe=$e.prefix+oe+$e.suffix,oe}}function b(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function P(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function $(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function C(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function K(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ye(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function we(){return Math.random()}function J(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=J(n[0]);else if(n.length>1){var l=n.filter(function(g){return J(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):k(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!A(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function Q(n){if(!(typeof n>"u"))return!J(n)}function he(n,o,l,g){var p=[o],x=me(n);return x>=2&&p.push(l),x>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}}async function Le(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);J(M)&&l.push(p)}return l}}async function st(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var x=n[p],M=!0;if(typeof o<"u"){var q=he(o,x,p,n),X=await o.apply(this,q);M=J(X)}if(M)if(!l)g=x,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function We(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(x){return Array.isArray(x)?x.length:0})),g=0;g<l;g++){var p=o.map(x=>x[g]);n.push(p)}return n}async function Ue(n,o,l){if(!(typeof n>"u")){var g,p=me(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var x;for(typeof l>"u"&&n.length>0?(g=n[0],x=1):(g=l,x=0);x<n.length;){var M=[g,n[x]];p>=3&&M.push(x),p>=4&&M.push(n),g=await o.apply(this,M),x++}return g}}function qe(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=qe(g);p.forEach(function(x){l[x]=!0})}),o=qe(l)}else n!==null&&typeof n=="object"&&!A(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function vt(n,o){var l;if(Array.isArray(n)){l=S();for(var g=0;g<n.length;g++){var p=vt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(x=>l.push(x)):l.push(p))}}else n!==null&&typeof n=="object"&&!A(n)&&(l=n[o]);return l}function _t(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=S(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function fr(n){return!(typeof n>"u")}function Et(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=_t(o,Et(p))});else if(n!==null&&typeof n=="object"&&!I(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function dr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Ht(n,o){var l=S();for(var g in n){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}function ot(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Ft(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function pt(n){if(n!==void 0)return n===null?"null":k(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":A(n)?"function":"object"}async function Ce(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!R(n)&&!_(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(M,q){return M>q}}else l=o;var g=async function(M,q){var X=async function(pe,Pe,Se){Pe.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Pe):await l(Pe[0],Se[0])?(pe.push(Se[0]),await X(pe,Pe,Se.slice(1))):(pe.push(Pe[0]),await X(pe,Pe.slice(1),Se))},Oe=[];return await X(Oe,M,q),Oe},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var q=Math.floor(M.length/2),X=M.slice(0,q),Oe=M.slice(q);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},x=await p(n);return x}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=w(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,x=0;x<o.length;x++)if(ge(g,o[x])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);J(M)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:E,average:B,string:V,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Me,trim:Qe,pad:_e,match:ae,contains:et,replace:Fe,split:Ee,join:v,formatNumber:T,formatBase:b,number:P,floor:j,ceil:C,round:F,abs:$,sqrt:K,power:ye,random:we,boolean:J,not:Q,map:G,zip:We,filter:Le,single:st,foldLeft:Ue,sift:y,keys:qe,lookup:vt,append:_t,exists:fr,spread:Et,merge:Z,reverse:dr,each:Ht,error:ot,assert:Ft,type:pt,sort:Ce,shuffle:u,distinct:h,base64encode:at,base64decode:d,encodeUrlComponent:m,encodeUrl:W,decodeUrlComponent:le,decodeUrl:De}})();a.exports=f}).call(this)}).call(this,typeof cn<"u"?cn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,a,s){var i=t("./datetime"),c=t("./functions"),f=t("./utils"),k=t("./parser"),_=t("./signature"),R=(function(){var S=f.isNumeric,w=f.isArrayOfStrings,A=f.isArrayOfNumbers,I=f.createSequence,se=f.isSequence,me=f.isFunction,ge=f.isLambda,H=f.isIterable,N=f.isPromise,ne=f.getFunctionArity,L=f.isDeepEqual,E=ot(null);async function B(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await V(u,h,y);break;case"binary":n=await Me(u,h,y);break;case"unary":n=await Qe(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=et(u,h);break;case"descendant":n=Fe(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await C(u,h,y);break;case"bind":n=await $(u,h,y);break;case"regex":n=F(u);break;case"function":n=await he(u,h,y);break;case"variable":n=K(u,h,y);break;case"lambda":n=st(u,h,y);break;case"partial":n=await We(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=we(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await T(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&se(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function V(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=I(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var x=u.steps[p];if(x.tuple&&(l=!0),p===0&&x.consarray?o=await B(x,n,y):l?g=await Ae(x,n,g,y):o=await xe(x,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof x.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=I(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=I(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await T(u.group,l?g:o,y)),o}function de(u,h){var y=ot(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ye(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=I();for(var l=0;l<h.length;l++){var g=await B(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var x=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?x=o[0]:o.forEach(function(M){!Array.isArray(M)||M.cons?x.push(M):M.forEach(q=>x.push(q))}),x}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ye(u,y,n);else{var l=await ye(u,h,n);o=I(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=I(),o.tupleStream=!0;var x=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var M=0;M<y.length;M++){x=de(n,y[M]);var q=await B(u,y[M]["@"],x);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[M]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[M]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[M]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=I();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=I(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=de(y,l));var x=await B(u,g,p);S(x)&&(x=[x]),A(x)?x.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(x)&&n.push(l)}return n}async function Me(u,h,y){var n,o=await B(u.lhs,h,y),l=u.value,g=async()=>await B(u.rhs,h,y);if(l==="and"||l==="or")try{return await De(o,g,l)}catch(x){throw x.position=u.position,x.token=l,x}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=W(o,p,l);break;case"&":n=v(o,p);break;case"..":n=P(o,p);break;case"in":n=le(o,p);break}}catch(x){throw x.position=u.position,x.token=l,x}return n}async function Qe(u,h,y){var n;switch(u.value){case"-":if(n=await B(u.expression,h,y),typeof n>"u")n=void 0;else if(S(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,x)=>(y.isParallelCall=x>0,[p,await B(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await T(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function et(u,h){var y=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ae(o),y=c.append(y,o)):y.push(o)}),y}function ae(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ae(y,h)}):h.push(u),h}function Fe(u,h){var y,n=I();return typeof h<"u"&&(at(h,n),n.length===1?y=n[0]:y=n),y}function at(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){at(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){at(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!S(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!S(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function W(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function le(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function De(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function v(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function T(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],x=l?de(y,p):y,M=0;M<u.lhs.length;M++){var q=u.lhs[M],X=await B(q[0],l?p["@"]:p,x);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:M};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}let pe=await Promise.all(Object.keys(o).map(async(Se,Ze)=>{let ke=o[Se];var je=ke.data,it=y;if(l){var ze=b(ke.data);je=ze["@"],delete ze["@"],it=de(y,ze)}return y.isParallelCall=Ze>0,[Se,await B(u.lhs[ke.exprIndex][1],je,it)]}));for(let Se of pe){var[X,Pe]=await Se;typeof Pe<"u"&&(n[X]=Pe)}return n}function b(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function P(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function $(u,h,y){var n=await B(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await B(u.condition,h,y);return c.boolean(o)?n=await B(u.then,h,y):typeof u.else<"u"&&(n=await B(u.else,h,y)),n}async function C(u,h,y){for(var n,o=ot(y),l=0;l<u.expressions.length;l++)n=await B(u.expressions[l],h,o);return n}function F(u){var h=new Ce.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var x=y(n,h.lastIndex);if(x&&x.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return x}}}return l};return y}function K(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ye(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(x,M){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var Oe=u.terms[X],pe=x,Pe=y;l&&(pe=x["@"],Pe=de(y,x));var Se=await B(Oe.expression,pe,Pe);pe=M,Pe=y,l&&(pe=M["@"],Pe=de(y,M));var Ze=await B(Oe.expression,pe,Pe),ke=typeof Se,je=typeof Ze;if(ke==="undefined"){q=je==="undefined"?0:1;continue}if(je==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?Ze:Se};if(ke!==je)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:Ze};Se!==Ze&&(Se<Ze?q=-1:q=1,Oe.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function we(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!me(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await B(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var x=0;x<p.length;x++){var M=p[x];if(M&&(M.isPrototypeOf(g)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await B(u.update,M,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var Oe in q)M[Oe]=q[Oe]}if(typeof u.delete<"u"){var pe=await B(u.delete,M,y);if(typeof pe<"u"){var Pe=pe;if(Array.isArray(pe)||(pe=[pe]),!w(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Pe};for(var Se=0;Se<pe.length;Se++)typeof M=="object"&&M!==null&&delete M[pe[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var J=k("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await B(u.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await B(u.rhs,h,y);if(!me(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(me(o)){var g=await B(J,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function he(u,h,y,n){var o,l=await B(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const M=await B(u.arguments[p],h,y);if(me(M)){const q=async function(...X){return await G(M,X,null,y)};q.arity=ne(M),g.push(q)}else g.push(M)}var x=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=x,l.position=u.position),o=await G(l,g,h,y)}catch(M){throw M.position||(M.position=u.position),M.token||(M.token=x),M}return o}async function G(u,h,y,n){var o;for(o=await Le(u,h,y,n);ge(o)&&o.thunk===!0;){var l=await B(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await B(o.body.arguments[p],o.input,o.environment));o=await Le(l,g,y,n)}return o}async function Le(u,h,y,n){var o;try{var l=h;if(u&&(l=Ue(u.signature,h,y)),ge(u))o=await qe(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),N(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),N(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function st(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function We(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await B(g,h,y))}var p=await B(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(ge(p))n=vt(p,o);else if(p&&p._jsonata_function===!0)n=_t(p.implementation,o);else if(typeof p=="function")n=_t(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function Ue(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function qe(u,h){var y,n=ot(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await fr(u.body,n):y=await B(u.body,u.input,n),y}function vt(u,h){var y=ot(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function _t(u,h){var y=Et(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=k(n);o.body=u;var l=vt(o,h);return l}async function fr(u,h){var y=Et(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return N(l)&&(l=await l),l}function Et(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=_(h)),y}async function dr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=I(y),y.outerWrapper=!0));try{var n=k(u,!1)}catch(l){throw pt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await B(n,y,this.environment)}catch(l){throw pt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Ht(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ot(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}E.bind("sum",Z(c.sum,"<a<n>:n>")),E.bind("count",Z(c.count,"<a:n>")),E.bind("max",Z(c.max,"<a<n>:n>")),E.bind("min",Z(c.min,"<a<n>:n>")),E.bind("average",Z(c.average,"<a<n>:n>")),E.bind("string",Z(c.string,"<x-b?:s>")),E.bind("substring",Z(c.substring,"<s-nn?:s>")),E.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),E.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),E.bind("lowercase",Z(c.lowercase,"<s-:s>")),E.bind("uppercase",Z(c.uppercase,"<s-:s>")),E.bind("length",Z(c.length,"<s-:n>")),E.bind("trim",Z(c.trim,"<s-:s>")),E.bind("pad",Z(c.pad,"<s-ns?:s>")),E.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),E.bind("contains",Z(c.contains,"<s-(sf):b>")),E.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),E.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),E.bind("join",Z(c.join,"<a<s>s?:s>")),E.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),E.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),E.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),E.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),E.bind("number",Z(c.number,"<(nsb)-:n>")),E.bind("floor",Z(c.floor,"<n-:n>")),E.bind("ceil",Z(c.ceil,"<n-:n>")),E.bind("round",Z(c.round,"<n-n?:n>")),E.bind("abs",Z(c.abs,"<n-:n>")),E.bind("sqrt",Z(c.sqrt,"<n-:n>")),E.bind("power",Z(c.power,"<n-n:n>")),E.bind("random",Z(c.random,"<:n>")),E.bind("boolean",Z(c.boolean,"<x-:b>")),E.bind("not",Z(c.not,"<x-:b>")),E.bind("map",Z(c.map,"<af>")),E.bind("zip",Z(c.zip,"<a+>")),E.bind("filter",Z(c.filter,"<af>")),E.bind("single",Z(c.single,"<af?>")),E.bind("reduce",Z(c.foldLeft,"<afj?:j>")),E.bind("sift",Z(c.sift,"<o-f?:o>")),E.bind("keys",Z(c.keys,"<x-:a<s>>")),E.bind("lookup",Z(c.lookup,"<x-s:x>")),E.bind("append",Z(c.append,"<xx:a>")),E.bind("exists",Z(c.exists,"<x:b>")),E.bind("spread",Z(c.spread,"<x-:a<o>>")),E.bind("merge",Z(c.merge,"<a<o>:o>")),E.bind("reverse",Z(c.reverse,"<a:a>")),E.bind("each",Z(c.each,"<o-f:a>")),E.bind("error",Z(c.error,"<s?:x>")),E.bind("assert",Z(c.assert,"<bs?:x>")),E.bind("type",Z(c.type,"<x:s>")),E.bind("sort",Z(c.sort,"<af?:a>")),E.bind("shuffle",Z(c.shuffle,"<a:a>")),E.bind("distinct",Z(c.distinct,"<x:x>")),E.bind("base64encode",Z(c.base64encode,"<s-:s>")),E.bind("base64decode",Z(c.base64decode,"<s-:s>")),E.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),E.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),E.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),E.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),E.bind("eval",Z(dr,"<sx?:x>")),E.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),E.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),E.bind("clone",Z(Ht,"<(oa)-:o>"));var Ft={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function pt(u){var h=Ft[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function Ce(u,h){var y,n;try{y=k(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw pt(g),g}var o=ot(E),l=new Date;return o.bind("now",Z(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",Z(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?Ce.RegexEngine=h.RegexEngine:Ce.RegexEngine=RegExp,{evaluate:async function(g,p,x){if(typeof n<"u"){var M={code:"S0500",position:0};throw pt(M),M}if(typeof p<"u"){var q;q=ot(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!se(g)&&(g=I(g),g.outerWrapper=!0);var Oe;try{return Oe=await B(y,g,q),typeof x=="function"&&x(null,Oe),Oe}catch(pe){throw pt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,x){var M=Z(p,x);o.bind(g,M)},ast:function(){return y},errors:function(){return n}}}return Ce.parser=k,Ce})();a.exports=R},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,a,s){var i=t("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},k={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},_=function(S){var w=0,A=S.length,I=function(ge,H){var N={type:ge,value:H,position:w};return N},se=function(){for(var ge=w,H=0,N,ne,L=function(B){if(S.charAt(B)==="/"&&H===0){for(var V=0;S.charAt(B-(V+1))==="\\";)V++;if(V%2===0)return!0}return!1};w<A;){var E=S.charAt(w);if(L(w)){if(N=S.substring(ge,w),N==="")throw{code:"S0301",stack:new Error().stack,position:w};for(w++,E=S.charAt(w),ge=w;E==="i"||E==="m";)w++,E=S.charAt(w);return ne=S.substring(ge,w)+"g",new RegExp(N,ne)}(E==="("||E==="["||E==="{")&&S.charAt(w-1)!=="\\"&&H++,(E===")"||E==="]"||E==="}")&&S.charAt(w-1)!=="\\"&&H--,w++}throw{code:"S0302",stack:new Error().stack,position:w}},me=function(ge){if(w>=A)return null;for(var H=S.charAt(w);w<A&&`
3
+ \r\v`.indexOf(H)>-1;)w++,H=S.charAt(w);if(H==="/"&&S.charAt(w+1)==="*"){var N=w;for(w+=2,H=S.charAt(w);!(H==="*"&&S.charAt(w+1)==="/");)if(H=S.charAt(++w),w>=A)throw{code:"S0106",stack:new Error().stack,position:N};return w+=2,H=S.charAt(w),me(ge)}if(ge!==!0&&H==="/")return w++,I("regex",se());if(H==="."&&S.charAt(w+1)===".")return w+=2,I("operator","..");if(H===":"&&S.charAt(w+1)==="=")return w+=2,I("operator",":=");if(H==="!"&&S.charAt(w+1)==="=")return w+=2,I("operator","!=");if(H===">"&&S.charAt(w+1)==="=")return w+=2,I("operator",">=");if(H==="<"&&S.charAt(w+1)==="=")return w+=2,I("operator","<=");if(H==="*"&&S.charAt(w+1)==="*")return w+=2,I("operator","**");if(H==="~"&&S.charAt(w+1)===">")return w+=2,I("operator","~>");if(H==="?"&&S.charAt(w+1)===":")return w+=2,I("operator","?:");if(H==="?"&&S.charAt(w+1)==="?")return w+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return w++,I("operator",H);if(H==='"'||H==="'"){var ne=H;w++;for(var L="";w<A;){if(H=S.charAt(w),H==="\\")if(w++,H=S.charAt(w),Object.prototype.hasOwnProperty.call(k,H))L+=k[H];else if(H==="u"){var E=S.substr(w+1,4);if(/^[0-9a-fA-F]+$/.test(E)){var B=parseInt(E,16);L+=String.fromCharCode(B),w+=4}else throw{code:"S0104",stack:new Error().stack,position:w}}else throw{code:"S0103",stack:new Error().stack,position:w,token:H};else{if(H===ne)return w++,I("string",L);L+=H}w++}throw{code:"S0101",stack:new Error().stack,position:w}}var V=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,de=V.exec(S.substring(w));if(de!==null){var xe=parseFloat(de[0]);if(!isNaN(xe)&&isFinite(xe))return w+=de[0].length,I("number",xe);throw{code:"S0102",stack:new Error().stack,position:w,token:de[0]}}var Te;if(H==="`"){w++;var Ae=S.indexOf("`",w);if(Ae!==-1)return Te=S.substring(w,Ae),w=Ae+1,I("name",Te);throw w=A,{code:"S0105",stack:new Error().stack,position:w}}for(var ve=w,Me;;)if(Me=S.charAt(ve),ve===A||`
4
+ \r\v`.indexOf(Me)>-1||Object.prototype.hasOwnProperty.call(f,Me)){if(S.charAt(w)==="$")return Te=S.substring(w+1,ve),w=ve,I("variable",Te);switch(Te=S.substring(w,ve),w=ve,Te){case"or":case"in":case"and":return I("operator",Te);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return w===A&&Te===""?null:I("name",Te)}}else ve++};return me},R=function(S,w){var A,I,se={},me=[],ge=function(){var d=[];A.id!=="(end)"&&d.push({type:A.type,value:A.value,position:A.position});for(var m=I();m!==null;)d.push(m),m=I();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(w)return d.remaining=ge(),d.type="error",me.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var W=se[d];return m=m||0,W?m>=W.lbp&&(W.lbp=m):(W=Object.create(H),W.id=W.value=d,W.lbp=m,se[d]=W),W},ne=function(d){if(w){d.remaining=ge(),me.push(d);var m=se["(error)"];return A=Object.create(m),A.error=d,A.type="(error)",A}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&A.id!==d){var W;A.id==="(end)"?W="S0203":W="S0202";var le={code:W,position:A.position,token:A.value,value:d};return ne(le)}var De=I(m);if(De===null)return A=se["(end)"],A.position=S.length,A;var Ee=De.value,v=De.type,T;switch(v){case"name":case"variable":T=se["(name)"];break;case"operator":if(T=se[Ee],!T)return ne({code:"S0204",stack:new Error().stack,position:De.position,token:Ee});break;case"string":case"number":case"value":T=se["(literal)"];break;case"regex":v="regex",T=se["(regex)"];break;default:return ne({code:"S0205",stack:new Error().stack,position:De.position,token:Ee})}return A=Object.create(T),A.value=Ee,A.type=v,A.position=De.position,A},E=function(d){var m,W=A;for(L(null,!0),m=W.nud();d<A.lbp;)W=A,L(),m=W.led(m);return m},B=function(d){var m=N(d,0);m.nud=function(){return this}},V=function(d,m,W){var le=m||f[d],De=N(d,le);return De.led=W||function(Ee){return this.lhs=Ee,this.rhs=E(le),this.type="binary",this},De},de=function(d,m,W){var le=N(d,m);return le.led=W,le},xe=function(d,m){var W=N(d);return W.nud=m||function(){return this.expression=E(70),this.type="unary",this},W};B("(end)"),B("(name)"),B("(literal)"),B("(regex)"),N(":"),N(";"),N(","),N(")"),N("]"),N("}"),N(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),B("and"),B("or"),B("in"),xe("-"),V("~>"),V("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=E(0),this}),de("(error)",10,function(d){return this.lhs=d,this.error=A.error,this.remaining=ge(),this.type="error",this}),xe("*",function(){return this.type="wildcard",this}),xe("**",function(){return this.type="descendant",this}),xe("%",function(){return this.type="parent",this}),V("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],A.id!==")")for(;A.type==="operator"&&A.id==="?"?(this.type="partial",this.arguments.push(A),L("?")):this.arguments.push(E(0)),A.id===",";)L(",");if(L(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,v){if(Ee.type!=="variable")return ne({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:v+1})}),this.type="lambda",A.id==="<"){for(var m=A.position,W=1,le="<";W>0&&A.id!=="{"&&A.id!=="(end)";){var De=L();De.id===">"?W--:De.id==="<"&&W++,le+=De.value}L(">");try{this.signature=i(le)}catch(Ee){return Ee.position=m+Ee.offset,ne(Ee)}}L("{"),this.body=E(0),L("}")}return this}),xe("(",function(){for(var d=[];A.id!==")"&&(d.push(E(0)),A.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(A.id!=="]")for(;;){var m=E(0);if(A.id===".."){var W={type:"binary",value:"..",position:A.position,lhs:m};L(".."),W.rhs=E(0),m=W}if(d.push(m),A.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),V("[",f["["],function(d){if(A.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,L("]"),d}else return this.lhs=d,this.rhs=E(f["]"]),this.type="binary",L("]",!0),this}),V("^",f["^"],function(d){L("(");for(var m=[];;){var W={descending:!1};if(A.id==="<"?L("<"):A.id===">"&&(W.descending=!0,L(">")),W.expression=E(0),m.push(W),A.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(A.id!=="}")for(;;){var W=E(0);L(":");var le=E(0);if(m.push([W,le]),A.id!==",")break;L(",")}return L("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Te),V("{",f["{"],Te),de(":=",f[":="],function(d){return d.type!=="variable"?ne({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=E(f[":="]-1),this.type="binary",this)}),V("@",f["@"],function(d){return this.lhs=d,this.rhs=E(f["@"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),V("#",f["#"],function(d){return this.lhs=d,this.rhs=E(f["#"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),V("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=E(0),A.id===":"&&(L(":"),this.else=E(0)),this}),V("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=E(0),this}),xe("|",function(){return this.type="transform",this.pattern=E(0),L("|"),this.update=E(0),A.id===","&&(L(","),this.delete=E(0)),L("|"),this});var Ae=function(d){var m;if(d.type==="function"&&!d.predicate){var W={type:"lambda",thunk:!0,arguments:[],position:d.position};W.body=d,m=W}else if(d.type==="condition")d.then=Ae(d.then),typeof d.else<"u"&&(d.else=Ae(d.else)),m=d;else if(d.type==="block"){var le=d.expressions.length;le>0&&(d.expressions[le-1]=Ae(d.expressions[le-1])),m=d}else m=d;return m},ve=0,Me=0,Qe=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(Qe[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var W=d.steps.length-1;for(m=_e(d.steps[W--],m);m.level>0&&W>=0;)m=_e(d.steps[W--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},ue=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var W=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&W.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=W:Array.prototype.push.apply(d.seekingParent,W)}},et=function(d){var m=d.steps.length-1,W=d.steps[m],le=typeof W.seekingParent<"u"?W.seekingParent:[];W.type==="parent"&&le.push(W.slot);for(var De=0;De<le.length;De++){var Ee=le[De];for(m=d.steps.length-2;Ee.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[Ee]:d.seekingParent.push(Ee);break}for(var v=d.steps[m--];m>=0&&v.focus&&d.steps[m].focus;)v=d.steps[m--];Ee=_e(v,Ee)}}},ae=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var W=ae(d.lhs);W.type==="path"?m=W:m={type:"path",steps:[W]},W.type==="parent"&&(m.seekingParent=[W.slot]);var le=ae(d.rhs);le.type==="function"&&le.procedure.type==="path"&&le.procedure.steps.length===1&&le.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=le.procedure.steps[0].value),le.type==="path"?Array.prototype.push.apply(m.steps,le.steps):(typeof le.predicate<"u"&&(le.stages=le.predicate,delete le.predicate),m.steps.push(le)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var De=m.steps[0];De.type==="unary"&&De.value==="["&&(De.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),et(m);break;case"[":m=ae(d.lhs);var v=m,T="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],T="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[T]>"u"&&(v[T]=[]);var b=ae(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?_e(v,F):F.level--}),ue(v,b)),v[T].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ae(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ae(F[0]),ae(F[1])]}),position:d.position};break;case"^":m=ae(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var P={type:"sort",position:d.position};P.terms=d.rhs.map(function(F){var K=ae(F.expression);return ue(P,K),{descending:F.descending,expression:K}}),m.steps.push(P),et(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.rhs);break;case"@":if(m=ae(d.lhs),v=m,m.type==="path"&&(v=m.steps[m.steps.length-1]),typeof v.stages<"u"||typeof v.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(v.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(v.keepArray=!0),v.focus=d.rhs.value,v.tuple=!0;break;case"#":m=ae(d.lhs),v=m,m.type==="path"?v=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof v.predicate<"u"&&(v.stages=v.predicate,delete v.predicate)),typeof v.stages>"u"?v.index=d.rhs.value:v.stages.push({type:"index",value:d.rhs.value,position:d.position}),v.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.lhs),ue(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var K=ae(F);return ue(m,K),K}):d.value==="{"?m.lhs=d.lhs.map(function(F){var K=ae(F[0]);ue(m,K);var ye=ae(F[1]);return ue(m,ye),[K,ye]}):(m.expression=ae(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):ue(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var K=ae(F);return ue(m,K),K}),m.procedure=ae(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var $=ae(d.body);m.body=Ae($);break;case"condition":m={type:d.type,position:d.position},m.condition=ae(d.condition),ue(m,m.condition),m.then=ae(d.then),ue(m,m.then),typeof d.else<"u"&&(m.else=ae(d.else),ue(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ae(d.pattern),m.update=ae(d.update),typeof d.delete<"u"&&(m.delete=ae(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var K=ae(F);return ue(m,K),(K.consarray||K.type==="path"&&K.steps[0].consarray)&&(m.consarray=!0),K});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ve++,level:1,index:Me++}},Qe.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ae(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ae(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var C={code:j,position:d.position,token:d.value};if(w)return me.push(C),{type:"error",error:C};throw C.stack=new Error().stack,C}return d.keepArray&&(m.keepArray=!0),m};I=_(S),L();var Fe=E(0);if(A.id!=="(end)"){var at={code:"S0201",position:A.position,token:A.value};ne(at)}if(Fe=ae(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return me.length>0&&(Fe.errors=me),Fe};return R})();a.exports=c},{"./signature":5}],5:[function(t,a,s){var i=t("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function k(_){for(var R=1,S=[],w={},A=w;R<_.length;){var I=_.charAt(R);if(I===":")break;var se=function(){S.push(w),A=w,w={}},me=function(V,de,xe,Te){for(var Ae=1,ve=de;ve<V.length;)if(ve++,I=V.charAt(ve),I===Te){if(Ae--,Ae===0)break}else I===xe&&Ae++;return ve};switch(I){case"s":case"n":case"b":case"l":case"o":w.regex="["+I+"m]",w.type=I,se();break;case"a":w.regex="[asnblfom]",w.type=I,w.array=!0,se();break;case"f":w.regex="f",w.type=I,se();break;case"j":w.regex="[asnblom]",w.type=I,se();break;case"x":w.regex="[asnblfom]",w.type=I,se();break;case"-":A.context=!0,A.contextRegex=new RegExp(A.regex),A.regex+="?";break;case"?":case"+":A.regex+=I;break;case"(":var ge=me(_,R,"(",")"),H=_.substring(R+1,ge);if(H.indexOf("<")===-1)w.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:R};w.type="("+H+")",R=ge,se();break;case"<":if(A.type==="a"||A.type==="f"){var N=me(_,R,"<",">");A.subtype=_.substring(R+1,N),R=N}else throw{code:"S0401",stack:new Error().stack,value:A.type,offset:R};break}R++}var ne="^"+S.map(function(V){return"("+V.regex+")"}).join("")+"$",L=new RegExp(ne),E=function(V){var de;if(i.isFunction(V))de="f";else{var xe=typeof V;switch(xe){case"string":de="s";break;case"number":de="n";break;case"boolean":de="b";break;case"object":V===null?de="l":Array.isArray(V)?de="a":de="o";break;case"undefined":default:de="m"}}return de},B=function(V,de){for(var xe="^",Te=0,Ae=0;Ae<S.length;Ae++){xe+=S[Ae].regex;var ve=de.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:V[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:V[Te],index:Te+1}};return{definition:_,validate:function(V,de){var xe="";V.forEach(function(Me){xe+=E(Me)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Me,Qe){var _e=V[ve],ue=Te[Qe+1];if(ue==="")if(Me.context&&Me.contextRegex){var et=E(de);if(Me.contextRegex.test(et))Ae.push(de);else throw{code:"T0411",stack:new Error().stack,value:de,index:ve+1}}else Ae.push(_e),ve++;else ue.split("").forEach(function(ae){if(Me.type==="a"){if(ae==="m")_e=void 0;else{_e=V[ve];var Fe=!0;if(typeof Me.subtype<"u"){if(ae!=="a"&&ue!==Me.subtype)Fe=!1;else if(ae==="a"&&_e.length>0){var at=E(_e[0]);if(at!==Me.subtype.charAt(0))Fe=!1;else{var d=_e.filter(function(m){return E(m)!==at});Fe=d.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Me.subtype]};ae!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}B(V,xe)}}}return k})();a.exports=c},{"./utils":6}],6:[function(t,a,s){const i=(()=>{function c(N){var ne=!1;if(typeof N=="number"&&(ne=!isNaN(N),ne&&!isFinite(N)))throw{code:"D1001",value:N,stack:new Error().stack};return ne}function f(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return typeof L!="string"}).length===0),ne}function k(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return!c(L)}).length===0),ne}function _(){var N=[];return N.sequence=!0,arguments.length===1&&N.push(arguments[0]),N}function R(N){return N.sequence===!0&&Array.isArray(N)}function S(N){return N&&(N._jsonata_function===!0||N._jsonata_lambda===!0)||typeof N=="function"}function w(N){var ne=typeof N.arity=="number"?N.arity:typeof N.implementation=="function"?N.implementation.length:typeof N.length=="number"?N.length:N.arguments.length;return ne}function A(N){return N&&N._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function se(N){return typeof N=="object"&&N!==null&&I in N&&"next"in N&&typeof N.next=="function"}function me(N,ne){if(N===ne)return!0;if(typeof N=="object"&&typeof ne=="object"&&N!==null&&ne!==null){if(Array.isArray(N)&&Array.isArray(ne)){if(N.length!==ne.length)return!1;for(var L=0;L<N.length;L++)if(!me(N[L],ne[L]))return!1;return!0}var E=Object.getOwnPropertyNames(N),B=Object.getOwnPropertyNames(ne);if(E.length!==B.length)return!1;for(E=E.sort(),B=B.sort(),L=0;L<E.length;L++)if(E[L]!==B[L])return!1;for(L=0;L<E.length;L++){var V=E[L];if(!me(N[V],ne[V]))return!1}return!0}return!1}function ge(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function H(N){var ne=[];for(let L of N)ne.push(L);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:k,createSequence:_,isSequence:R,isFunction:S,isLambda:A,isIterable:se,getFunctionArity:w,isDeepEqual:me,stringToArray:H,isPromise:ge}})();a.exports=i},{}]},{},[3])(3)})})(Dr)),Dr.exports}var js=Is();const Fs=Rs(js),Qr=O.object({name:O.literal("data-extract"),code:O.string(),inputData:O.any().optional()});function $s(r){return Qr.parse(r)}async function Us(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Fs(r.code).evaluate(r.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:t}}catch(e){return console.error("[DataExtractBlock] Data extraction error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in data extraction",data:void 0}}}const Bs={"get-text":Ur,"attribute-value":Br,"get-value-form":Lr,"set-value-form":Zr,"clear-value-form":zr,"element-exists":Vr,"event-click":Wr,keypress:qr,wait:Hr,"wait-for-condition":Gr,"save-assets":Yr,"get-element-data":Jr,scroll:Kr,"ai-parse-data":$r,"fetch-api":Xr,"data-extract":Qr};class Ls{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=qa(e);return await Ha(t)}case"attribute-value":{const t=Ya(e);return await Ja(t)}case"get-value-form":{const t=Ka(e);return await Xa(t)}case"set-value-form":{const t=es(e);return await ts(t)}case"clear-value-form":{const t=ns(e);return await as(t)}case"element-exists":{const t=is(e);return await os(t)}case"event-click":{const t=cs(e);return await us(t)}case"keypress":{const t=hs(e);return await ps(t)}case"wait":{const t=ys(e);return await gs(t)}case"wait-for-condition":{const t=vs(e);return await bs(t)}case"save-assets":{const t=ws(e);return await ks(t)}case"get-element-data":{const t=_s(e);return await Es(t)}case"scroll":{const t=As(e);return await Ss(t)}case"ai-parse-data":{const t=Ia(e);return await ja(t)}case"fetch-api":{const t=Ns(e);return await Ms(t)}case"data-extract":{const t=$s(e);return await Us(t)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(t){return{hasError:!0,message:t instanceof Error?t.message:"Unknown error in block execution",data:null}}}}class Zs{constructor(){fe(this,"expr");fe(this,"json")}}class zs{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class Vs{constructor(){fe(this,"id");fe(this,"title");fe(this,"when");fe(this,"block");fe(this,"repeat");fe(this,"next");fe(this,"onSuccess");fe(this,"onFailure");fe(this,"switch");fe(this,"timeoutMs");fe(this,"retry");fe(this,"delayAfterMs")}}class Ws{constructor(){fe(this,"version");fe(this,"id");fe(this,"title");fe(this,"description");fe(this,"start");fe(this,"steps");fe(this,"vars");fe(this,"defaultDelayMs")}}class qs{constructor(){fe(this,"stepId");fe(this,"skipped");fe(this,"success");fe(this,"message");fe(this,"result");fe(this,"startedAt");fe(this,"finishedAt");fe(this,"attempts")}}class Hs{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}exports.AiParseDataBlockSchema=$r;exports.AllBlockSchemas=Bs;exports.BaseBlockSchema=dt;exports.Binding=zs;exports.BlockHandler=Ls;exports.ClearValueFormsBlockSchema=zr;exports.CollectWorkflowResult=Hs;exports.Condition=Zs;exports.DataExtractBlockSchema=Qr;exports.EightGClient=Tn;exports.EightGError=At;exports.ElementExistsBlockSchema=Vr;exports.EventClickBlockSchema=Wr;exports.FetchApiBlockSchema=Xr;exports.GetAttributeValueBlockSchema=Br;exports.GetElementDataBlockSchema=Jr;exports.GetTextBlockSchema=Ur;exports.GetValueFormsBlockSchema=Lr;exports.KeypressBlockSchema=qr;exports.SaveAssetsBlockSchema=Yr;exports.Schema=Ua;exports.ScrollBlockSchema=Kr;exports.SetValueFormsBlockSchema=Zr;exports.WaitBlockSchema=Hr;exports.WaitForConditionBlockSchema=Gr;exports.Workflow=Ws;exports.WorkflowStep=Vs;exports.WorkflowStepRunResult=qs;exports.createArraySchema=$a;exports.createSchema=Fa;