scordi-extension 1.14.4 → 1.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/index.cjs +4 -0
- package/dist/blocks/index.js +7839 -0
- package/dist/sdk/index.cjs +1 -0
- package/dist/sdk/index.js +605 -587
- package/package.json +5 -5
- package/dist/.vite/manifest.json +0 -67
- package/dist/assets/DataExtractBlock-B7AuVonx.js +0 -6
- package/dist/assets/index-B9PKMhAi.js +0 -6
- package/dist/assets/index-BAWpTgrx.js +0 -4
- package/dist/assets/index-CMlx_xZE.css +0 -1
- package/dist/assets/index-CZjAbH8z.js +0 -1
- package/dist/assets/index-DkFIvNAm.css +0 -1
- package/dist/assets/index-r5QRyJ4m.js +0 -1
- package/dist/assets/index.html-BIbPySIb.js +0 -74
- package/dist/assets/index.html-cr-_Qdxq.js +0 -49
- package/dist/assets/index.ts-BqxJYCmp.js +0 -160
- package/dist/assets/index.ts-Yg98L0Rk.js +0 -158
- package/dist/assets/internal-messages-Drf0Gb9U.js +0 -1
- package/dist/assets/loading-page-1924caaa.js +0 -51
- package/dist/assets/main.tsx-BEyI95mZ.js +0 -2
- package/dist/assets/main.tsx-BKzdlur-.js +0 -2
- package/dist/assets/main.tsx-CiPjkJNz.js +0 -2
- package/dist/assets/main.tsx-loader-BYP9L25W.js +0 -13
- package/dist/assets/main.tsx-loader-CRGmwXNh.js +0 -13
- package/dist/assets/main.tsx-loader-FYb0LhDu.js +0 -13
- package/dist/assets/schemas-C8r0jYHO.js +0 -21
- package/dist/assets/types-oHwqLVs0.js +0 -1
- package/dist/manifest.json +0 -58
- package/dist/public/logo.png +0 -0
- package/dist/service-worker-loader.js +0 -1
- package/dist/src/blocks/AiParseDataBlock.ts.js +0 -101
- package/dist/src/blocks/ClearValueFormBlock.ts.js +0 -55
- package/dist/src/blocks/DataExtractBlock.ts.js +0 -28
- package/dist/src/blocks/ElementExistsBlock.ts.js +0 -26
- package/dist/src/blocks/EventClickBlock.ts.js +0 -143
- package/dist/src/blocks/FetchApiBlock.ts.js +0 -50
- package/dist/src/blocks/GetAttributeValueBlock.ts.js +0 -33
- package/dist/src/blocks/GetElementDataBlock.ts.js +0 -114
- package/dist/src/blocks/GetTextBlock.ts.js +0 -152
- package/dist/src/blocks/GetValueFormBlock.ts.js +0 -52
- package/dist/src/blocks/KeypressBlock.ts.js +0 -89
- package/dist/src/blocks/SaveAssetsBlock.ts.js +0 -35
- package/dist/src/blocks/ScrollBlock.ts.js +0 -111
- package/dist/src/blocks/SetValueFormBlock.ts.js +0 -56
- package/dist/src/blocks/WaitBlock.ts.js +0 -24
- package/dist/src/blocks/index.ts.js +0 -163
- package/dist/src/blocks/types.ts.js +0 -11
- package/dist/src/content/elements/finders/CssSelector.ts.js +0 -51
- package/dist/src/content/elements/finders/ElementSelector.ts.js +0 -20
- package/dist/src/content/elements/finders/IframeSelector.ts.js +0 -32
- package/dist/src/content/elements/finders/ShadowDOMSelector.ts.js +0 -38
- package/dist/src/content/elements/finders/XPathFinder.ts.js +0 -32
- package/dist/src/content/elements/index.ts.js +0 -26
- package/dist/src/content/elements/utils/CSSSelectorGenerator.ts.js +0 -72
- package/dist/src/content/elements/utils/XPathGenerator.ts.js +0 -62
- package/dist/src/content/handler/ExternalMessageHandler.ts.js +0 -78
- package/dist/src/content/handler/InternalMessageHandler.ts.js +0 -18
- package/dist/src/content/kernel/MessageKernel.ts.js +0 -83
- package/dist/src/content/main.tsx-loader.js +0 -22
- package/dist/src/content/main.tsx.js +0 -13
- package/dist/src/content/utils/index.ts.js +0 -1
- package/dist/src/content/utils/synchronizedLock.ts.js +0 -35
- package/dist/src/popup/index.html +0 -11
- package/dist/src/types/internal-messages.ts.js +0 -15
- package/dist/vendor/.vite-deps-chunk-PR4QN5HX.js__v--57e88532.js +0 -42
- package/dist/vendor/.vite-deps-chunk-PR4QN5HX.js__v--ba9031c0.js +0 -42
- package/dist/vendor/.vite-deps-chunk-VBBIEGWT.js__v--57e88532.js +0 -4156
- package/dist/vendor/.vite-deps-jsonata.js__v--5da6ca24.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--ba9031c0.js +0 -5761
- package/dist/vendor/.vite-deps-zod.js__v--13965f26.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--ba9031c0.js +0 -12651
- package/dist/vendor/crx-client-port.js +0 -66
- package/dist/vendor/crx-client-preamble.js +0 -4
- package/dist/vendor/react-refresh.js +0 -670
- package/dist/vendor/vite-client.js +0 -1098
- package/dist/vendor/vite-dist-client-env.mjs.js +0 -19
- package/dist/vendor/webcomponents-custom-elements.js +0 -47
- /package/dist/{logo.png → blocks/logo.png} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ye;(function(r){r.assertEqual=i=>{};function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const c of i)s[c]=c;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),c={};for(const f of s)c[f]=i[f];return r.objectValues(c)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const c in i)Object.prototype.hasOwnProperty.call(i,c)&&s.push(c);return s},r.find=(i,s)=>{for(const c of i)if(s(c))return c},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,s=" | "){return i.map(c=>typeof c=="string"?`'${c}'`:c).join(s)}r.joinValues=a,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(ye||(ye={}));var Or;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Or||(Or={}));const z=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 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}},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"]),bn=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=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(s){return s.message},a={_errors:[]},i=s=>{for(const c of s.issues)if(c.code==="invalid_union")c.unionErrors.map(i);else if(c.code==="invalid_return_type")i(c.returnTypeError);else if(c.code==="invalid_arguments")i(c.argumentsError);else if(c.path.length===0)a._errors.push(t(c));else{let f=a,w=0;for(;w<c.path.length;){const _=c.path[w];w===c.path.length-1?(f[_]=f[_]||{_errors:[]},f[_]._errors.push(t(c))):f[_]=f[_]||{_errors:[]},f=f[_],w++}}};return i(this),a}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=t=>t.message){const t={},a=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];t[s]=t[s]||[],t[s].push(e(i))}else a.push(e(i));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}rt.create=r=>new rt(r);const Lt=(r,e)=>{let t;switch(r.code){case O.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ye.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${ye.joinValues(r.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ye.joinValues(r.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${ye.joinValues(r.options)}, received '${r.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.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}"`:ye.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case O.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 O.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 O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,ye.assertNever(r)}return{message:t}};let on=Lt;function wn(r){on=r}function yr(){return on}const gr=r=>{const{data:e,path:t,errorMaps:a,issueData:i}=r,s=[...t,...i.path||[]],c={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let f="";const w=a.filter(_=>!!_).slice().reverse();for(const _ of w)f=_(c,{data:e,defaultError:f}).message;return{...i,path:s,message:f}},kn=[];function B(r,e){const t=yr(),a=gr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Lt?void 0:Lt].filter(i=>!!i)});r.common.issues.push(a)}class Ge{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 i of t){if(i.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),a.push(i.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const i of t){const s=await i.key,c=await i.value;a.push({key:s,value:c})}return Ge.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const i of t){const{key:s,value:c}=i;if(s.status==="aborted"||c.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof c.value<"u"||i.alwaysSet)&&(a[s.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Ut=r=>({status:"dirty",value:r}),Ye=r=>({status:"valid",value:r}),Cr=r=>r.status==="aborted",Pr=r=>r.status==="dirty",Nt=r=>r.status==="valid",Yt=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 mt{constructor(e,t,a,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=i}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 en=(r,e)=>{if(Nt(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 rt(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:i}=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:i}:{errorMap:(c,f)=>{const{message:w}=r;return c.code==="invalid_enum_value"?{message:w??f.defaultError}:typeof f.data>"u"?{message:w??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:w??t??f.defaultError}},description:i}}class ce{get description(){return this._def.description}_getType(e){return wt(e.data)}_getOrReturnCtx(e,t){return t||{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 Ge,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 t=this._parse(e);if(Yt(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:wt(e)},i=this._parseSync({data:e,path:a.path,parent:a});return en(a,i)}"~validate"(e){var a,i;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return Nt(s)?{value:s.value}:{issues:t.common.issues}}catch(s){(i=(a=s==null?void 0:s.message)==null?void 0:a.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>Nt(s)?{value:s.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:wt(e)},i=this._parse({data:e,path:a.path,parent:a}),s=await(Yt(i)?i:Promise.resolve(i));return en(a,s)}refine(e,t){const a=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const c=e(i),f=()=>s.addIssue({code:O.custom,...a(i)});return typeof Promise<"u"&&c instanceof Promise?c.then(w=>w?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,t){return this._refinement((a,i)=>e(a)?!0:(i.addIssue(typeof t=="function"?t(a,i):t),!1))}_refinement(e){return new lt({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 pt.create(this,this._def)}nullable(){return Dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ut.create(this)}promise(){return Vt.create(this,this._def)}or(e){return Qt.create([this,e],this._def)}and(e){return er.create(this,e,this._def)}transform(e){return new lt({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ir({...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 sr({...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 cr.create(this,e)}readonly(){return or.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const xn=/^c[^\s-]{8,}$/i,_n=/^[0-9a-z]+$/,En=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tn=/^[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,An=/^[a-z0-9_-]{21}$/i,Sn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Dn=/^[-+]?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)?)??$/,On=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ar;const Pn=/^(?:(?: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])$/,Nn=/^(?:(?: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])$/,Mn=/^(([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]))$/,jn=/^(([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])$/,Rn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,In=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cn="((\\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])))",Fn=new RegExp(`^${cn}$`);function un(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 $n(r){return new RegExp(`^${un(r)}$`)}function ln(r){let e=`${cn}T${un(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 Bn(r,e){return!!((e==="v4"||!e)&&Pn.test(r)||(e==="v6"||!e)&&Mn.test(r))}function Un(r,e){if(!Sn.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,"="),i=JSON.parse(atob(a));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Zn(r,e){return!!((e==="v4"||!e)&&Nn.test(r)||(e==="v6"||!e)&&jn.test(r))}class ct extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return B(s,{code:O.invalid_type,expected:z.string,received:s.parsedType}),ee}const a=new Ge;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),B(i,{code:O.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),B(i,{code:O.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){const c=e.data.length>s.value,f=e.data.length<s.value;(c||f)&&(i=this._getOrReturnCtx(e,i),c?B(i,{code:O.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):f&&B(i,{code:O.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")On.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"email",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")Ar||(Ar=new RegExp(Cn,"u")),Ar.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"emoji",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")Tn.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"uuid",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")An.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"nanoid",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")xn.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"cuid",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")_n.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"cuid2",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")En.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"ulid",code:O.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),B(i,{validation:"url",code:O.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"regex",code:O.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?ln(s).test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?Fn.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?$n(s).test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:O.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?Dn.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"duration",code:O.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?Bn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"ip",code:O.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?Un(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"jwt",code:O.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?Zn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"cidr",code:O.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?Rn.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"base64",code:O.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?In.test(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{validation:"base64url",code:O.invalid_string,message:s.message}),a.dirty()):ye.assertNever(s);return{status:a.value,value:e.data}}_regex(e,t,a){return this.refinement(i=>e.test(i),{validation:t,code:O.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ct({...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 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 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}}ct.create=r=>new ct({checks:[],typeName:re.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function Ln(r,e){const t=(r.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,i=t>a?t:a,s=Number.parseInt(r.toFixed(i).replace(".","")),c=Number.parseInt(e.toFixed(i).replace(".",""));return s%c/10**i}class Tt 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 s=this._getOrReturnCtx(e);return B(s,{code:O.invalid_type,expected:z.number,received:s.parsedType}),ee}let a;const i=new Ge;for(const s of this._def.checks)s.kind==="int"?ye.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Ln(e.data,s.value)!==0&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_finite,message:s.message}),i.dirty()):ye.assertNever(s);return{status:i.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,i){return new Tt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(i)}]})}_addCheck(e){return new Tt({...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"&&ye.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)}}Tt.create=r=>new Tt({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class At 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 i=new Ge;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ye.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.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,i){return new At({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(i)}]})}_addCheck(e){return new At({...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}}At.create=r=>new At({checks:[],typeName:re.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class Jt extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.boolean,received:a.parsedType}),ee}return Ye(e.data)}}Jt.create=r=>new Jt({typeName:re.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Mt extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return B(s,{code:O.invalid_type,expected:z.date,received:s.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return B(s,{code:O.invalid_date}),ee}const a=new Ge;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),B(i,{code:O.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),B(i,{code:O.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):ye.assertNever(s);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Mt({...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}}Mt.create=r=>new Mt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:re.ZodDate,...ie(r)});class vr extends ce{_parse(e){if(this._getType(e)!==z.symbol){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.symbol,received:a.parsedType}),ee}return Ye(e.data)}}vr.create=r=>new vr({typeName:re.ZodSymbol,...ie(r)});class Xt extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.undefined,received:a.parsedType}),ee}return Ye(e.data)}}Xt.create=r=>new Xt({typeName:re.ZodUndefined,...ie(r)});class Kt extends ce{_parse(e){if(this._getType(e)!==z.null){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.null,received:a.parsedType}),ee}return Ye(e.data)}}Kt.create=r=>new Kt({typeName:re.ZodNull,...ie(r)});class zt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Ye(e.data)}}zt.create=r=>new zt({typeName:re.ZodAny,...ie(r)});class Pt extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ye(e.data)}}Pt.create=r=>new Pt({typeName:re.ZodUnknown,...ie(r)});class kt extends ce{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:z.never,received:t.parsedType}),ee}}kt.create=r=>new kt({typeName:re.ZodNever,...ie(r)});class br extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.void,received:a.parsedType}),ee}return Ye(e.data)}}br.create=r=>new br({typeName:re.ZodVoid,...ie(r)});class ut extends ce{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return B(t,{code:O.invalid_type,expected:z.array,received:t.parsedType}),ee;if(i.exactLength!==null){const c=t.data.length>i.exactLength.value,f=t.data.length<i.exactLength.value;(c||f)&&(B(t,{code:c?O.too_big:O.too_small,minimum:f?i.exactLength.value:void 0,maximum:c?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(B(t,{code:O.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(B(t,{code:O.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((c,f)=>i.type._parseAsync(new mt(t,c,t.path,f)))).then(c=>Ge.mergeArray(a,c));const s=[...t.data].map((c,f)=>i.type._parseSync(new mt(t,c,t.path,f)));return Ge.mergeArray(a,s)}get element(){return this._def.type}min(e,t){return new ut({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new ut({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new ut({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}ut.create=(r,e)=>new ut({type:r,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function Bt(r){if(r instanceof je){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=pt.create(Bt(a))}return new je({...r._def,shape:()=>e})}else return r instanceof ut?new ut({...r._def,type:Bt(r.element)}):r instanceof pt?pt.create(Bt(r.unwrap())):r instanceof Dt?Dt.create(Bt(r.unwrap())):r instanceof yt?yt.create(r.items.map(e=>Bt(e))):r}class je 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=ye.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==z.object){const _=this._getOrReturnCtx(e);return B(_,{code:O.invalid_type,expected:z.object,received:_.parsedType}),ee}const{status:a,ctx:i}=this._processInputParams(e),{shape:s,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof kt&&this._def.unknownKeys==="strip"))for(const _ in i.data)c.includes(_)||f.push(_);const w=[];for(const _ of c){const R=s[_],D=i.data[_];w.push({key:{status:"valid",value:_},value:R._parse(new mt(i,D,i.path,_)),alwaysSet:_ in i.data})}if(this._def.catchall instanceof kt){const _=this._def.unknownKeys;if(_==="passthrough")for(const R of f)w.push({key:{status:"valid",value:R},value:{status:"valid",value:i.data[R]}});else if(_==="strict")f.length>0&&(B(i,{code:O.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 D=i.data[R];w.push({key:{status:"valid",value:R},value:_._parse(new mt(i,D,i.path,R)),alwaysSet:R in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const _=[];for(const R of w){const D=await R.key,T=await R.value;_.push({key:D,value:T,alwaysSet:R.alwaysSet})}return _}).then(_=>Ge.mergeObjectSync(a,_)):Ge.mergeObjectSync(a,w)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var s,c;const i=((c=(s=this._def).errorMap)==null?void 0:c.call(s,t,a).message)??a.defaultError;return t.code==="unrecognized_keys"?{message:Y.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({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 je({...this._def,catchall:e})}pick(e){const t={};for(const a of ye.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new je({...this._def,shape:()=>t})}omit(e){const t={};for(const a of ye.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new je({...this._def,shape:()=>t})}deepPartial(){return Bt(this)}partial(e){const t={};for(const a of ye.objectKeys(this.shape)){const i=this.shape[a];e&&!e[a]?t[a]=i:t[a]=i.optional()}return new je({...this._def,shape:()=>t})}required(e){const t={};for(const a of ye.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof pt;)s=s._def.innerType;t[a]=s}return new je({...this._def,shape:()=>t})}keyof(){return fn(ye.objectKeys(this.shape))}}je.create=(r,e)=>new je({shape:()=>r,unknownKeys:"strip",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});je.strictCreate=(r,e)=>new je({shape:()=>r,unknownKeys:"strict",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});je.lazycreate=(r,e)=>new je({shape:r,unknownKeys:"strip",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});class Qt extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function i(s){for(const f of s)if(f.result.status==="valid")return f.result;for(const f of s)if(f.result.status==="dirty")return t.common.issues.push(...f.ctx.common.issues),f.result;const c=s.map(f=>new rt(f.ctx.common.issues));return B(t,{code:O.invalid_union,unionErrors:c}),ee}if(t.common.async)return Promise.all(a.map(async s=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(i);{let s;const c=[];for(const w of a){const _={...t,common:{...t.common,issues:[]},parent:null},R=w._parseSync({data:t.data,path:t.path,parent:_});if(R.status==="valid")return R;R.status==="dirty"&&!s&&(s={result:R,ctx:_}),_.common.issues.length&&c.push(_.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const f=c.map(w=>new rt(w));return B(t,{code:O.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}Qt.create=(r,e)=>new Qt({options:r,typeName:re.ZodUnion,...ie(e)});const bt=r=>r instanceof rr?bt(r.schema):r instanceof lt?bt(r.innerType()):r instanceof nr?[r.value]:r instanceof St?r.options:r instanceof ar?ye.objectValues(r.enum):r instanceof ir?bt(r._def.innerType):r instanceof Xt?[void 0]:r instanceof Kt?[null]:r instanceof pt?[void 0,...bt(r.unwrap())]:r instanceof Dt?[null,...bt(r.unwrap())]:r instanceof jr||r instanceof or?bt(r.unwrap()):r instanceof sr?bt(r._def.innerType):[];class Er extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return B(t,{code:O.invalid_type,expected:z.object,received:t.parsedType}),ee;const a=this.discriminator,i=t.data[a],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:O.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 i=new Map;for(const s of t){const c=bt(s.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(i.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);i.set(f,s)}}return new Er({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...ie(a)})}}function Nr(r,e){const t=wt(r),a=wt(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&a===z.object){const i=ye.objectKeys(e),s=ye.objectKeys(r).filter(f=>i.indexOf(f)!==-1),c={...r,...e};for(const f of s){const w=Nr(r[f],e[f]);if(!w.valid)return{valid:!1};c[f]=w.data}return{valid:!0,data:c}}else if(t===z.array&&a===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const c=r[s],f=e[s],w=Nr(c,f);if(!w.valid)return{valid:!1};i.push(w.data)}return{valid:!0,data:i}}else return t===z.date&&a===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class er extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),i=(s,c)=>{if(Cr(s)||Cr(c))return ee;const f=Nr(s.value,c.value);return f.valid?((Pr(s)||Pr(c))&&t.dirty(),{status:t.value,value:f.data}):(B(a,{code:O.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(([s,c])=>i(s,c)):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}er.create=(r,e,t)=>new er({left:r,right:e,typeName:re.ZodIntersection,...ie(t)});class yt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.array)return B(a,{code:O.invalid_type,expected:z.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return B(a,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(B(a,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...a.data].map((c,f)=>{const w=this._def.items[f]||this._def.rest;return w?w._parse(new mt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(s).then(c=>Ge.mergeArray(t,c)):Ge.mergeArray(t,s)}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:re.ZodTuple,rest:null,...ie(e)})};class tr 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 B(a,{code:O.invalid_type,expected:z.object,received:a.parsedType}),ee;const i=[],s=this._def.keyType,c=this._def.valueType;for(const f in a.data)i.push({key:s._parse(new mt(a,f,a.path,f)),value:c._parse(new mt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ge.mergeObjectAsync(t,i):Ge.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof ce?new tr({keyType:e,valueType:t,typeName:re.ZodRecord,...ie(a)}):new tr({keyType:ct.create(),valueType:e,typeName:re.ZodRecord,...ie(t)})}}class wr 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 B(a,{code:O.invalid_type,expected:z.map,received:a.parsedType}),ee;const i=this._def.keyType,s=this._def.valueType,c=[...a.data.entries()].map(([f,w],_)=>({key:i._parse(new mt(a,f,a.path,[_,"key"])),value:s._parse(new mt(a,w,a.path,[_,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const w of c){const _=await w.key,R=await w.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 w of c){const _=w.key,R=w.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}}}}wr.create=(r,e,t)=>new wr({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 B(a,{code:O.invalid_type,expected:z.set,received:a.parsedType}),ee;const i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(B(a,{code:O.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&a.data.size>i.maxSize.value&&(B(a,{code:O.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function c(w){const _=new Set;for(const R of w){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((w,_)=>s._parse(new mt(a,w,a.path,_)));return a.common.async?Promise.all(f).then(w=>c(w)):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 B(t,{code:O.invalid_type,expected:z.function,received:t.parsedType}),ee;function a(f,w){return gr({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Lt].filter(_=>!!_),issueData:{code:O.invalid_arguments,argumentsError:w}})}function i(f,w){return gr({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Lt].filter(_=>!!_),issueData:{code:O.invalid_return_type,returnTypeError:w}})}const s={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Vt){const f=this;return Ye(async function(...w){const _=new rt([]),R=await f._def.args.parseAsync(w,s).catch(A=>{throw _.addIssue(a(w,A)),_}),D=await Reflect.apply(c,this,R);return await f._def.returns._def.type.parseAsync(D,s).catch(A=>{throw _.addIssue(i(D,A)),_})})}else{const f=this;return Ye(function(...w){const _=f._def.args.safeParse(w,s);if(!_.success)throw new rt([a(w,_.error)]);const R=Reflect.apply(c,this,_.data),D=f._def.returns.safeParse(R,s);if(!D.success)throw new rt([i(R,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Zt({...this._def,args:yt.create(e).rest(Pt.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||yt.create([]).rest(Pt.create()),returns:t||Pt.create(),typeName:re.ZodFunction,...ie(a)})}}class rr 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})}}rr.create=(r,e)=>new rr({getter:r,typeName:re.ZodLazy,...ie(e)});class nr extends ce{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}nr.create=(r,e)=>new nr({value:r,typeName:re.ZodLiteral,...ie(e)});function fn(r,e){return new St({values:r,typeName:re.ZodEnum,...ie(e)})}class St extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return B(t,{expected:ye.joinValues(a),received:t.parsedType,code:O.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 B(t,{received:t.data,code:O.invalid_enum_value,options:a}),ee}return Ye(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 St.create(e,{...this._def,...t})}exclude(e,t=this._def){return St.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}St.create=fn;class ar extends ce{_parse(e){const t=ye.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==z.string&&a.parsedType!==z.number){const i=ye.objectValues(t);return B(a,{expected:ye.joinValues(i),received:a.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(ye.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=ye.objectValues(t);return B(a,{received:a.data,code:O.invalid_enum_value,options:i}),ee}return Ye(e.data)}get enum(){return this._def.values}}ar.create=(r,e)=>new ar({values:r,typeName:re.ZodNativeEnum,...ie(e)});class Vt 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 B(t,{code:O.invalid_type,expected:z.promise,received:t.parsedType}),ee;const a=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return Ye(a.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Vt.create=(r,e)=>new Vt({type:r,typeName:re.ZodPromise,...ie(e)});class lt 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),i=this._def.effect||null,s={addIssue:c=>{B(a,c),c.fatal?t.abort():t.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const c=i.transform(a.data,s);if(a.common.async)return Promise.resolve(c).then(async f=>{if(t.value==="aborted")return ee;const w=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return w.status==="aborted"?ee:w.status==="dirty"||t.value==="dirty"?Ut(w.value):w});{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"?Ut(f.value):f}}if(i.type==="refinement"){const c=f=>{const w=i.refinement(f,s);if(a.common.async)return Promise.resolve(w);if(w 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(i.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Nt(c))return ee;const f=i.transform(c.value,s);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=>Nt(c)?Promise.resolve(i.transform(c.value,s)).then(f=>({status:t.value,value:f})):ee);ye.assertNever(i)}}lt.create=(r,e,t)=>new lt({schema:r,typeName:re.ZodEffects,effect:e,...ie(t)});lt.createWithPreprocess=(r,e,t)=>new lt({schema:e,effect:{type:"preprocess",transform:r},typeName:re.ZodEffects,...ie(t)});class pt extends ce{_parse(e){return this._getType(e)===z.undefined?Ye(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pt.create=(r,e)=>new pt({innerType:r,typeName:re.ZodOptional,...ie(e)});class Dt extends ce{_parse(e){return this._getType(e)===z.null?Ye(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 ir 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}}ir.create=(r,e)=>new ir({innerType:r,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class sr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Yt(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new rt(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}sr.create=(r,e)=>new sr({innerType:r,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class kr extends ce{_parse(e){if(this._getType(e)!==z.nan){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:z.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}kr.create=r=>new kr({typeName:re.ZodNaN,...ie(r)});const zn=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 cr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(t.dirty(),Ut(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{const i=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:a.path,parent:a})}}static create(e,t){return new cr({in:e,out:t,typeName:re.ZodPipeline})}}class or extends ce{_parse(e){const t=this._def.innerType._parse(e),a=i=>(Nt(i)&&(i.value=Object.freeze(i.value)),i);return Yt(t)?t.then(i=>a(i)):a(t)}unwrap(){return this._def.innerType}}or.create=(r,e)=>new or({innerType:r,typeName:re.ZodReadonly,...ie(e)});function tn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function dn(r,e={},t){return r?zt.create().superRefine((a,i)=>{const s=r(a);if(s instanceof Promise)return s.then(c=>{if(!c){const f=tn(e,a),w=f.fatal??t??!0;i.addIssue({code:"custom",...f,fatal:w})}});if(!s){const c=tn(e,a),f=c.fatal??t??!0;i.addIssue({code:"custom",...c,fatal:f})}}):zt.create()}const Vn={object:je.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 qn=(r,e={message:`Input not instance of ${r.name}`})=>dn(t=>t instanceof r,e),xr=ct.create,Rr=Tt.create,Wn=kr.create,Hn=At.create,_r=Jt.create,Gn=Mt.create,Yn=vr.create,Jn=Xt.create,Xn=Kt.create,Kn=zt.create,Qn=Pt.create,ea=kt.create,ta=br.create,ra=ut.create,Mr=je.create,na=je.strictCreate,aa=Qt.create,ia=Er.create,sa=er.create,oa=yt.create,ca=tr.create,ua=wr.create,la=jt.create,fa=Zt.create,da=rr.create,ha=nr.create,hn=St.create,pa=ar.create,ma=Vt.create,rn=lt.create,ya=pt.create,ga=Dt.create,va=lt.createWithPreprocess,ba=cr.create,wa=()=>xr().optional(),ka=()=>Rr().optional(),xa=()=>_r().optional(),_a={string:(r=>ct.create({...r,coerce:!0})),number:(r=>Tt.create({...r,coerce:!0})),boolean:(r=>Jt.create({...r,coerce:!0})),bigint:(r=>At.create({...r,coerce:!0})),date:(r=>Mt.create({...r,coerce:!0}))},Ea=ee,N=Object.freeze(Object.defineProperty({__proto__:null,BRAND:zn,DIRTY:Ut,EMPTY_PATH:kn,INVALID:ee,NEVER:Ea,OK:Ye,ParseStatus:Ge,Schema:ce,ZodAny:zt,ZodArray:ut,ZodBigInt:At,ZodBoolean:Jt,ZodBranded:jr,ZodCatch:sr,ZodDate:Mt,ZodDefault:ir,ZodDiscriminatedUnion:Er,ZodEffects:lt,ZodEnum:St,ZodError:rt,get ZodFirstPartyTypeKind(){return re},ZodFunction:Zt,ZodIntersection:er,ZodIssueCode:O,ZodLazy:rr,ZodLiteral:nr,ZodMap:wr,ZodNaN:kr,ZodNativeEnum:ar,ZodNever:kt,ZodNull:Kt,ZodNullable:Dt,ZodNumber:Tt,ZodObject:je,ZodOptional:pt,ZodParsedType:z,ZodPipeline:cr,ZodPromise:Vt,ZodReadonly:or,ZodRecord:tr,ZodSchema:ce,ZodSet:jt,ZodString:ct,ZodSymbol:vr,ZodTransformer:lt,ZodTuple:yt,ZodType:ce,ZodUndefined:Xt,ZodUnion:Qt,ZodUnknown:Pt,ZodVoid:br,addIssueToContext:B,any:Kn,array:ra,bigint:Hn,boolean:_r,coerce:_a,custom:dn,date:Gn,datetimeRegex:ln,defaultErrorMap:Lt,discriminatedUnion:ia,effect:rn,enum:hn,function:fa,getErrorMap:yr,getParsedType:wt,instanceof:qn,intersection:sa,isAborted:Cr,isAsync:Yt,isDirty:Pr,isValid:Nt,late:Vn,lazy:da,literal:ha,makeIssue:gr,map:ua,nan:Wn,nativeEnum:pa,never:ea,null:Xn,nullable:ga,number:Rr,object:Mr,get objectUtil(){return Or},oboolean:xa,onumber:ka,optional:ya,ostring:wa,pipeline:ba,preprocess:va,promise:ma,quotelessJson:bn,record:ca,set:la,setErrorMap:wn,strictObject:na,string:xr,symbol:Yn,transformer:rn,tuple:oa,undefined:Jn,union:aa,unknown:Qn,get util(){return ye},void:ta},Symbol.toStringTag,{value:"Module"})),ft=Mr({name:xr(),selector:xr(),findBy:hn(["cssSelector","xpath"]),option:Mr({waitForSelector:_r().optional(),waitSelectorTimeout:Rr().optional(),multiple:_r().optional()})}),Ta=N.object({type:N.literal("object"),shape:N.record(N.string(),N.any())}),Aa=N.object({type:N.literal("array"),items:N.any()}),Sa=N.discriminatedUnion("type",[Ta,Aa]),Ir=N.object({name:N.literal("ai-parse-data"),sourceData:N.any().optional(),schemaDefinition:Sa,prompt:N.string().optional(),model:N.string().optional(),apiKey:N.string().min(1,"OpenAI API key is required")});function Da(r){return Ir.parse(r)}async function Oa(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:i="gpt-4o-mini",apiKey:s}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!s||s.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:i,apiKey:s}});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 Ca(r){return{type:"object",shape:r}}function Pa(r){return{type:"array",items:r}}const Na={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 Tr{async waitForElement(e,t,a){return new Promise(i=>{const s=Date.now(),c=async()=>{const f=await this.find(e,t);if(f&&(!Array.isArray(f)||f.length>0)){i(f);return}if(Date.now()-s>=a){i(null);return}setTimeout(c,100)};c()})}}class Ma extends Tr{async find(e,t=document){const{selector:a,option:i}=e,{multiple:s=!1}=i||{};try{const c=this.processCustomPseudoSelectors(a,t);return s?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,(s,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(s,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var s;const i=((s=a.textContent)==null?void 0:s.trim())||"";if(i){a.setAttribute("data-contains",i);const f=Array.from(a.childNodes).filter(w=>w.nodeType===Node.TEXT_NODE).map(w=>{var _;return((_=w.textContent)==null?void 0:_.trim())||""}).join(" ").trim();(f&&f===i||a.children.length===0&&i)&&a.setAttribute("data-equal",i)}})}}class ja extends Tr{async find(e,t=document){const{selector:a,option:i}=e,{multiple:s=!1}=i||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(_=>_.trim());if(c.length!==2)return null;const f=c[0],w=c[1];if(!f||!w)return null;try{const _=t.querySelector(f);if(!_||!_.contentDocument)return null;const R=_.contentDocument;return s?Array.from(R.querySelectorAll(w)):R.querySelector(w)}catch(_){return console.error("Iframe Selector error:",_),null}}}class Ra extends Tr{async find(e,t=document){const{selector:a,option:i}=e,{multiple:s=!1}=i||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(w=>w.trim());let f=t;try{for(let w=0;w<c.length;w++){const _=c[w],R=w===c.length-1;if(!_)return null;if(R&&s)return Array.from(f.querySelectorAll(_));const D=f.querySelector(_);if(!D)return null;if(R)return D;if(D.shadowRoot)f=D.shadowRoot;else return null}}catch(w){return console.error("Shadow DOM Selector error:",w),null}return null}}class Ia extends Tr{async find(e,t=document){const{selector:a,option:i}=e,{multiple:s=!1}=i||{};try{const c=t.evaluate(a,t,null,s?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(s){const f=[];for(let w=0;w<c.snapshotLength;w++){const _=c.snapshotItem(w);_&&_.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 Fa{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const s of t){const c=e.getAttribute(s);if(c&&!this.isDynamicValue(c))return`[${s}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),i=e.parentElement;if(i){const s=Array.from(i.children),c=s.indexOf(e)+1;if(s.length>1)return`${a}:nth-child(${c})`}if(i){const s=this.generateParentSelector(i);if(s)return`${s} > ${a}:nth-child(${Array.from(i.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const s of a){const c=e.getAttribute(s);if(c&&!this.isDynamicValue(c))return`[${s}="${CSS.escape(c)}"]`}const i=e.parentElement;if(i){const s=Array.from(i.children),c=s.indexOf(e)+1;if(s.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 dt(r,e=document){const{selector:t,findBy:a="cssSelector",option:i}=r,{waitForSelector:s=!1,waitSelectorTimeout:c=5e3}=i||{},f=$a(t,a);return s?f.waitForElement(r,e,c):f.find(r,e)}function $a(r,e){return e==="xpath"?new Ia:r.includes(">>")?new Ra:r.includes("|>")?new ja:new Ma}const Fr=ft.extend({name:N.literal("get-text"),includeTags:N.boolean().optional(),useTextContent:N.boolean().optional(),regex:N.string().optional(),prefixText:N.string().optional(),suffixText:N.string().optional(),filterEmpty:N.boolean().optional(),scrollToCollect:N.boolean().optional(),scrollDistance:N.number().optional(),scrollWaitMs:N.number().optional(),maxScrollAttempts:N.number().optional()});function Ba(r){return Fr.parse(r)}async function Ua(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:i,prefixText:s="",suffixText:c="",findBy:f="cssSelector",option:w,filterEmpty:_=!0,scrollToCollect:R=!1,scrollDistance:D=500,scrollWaitMs:T=300,maxScrollAttempts:A=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(R&&(w!=null&&w.multiple))return await Za({selector:e,findBy:f,option:w,includeTags:t,useTextContent:a,regex:i,prefixText:s,suffixText:c,filterEmpty:_,scrollDistance:D,scrollWaitMs:T,maxScrollAttempts:A});const $=await dt({selector:e,findBy:f,option:w});if(!$)return{data:""};const se=pn(t,a,i,s,c);if(Array.isArray($)){const ge=$.map(se);return{data:_?ge.filter(H=>H.trim()!==""):ge}}else return{data:se($)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function Za(r){const{selector:e,findBy:t,option:a,includeTags:i,useTextContent:s,regex:c,prefixText:f,suffixText:w,filterEmpty:_,scrollDistance:R,scrollWaitMs:D,maxScrollAttempts:T}=r,A=pn(i,s,c,f,w),$=new Set;let se=0,ge=0;const Ae=5;for(;se<T;){const H=await dt({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const Z=$.size;if(H.forEach(U=>{const V=A(U);(!_||V.trim()!=="")&&$.add(V)}),$.size===Z){if(ge++,ge>=Ae)break}else ge=0}const P=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:R,behavior:"auto"}),await new Promise(Z=>setTimeout(Z,D)),(window.pageYOffset||document.documentElement.scrollTop)===P)break;se++}return{data:Array.from($)}}function pn(r,e,t,a="",i=""){return s=>{let c="";if(r?c=s.innerHTML:c=e?s.textContent||"":s.innerText||"",t){const f=new RegExp(t,"g"),w=c.match(f);c=w?w.join(" "):""}return c.trim()&&(c=a+c.trim()+i),c}}const $r=ft.extend({name:N.literal("attribute-value"),attributeName:N.string()});function La(r){return $r.parse(r)}async function za(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:i}=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 s=await dt({selector:e,findBy:a,option:i});return s?{data:Array.isArray(s)?s.map(f=>f.getAttribute(t)).filter(f=>f!==null):s.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Br=ft.extend({name:N.literal("get-value-form"),type:N.enum(["text-field","select","checkbox"]).optional()});function Va(r){return Br.parse(r)}async function qa(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 i=await dt({selector:e,findBy:a,option:r.option});if(!i)throw new Error("Form element not found");return{data:Wa(i,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function Wa(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 Ur=ft.extend({name:N.literal("set-value-form"),setValue:N.string(),type:N.enum(["text-field","select","checkbox"]).optional()});function Ha(r){return Ur.parse(r)}async function Ga(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:i="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const s=await dt({selector:e,findBy:i,option:r.option});if(!s)throw new Error("Form element not found");return Ya(s,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 Ya(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=ft.extend({name:N.literal("clear-value-form"),type:N.enum(["text-field","select","checkbox"]).optional()});function Ja(r){return Zr.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 clear-value-form block");const i=await dt({selector:e,findBy:a,option:r.option});if(!i)throw new Error("Form element not found");return Ka(i,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 Ka(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 Lr=ft.extend({name:N.literal("element-exists")});function Qa(r){return Lr.parse(r)}async function ei(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 dt({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 zr=ft.extend({name:N.literal("event-click"),textFilter:N.object({text:N.union([N.string(),N.array(N.string())]),mode:N.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function ti(r){return zr.parse(r)}async function ri(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:i}=r;if(!e)throw new Error("Selector is required for event-click block");const s=await dt({selector:e,findBy:t,option:a});if(!s)throw new Error("Element not found for clicking");let c;if(Array.isArray(s))if(i){const f=ni(s,i.text,i.mode);if(!f){const w=Array.isArray(i.text)?i.text.join(", "):i.text;throw new Error(`No element found with text filter: "${w}" (mode: ${i.mode})`)}c=f}else c=s[0];else c=s;return await ii(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 ni(r,e,t){for(const a of r){const i=ai(a),s=Array.isArray(e)?e:[e];for(const c of s){let f=!1;switch(t){case"exact":f=i===c;break;case"contains":f=i.includes(c);break;case"startsWith":f=i.startsWith(c);break;case"endsWith":f=i.endsWith(c);break;case"regex":try{f=new RegExp(c).test(i)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ai(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 ii(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(i=>setTimeout(i,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const i=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(i&&!i.$isError)console.log("[EventClick] CDP click successful:",i);else throw new Error((i==null?void 0:i.message)||"CDP click failed")}catch(i){console.error("[EventClick] CDP click failed, falling back to native click:",i),r.click&&r.click()}await new Promise(i=>setTimeout(i,50))}const Vr=N.object({name:N.literal("keypress"),key:N.string(),code:N.string().optional(),keyCode:N.number().optional(),modifiers:N.array(N.enum(["Alt","Control","Meta","Shift"])).optional()});function si(r){return Vr.parse(r)}async function oi(r){try{const{key:e,code:t,keyCode:a,modifiers:i=[]}=r;return await ci(e,t,a,i),{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 ci(r,e,t,a=[]){try{const i=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Sr(r),modifiers:a}});if(i&&!i.$isError)console.log("[Keypress] CDP keypress successful:",i);else throw new Error((i==null?void 0:i.message)||"CDP keypress failed")}catch(i){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",i);const s=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Sr(r),bubbles:!0,cancelable:!0,...nn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Sr(r),bubbles:!0,cancelable:!0,...nn(a)});document.dispatchEvent(s),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(i=>setTimeout(i,50))}function Sr(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 nn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const qr=N.object({name:N.literal("wait"),duration:N.number().min(0)});function ui(r){return qr.parse(r)}async function li(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 Wr=ft.extend({name:N.literal("save-assets")});function fi(r){return Wr.parse(r)}async function di(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,i=await dt({selector:e,findBy:t,option:a});if(!i||!Array.isArray(i))return{data:[]};const s=[];return i.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!s.includes(f)&&s.push(f)}),{data:s}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class hi{static generate(e){var i;const t=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let s=a.tagName.toLowerCase();const c=Array.from(((i=a.parentElement)==null?void 0:i.children)||[]).filter(w=>w.tagName===a.tagName);if(c.length>1){const w=c.indexOf(a)+1;s+=`[${w}]`}const f=this.getStableAttributes(a);f.length>0&&(s+=`[@${f.join(" and @")}]`),t.unshift(s),a=a.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],a=["data-testid","aria-label","title","alt","role"];for(const i of a){const s=e.getAttribute(i);s&&!this.isDynamicValue(s)&&t.push(`${i}="${s}"`)}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 Hr=ft.extend({name:N.literal("get-element-data"),includeText:N.boolean().optional(),includeTags:N.boolean().optional(),useTextContent:N.boolean().optional(),regex:N.string().optional(),prefixText:N.string().optional(),suffixText:N.string().optional(),attributes:N.array(N.string()).optional(),includeSelector:N.boolean().optional(),includeXPath:N.boolean().optional()});function pi(r){return Hr.parse(r)}async function mi(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:i=!1,regex:s,prefixText:c="",suffixText:f="",attributes:w=[],includeSelector:_=!1,includeXPath:R=!1,findBy:D="cssSelector",option:T}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&w.length===0)throw new Error("Either includeText must be true or attributes must be provided");const A=await dt({selector:e,findBy:D,option:T});if(!A)return{data:Array.isArray(A)?[]:{}};const $=yi(t,a,i,s,c,f,w,_,R);return Array.isArray(A)?{data:A.map($)}:{data:$(A)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function yi(r,e,t,a,i="",s="",c=[],f=!1,w=!1){return _=>{const R={};if(r){let D="";if(e?D=_.innerHTML:D=t?_.textContent||"":_.innerText||"",a){const T=new RegExp(a,"g"),A=D.match(T);D=A?A.join(" "):""}D.trim()&&(D=i+D.trim()+s),R.text=D}return c.length>0&&(R.attributes={},c.forEach(D=>{let T=_.getAttribute(D);if(T===null){const A=_.querySelector(`[${D}]`);A&&(T=A.getAttribute(D))}R.attributes[D]=T})),f&&(R.selector=Fa.generate(_)),w&&(R.xpath=hi.generate(_)),R}}const Gr=ft.extend({name:N.literal("scroll"),scrollType:N.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:N.number().optional(),behavior:N.enum(["auto","smooth"]).optional(),maxScrolls:N.number().optional(),waitAfterScroll:N.number().optional()});function gi(r){return Gr.parse(r)}async function vi(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:i="smooth",maxScrolls:s=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:w}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await bi(e,f,w,i);case"toBottom":return await wi(i,c);case"byDistance":return await ki(a,i);case"untilLoaded":return await xi(s,a,i,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 bi(r,e,t,a){const i=await dt({selector:r,findBy:e,option:t});return i?((Array.isArray(i)?i[0]:i).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function wi(r,e){let t=document.body.scrollHeight,a=0;const i=50;for(;a<i;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const s=document.body.scrollHeight;if(s===t)break;t=s,a++}return{data:!0}}async function ki(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function xi(r,e,t,a){let i=0,s=document.body.scrollHeight;for(;i<r;){window.scrollBy({top:e,behavior:t}),await new Promise(_=>setTimeout(_,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,w=window.innerHeight;if(f+w>=c-10&&c===s)break;s=c,i++}return{data:!0}}const Yr=N.object({name:N.literal("fetch-api"),url:N.string(),method:N.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:N.record(N.string(),N.string()).optional(),body:N.record(N.string(),N.any()).optional(),timeout:N.number().min(0).optional(),parseJson:N.boolean().optional(),returnHeaders:N.boolean().optional()});function _i(r){return Yr.parse(r)}async function Ei(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 an=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ti(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function mr(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:{}},sn;function Ai(){return sn||(sn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,i,s){function c(_,R){if(!i[_]){if(!a[_]){var D=typeof mr=="function"&&mr;if(!R&&D)return D(_,!0);if(f)return f(_,!0);var T=new Error("Cannot find module '"+_+"'");throw T.code="MODULE_NOT_FOUND",T}var A=i[_]={exports:{}};a[_][0].call(A.exports,function($){var se=a[_][1][$];return c(se||$)},A,A.exports,t,a,i,s)}return i[_].exports}for(var f=typeof mr=="function"&&mr,w=0;w<s.length;w++)c(s[w]);return c}return t})()({1:[function(t,a,i){const s=t("./utils"),c=(function(){const f=s.stringToArray,w=["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"],D=["Thousand","Million","Billion","Trillion"];function T(v,E){var b=function(F,j,S){var I="";if(F<=19)I=(j?" and ":"")+(S?_[F]:w[F]);else if(F<100){const pe=Math.floor(F/10),ve=F%10;I=(j?" and ":"")+R[pe-2],ve>0?I+="-"+b(ve,!1,S):S&&(I=I.substring(0,I.length-1)+"ieth")}else if(F<1e3){const pe=Math.floor(F/100),ve=F%100;I=(j?", ":"")+w[pe]+" Hundred",ve>0?I+=b(ve,!0,S):S&&(I+="th")}else{var X=Math.floor(Math.log10(F)/3);X>D.length&&(X=D.length);const pe=Math.pow(10,X*3),ve=Math.floor(F/pe),J=F-ve*pe;I=(j?", ":"")+b(ve,!1,!1)+" "+D[X-1],J>0?I+=b(J,!0,S):S&&(I+="th")}return I},C=b(v,!1,E);return C}const A={};w.forEach(function(v,E){A[v.toLowerCase()]=E}),_.forEach(function(v,E){A[v.toLowerCase()]=E}),R.forEach(function(v,E){const b=v.toLowerCase();A[b]=(E+2)*10,A[b.substring(0,v.length-1)+"ieth"]=A[b]}),A.hundredth=100,D.forEach(function(v,E){const b=v.toLowerCase(),C=Math.pow(10,(E+1)*3);A[b]=C,A[b+"th"]=C});function $(v){const b=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>A[j]);let C=[0];return b.forEach(j=>{if(j<100){let S=C.pop();S>=1e3&&(C.push(S),S=0),C.push(S+j)}else C.push(C.pop()*j)}),C.reduce((j,S)=>j+S,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"]],ge={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function Ae(v){for(var E=0;E<se.length;E++){const b=se[E];if(v>=b[0])return b[1]+Ae(v-b[0])}return""}function H(v){for(var E=0,b=1,C=v.length-1;C>=0;C--){const F=v[C],j=ge[F];j<b?E-=j:(b=j,E+=j)}return E}function P(v,E){for(var b=[],C=E.charCodeAt(0);v>0;)b.unshift(String.fromCharCode((v-1)%26+C)),v=Math.floor((v-1)/26);return b.join("")}function ne(v,E){for(var b=E.charCodeAt(0),C=0,F=0;F<v.length;F++)C+=(v.charCodeAt(v.length-F-1)-b+1)*Math.pow(26,F);return C}function Z(v,E){if(typeof v>"u")return;v=Math.floor(v);const b=we(E);return V(v,b)}const x={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},U={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(v,E){let b;const C=v<0;switch(v=Math.abs(v),E.primary){case x.LETTERS:b=P(v,E.case===U.UPPER?"A":"a");break;case x.ROMAN:b=Ae(v),E.case===U.UPPER&&(b=b.toUpperCase());break;case x.WORDS:b=T(v,E.ordinal),E.case===U.UPPER?b=b.toUpperCase():E.case===U.LOWER&&(b=b.toLowerCase());break;case x.DECIMAL:b=""+v;var F=E.mandatoryDigits-b.length;if(F>0){var j=new Array(F+1).join("0");b=j+b}if(E.zeroCode!==48&&(b=f(b).map(pe=>String.fromCodePoint(pe.codePointAt(0)+E.zeroCode-48)).join("")),E.regular){const pe=Math.floor((b.length-1)/E.groupingSeparators.position);for(let ve=pe;ve>0;ve--){const J=b.length-ve*E.groupingSeparators.position;b=b.substr(0,J)+E.groupingSeparators.character+b.substr(J)}}else E.groupingSeparators.reverse().forEach(pe=>{const ve=b.length-pe.position;b=b.substr(0,ve)+pe.character+b.substr(ve)});if(E.ordinal){var S={1:"st",2:"nd",3:"rd"},I=b[b.length-1],X=S[I];(!X||b.length>1&&b[b.length-2]==="1")&&(X="th"),b=b+X}break;case x.SEQUENCE:throw{code:"D3130",value:E.token}}return C&&(b="-"+b),b}const fe=[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(v){const E={type:"integer",primary:x.DECIMAL,case:U.LOWER,ordinal:!1};let b,C;const F=v.lastIndexOf(";");switch(F===-1?b=v:(b=v.substring(0,F),C=v.substring(F+1),C[0]==="o"&&(E.ordinal=!0)),b){case"A":E.case=U.UPPER;case"a":E.primary=x.LETTERS;break;case"I":E.case=U.UPPER;case"i":E.primary=x.ROMAN;break;case"W":E.case=U.UPPER,E.primary=x.WORDS;break;case"Ww":E.case=U.TITLE,E.primary=x.WORDS;break;case"w":E.primary=x.WORDS;break;default:{let j=null,S=0,I=0,X=[],pe=0;if(f(b).map(J=>J.codePointAt(0)).reverse().forEach(J=>{let Q=!1;for(let de=0;de<fe.length;de++){const G=fe[de];if(J>=G&&J<=G+9){if(Q=!0,S++,pe++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(J===35?(pe++,I++):X.push({position:pe,character:String.fromCodePoint(J)}))}),S>0){E.primary=x.DECIMAL,E.zeroCode=j,E.mandatoryDigits=S,E.optionalDigits=I;const Q=function(de){if(de.length===0)return 0;const G=de[0].character;for(let $e=1;$e<de.length;$e++)if(de[$e].character!==G)return 0;const Ue=de.map($e=>$e.position),at=function($e,qe){return qe===0?$e:at(qe,$e%qe)},Ve=Ue.reduce(at);for(let $e=1;$e<=Ue.length;$e++)if(Ue.indexOf($e*Ve)===-1)return 0;return Ve}(X);Q>0?(E.regular=!0,E.groupingSeparators={position:Q,character:X[0].character}):(E.regular=!1,E.groupingSeparators=X)}else E.primary=x.SEQUENCE,E.token=b}}return E}const _e={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 Ee(v){var E=[];const b={type:"datetime",parts:E},C=function(Q,de){if(de>Q){let G=v.substring(Q,de);G=G.split("]]").join("]"),E.push({type:"literal",value:G})}};for(var F=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){C(F,j),E.push({type:"literal",value:"["}),j+=2,F=j;continue}if(C(F,j),F=j,j=v.indexOf("]",F),j===-1)throw{code:"D3135"};let Q=v.substring(F+1,j);Q=Q.split(/\s+/).join("");var S={type:"marker",component:Q.charAt(0)},I=Q.lastIndexOf(","),X;if(I!==-1){const de=Q.substring(I+1),G=de.indexOf("-");let Ue,at;const Ve=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Ue=de:(Ue=de.substring(0,G),at=de.substring(G+1));const $e={min:Ve(Ue),max:Ve(at)};S.width=$e,X=Q.substring(1,I)}else X=Q.substring(1);if(X.length===1)S.presentation1=X;else if(X.length>1){var pe=X.charAt(X.length-1);"atco".indexOf(pe)!==-1?(S.presentation2=pe,pe==="o"&&(S.ordinal=!0),S.presentation1=X.substring(0,X.length-1)):S.presentation1=X}else S.presentation1=_e[S.component];if(typeof S.presentation1>"u")throw{code:"D3132",value:S.component};if(S.presentation1[0]==="n")S.names=U.LOWER;else if(S.presentation1[0]==="N")S.presentation1[1]==="n"?S.names=U.TITLE:S.names=U.UPPER;else if("YMDdFWwXxHhmsf".indexOf(S.component)!==-1){var ve=S.presentation1;if(S.presentation2&&(ve+=";"+S.presentation2),S.integerFormat=we(ve),S.width&&S.width.min!==void 0&&S.integerFormat.mandatoryDigits<S.width.min&&(S.integerFormat.mandatoryDigits=S.width.min),S.component==="Y")if(S.n=-1,S.width&&S.width.max!==void 0)S.n=S.width.max,S.integerFormat.mandatoryDigits=S.n;else{var J=S.integerFormat.mandatoryDigits+S.integerFormat.optionalDigits;J>=2&&(S.n=J)}const de=E[E.length-1];de&&de.integerFormat&&(de.integerFormat.parseWidth=de.integerFormat.mandatoryDigits)}(S.component==="Z"||S.component==="z")&&(S.integerFormat=we(S.presentation1)),E.push(S),F=j+1}j++}return C(F,j),b}const me=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],Ke=1e3*60*60*24,ke=function(v){const E=Date.UTC(v.year,v.month);var b=new Date(E).getUTCDay();return b===0&&(b=7),b>4?E+(8-b)*Ke:E-(b-1)*Ke},ue=function(v,E){return{year:v,month:E,nextMonth:function(){return E===11?ue(v+1,0):ue(v,E+1)},previousMonth:function(){return E===0?ue(v-1,11):ue(v,E-1)},nextYear:function(){return ue(v+1,E)},previousYear:function(){return ue(v-1,E)}}},Qe=function(v,E){return(E-v)/(Ke*7)+1},ae=(v,E)=>{let b;switch(E){case"Y":b=v.getUTCFullYear();break;case"M":b=v.getUTCMonth()+1;break;case"D":b=v.getUTCDate();break;case"d":{const C=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),F=Date.UTC(v.getUTCFullYear(),0);b=(C-F)/Ke+1;break}case"F":b=v.getUTCDay(),b===0&&(b=7);break;case"W":{const C=ue(v.getUTCFullYear(),0),F=ke(C),j=Date.UTC(C.year,v.getUTCMonth(),v.getUTCDate());let S=Qe(F,j);if(S>52){const I=ke(C.nextYear());j>=I&&(S=1)}else if(S<1){const I=ke(C.previousYear());S=Qe(I,j)}b=Math.floor(S);break}case"w":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),F=ke(C),j=Date.UTC(C.year,C.month,v.getUTCDate());let S=Qe(F,j);if(S>4){const I=ke(C.nextMonth());j>=I&&(S=1)}else if(S<1){const I=ke(C.previousMonth());S=Qe(I,j)}b=Math.floor(S);break}case"X":{const C=ue(v.getUTCFullYear(),0),F=ke(C),j=ke(C.nextYear()),S=v.getTime();S<F?b=C.year-1:S>=j?b=C.year+1:b=C.year;break}case"x":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),F=ke(C),j=C.nextMonth(),S=ke(j),I=v.getTime();I<F?b=C.previousMonth().month+1:I>=S?b=j.month+1:b=C.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 Ie=null;function nt(v,E,b){var C=0,F=0;if(typeof b<"u"){const ve=parseInt(b);C=Math.floor(ve/100),F=ve%100}var j=function(ve,J){var Q=ae(ve,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=Ne[Q-1];else if(J.component==="F")Q=me[Q];else throw{code:"D3133",value:J.component};J.names===U.UPPER?Q=Q.toUpperCase():J.names===U.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 de=C*100+F;if(J.integerFormat.regular)Q=V(de,J.integerFormat);else{const G=J.integerFormat.mandatoryDigits;if(G===1||G===2)Q=V(C,J.integerFormat),F!==0&&(Q+=":"+Z(F,"00"));else if(G===3||G===4)Q=V(de,J.integerFormat);else throw{code:"D3134",value:G}}de>=0&&(Q="+"+Q),J.component==="z"&&(Q="GMT"+Q),de===0&&J.presentation2==="t"&&(Q="Z")}else J.component==="P"&&J.names===U.UPPER&&(Q=Q.toUpperCase());return Q};let S;typeof E>"u"?(Ie===null&&(Ie=Ee("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),S=Ie):S=Ee(E);const I=(60*C+F)*60*1e3,X=new Date(v+I);let pe="";return S.parts.forEach(function(ve){ve.type==="literal"?pe+=ve.value:pe+=j(X,ve)}),pe}function d(v){var E={};if(v.type==="datetime")E.type="datetime",E.parts=v.parts.map(function(b){var C={};if(b.type==="literal")C.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),C.regex="",b.component==="z"&&(C.regex="GMT"),C.regex+="[-+][0-9]+",j&&(C.regex+=j.character+"[0-9]+"),C.parse=function(S){b.component==="z"&&(S=S.substring(3));let I=0,X=0;return j?(I=Number.parseInt(S.substring(0,S.indexOf(j.character))),X=Number.parseInt(S.substring(S.indexOf(j.character)+1))):S.length-1<=2?I=Number.parseInt(S):(I=Number.parseInt(S.substring(0,3)),X=Number.parseInt(S.substring(3))),I*60+X}}else if(b.integerFormat)C=d(b.integerFormat);else{C.regex="[a-zA-Z]+";var F={};if(b.component==="M"||b.component==="x")Ne.forEach(function(j,S){b.width&&b.width.max?F[j.substring(0,b.width.max)]=S+1:F[j]=S+1});else if(b.component==="F")me.forEach(function(j,S){S>0&&(b.width&&b.width.max?F[j.substring(0,b.width.max)]=S:F[j]=S)});else if(b.component==="P")F={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};C.parse=function(j){return F[j]}}return C.component=b.component,C});else{E.type="integer";const b=v.case===U.UPPER;switch(v.primary){case x.LETTERS:E.regex=b?"[A-Z]+":"[a-z]+",E.parse=function(C){return ne(C,b?"A":"a")};break;case x.ROMAN:E.regex=b?"[MDCLXVI]+":"[mdclxvi]+",E.parse=function(C){return H(b?C:C.toUpperCase())};break;case x.WORDS:E.regex="(?:"+Object.keys(A).concat("and","[\\-, ]").join("|")+")+",E.parse=function(C){return $(C.toLowerCase())};break;case x.DECIMAL:E.regex="[0-9]",v.parseWidth?E.regex+=`{${v.parseWidth}}`:E.regex+="+",v.ordinal&&(E.regex+="(?:th|st|nd|rd)"),E.parse=function(C){let F=C;return v.ordinal&&(F=C.substring(0,C.length-2)),v.regular?F=F.split(",").join(""):v.groupingSeparators.forEach(j=>{F=F.split(j.character).join("")}),v.zeroCode!==48&&(F=F.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt(F)};break;case x.SEQUENCE:throw{code:"D3130",value:v.token}}}return E}function m(v,E){if(typeof v>"u")return;const b=we(E);return d(b).parse(v)}function q(v,E){const b=Ee(E),C=d(b),F="^"+C.parts.map(X=>"("+X.regex+")").join("")+"$";var S=new RegExp(F,"i").exec(v);if(S!==null){const G={};for(let Se=1;Se<S.length;Se++){const u=C.parts[Se-1];u.parse&&(G[u.component]=u.parse(S[Se]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ue=0;const at=Se=>{Ue<<=1,Ue+=Se?1:0},Ve=Se=>!(~Se&Ue)&&!!(Se&Ue);"YXMxWwdD".split("").forEach(Se=>at(G[Se]));const qe=!Ve(161)&&Ve(130),gt=Ve(84),xt=!gt&&Ve(72);Ue=0,"PHhmsf".split("").forEach(Se=>at(G[Se]));const _t=!Ve(23)&&Ve(47),qt=(qe?"YD":gt?"XxwF":xt?"XWF":"YMD")+(_t?"Phmsf":"Hmsf"),st=this.environment.timestamp;let Rt=!1,ht=!1;if(qt.split("").forEach(Se=>{if(typeof G[Se]>"u")Rt?(G[Se]="MDd".indexOf(Se)!==-1?1:0,ht=!0):G[Se]=ae(st,Se);else if(Rt=!0,ht)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const Se=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(Se+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(gt)throw{code:"D3136"};if(xt)throw{code:"D3136"};_t&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var I=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(I-=(G.Z||G.z)*60*1e3),I}}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 Oe(v,E){if(!(typeof v>"u"))if(typeof E>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return q.call(this,v,E)}function xe(v,E,b){if(!(typeof v>"u"))return nt.call(this,v,E,b)}return{formatInteger:Z,parseInteger:m,fromMillis:xe,toMillis:Oe}})();a.exports=c},{"./utils":6}],2:[function(t,a,i){(function(s){(function(){var c=t("./utils");const f=(()=>{var w=c.isNumeric,_=c.isArrayOfStrings,R=c.isArrayOfNumbers,D=c.createSequence,T=c.isSequence,A=c.isFunction,$=c.isLambda,se=c.isPromise,ge=c.getFunctionArity,Ae=c.isDeepEqual,H=c.stringToArray;function P(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 Z(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function x(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function U(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,k){return typeof k<"u"&&k!==null&&k.toPrecision&&w(k)?Number(k.toPrecision(15)):k&&A(k)?"":k},g)}return l}}function fe(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 k=o>=0?o+l:p+o+l;return g.slice(o,k).join("")}return g.slice(o).join("")}}function we(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function _e(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ee(n){if(!(typeof n>"u"))return n.toLowerCase()}function me(n){if(!(typeof n>"u"))return n.toUpperCase()}function Ne(n){if(!(typeof n>"u"))return H(n).length}function Ke(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 ke(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)-Ne(n);if(p>0){var k=new Array(p+1).join(l);l.length>1&&(k=fe(k,0,p)),o>0?g=n+k:g=k+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 Qe(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=D();if(typeof l>"u"||l>0){var p=0,k=await ue(o,n);if(typeof k<"u")for(;typeof k<"u"&&(typeof l>"u"||p<l);)g.push({match:k.match,index:k.start,groups:k.groups}),k=await ue(k.next),p++}return g}}async function Ie(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 k;typeof l=="string"?k=function(Te){for(var Ze="",be=0,Re=l.indexOf("$",be);Re!==-1&&be<l.length;){Ze+=l.substring(be,Re),be=Re+1;var it=l.charAt(be);if(it==="$")Ze+="$",be++;else if(it==="0")Ze+=Te.match,be++;else{var Le;if(Te.groups.length===0?Le=1:Le=Math.floor(Math.log(Te.groups.length)*Math.LOG10E)+1,Re=parseInt(l.substring(be,be+Le),10),Le>1&&Re>Te.groups.length&&(Re=parseInt(l.substring(be,be+Le-1),10)),isNaN(Re))Ze+="$";else{if(Te.groups.length>0){var It=Te.groups[Re-1];typeof It<"u"&&(Ze+=It)}be+=Re.toString().length}}Re=l.indexOf("$",be)}return Ze+=l.substring(be),Ze}:k=l;var M="",W=0;if(typeof g>"u"||g>0){var K=0;if(typeof o=="string"){for(var De=n.indexOf(o,W);De!==-1&&(typeof g>"u"||K<g);)M+=n.substring(W,De),M+=l,W=De+o.length,K++,De=n.indexOf(o,W);M+=n.substring(W)}else{var he=await ue(o,n);if(typeof he<"u"){for(;typeof he<"u"&&(typeof g>"u"||K<g);){M+=n.substring(W,he.start);var Ce=k.apply(p,[he]);if(se(Ce)&&(Ce=await Ce),typeof Ce=="string")M+=Ce;else throw{code:"D3012",stack:new Error().stack,value:Ce};W=he.start+he.match.length,K++,he=await ue(he.next)}M+=n.substring(W)}else M=n}}else M=n;return M}}function nt(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new s.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 s.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 q(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 Oe(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 xe(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,k=await ue(o,n);if(typeof k<"u"){for(var M=0;typeof k<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(M,k.start)),M=k.end,k=await ue(k.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 E(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 k=[],M=p["zero-digit"].charCodeAt(0),W=M;W<M+10;W++)k.push(String.fromCharCode(W));var K=k.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),De=o.split(p["pattern-separator"]);if(De.length>2)throw{code:"D3080",stack:new Error().stack};var he=function(te){var Me=(function(){for(var Be,tt=0;tt<te.length;tt++)if(Be=te.charAt(tt),K.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(0,tt)})(),He=(function(){for(var Be,tt=te.length-1;tt>=0;tt--)if(Be=te.charAt(tt),K.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(tt+1)})(),Pe=te.substring(Me.length,te.length-He.length),Je,Et,Xe,Ct,et=te.indexOf(p["exponent-separator"],Me.length);et===-1||et>te.length-He.length?(Je=Pe,Et=void 0):(Je=Pe.substring(0,et),Et=Pe.substring(et+1));var ot=Je.indexOf(p["decimal-separator"]);return ot===-1?(Xe=Je,Ct=He):(Xe=Je.substring(0,ot),Ct=Je.substring(ot+1)),{prefix:Me,suffix:He,activePart:Pe,mantissaPart:Je,exponentPart:Et,integerPart:Xe,fractionalPart:Ct,subpicture:te}},Ce=function(te){var Me,He,Pe=te.subpicture,Je=Pe.indexOf(p["decimal-separator"]);Je!==Pe.lastIndexOf(p["decimal-separator"])&&(Me="D3081"),Pe.indexOf(p.percent)!==Pe.lastIndexOf(p.percent)&&(Me="D3082"),Pe.indexOf(p["per-mille"])!==Pe.lastIndexOf(p["per-mille"])&&(Me="D3083"),Pe.indexOf(p.percent)!==-1&&Pe.indexOf(p["per-mille"])!==-1&&(Me="D3084");var Et=!1;for(He=0;He<te.mantissaPart.length;He++){var Xe=te.mantissaPart.charAt(He);if(k.indexOf(Xe)!==-1||Xe===p.digit){Et=!0;break}}Et||(Me="D3085");var Ct=te.activePart.split("").map(function(Be){return K.indexOf(Be)===-1?"p":"a"}).join("");Ct.indexOf("p")!==-1&&(Me="D3086"),Je!==-1?(Pe.charAt(Je-1)===p["grouping-separator"]||Pe.charAt(Je+1)===p["grouping-separator"])&&(Me="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Pe.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var et=te.integerPart.indexOf(p.digit);et!==-1&&te.integerPart.substring(0,et).split("").filter(function(Be){return k.indexOf(Be)>-1}).length>0&&(Me="D3090"),et=te.fractionalPart.lastIndexOf(p.digit),et!==-1&&te.fractionalPart.substring(et).split("").filter(function(Be){return k.indexOf(Be)>-1}).length>0&&(Me="D3091");var ot=typeof te.exponentPart=="string";if(ot&&te.exponentPart.length>0&&(Pe.indexOf(p.percent)!==-1||Pe.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),ot&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Be){return k.indexOf(Be)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Te=function(te){var Me=function(ze,hr){for(var Gt=[],vt=ze.indexOf(p["grouping-separator"]);vt!==-1;){var pr=(hr?ze.substring(0,vt):ze.substring(vt)).split("").filter(function($t){return k.indexOf($t)!==-1||$t===p.digit}).length;Gt.push(pr),vt=te.integerPart.indexOf(p["grouping-separator"],vt+1)}return Gt},He=Me(te.integerPart),Pe=function(ze){if(ze.length===0)return 0;for(var hr=function(pr,$t){return $t===0?pr:hr($t,pr%$t)},Gt=ze.reduce(hr),vt=1;vt<=ze.length;vt++)if(ze.indexOf(vt*Gt)===-1)return 0;return Gt},Je=Pe(He),Et=Me(te.fractionalPart,!0),Xe=te.integerPart.split("").filter(function(ze){return k.indexOf(ze)!==-1}).length,Ct=Xe,et=te.fractionalPart.split(""),ot=et.filter(function(ze){return k.indexOf(ze)!==-1}).length,Be=et.filter(function(ze){return k.indexOf(ze)!==-1||ze===p.digit}).length,tt=typeof te.exponentPart=="string";Xe===0&&Be===0&&(tt?(ot=1,Be=1):Xe=1),tt&&Xe===0&&te.integerPart.indexOf(p.digit)!==-1&&(Xe=1),Xe===0&&ot===0&&(ot=1);var Qr=0;return tt&&(Qr=te.exponentPart.split("").filter(function(ze){return k.indexOf(ze)!==-1}).length),{integerPartGroupingPositions:He,regularGrouping:Je,minimumIntegerPartSize:Xe,scalingFactor:Ct,prefix:te.prefix,fractionalPartGroupingPositions:Et,minimumFactionalPartSize:ot,maximumFactionalPartSize:Be,minimumExponentSize:Qr,suffix:te.suffix,picture:te.subpicture}},Ze=De.map(he);Ze.forEach(Ce);var be=Ze.map(Te),Re=p["minus-sign"],it=p["zero-digit"],Le=p["decimal-separator"],It=p["grouping-separator"];be.length===1&&(be.push(JSON.parse(JSON.stringify(be[0]))),be[1].prefix=Re+be[1].prefix);var Fe;n>=0?Fe=be[0]:Fe=be[1];var Wt;Fe.picture.indexOf(p.percent)!==-1?Wt=n*100:Fe.picture.indexOf(p["per-mille"])!==-1?Wt=n*1e3:Wt=n;var Ot,Ft;if(Fe.minimumExponentSize===0)Ot=Wt;else{var mn=Math.pow(10,Fe.scalingFactor),yn=Math.pow(10,Fe.scalingFactor-1);for(Ot=Wt,Ft=0;Ot<yn;)Ot*=10,Ft-=1;for(;Ot>mn;)Ot/=10,Ft+=1}var gn=I(Ot,Fe.maximumFactionalPartSize),Xr=function(te,Me){var He=Math.abs(te).toFixed(Me);return it!=="0"&&(He=He.split("").map(function(Pe){return Pe>="0"&&Pe<="9"?k[Pe.charCodeAt(0)-48]:Pe}).join("")),He},oe=Xr(gn,Fe.maximumFactionalPartSize),We=oe.indexOf(".");for(We===-1?oe=oe+Le:oe=oe.replace(".",Le);oe.charAt(0)===it;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===it;)oe=oe.substring(0,oe.length-1);We=oe.indexOf(Le);var Ht=Fe.minimumIntegerPartSize-We,Kr=Fe.minimumFactionalPartSize-(oe.length-We-1);if(oe=(Ht>0?new Array(Ht+1).join(it):"")+oe,oe=oe+(Kr>0?new Array(Kr+1).join(it):""),We=oe.indexOf(Le),Fe.regularGrouping>0)for(var vn=Math.floor((We-1)/Fe.regularGrouping),fr=1;fr<=vn;fr++)oe=[oe.slice(0,We-fr*Fe.regularGrouping),It,oe.slice(We-fr*Fe.regularGrouping)].join("");else Fe.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,We-te),It,oe.slice(We-te)].join(""),We++});if(We=oe.indexOf(Le),Fe.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+We+1),It,oe.slice(te+We+1)].join("")}),We=oe.indexOf(Le),(Fe.picture.indexOf(Le)===-1||We===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Ft<"u"){var dr=Xr(Ft,0);Ht=Fe.minimumExponentSize-dr.length,Ht>0&&(dr=new Array(Ht+1).join(it)+dr),oe=oe+p["exponent-separator"]+(Ft<0?Re:"")+dr}return oe=Fe.prefix+oe+Fe.suffix,oe}}function b(n,o){if(!(typeof n>"u")){if(n=I(n),typeof o>"u"?o=10:o=I(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function C(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 F(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 S(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function I(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 X(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 pe(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 ve(){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):w(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 de(n,o,l,g){var p=[o],k=ge(n);return k>=2&&p.push(l),k>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=de(o,n[g],g,n),k=await o.apply(this,p);typeof k<"u"&&l.push(k)}return l}}async function Ue(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=n[g],k=de(o,p,g,n),M=await o.apply(this,k);J(M)&&l.push(p)}return l}}async function at(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var k=n[p],M=!0;if(typeof o<"u"){var W=de(o,k,p,n),K=await o.apply(this,W);M=J(K)}if(M)if(!l)g=k,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function Ve(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(k){return Array.isArray(k)?k.length:0})),g=0;g<l;g++){var p=o.map(k=>k[g]);n.push(p)}return n}async function $e(n,o,l){if(!(typeof n>"u")){var g,p=ge(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var k;for(typeof l>"u"&&n.length>0?(g=n[0],k=1):(g=l,k=0);k<n.length;){var M=[g,n[k]];p>=3&&M.push(k),p>=4&&M.push(n),g=await o.apply(this,M),k++}return g}}function qe(n){var o=D();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=qe(g);p.forEach(function(k){l[k]=!0})}),o=qe(l)}else n!==null&&typeof n=="object"&&!A(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function gt(n,o){var l;if(Array.isArray(n)){l=D();for(var g=0;g<n.length;g++){var p=gt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(k=>l.push(k)):l.push(p))}}else n!==null&&typeof n=="object"&&!A(n)&&(l=n[o]);return l}function xt(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=D(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function ur(n){return!(typeof n>"u")}function _t(n){var o=D();if(Array.isArray(n))n.forEach(function(p){o=xt(o,_t(p))});else if(n!==null&&typeof n=="object"&&!$(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function L(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function lr(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 qt(n,o){var l=D();for(var g in n){var p=de(o,n[g],g,n),k=await o.apply(this,p);typeof k<"u"&&l.push(k)}return l}function st(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Rt(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function ht(n){if(n!==void 0)return n===null?"null":w(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":A(n)?"function":"object"}async function Se(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,W){return M>W}}else l=o;var g=async function(M,W){var K=async function(he,Ce,Te){Ce.length===0?Array.prototype.push.apply(he,Te):Te.length===0?Array.prototype.push.apply(he,Ce):await l(Ce[0],Te[0])?(he.push(Te[0]),await K(he,Ce,Te.slice(1))):(he.push(Ce[0]),await K(he,Ce.slice(1),Te))},De=[];return await K(De,M,W),De},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var W=Math.floor(M.length/2),K=M.slice(0,W),De=M.slice(W);return K=await p(K),De=await p(De),await g(K,De)},k=await p(n);return k}}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=T(n)?D():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,k=0;k<o.length;k++)if(Ae(g,o[k])){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],k=de(o,p,g,n),M=await o.apply(this,k);J(M)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:P,count:ne,max:Z,min:x,average:U,string:V,substring:fe,substringBefore:we,substringAfter:_e,lowercase:Ee,uppercase:me,length:Ne,trim:Ke,pad:ke,match:ae,contains:Qe,replace:Ie,split:xe,join:v,formatNumber:E,formatBase:b,number:C,floor:j,ceil:S,round:I,abs:F,sqrt:X,power:pe,random:ve,boolean:J,not:Q,map:G,zip:Ve,filter:Ue,single:at,foldLeft:$e,sift:y,keys:qe,lookup:gt,append:xt,exists:ur,spread:_t,merge:L,reverse:lr,each:qt,error:st,assert:Rt,type:ht,sort:Se,shuffle:u,distinct:h,base64encode:nt,base64decode:d,encodeUrlComponent:m,encodeUrl:q,decodeUrlComponent:le,decodeUrl:Oe}})();a.exports=f}).call(this)}).call(this,typeof an<"u"?an:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,a,i){var s=t("./datetime"),c=t("./functions"),f=t("./utils"),w=t("./parser"),_=t("./signature"),R=(function(){var D=f.isNumeric,T=f.isArrayOfStrings,A=f.isArrayOfNumbers,$=f.createSequence,se=f.isSequence,ge=f.isFunction,Ae=f.isLambda,H=f.isIterable,P=f.isPromise,ne=f.getFunctionArity,Z=f.isDeepEqual,x=st(null);async function U(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 Ne(u,h,y);break;case"unary":n=await Ke(u,h,y);break;case"name":n=ke(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=Qe(u,h);break;case"descendant":n=Ie(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 S(u,h,y);break;case"bind":n=await F(u,h,y);break;case"regex":n=I(u);break;case"function":n=await de(u,h,y);break;case"variable":n=X(u,h,y);break;case"lambda":n=at(u,h,y);break;case"partial":n=await Ve(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=ve(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await me(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await E(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=$(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var k=u.steps[p];if(k.tuple&&(l=!0),p===0&&k.consarray?o=await U(k,n,y):l?g=await Ee(k,n,g,y):o=await we(k,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof k.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=$(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=$(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await E(u.group,l?g:o,y)),o}function fe(u,h){var y=st(u);for(const n in h)y.bind(n,h[n]);return y}async function we(u,h,y,n){var o;if(u.type==="sort")return o=await pe(u,h,y),u.stages&&(o=await _e(u.stages,o,y)),o;o=$();for(var l=0;l<h.length;l++){var g=await U(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await me(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var k=$();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?k=o[0]:o.forEach(function(M){!Array.isArray(M)||M.cons?k.push(M):M.forEach(W=>k.push(W))}),k}async function _e(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await me(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 Ee(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await pe(u,y,n);else{var l=await pe(u,h,n);o=$(),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 _e(u.stages,o,n)),o}o=$(),o.tupleStream=!0;var k=n;y===void 0&&(y=h.map(De=>({"@":De})));for(var M=0;M<y.length;M++){k=fe(n,y[M]);var W=await U(u,y[M]["@"],k);if(typeof W<"u"){Array.isArray(W)||(W=[W]);for(var K=0;K<W.length;K++)p={},Object.assign(p,y[M]),W.tupleStream?Object.assign(p,W[K]):(u.focus?(p[u.focus]=W[K],p["@"]=y[M]["@"]):p["@"]=W[K],u.index&&(p[u.index]=K),u.ancestor&&(p[u.ancestor.label]=y[M]["@"])),o.push(p)}}return u.stages&&(o=await _e(u.stages,o,n)),o}async function me(u,h,y){var n=$();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=$(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=fe(y,l));var k=await U(u,g,p);D(k)&&(k=[k]),A(k)?k.forEach(function(W){var K=Math.floor(W);K<0&&(K=h.length+K),K===o&&n.push(l)}):c.boolean(k)&&n.push(l)}return n}async function Ne(u,h,y){var n,o=await U(u.lhs,h,y),l=u.value,g=async()=>await U(u.rhs,h,y);if(l==="and"||l==="or")try{return await Oe(o,g,l)}catch(k){throw k.position=u.position,k.token=l,k}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=q(o,p,l);break;case"&":n=v(o,p);break;case"..":n=C(o,p);break;case"in":n=le(o,p);break}}catch(k){throw k.position=u.position,k.token=l,k}return n}async function Ke(u,h,y){var n;switch(u.value){case"-":if(n=await U(u.expression,h,y),typeof n>"u")n=void 0;else if(D(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,k)=>(y.isParallelCall=k>0,[p,await U(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 E(u,h,y);break}return n}function ke(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function Qe(u,h){var y=$();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 Ie(u,h){var y,n=$();return typeof h<"u"&&(nt(h,n),n.length===1?y=n[0]:y=n),y}function nt(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){nt(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){nt(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!D(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!D(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=Z(u,h);break;case"!=":n=!Z(u,h);break}return n}function q(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 Oe(u,h,y){var n,o=xe(u);switch(y){case"and":n=o&&xe(await h());break;case"or":n=o||xe(await h());break}return n}function xe(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 E(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=$(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],k=l?fe(y,p):y,M=0;M<u.lhs.length;M++){var W=u.lhs[M],K=await U(W[0],l?p["@"]:p,k);if(typeof K!="string"&&K!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:K};if(K!==void 0){var De={data:p,exprIndex:M};if(o.hasOwnProperty(K)){if(o[K].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:u.position,value:K};o[K].data=c.append(o[K].data,p)}else o[K]=De}}let he=await Promise.all(Object.keys(o).map(async(Te,Ze)=>{let be=o[Te];var Re=be.data,it=y;if(l){var Le=b(be.data);Re=Le["@"],delete Le["@"],it=fe(y,Le)}return y.isParallelCall=Ze>0,[Te,await U(u.lhs[be.exprIndex][1],Re,it)]}));for(let Te of he){var[K,Ce]=await Te;typeof Ce<"u"&&(n[K]=Ce)}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 C(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 F(u,h,y){var n=await U(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await U(u.condition,h,y);return c.boolean(o)?n=await U(u.then,h,y):typeof u.else<"u"&&(n=await U(u.else,h,y)),n}async function S(u,h,y){for(var n,o=st(y),l=0;l<u.expressions.length;l++)n=await U(u.expressions[l],h,o);return n}function I(u){var h=new Se.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 k=y(n,h.lastIndex);if(k&&k.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return k}}}return l};return y}function X(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function pe(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(k,M){for(var W=0,K=0;W===0&&K<u.terms.length;K++){var De=u.terms[K],he=k,Ce=y;l&&(he=k["@"],Ce=fe(y,k));var Te=await U(De.expression,he,Ce);he=M,Ce=y,l&&(he=M["@"],Ce=fe(y,M));var Ze=await U(De.expression,he,Ce),be=typeof Te,Re=typeof Ze;if(be==="undefined"){W=Re==="undefined"?0:1;continue}if(Re==="undefined"){W=-1;continue}if(!(be==="string"||be==="number")||!(Re==="string"||Re==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:be==="string"||be==="number"?Ze:Te};if(be!==Re)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Te,value2:Ze};Te!==Ze&&(Te<Ze?W=-1:W=1,De.descending===!0&&(W=-W))}return W===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function ve(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!ge(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await U(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var k=0;k<p.length;k++){var M=p[k];if(M&&(M.isPrototypeOf(g)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var W=await U(u.update,M,y),K=typeof W;if(K!=="undefined"){if(K!=="object"||W===null||Array.isArray(W))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:W};for(var De in W)M[De]=W[De]}if(typeof u.delete<"u"){var he=await U(u.delete,M,y);if(typeof he<"u"){var Ce=he;if(Array.isArray(he)||(he=[he]),!T(he))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ce};for(var Te=0;Te<he.length;Te++)typeof M=="object"&&M!==null&&delete M[he[Te]]}}}}return g}};return L(n,"<(oa):o>")}var J=w("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await U(u.lhs,h,y);if(u.rhs.type==="function")n=await de(u.rhs,h,y,{context:o});else{var l=await U(u.rhs,h,y);if(!ge(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(ge(o)){var g=await U(J,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function de(u,h,y,n){var o,l=await U(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 U(u.arguments[p],h,y);if(ge(M)){const W=async function(...K){return await G(M,K,null,y)};W.arity=ne(M),g.push(W)}else g.push(M)}var k=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=k,l.position=u.position),o=await G(l,g,h,y)}catch(M){throw M.position||(M.position=u.position),M.token||(M.token=k),M}return o}async function G(u,h,y,n){var o;for(o=await Ue(u,h,y,n);Ae(o)&&o.thunk===!0;){var l=await U(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 U(o.body.arguments[p],o.input,o.environment));o=await Ue(l,g,y,n)}return o}async function Ue(u,h,y,n){var o;try{var l=h;if(u&&(l=$e(u.signature,h,y)),Ae(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),P(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),P(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 at(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 Ve(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 U(g,h,y))}var p=await U(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(Ae(p))n=gt(p,o);else if(p&&p._jsonata_function===!0)n=xt(p.implementation,o);else if(typeof p=="function")n=xt(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 $e(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=st(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await ur(u.body,n):y=await U(u.body,u.input,n),y}function gt(u,h){var y=st(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 xt(u,h){var y=_t(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=w(n);o.body=u;var l=gt(o,h);return l}async function ur(u,h){var y=_t(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return P(l)&&(l=await l),l}function _t(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function L(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=_(h)),y}async function lr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=$(y),y.outerWrapper=!0));try{var n=w(u,!1)}catch(l){throw ht(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await U(n,y,this.environment)}catch(l){throw ht(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function qt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function st(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}x.bind("sum",L(c.sum,"<a<n>:n>")),x.bind("count",L(c.count,"<a:n>")),x.bind("max",L(c.max,"<a<n>:n>")),x.bind("min",L(c.min,"<a<n>:n>")),x.bind("average",L(c.average,"<a<n>:n>")),x.bind("string",L(c.string,"<x-b?:s>")),x.bind("substring",L(c.substring,"<s-nn?:s>")),x.bind("substringBefore",L(c.substringBefore,"<s-s:s>")),x.bind("substringAfter",L(c.substringAfter,"<s-s:s>")),x.bind("lowercase",L(c.lowercase,"<s-:s>")),x.bind("uppercase",L(c.uppercase,"<s-:s>")),x.bind("length",L(c.length,"<s-:n>")),x.bind("trim",L(c.trim,"<s-:s>")),x.bind("pad",L(c.pad,"<s-ns?:s>")),x.bind("match",L(c.match,"<s-f<s:o>n?:a<o>>")),x.bind("contains",L(c.contains,"<s-(sf):b>")),x.bind("replace",L(c.replace,"<s-(sf)(sf)n?:s>")),x.bind("split",L(c.split,"<s-(sf)n?:a<s>>")),x.bind("join",L(c.join,"<a<s>s?:s>")),x.bind("formatNumber",L(c.formatNumber,"<n-so?:s>")),x.bind("formatBase",L(c.formatBase,"<n-n?:s>")),x.bind("formatInteger",L(s.formatInteger,"<n-s:s>")),x.bind("parseInteger",L(s.parseInteger,"<s-s:n>")),x.bind("number",L(c.number,"<(nsb)-:n>")),x.bind("floor",L(c.floor,"<n-:n>")),x.bind("ceil",L(c.ceil,"<n-:n>")),x.bind("round",L(c.round,"<n-n?:n>")),x.bind("abs",L(c.abs,"<n-:n>")),x.bind("sqrt",L(c.sqrt,"<n-:n>")),x.bind("power",L(c.power,"<n-n:n>")),x.bind("random",L(c.random,"<:n>")),x.bind("boolean",L(c.boolean,"<x-:b>")),x.bind("not",L(c.not,"<x-:b>")),x.bind("map",L(c.map,"<af>")),x.bind("zip",L(c.zip,"<a+>")),x.bind("filter",L(c.filter,"<af>")),x.bind("single",L(c.single,"<af?>")),x.bind("reduce",L(c.foldLeft,"<afj?:j>")),x.bind("sift",L(c.sift,"<o-f?:o>")),x.bind("keys",L(c.keys,"<x-:a<s>>")),x.bind("lookup",L(c.lookup,"<x-s:x>")),x.bind("append",L(c.append,"<xx:a>")),x.bind("exists",L(c.exists,"<x:b>")),x.bind("spread",L(c.spread,"<x-:a<o>>")),x.bind("merge",L(c.merge,"<a<o>:o>")),x.bind("reverse",L(c.reverse,"<a:a>")),x.bind("each",L(c.each,"<o-f:a>")),x.bind("error",L(c.error,"<s?:x>")),x.bind("assert",L(c.assert,"<bs?:x>")),x.bind("type",L(c.type,"<x:s>")),x.bind("sort",L(c.sort,"<af?:a>")),x.bind("shuffle",L(c.shuffle,"<a:a>")),x.bind("distinct",L(c.distinct,"<x:x>")),x.bind("base64encode",L(c.base64encode,"<s-:s>")),x.bind("base64decode",L(c.base64decode,"<s-:s>")),x.bind("encodeUrlComponent",L(c.encodeUrlComponent,"<s-:s>")),x.bind("encodeUrl",L(c.encodeUrl,"<s-:s>")),x.bind("decodeUrlComponent",L(c.decodeUrlComponent,"<s-:s>")),x.bind("decodeUrl",L(c.decodeUrl,"<s-:s>")),x.bind("eval",L(lr,"<sx?:x>")),x.bind("toMillis",L(s.toMillis,"<s-s?:n>")),x.bind("fromMillis",L(s.fromMillis,"<n-s?s?:s>")),x.bind("clone",L(qt,"<(oa)-:o>"));var Rt={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(u){var h=Rt[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 Se(u,h){var y,n;try{y=w(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw ht(g),g}var o=st(x),l=new Date;return o.bind("now",L(function(g,p){return s.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",L(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?Se.RegexEngine=h.RegexEngine:Se.RegexEngine=RegExp,{evaluate:async function(g,p,k){if(typeof n<"u"){var M={code:"S0500",position:0};throw ht(M),M}if(typeof p<"u"){var W;W=st(o);for(var K in p)W.bind(K,p[K])}else W=o;W.bind("$",g),l=new Date,W.timestamp=l,Array.isArray(g)&&!se(g)&&(g=$(g),g.outerWrapper=!0);var De;try{return De=await U(y,g,W),typeof k=="function"&&k(null,De),De}catch(he){throw ht(he),he}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,k){var M=L(p,k);o.bind(g,M)},ast:function(){return y},errors:function(){return n}}}return Se.parser=w,Se})();a.exports=R},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,a,i){var s=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},w={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},_=function(D){var T=0,A=D.length,$=function(Ae,H){var P={type:Ae,value:H,position:T};return P},se=function(){for(var Ae=T,H=0,P,ne,Z=function(U){if(D.charAt(U)==="/"&&H===0){for(var V=0;D.charAt(U-(V+1))==="\\";)V++;if(V%2===0)return!0}return!1};T<A;){var x=D.charAt(T);if(Z(T)){if(P=D.substring(Ae,T),P==="")throw{code:"S0301",stack:new Error().stack,position:T};for(T++,x=D.charAt(T),Ae=T;x==="i"||x==="m";)T++,x=D.charAt(T);return ne=D.substring(Ae,T)+"g",new RegExp(P,ne)}(x==="("||x==="["||x==="{")&&D.charAt(T-1)!=="\\"&&H++,(x===")"||x==="]"||x==="}")&&D.charAt(T-1)!=="\\"&&H--,T++}throw{code:"S0302",stack:new Error().stack,position:T}},ge=function(Ae){if(T>=A)return null;for(var H=D.charAt(T);T<A&&`
|
|
3
|
+
\r\v`.indexOf(H)>-1;)T++,H=D.charAt(T);if(H==="/"&&D.charAt(T+1)==="*"){var P=T;for(T+=2,H=D.charAt(T);!(H==="*"&&D.charAt(T+1)==="/");)if(H=D.charAt(++T),T>=A)throw{code:"S0106",stack:new Error().stack,position:P};return T+=2,H=D.charAt(T),ge(Ae)}if(Ae!==!0&&H==="/")return T++,$("regex",se());if(H==="."&&D.charAt(T+1)===".")return T+=2,$("operator","..");if(H===":"&&D.charAt(T+1)==="=")return T+=2,$("operator",":=");if(H==="!"&&D.charAt(T+1)==="=")return T+=2,$("operator","!=");if(H===">"&&D.charAt(T+1)==="=")return T+=2,$("operator",">=");if(H==="<"&&D.charAt(T+1)==="=")return T+=2,$("operator","<=");if(H==="*"&&D.charAt(T+1)==="*")return T+=2,$("operator","**");if(H==="~"&&D.charAt(T+1)===">")return T+=2,$("operator","~>");if(H==="?"&&D.charAt(T+1)===":")return T+=2,$("operator","?:");if(H==="?"&&D.charAt(T+1)==="?")return T+=2,$("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return T++,$("operator",H);if(H==='"'||H==="'"){var ne=H;T++;for(var Z="";T<A;){if(H=D.charAt(T),H==="\\")if(T++,H=D.charAt(T),Object.prototype.hasOwnProperty.call(w,H))Z+=w[H];else if(H==="u"){var x=D.substr(T+1,4);if(/^[0-9a-fA-F]+$/.test(x)){var U=parseInt(x,16);Z+=String.fromCharCode(U),T+=4}else throw{code:"S0104",stack:new Error().stack,position:T}}else throw{code:"S0103",stack:new Error().stack,position:T,token:H};else{if(H===ne)return T++,$("string",Z);Z+=H}T++}throw{code:"S0101",stack:new Error().stack,position:T}}var V=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,fe=V.exec(D.substring(T));if(fe!==null){var we=parseFloat(fe[0]);if(!isNaN(we)&&isFinite(we))return T+=fe[0].length,$("number",we);throw{code:"S0102",stack:new Error().stack,position:T,token:fe[0]}}var _e;if(H==="`"){T++;var Ee=D.indexOf("`",T);if(Ee!==-1)return _e=D.substring(T,Ee),T=Ee+1,$("name",_e);throw T=A,{code:"S0105",stack:new Error().stack,position:T}}for(var me=T,Ne;;)if(Ne=D.charAt(me),me===A||`
|
|
4
|
+
\r\v`.indexOf(Ne)>-1||Object.prototype.hasOwnProperty.call(f,Ne)){if(D.charAt(T)==="$")return _e=D.substring(T+1,me),T=me,$("variable",_e);switch(_e=D.substring(T,me),T=me,_e){case"or":case"in":case"and":return $("operator",_e);case"true":return $("value",!0);case"false":return $("value",!1);case"null":return $("value",null);default:return T===A&&_e===""?null:$("name",_e)}}else me++};return ge},R=function(D,T){var A,$,se={},ge=[],Ae=function(){var d=[];A.id!=="(end)"&&d.push({type:A.type,value:A.value,position:A.position});for(var m=$();m!==null;)d.push(m),m=$();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(T)return d.remaining=Ae(),d.type="error",ge.push(d),d;throw d.stack=new Error().stack,d}},P=function(d,m){var q=se[d];return m=m||0,q?m>=q.lbp&&(q.lbp=m):(q=Object.create(H),q.id=q.value=d,q.lbp=m,se[d]=q),q},ne=function(d){if(T){d.remaining=Ae(),ge.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},Z=function(d,m){if(d&&A.id!==d){var q;A.id==="(end)"?q="S0203":q="S0202";var le={code:q,position:A.position,token:A.value,value:d};return ne(le)}var Oe=$(m);if(Oe===null)return A=se["(end)"],A.position=D.length,A;var xe=Oe.value,v=Oe.type,E;switch(v){case"name":case"variable":E=se["(name)"];break;case"operator":if(E=se[xe],!E)return ne({code:"S0204",stack:new Error().stack,position:Oe.position,token:xe});break;case"string":case"number":case"value":E=se["(literal)"];break;case"regex":v="regex",E=se["(regex)"];break;default:return ne({code:"S0205",stack:new Error().stack,position:Oe.position,token:xe})}return A=Object.create(E),A.value=xe,A.type=v,A.position=Oe.position,A},x=function(d){var m,q=A;for(Z(null,!0),m=q.nud();d<A.lbp;)q=A,Z(),m=q.led(m);return m},U=function(d){var m=P(d,0);m.nud=function(){return this}},V=function(d,m,q){var le=m||f[d],Oe=P(d,le);return Oe.led=q||function(xe){return this.lhs=xe,this.rhs=x(le),this.type="binary",this},Oe},fe=function(d,m,q){var le=P(d,m);return le.led=q,le},we=function(d,m){var q=P(d);return q.nud=m||function(){return this.expression=x(70),this.type="unary",this},q};U("(end)"),U("(name)"),U("(literal)"),U("(regex)"),P(":"),P(";"),P(","),P(")"),P("]"),P("}"),P(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),U("and"),U("or"),U("in"),we("-"),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=x(0),this}),fe("(error)",10,function(d){return this.lhs=d,this.error=A.error,this.remaining=Ae(),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}),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),Z("?")):this.arguments.push(x(0)),A.id===",";)Z(",");if(Z(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(xe,v){if(xe.type!=="variable")return ne({code:"S0208",stack:new Error().stack,position:xe.position,token:xe.value,value:v+1})}),this.type="lambda",A.id==="<"){for(var m=A.position,q=1,le="<";q>0&&A.id!=="{"&&A.id!=="(end)";){var Oe=Z();Oe.id===">"?q--:Oe.id==="<"&&q++,le+=Oe.value}Z(">");try{this.signature=s(le)}catch(xe){return xe.position=m+xe.offset,ne(xe)}}Z("{"),this.body=x(0),Z("}")}return this}),we("(",function(){for(var d=[];A.id!==")"&&(d.push(x(0)),A.id===";");)Z(";");return Z(")",!0),this.type="block",this.expressions=d,this}),we("[",function(){var d=[];if(A.id!=="]")for(;;){var m=x(0);if(A.id===".."){var q={type:"binary",value:"..",position:A.position,lhs:m};Z(".."),q.rhs=x(0),m=q}if(d.push(m),A.id!==",")break;Z(",")}return Z("]",!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,Z("]"),d}else return this.lhs=d,this.rhs=x(f["]"]),this.type="binary",Z("]",!0),this}),V("^",f["^"],function(d){Z("(");for(var m=[];;){var q={descending:!1};if(A.id==="<"?Z("<"):A.id===">"&&(q.descending=!0,Z(">")),q.expression=x(0),m.push(q),A.id!==",")break;Z(",")}return Z(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var _e=function(d){var m=[];if(A.id!=="}")for(;;){var q=x(0);Z(":");var le=x(0);if(m.push([q,le]),A.id!==",")break;Z(",")}return Z("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};we("{",_e),V("{",f["{"],_e),fe(":=",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=x(f[":="]-1),this.type="binary",this)}),V("@",f["@"],function(d){return this.lhs=d,this.rhs=x(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=x(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=x(0),A.id===":"&&(Z(":"),this.else=x(0)),this}),V("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=x(0),this}),we("|",function(){return this.type="transform",this.pattern=x(0),Z("|"),this.update=x(0),A.id===","&&(Z(","),this.delete=x(0)),Z("|"),this});var Ee=function(d){var m;if(d.type==="function"&&!d.predicate){var q={type:"lambda",thunk:!0,arguments:[],position:d.position};q.body=d,m=q}else if(d.type==="condition")d.then=Ee(d.then),typeof d.else<"u"&&(d.else=Ee(d.else)),m=d;else if(d.type==="block"){var le=d.expressions.length;le>0&&(d.expressions[le-1]=Ee(d.expressions[le-1])),m=d}else m=d;return m},me=0,Ne=0,Ke=[],ke=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(Ke[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=ke(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var q=d.steps.length-1;for(m=ke(d.steps[q--],m);m.level>0&&q>=0;)m=ke(d.steps[q--],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 q=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&q.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=q:Array.prototype.push.apply(d.seekingParent,q)}},Qe=function(d){var m=d.steps.length-1,q=d.steps[m],le=typeof q.seekingParent<"u"?q.seekingParent:[];q.type==="parent"&&le.push(q.slot);for(var Oe=0;Oe<le.length;Oe++){var xe=le[Oe];for(m=d.steps.length-2;xe.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[xe]:d.seekingParent.push(xe);break}for(var v=d.steps[m--];m>=0&&v.focus&&d.steps[m].focus;)v=d.steps[m--];xe=ke(v,xe)}}},ae=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var q=ae(d.lhs);q.type==="path"?m=q:m={type:"path",steps:[q]},q.type==="parent"&&(m.seekingParent=[q.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(I){if(I.type==="number"||I.type==="value")throw{code:"S0213",stack:new Error().stack,position:I.position,value:I.value};return I.type==="string"}).forEach(function(I){I.type="name"}),m.steps.filter(function(I){return I.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var Oe=m.steps[0];Oe.type==="unary"&&Oe.value==="["&&(Oe.consarray=!0);var xe=m.steps[m.steps.length-1];xe.type==="unary"&&xe.value==="["&&(xe.consarray=!0),Qe(m);break;case"[":m=ae(d.lhs);var v=m,E="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],E="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[E]>"u"&&(v[E]=[]);var b=ae(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(I=>{I.level===1?ke(v,I):I.level--}),ue(v,b)),v[E].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(I){return[ae(I[0]),ae(I[1])]}),position:d.position};break;case"^":m=ae(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var C={type:"sort",position:d.position};C.terms=d.rhs.map(function(I){var X=ae(I.expression);return ue(C,X),{descending:I.descending,expression:X}}),m.steps.push(C),Qe(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(I){var X=ae(I);return ue(m,X),X}):d.value==="{"?m.lhs=d.lhs.map(function(I){var X=ae(I[0]);ue(m,X);var pe=ae(I[1]);return ue(m,pe),[X,pe]}):(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(I){var X=ae(I);return ue(m,X),X}),m.procedure=ae(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var F=ae(d.body);m.body=Ee(F);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(I){var X=ae(I);return ue(m,X),(X.consarray||X.type==="path"&&X.steps[0].consarray)&&(m.consarray=!0),X});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+me++,level:1,index:Ne++}},Ke.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 S={code:j,position:d.position,token:d.value};if(T)return ge.push(S),{type:"error",error:S};throw S.stack=new Error().stack,S}return d.keepArray&&(m.keepArray=!0),m};$=_(D),Z();var Ie=x(0);if(A.id!=="(end)"){var nt={code:"S0201",position:A.position,token:A.value};ne(nt)}if(Ie=ae(Ie),Ie.type==="parent"||typeof Ie.seekingParent<"u")throw{code:"S0217",token:Ie.type,position:Ie.position};return ge.length>0&&(Ie.errors=ge),Ie};return R})();a.exports=c},{"./signature":5}],5:[function(t,a,i){var s=t("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function w(_){for(var R=1,D=[],T={},A=T;R<_.length;){var $=_.charAt(R);if($===":")break;var se=function(){D.push(T),A=T,T={}},ge=function(V,fe,we,_e){for(var Ee=1,me=fe;me<V.length;)if(me++,$=V.charAt(me),$===_e){if(Ee--,Ee===0)break}else $===we&&Ee++;return me};switch($){case"s":case"n":case"b":case"l":case"o":T.regex="["+$+"m]",T.type=$,se();break;case"a":T.regex="[asnblfom]",T.type=$,T.array=!0,se();break;case"f":T.regex="f",T.type=$,se();break;case"j":T.regex="[asnblom]",T.type=$,se();break;case"x":T.regex="[asnblfom]",T.type=$,se();break;case"-":A.context=!0,A.contextRegex=new RegExp(A.regex),A.regex+="?";break;case"?":case"+":A.regex+=$;break;case"(":var Ae=ge(_,R,"(",")"),H=_.substring(R+1,Ae);if(H.indexOf("<")===-1)T.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:R};T.type="("+H+")",R=Ae,se();break;case"<":if(A.type==="a"||A.type==="f"){var P=ge(_,R,"<",">");A.subtype=_.substring(R+1,P),R=P}else throw{code:"S0401",stack:new Error().stack,value:A.type,offset:R};break}R++}var ne="^"+D.map(function(V){return"("+V.regex+")"}).join("")+"$",Z=new RegExp(ne),x=function(V){var fe;if(s.isFunction(V))fe="f";else{var we=typeof V;switch(we){case"string":fe="s";break;case"number":fe="n";break;case"boolean":fe="b";break;case"object":V===null?fe="l":Array.isArray(V)?fe="a":fe="o";break;case"undefined":default:fe="m"}}return fe},U=function(V,fe){for(var we="^",_e=0,Ee=0;Ee<D.length;Ee++){we+=D[Ee].regex;var me=fe.match(we);if(me===null)throw{code:"T0410",stack:new Error().stack,value:V[_e],index:_e+1};_e=me[0].length}throw{code:"T0410",stack:new Error().stack,value:V[_e],index:_e+1}};return{definition:_,validate:function(V,fe){var we="";V.forEach(function(Ne){we+=x(Ne)});var _e=Z.exec(we);if(_e){var Ee=[],me=0;return D.forEach(function(Ne,Ke){var ke=V[me],ue=_e[Ke+1];if(ue==="")if(Ne.context&&Ne.contextRegex){var Qe=x(fe);if(Ne.contextRegex.test(Qe))Ee.push(fe);else throw{code:"T0411",stack:new Error().stack,value:fe,index:me+1}}else Ee.push(ke),me++;else ue.split("").forEach(function(ae){if(Ne.type==="a"){if(ae==="m")ke=void 0;else{ke=V[me];var Ie=!0;if(typeof Ne.subtype<"u"){if(ae!=="a"&&ue!==Ne.subtype)Ie=!1;else if(ae==="a"&&ke.length>0){var nt=x(ke[0]);if(nt!==Ne.subtype.charAt(0))Ie=!1;else{var d=ke.filter(function(m){return x(m)!==nt});Ie=d.length===0}}}if(!Ie)throw{code:"T0412",stack:new Error().stack,value:ke,index:me+1,type:f[Ne.subtype]};ae!=="a"&&(ke=[ke])}Ee.push(ke),me++}else Ee.push(ke),me++})}),Ee}U(V,we)}}}return w})();a.exports=c},{"./utils":6}],6:[function(t,a,i){const s=(()=>{function c(P){var ne=!1;if(typeof P=="number"&&(ne=!isNaN(P),ne&&!isFinite(P)))throw{code:"D1001",value:P,stack:new Error().stack};return ne}function f(P){var ne=!1;return Array.isArray(P)&&(ne=P.filter(function(Z){return typeof Z!="string"}).length===0),ne}function w(P){var ne=!1;return Array.isArray(P)&&(ne=P.filter(function(Z){return!c(Z)}).length===0),ne}function _(){var P=[];return P.sequence=!0,arguments.length===1&&P.push(arguments[0]),P}function R(P){return P.sequence===!0&&Array.isArray(P)}function D(P){return P&&(P._jsonata_function===!0||P._jsonata_lambda===!0)||typeof P=="function"}function T(P){var ne=typeof P.arity=="number"?P.arity:typeof P.implementation=="function"?P.implementation.length:typeof P.length=="number"?P.length:P.arguments.length;return ne}function A(P){return P&&P._jsonata_lambda===!0}var $=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function se(P){return typeof P=="object"&&P!==null&&$ in P&&"next"in P&&typeof P.next=="function"}function ge(P,ne){if(P===ne)return!0;if(typeof P=="object"&&typeof ne=="object"&&P!==null&&ne!==null){if(Array.isArray(P)&&Array.isArray(ne)){if(P.length!==ne.length)return!1;for(var Z=0;Z<P.length;Z++)if(!ge(P[Z],ne[Z]))return!1;return!0}var x=Object.getOwnPropertyNames(P),U=Object.getOwnPropertyNames(ne);if(x.length!==U.length)return!1;for(x=x.sort(),U=U.sort(),Z=0;Z<x.length;Z++)if(x[Z]!==U[Z])return!1;for(Z=0;Z<x.length;Z++){var V=x[Z];if(!ge(P[V],ne[V]))return!1}return!0}return!1}function Ae(P){return typeof P=="object"&&P!==null&&"then"in P&&typeof P.then=="function"}function H(P){var ne=[];for(let Z of P)ne.push(Z);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:w,createSequence:_,isSequence:R,isFunction:D,isLambda:A,isIterable:se,getFunctionArity:T,isDeepEqual:ge,stringToArray:H,isPromise:Ae}})();a.exports=s},{}]},{},[3])(3)})})(Dr)),Dr.exports}var Si=Ai();const Di=Ti(Si),Jr=N.object({name:N.literal("data-extract"),code:N.string(),inputData:N.any().optional()});function Oi(r){return Jr.parse(r)}async function Ci(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Di(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 Pi={"get-text":Fr,"attribute-value":$r,"get-value-form":Br,"set-value-form":Ur,"clear-value-form":Zr,"element-exists":Lr,"event-click":zr,keypress:Vr,wait:qr,"save-assets":Wr,"get-element-data":Hr,scroll:Gr,"ai-parse-data":Ir,"fetch-api":Yr,"data-extract":Jr};class Ni{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=Ba(e);return await Ua(t)}case"attribute-value":{const t=La(e);return await za(t)}case"get-value-form":{const t=Va(e);return await qa(t)}case"set-value-form":{const t=Ha(e);return await Ga(t)}case"clear-value-form":{const t=Ja(e);return await Xa(t)}case"element-exists":{const t=Qa(e);return await ei(t)}case"event-click":{const t=ti(e);return await ri(t)}case"keypress":{const t=si(e);return await oi(t)}case"wait":{const t=ui(e);return await li(t)}case"save-assets":{const t=fi(e);return await di(t)}case"get-element-data":{const t=pi(e);return await mi(t)}case"scroll":{const t=gi(e);return await vi(t)}case"ai-parse-data":{const t=Da(e);return await Oa(t)}case"fetch-api":{const t=_i(e);return await Ei(t)}case"data-extract":{const t=Oi(e);return await Ci(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}}}}exports.AiParseDataBlockSchema=Ir;exports.AllBlockSchemas=Pi;exports.BaseBlockSchema=ft;exports.BlockHandler=Ni;exports.ClearValueFormsBlockSchema=Zr;exports.DataExtractBlockSchema=Jr;exports.ElementExistsBlockSchema=Lr;exports.EventClickBlockSchema=zr;exports.FetchApiBlockSchema=Yr;exports.GetAttributeValueBlockSchema=$r;exports.GetElementDataBlockSchema=Hr;exports.GetTextBlockSchema=Fr;exports.GetValueFormsBlockSchema=Br;exports.KeypressBlockSchema=Vr;exports.SaveAssetsBlockSchema=Wr;exports.Schema=Na;exports.ScrollBlockSchema=Gr;exports.SetValueFormsBlockSchema=Ur;exports.WaitBlockSchema=qr;exports.createArraySchema=Pa;exports.createSchema=Ca;
|