scordi-extension 1.14.3 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "../../../../../@crx/manifest": {
3
- "file": "assets/crx-manifest.js-DZY6Y38P.js",
3
+ "file": "assets/crx-manifest.js-B1Q3rhTS.js",
4
4
  "name": "crx-manifest.js",
5
5
  "src": "../../../../../@crx/manifest",
6
6
  "isEntry": true
@@ -9,35 +9,35 @@
9
9
  "file": "assets/internal-messages-Drf0Gb9U.js",
10
10
  "name": "internal-messages"
11
11
  },
12
- "_main.tsx-loader-FYb0LhDu.js": {
13
- "file": "assets/main.tsx-loader-FYb0LhDu.js",
14
- "src": "_main.tsx-loader-FYb0LhDu.js"
12
+ "_main.tsx-loader-CRGmwXNh.js": {
13
+ "file": "assets/main.tsx-loader-CRGmwXNh.js",
14
+ "src": "_main.tsx-loader-CRGmwXNh.js"
15
15
  },
16
- "_schemas-C8r0jYHO.js": {
17
- "file": "assets/schemas-C8r0jYHO.js",
18
- "name": "schemas"
16
+ "_types-oHwqLVs0.js": {
17
+ "file": "assets/types-oHwqLVs0.js",
18
+ "name": "types"
19
19
  },
20
20
  "src/background/index.ts": {
21
- "file": "assets/index.ts-BqxJYCmp.js",
21
+ "file": "assets/index.ts-Yg98L0Rk.js",
22
22
  "name": "index.ts",
23
23
  "src": "src/background/index.ts",
24
24
  "isEntry": true,
25
25
  "imports": [
26
26
  "_internal-messages-Drf0Gb9U.js",
27
- "_schemas-C8r0jYHO.js"
27
+ "_types-oHwqLVs0.js"
28
28
  ]
29
29
  },
30
30
  "src/blocks/index.ts": {
31
- "file": "assets/index-B9PKMhAi.js",
31
+ "file": "assets/index-BAWpTgrx.js",
32
32
  "name": "index",
33
33
  "src": "src/blocks/index.ts",
34
34
  "isDynamicEntry": true,
35
35
  "imports": [
36
- "_schemas-C8r0jYHO.js"
36
+ "_types-oHwqLVs0.js"
37
37
  ]
38
38
  },
39
39
  "src/content/main.tsx": {
40
- "file": "assets/main.tsx-BEyI95mZ.js",
40
+ "file": "assets/main.tsx-CiPjkJNz.js",
41
41
  "name": "main.tsx",
42
42
  "src": "src/content/main.tsx",
43
43
  "isEntry": true,
@@ -0,0 +1,4 @@
1
+ import{B as zt,D as Zt,E as Ht,I as _t,N as Wt,O as Vt,P as Yt,d as kt,f as Gt,h as Jt,i as Kt,j as Xt,k as Qt,m as er,p as tr,q as rr,r as nr,t as Ct,v as ar,w as or,Z as ir,x as sr,y as ur,z as cr,A as fr,C as lr,F as dr,G as pr,H as hr,J as yr,K as vr,L as gr,M as mr,Q as br,R as wr,S as kr,T as Er,U as Ar,V as Tr,W as xr,X as Sr,Y as Dr,_ as Pr,$ as Or,a0 as Cr,a1 as Mr,a2 as Fr,a3 as Nr,a4 as Ur,a as jr,b as Br,a5 as Ir,c as Tt,a6 as Rr,a7 as Lr,a8 as $r,a9 as qr,aa as zr,ab as Zr,ac as Mt,e as jt,ad as Hr,ae as _r,af as Wr,ag as Vr,ah as Yr,ai as Gr,aj as Jr,ak as Kr,al as Xr,am as Qr,an as en,l as tn,ao as rn,ap as nn,aq as an,ar as on,as as sn,at as un,au as cn,n as Bt,o as xt,av as fn,aw as ln,ax as dn,ay as pn,az as hn,aA as yn,aB as vn,aC as gn,aD as mn,aE as bn,aF as wn,aG as kn,aH as En,s as St,aI as An,aJ as Tn,aK as xn,u as Sn,aL as Dn,aM as Pn,aN as On,aO as Ft,g as Cn}from"./types-oHwqLVs0.js";const O=Object.freeze(Object.defineProperty({__proto__:null,BRAND:zt,DIRTY:Zt,EMPTY_PATH:Ht,INVALID:_t,NEVER:Wt,OK:Vt,ParseStatus:Yt,Schema:kt,ZodAny:Gt,ZodArray:Jt,ZodBigInt:Kt,ZodBoolean:Xt,ZodBranded:Qt,ZodCatch:er,ZodDate:tr,ZodDefault:rr,ZodDiscriminatedUnion:nr,ZodEffects:Ct,ZodEnum:ar,ZodError:or,get ZodFirstPartyTypeKind(){return ir},ZodFunction:sr,ZodIntersection:ur,ZodIssueCode:cr,ZodLazy:fr,ZodLiteral:lr,ZodMap:dr,ZodNaN:pr,ZodNativeEnum:hr,ZodNever:yr,ZodNull:vr,ZodNullable:gr,ZodNumber:mr,ZodObject:br,ZodOptional:wr,ZodParsedType:kr,ZodPipeline:Er,ZodPromise:Ar,ZodReadonly:Tr,ZodRecord:xr,ZodSchema:kt,ZodSet:Sr,ZodString:Dr,ZodSymbol:Pr,ZodTransformer:Ct,ZodTuple:Or,ZodType:kt,ZodUndefined:Cr,ZodUnion:Mr,ZodUnknown:Fr,ZodVoid:Nr,addIssueToContext:Ur,any:jr,array:Br,bigint:Ir,boolean:Tt,coerce:Rr,custom:Lr,date:$r,datetimeRegex:qr,defaultErrorMap:zr,discriminatedUnion:Zr,effect:Mt,enum:jt,function:Hr,getErrorMap:_r,getParsedType:Wr,instanceof:Vr,intersection:Yr,isAborted:Gr,isAsync:Jr,isDirty:Kr,isValid:Xr,late:Qr,lazy:en,literal:tn,makeIssue:rn,map:nn,nan:an,nativeEnum:on,never:sn,null:un,nullable:cn,number:Bt,object:xt,get objectUtil(){return fn},oboolean:ln,onumber:dn,optional:pn,ostring:hn,pipeline:yn,preprocess:vn,promise:gn,quotelessJson:mn,record:bn,set:wn,setErrorMap:kn,strictObject:En,string:St,symbol:An,transformer:Mt,tuple:Tn,undefined:xn,union:Sn,unknown:Dn,get util(){return Pn},void:On},Symbol.toStringTag,{value:"Module"})),Ke=xt({name:St(),selector:St(),findBy:jt(["cssSelector","xpath"]),option:xt({waitForSelector:Tt().optional(),waitSelectorTimeout:Bt().optional(),multiple:Tt().optional()})}),Mn=O.object({type:O.literal("object"),shape:O.record(O.string(),O.any())}),Fn=O.object({type:O.literal("array"),items:O.any()}),Nn=O.discriminatedUnion("type",[Mn,Fn]),Un=O.object({name:O.literal("ai-parse-data"),sourceData:O.any().optional(),schemaDefinition:Nn,prompt:O.string().optional(),model:O.string().optional(),apiKey:O.string().min(1,"OpenAI API key is required")});function jn(d){return Un.parse(d)}async function Bn(d){try{const{sourceData:c,schemaDefinition:y,prompt:E,model:b="gpt-4o-mini",apiKey:T}=d;if(c==null)throw new Error("sourceData is required for ai-parse-data block");if(!T||T.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const l=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:c,schemaDefinition:y,prompt:E,model:b,apiKey:T}});if(l.$isError)throw new Error(l.message||"AI parsing failed");return{data:l.data}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in ai-parse-data handler",data:null}}}class wt{async waitForElement(c,y,E){return new Promise(b=>{const T=Date.now(),l=async()=>{const x=await this.find(c,y);if(x&&(!Array.isArray(x)||x.length>0)){b(x);return}if(Date.now()-T>=E){b(null);return}setTimeout(l,100)};l()})}}class In extends wt{async find(c,y=document){const{selector:E,option:b}=c,{multiple:T=!1}=b||{};try{const l=this.processCustomPseudoSelectors(E,y);return T?Array.from(y.querySelectorAll(l)):y.querySelector(l)}catch(l){return console.error("CSS Selector error:",l),null}}processCustomPseudoSelectors(c,y){return/:contains\(['"]([^'"]*)['"]\)/g.test(c)?(this.markElementsWithText(y),c.replace(/:contains\(['"]([^'"]*)['"]\)/g,(T,l)=>`[data-contains="${l}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(c)?(this.markElementsWithText(y),c.replace(/:equal\(['"]([^'"]*)['"]\)/g,(T,l)=>`[data-equal="${l}"]`)):c}markElementsWithText(c){c.querySelectorAll("*").forEach(E=>{const b=E.textContent?.trim()||"";if(b){E.setAttribute("data-contains",b);const l=Array.from(E.childNodes).filter(x=>x.nodeType===Node.TEXT_NODE).map(x=>x.textContent?.trim()||"").join(" ").trim();(l&&l===b||E.children.length===0&&b)&&E.setAttribute("data-equal",b)}})}}class Rn extends wt{async find(c,y=document){const{selector:E,option:b}=c,{multiple:T=!1}=b||{};if(!E||E.trim()==="")return null;const l=E.split("|>").map(z=>z.trim());if(l.length!==2)return null;const x=l[0],$=l[1];if(!x||!$)return null;try{const z=y.querySelector(x);if(!z||!z.contentDocument)return null;const X=z.contentDocument;return T?Array.from(X.querySelectorAll($)):X.querySelector($)}catch(z){return console.error("Iframe Selector error:",z),null}}}class Ln extends wt{async find(c,y=document){const{selector:E,option:b}=c,{multiple:T=!1}=b||{};if(!E||E.trim()==="")return null;const l=E.split(">>").map($=>$.trim());let x=y;try{for(let $=0;$<l.length;$++){const z=l[$],X=$===l.length-1;if(!z)return null;if(X&&T)return Array.from(x.querySelectorAll(z));const S=x.querySelector(z);if(!S)return null;if(X)return S;if(S.shadowRoot)x=S.shadowRoot;else return null}}catch($){return console.error("Shadow DOM Selector error:",$),null}return null}}class $n extends wt{async find(c,y=document){const{selector:E,option:b}=c,{multiple:T=!1}=b||{};try{const l=y.evaluate(E,y,null,T?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(T){const x=[];for(let $=0;$<l.snapshotLength;$++){const z=l.snapshotItem($);z&&z.nodeType===Node.ELEMENT_NODE&&x.push(z)}return Promise.resolve(x.length>0?x:null)}else{const x=l.singleNodeValue;return x&&x.nodeType===Node.ELEMENT_NODE?x:null}}catch(l){return console.error("XPath error:",l),null}}}class qn{static generate(c){const y=["data-testid","aria-label","title","alt","role"];for(const T of y){const l=c.getAttribute(T);if(l&&!this.isDynamicValue(l))return`[${T}="${CSS.escape(l)}"]`}const E=c.tagName.toLowerCase(),b=c.parentElement;if(b){const T=Array.from(b.children),l=T.indexOf(c)+1;if(T.length>1)return`${E}:nth-child(${l})`}if(b){const T=this.generateParentSelector(b);if(T)return`${T} > ${E}:nth-child(${Array.from(b.children).indexOf(c)+1})`}return E}static generateParentSelector(c){const y=c.tagName.toLowerCase(),E=["data-testid","aria-label","title","alt","role"];for(const T of E){const l=c.getAttribute(T);if(l&&!this.isDynamicValue(l))return`[${T}="${CSS.escape(l)}"]`}const b=c.parentElement;if(b){const T=Array.from(b.children),l=T.indexOf(c)+1;if(T.length>1)return`${y}:nth-child(${l})`}return y}static isDynamicValue(c){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(E=>E.test(c))}}async function Ge(d,c=document){const{selector:y,findBy:E="cssSelector",option:b}=d,{waitForSelector:T=!1,waitSelectorTimeout:l=5e3}=b||{},x=zn(y,E);return T?x.waitForElement(d,c,l):x.find(d,c)}function zn(d,c){return c==="xpath"?new $n:d.includes(">>")?new Ln:d.includes("|>")?new Rn:new In}const Zn=Ke.extend({name:O.literal("get-text"),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),filterEmpty:O.boolean().optional(),scrollToCollect:O.boolean().optional(),scrollDistance:O.number().optional(),scrollWaitMs:O.number().optional(),maxScrollAttempts:O.number().optional()});function Hn(d){return Zn.parse(d)}async function _n(d){try{const{selector:c="",includeTags:y=!1,useTextContent:E=!1,regex:b,prefixText:T="",suffixText:l="",findBy:x="cssSelector",option:$,filterEmpty:z=!0,scrollToCollect:X=!1,scrollDistance:S=500,scrollWaitMs:w=300,maxScrollAttempts:A=100}=d;if(!c)throw new Error("Selector is required for get-text block");if(X&&$?.multiple)return await Wn({selector:c,findBy:x,option:$,includeTags:y,useTextContent:E,regex:b,prefixText:T,suffixText:l,filterEmpty:z,scrollDistance:S,scrollWaitMs:w,maxScrollAttempts:A});const U=await Ge({selector:c,findBy:x,option:$});if(!U)return{data:""};const Q=It(y,E,b,T,l);if(Array.isArray(U)){const ue=U.map(Q);return{data:z?ue.filter(Z=>Z.trim()!==""):ue}}else return{data:Q(U)}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in get-text handler",data:""}}}async function Wn(d){const{selector:c,findBy:y,option:E,includeTags:b,useTextContent:T,regex:l,prefixText:x,suffixText:$,filterEmpty:z,scrollDistance:X,scrollWaitMs:S,maxScrollAttempts:w}=d,A=It(b,T,l,x,$),U=new Set;let Q=0,ue=0;const ge=5;for(;Q<w;){const Z=await Ge({selector:c,findBy:y,option:E});if(Z&&Array.isArray(Z)){const B=U.size;if(Z.forEach(j=>{const R=A(j);(!z||R.trim()!=="")&&U.add(R)}),U.size===B){if(ue++,ue>=ge)break}else ue=0}const P=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:X,behavior:"auto"}),await new Promise(B=>setTimeout(B,S)),(window.pageYOffset||document.documentElement.scrollTop)===P)break;Q++}return{data:Array.from(U)}}function It(d,c,y,E="",b=""){return T=>{let l="";if(d?l=T.innerHTML:l=c?T.textContent||"":T.innerText||"",y){const x=new RegExp(y,"g"),$=l.match(x);l=$?$.join(" "):""}return l.trim()&&(l=E+l.trim()+b),l}}const Vn=Ke.extend({name:O.literal("attribute-value"),attributeName:O.string()});function Yn(d){return Vn.parse(d)}async function Gn(d){try{const{selector:c="",attributeName:y,findBy:E="cssSelector",option:b}=d;if(!c)throw new Error("Selector is required for attribute-value block");if(!y)throw new Error("Attribute name is required for attribute-value block");const T=await Ge({selector:c,findBy:E,option:b});return T?{data:Array.isArray(T)?T.map(x=>x.getAttribute(y)).filter(x=>x!==null):T.getAttribute(y)}:{data:null}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in attribute-value handler",data:null}}}const Jn=Ke.extend({name:O.literal("get-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function Kn(d){return Jn.parse(d)}async function Xn(d){try{const{selector:c="",type:y="text-field",findBy:E="cssSelector"}=d;if(!c)throw new Error("Selector is required for get-value-form block");const b=await Ge({selector:c,findBy:E,option:d.option});if(!b)throw new Error("Form element not found");return{data:Qn(b,y)}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in get-value-form handler",data:null}}}function Qn(d,c){switch(c){case"text-field":if(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)return d.value;break;case"select":if(d instanceof HTMLSelectElement)return d.value;break;case"checkbox":if(d instanceof HTMLInputElement&&d.type==="checkbox")return d.checked;break;default:throw new Error(`Unsupported form element type: ${c}`)}throw new Error(`Invalid element type for ${c}`)}const ea=Ke.extend({name:O.literal("set-value-form"),setValue:O.string(),type:O.enum(["text-field","select","checkbox"]).optional()});function ta(d){return ea.parse(d)}async function ra(d){try{const{selector:c="",setValue:y,type:E="text-field",findBy:b="cssSelector"}=d;if(!c)throw new Error("Selector is required for set-value-form block");const T=await Ge({selector:c,findBy:b,option:d.option});if(!T)throw new Error("Form element not found");return na(T,y,E),{data:"Form element updated successfully"}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in set-value-form handler",data:null}}}function na(d,c,y){switch(y){case"text-field":(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&(d.value=c,d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":d instanceof HTMLSelectElement&&(d.value=c,d.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":d instanceof HTMLInputElement&&d.type==="checkbox"&&(d.checked=c==="true"||c==="checked",d.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${y}`)}}const aa=Ke.extend({name:O.literal("clear-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function oa(d){return aa.parse(d)}async function ia(d){try{const{selector:c="",type:y="text-field",findBy:E="cssSelector"}=d;if(!c)throw new Error("Selector is required for clear-value-form block");const b=await Ge({selector:c,findBy:E,option:d.option});if(!b)throw new Error("Form element not found");return sa(b,y),{data:"Form element cleared successfully"}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in clear-value-form handler",data:null}}}function sa(d,c){switch(c){case"text-field":(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&(d.value="",d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":d instanceof HTMLSelectElement&&(d.selectedIndex=0,d.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":d instanceof HTMLInputElement&&d.type==="checkbox"&&(d.checked=!1,d.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${c}`)}}const ua=Ke.extend({name:O.literal("element-exists")});function ca(d){return ua.parse(d)}async function fa(d){try{const{selector:c="",findBy:y="cssSelector",option:E}=d;if(!c)throw new Error("Selector is required for element-exists block");return{data:await Ge({selector:c,findBy:y,option:E})!==null}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in element-exists handler",data:null}}}const la=Ke.extend({name:O.literal("event-click"),textFilter:O.object({text:O.union([O.string(),O.array(O.string())]),mode:O.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function da(d){return la.parse(d)}async function pa(d){try{const{selector:c="",findBy:y="cssSelector",option:E,textFilter:b}=d;if(!c)throw new Error("Selector is required for event-click block");const T=await Ge({selector:c,findBy:y,option:E});if(!T)throw new Error("Element not found for clicking");let l;if(Array.isArray(T))if(b){const x=ha(T,b.text,b.mode);if(!x){const $=Array.isArray(b.text)?b.text.join(", "):b.text;throw new Error(`No element found with text filter: "${$}" (mode: ${b.mode})`)}l=x}else l=T[0];else l=T;return await va(l),{data:!0}}catch(c){return console.log(c),{hasError:!0,message:c instanceof Error?c.message:"Unknown error in event-click handler",data:!1}}}function ha(d,c,y){for(const E of d){const b=ya(E),T=Array.isArray(c)?c:[c];for(const l of T){let x=!1;switch(y){case"exact":x=b===l;break;case"contains":x=b.includes(l);break;case"startsWith":x=b.startsWith(l);break;case"endsWith":x=b.endsWith(l);break;case"regex":try{x=new RegExp(l).test(b)}catch{console.warn("Invalid regex pattern:",l);continue}break}if(x)return E}}return null}function ya(d){if(d.innerText)return d.innerText.trim();if(d.textContent)return d.textContent.trim();if(d instanceof HTMLInputElement&&d.value)return d.value.trim();const c=d.getAttribute("placeholder");if(c)return c.trim();const y=d.getAttribute("title");if(y)return y.trim();const E=d.getAttribute("aria-label");return E?E.trim():""}async function va(d){d.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(b=>setTimeout(b,50)),d.focus&&d.focus();const c=d.getBoundingClientRect(),y=c.left+c.width/2,E=c.top+c.height/2;try{const b=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:y,y:E}});if(b&&!b.$isError)console.log("[EventClick] CDP click successful:",b);else throw new Error(b?.message||"CDP click failed")}catch(b){console.error("[EventClick] CDP click failed, falling back to native click:",b),d.click&&d.click()}await new Promise(b=>setTimeout(b,50))}const ga=O.object({name:O.literal("keypress"),key:O.string(),code:O.string().optional(),keyCode:O.number().optional(),modifiers:O.array(O.enum(["Alt","Control","Meta","Shift"])).optional()});function ma(d){return ga.parse(d)}async function ba(d){try{const{key:c,code:y,keyCode:E,modifiers:b=[]}=d;return await wa(c,y,E,b),{data:!0}}catch(c){return console.log(c),{hasError:!0,message:c instanceof Error?c.message:"Unknown error in keypress handler",data:!1}}}async function wa(d,c,y,E=[]){try{const b=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:d,code:c||d,keyCode:y||Et(d),modifiers:E}});if(b&&!b.$isError)console.log("[Keypress] CDP keypress successful:",b);else throw new Error(b?.message||"CDP keypress failed")}catch(b){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",b);const T=new KeyboardEvent("keydown",{key:d,code:c||d,keyCode:y||Et(d),bubbles:!0,cancelable:!0,...Nt(E)}),l=new KeyboardEvent("keyup",{key:d,code:c||d,keyCode:y||Et(d),bubbles:!0,cancelable:!0,...Nt(E)});document.dispatchEvent(T),await new Promise(x=>setTimeout(x,10)),document.dispatchEvent(l)}await new Promise(b=>setTimeout(b,50))}function Et(d){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[d]||0}function Nt(d){return{altKey:d.includes("Alt"),ctrlKey:d.includes("Control"),metaKey:d.includes("Meta"),shiftKey:d.includes("Shift")}}const ka=O.object({name:O.literal("wait"),duration:O.number().min(0)});function Ea(d){return ka.parse(d)}async function Aa(d){try{const{duration:c}=d;return console.log(`[Wait] Waiting for ${c}ms...`),await new Promise(y=>setTimeout(y,c)),console.log(`[Wait] Wait completed after ${c}ms`),{data:!0}}catch(c){return console.log(c),{hasError:!0,message:c instanceof Error?c.message:"Unknown error in wait handler",data:!1}}}const Ta=Ke.extend({name:O.literal("save-assets")});function xa(d){return Ta.parse(d)}async function Sa(d){try{const{selector:c="img, audio, video, source",findBy:y="cssSelector",option:E}=d,b=await Ge({selector:c,findBy:y,option:E});if(!b||!Array.isArray(b))return{data:[]};const T=[];return b.forEach(l=>{let x="";(l instanceof HTMLImageElement||l instanceof HTMLAudioElement||l instanceof HTMLVideoElement||l instanceof HTMLSourceElement)&&(x=l.src),x&&!T.includes(x)&&T.push(x)}),{data:T}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in save-assets handler",data:null}}}class Da{static generate(c){const y=[];let E=c;for(;E&&E.nodeType===Node.ELEMENT_NODE;){let b=E.tagName.toLowerCase();const T=Array.from(E.parentElement?.children||[]).filter(x=>x.tagName===E.tagName);if(T.length>1){const x=T.indexOf(E)+1;b+=`[${x}]`}const l=this.getStableAttributes(E);l.length>0&&(b+=`[@${l.join(" and @")}]`),y.unshift(b),E=E.parentElement}return"/"+y.join("/")}static getStableAttributes(c){const y=[],E=["data-testid","aria-label","title","alt","role"];for(const b of E){const T=c.getAttribute(b);T&&!this.isDynamicValue(T)&&y.push(`${b}="${T}"`)}return y}static isDynamicValue(c){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(E=>E.test(c))}}const Pa=Ke.extend({name:O.literal("get-element-data"),includeText:O.boolean().optional(),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),attributes:O.array(O.string()).optional(),includeSelector:O.boolean().optional(),includeXPath:O.boolean().optional()});function Oa(d){return Pa.parse(d)}async function Ca(d){try{const{selector:c="",includeText:y=!0,includeTags:E=!1,useTextContent:b=!1,regex:T,prefixText:l="",suffixText:x="",attributes:$=[],includeSelector:z=!1,includeXPath:X=!1,findBy:S="cssSelector",option:w}=d;if(!c)throw new Error("Selector is required for get-element-data block");if(!y&&$.length===0)throw new Error("Either includeText must be true or attributes must be provided");const A=await Ge({selector:c,findBy:S,option:w});if(!A)return{data:Array.isArray(A)?[]:{}};const U=Ma(y,E,b,T,l,x,$,z,X);return Array.isArray(A)?{data:A.map(U)}:{data:U(A)}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in get-element-data handler",data:{}}}}function Ma(d,c,y,E,b="",T="",l=[],x=!1,$=!1){return z=>{const X={};if(d){let S="";if(c?S=z.innerHTML:S=y?z.textContent||"":z.innerText||"",E){const w=new RegExp(E,"g"),A=S.match(w);S=A?A.join(" "):""}S.trim()&&(S=b+S.trim()+T),X.text=S}return l.length>0&&(X.attributes={},l.forEach(S=>{let w=z.getAttribute(S);if(w===null){const A=z.querySelector(`[${S}]`);A&&(w=A.getAttribute(S))}X.attributes[S]=w})),x&&(X.selector=qn.generate(z)),$&&(X.xpath=Da.generate(z)),X}}const Fa=Ke.extend({name:O.literal("scroll"),scrollType:O.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:O.number().optional(),behavior:O.enum(["auto","smooth"]).optional(),maxScrolls:O.number().optional(),waitAfterScroll:O.number().optional()});function Na(d){return Fa.parse(d)}async function Ua(d){try{const{selector:c="",scrollType:y="toBottom",distance:E=500,behavior:b="smooth",maxScrolls:T=50,waitAfterScroll:l=300,findBy:x="cssSelector",option:$}=d;switch(y){case"toElement":if(!c)throw new Error("Selector is required for toElement scroll type");return await ja(c,x,$,b);case"toBottom":return await Ba(b,l);case"byDistance":return await Ia(E,b);case"untilLoaded":return await Ra(T,E,b,l);default:throw new Error(`Unknown scroll type: ${y}`)}}catch(c){return{hasError:!0,message:c instanceof Error?c.message:"Unknown error in scroll handler",data:!1}}}async function ja(d,c,y,E){const b=await Ge({selector:d,findBy:c,option:y});return b?((Array.isArray(b)?b[0]:b).scrollIntoView({behavior:E,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Ba(d,c){let y=document.body.scrollHeight,E=0;const b=50;for(;E<b;){window.scrollTo({top:document.body.scrollHeight,behavior:d}),await new Promise(l=>setTimeout(l,c));const T=document.body.scrollHeight;if(T===y)break;y=T,E++}return{data:!0}}async function Ia(d,c){return window.scrollBy({top:d,behavior:c}),{data:!0}}async function Ra(d,c,y,E){let b=0,T=document.body.scrollHeight;for(;b<d;){window.scrollBy({top:c,behavior:y}),await new Promise(z=>setTimeout(z,E));const l=document.body.scrollHeight,x=window.pageYOffset||document.documentElement.scrollTop,$=window.innerHeight;if(x+$>=l-10&&l===T)break;T=l,b++}return{data:!0}}const La=O.object({name:O.literal("fetch-api"),url:O.string(),method:O.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:O.record(O.string(),O.string()).optional(),body:O.record(O.string(),O.any()).optional(),timeout:O.number().min(0).optional(),parseJson:O.boolean().optional(),returnHeaders:O.boolean().optional()});function $a(d){return La.parse(d)}async function qa(d){try{console.log("[FetchApiBlock] Sending API request to background:",d.url);const c=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:d.url,method:d.method||"GET",headers:d.headers||{},body:d.body,timeout:d.timeout||3e4,parseJson:d.parseJson??!0,returnHeaders:d.returnHeaders??!1}});return c.$isError?{hasError:!0,message:c.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:c.data})}catch(c){return console.error("[FetchApiBlock] API request error:",c),{hasError:!0,message:c instanceof Error?c.message:"Unknown error in API request",data:void 0}}}function bt(d){throw new Error('Could not dynamically require "'+d+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var At={exports:{}},Ut;function za(){return Ut||(Ut=1,(function(d,c){(function(y){d.exports=y()})(function(){return(function(){function y(E,b,T){function l(z,X){if(!b[z]){if(!E[z]){var S=typeof bt=="function"&&bt;if(!X&&S)return S(z,!0);if(x)return x(z,!0);var w=new Error("Cannot find module '"+z+"'");throw w.code="MODULE_NOT_FOUND",w}var A=b[z]={exports:{}};E[z][0].call(A.exports,function(U){var Q=E[z][1][U];return l(Q||U)},A,A.exports,y,E,b,T)}return b[z].exports}for(var x=typeof bt=="function"&&bt,$=0;$<T.length;$++)l(T[$]);return l}return y})()({1:[function(y,E,b){const T=y("./utils"),l=(function(){const x=T.stringToArray,$=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],z=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],X=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function w(p,m){var h=function(N,M,k){var F="";if(N<=19)F=(M?" and ":"")+(k?z[N]:$[N]);else if(N<100){const ie=Math.floor(N/10),ce=N%10;F=(M?" and ":"")+X[ie-2],ce>0?F+="-"+h(ce,!1,k):k&&(F=F.substring(0,F.length-1)+"ieth")}else if(N<1e3){const ie=Math.floor(N/100),ce=N%100;F=(M?", ":"")+$[ie]+" Hundred",ce>0?F+=h(ce,!0,k):k&&(F+="th")}else{var W=Math.floor(Math.log10(N)/3);W>S.length&&(W=S.length);const ie=Math.pow(10,W*3),ce=Math.floor(N/ie),_=N-ce*ie;F=(M?", ":"")+h(ce,!1,!1)+" "+S[W-1],_>0?F+=h(_,!0,k):k&&(F+="th")}return F},D=h(p,!1,m);return D}const A={};$.forEach(function(p,m){A[p.toLowerCase()]=m}),z.forEach(function(p,m){A[p.toLowerCase()]=m}),X.forEach(function(p,m){const h=p.toLowerCase();A[h]=(m+2)*10,A[h.substring(0,p.length-1)+"ieth"]=A[h]}),A.hundredth=100,S.forEach(function(p,m){const h=p.toLowerCase(),D=Math.pow(10,(m+1)*3);A[h]=D,A[h+"th"]=D});function U(p){const h=p.split(/,\s|\sand\s|[\s\\-]/).map(M=>A[M]);let D=[0];return h.forEach(M=>{if(M<100){let k=D.pop();k>=1e3&&(D.push(k),k=0),D.push(k+M)}else D.push(D.pop()*M)}),D.reduce((M,k)=>M+k,0)}const Q=[[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"]],ue={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ge(p){for(var m=0;m<Q.length;m++){const h=Q[m];if(p>=h[0])return h[1]+ge(p-h[0])}return""}function Z(p){for(var m=0,h=1,D=p.length-1;D>=0;D--){const N=p[D],M=ue[N];M<h?m-=M:(h=M,m+=M)}return m}function P(p,m){for(var h=[],D=m.charCodeAt(0);p>0;)h.unshift(String.fromCharCode((p-1)%26+D)),p=Math.floor((p-1)/26);return h.join("")}function J(p,m){for(var h=m.charCodeAt(0),D=0,N=0;N<p.length;N++)D+=(p.charCodeAt(p.length-N-1)-h+1)*Math.pow(26,N);return D}function B(p,m){if(typeof p>"u")return;p=Math.floor(p);const h=le(m);return R(p,h)}const g={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},j={UPPER:"upper",LOWER:"lower",TITLE:"title"};function R(p,m){let h;const D=p<0;switch(p=Math.abs(p),m.primary){case g.LETTERS:h=P(p,m.case===j.UPPER?"A":"a");break;case g.ROMAN:h=ge(p),m.case===j.UPPER&&(h=h.toUpperCase());break;case g.WORDS:h=w(p,m.ordinal),m.case===j.UPPER?h=h.toUpperCase():m.case===j.LOWER&&(h=h.toLowerCase());break;case g.DECIMAL:h=""+p;var N=m.mandatoryDigits-h.length;if(N>0){var M=new Array(N+1).join("0");h=M+h}if(m.zeroCode!==48&&(h=x(h).map(ie=>String.fromCodePoint(ie.codePointAt(0)+m.zeroCode-48)).join("")),m.regular){const ie=Math.floor((h.length-1)/m.groupingSeparators.position);for(let ce=ie;ce>0;ce--){const _=h.length-ce*m.groupingSeparators.position;h=h.substr(0,_)+m.groupingSeparators.character+h.substr(_)}}else m.groupingSeparators.reverse().forEach(ie=>{const ce=h.length-ie.position;h=h.substr(0,ce)+ie.character+h.substr(ce)});if(m.ordinal){var k={1:"st",2:"nd",3:"rd"},F=h[h.length-1],W=k[F];(!W||h.length>1&&h[h.length-2]==="1")&&(W="th"),h=h+W}break;case g.SEQUENCE:throw{code:"D3130",value:m.token}}return D&&(h="-"+h),h}const ne=[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 le(p){const m={type:"integer",primary:g.DECIMAL,case:j.LOWER,ordinal:!1};let h,D;const N=p.lastIndexOf(";");switch(N===-1?h=p:(h=p.substring(0,N),D=p.substring(N+1),D[0]==="o"&&(m.ordinal=!0)),h){case"A":m.case=j.UPPER;case"a":m.primary=g.LETTERS;break;case"I":m.case=j.UPPER;case"i":m.primary=g.ROMAN;break;case"W":m.case=j.UPPER,m.primary=g.WORDS;break;case"Ww":m.case=j.TITLE,m.primary=g.WORDS;break;case"w":m.primary=g.WORDS;break;default:{let M=null,k=0,F=0,W=[],ie=0;if(x(h).map(_=>_.codePointAt(0)).reverse().forEach(_=>{let Y=!1;for(let ae=0;ae<ne.length;ae++){const H=ne[ae];if(_>=H&&_<=H+9){if(Y=!0,k++,ie++,M===null)M=H;else if(H!==M)throw{code:"D3131"};break}}Y||(_===35?(ie++,F++):W.push({position:ie,character:String.fromCodePoint(_)}))}),k>0){m.primary=g.DECIMAL,m.zeroCode=M,m.mandatoryDigits=k,m.optionalDigits=F;const Y=function(ae){if(ae.length===0)return 0;const H=ae[0].character;for(let Pe=1;Pe<ae.length;Pe++)if(ae[Pe].character!==H)return 0;const Ce=ae.map(Pe=>Pe.position),_e=function(Pe,je){return je===0?Pe:_e(je,Pe%je)},Ue=Ce.reduce(_e);for(let Pe=1;Pe<=Ce.length;Pe++)if(Ce.indexOf(Pe*Ue)===-1)return 0;return Ue}(W);Y>0?(m.regular=!0,m.groupingSeparators={position:Y,character:W[0].character}):(m.regular=!1,m.groupingSeparators=W)}else m.primary=g.SEQUENCE,m.token=h}}return m}const he={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 ye(p){var m=[];const h={type:"datetime",parts:m},D=function(Y,ae){if(ae>Y){let H=p.substring(Y,ae);H=H.split("]]").join("]"),m.push({type:"literal",value:H})}};for(var N=0,M=0;M<p.length;){if(p.charAt(M)==="["){if(p.charAt(M+1)==="["){D(N,M),m.push({type:"literal",value:"["}),M+=2,N=M;continue}if(D(N,M),N=M,M=p.indexOf("]",N),M===-1)throw{code:"D3135"};let Y=p.substring(N+1,M);Y=Y.split(/\s+/).join("");var k={type:"marker",component:Y.charAt(0)},F=Y.lastIndexOf(","),W;if(F!==-1){const ae=Y.substring(F+1),H=ae.indexOf("-");let Ce,_e;const Ue=function(je){if(!(typeof je>"u"||je==="*"))return parseInt(je)};H===-1?Ce=ae:(Ce=ae.substring(0,H),_e=ae.substring(H+1));const Pe={min:Ue(Ce),max:Ue(_e)};k.width=Pe,W=Y.substring(1,F)}else W=Y.substring(1);if(W.length===1)k.presentation1=W;else if(W.length>1){var ie=W.charAt(W.length-1);"atco".indexOf(ie)!==-1?(k.presentation2=ie,ie==="o"&&(k.ordinal=!0),k.presentation1=W.substring(0,W.length-1)):k.presentation1=W}else k.presentation1=he[k.component];if(typeof k.presentation1>"u")throw{code:"D3132",value:k.component};if(k.presentation1[0]==="n")k.names=j.LOWER;else if(k.presentation1[0]==="N")k.presentation1[1]==="n"?k.names=j.TITLE:k.names=j.UPPER;else if("YMDdFWwXxHhmsf".indexOf(k.component)!==-1){var ce=k.presentation1;if(k.presentation2&&(ce+=";"+k.presentation2),k.integerFormat=le(ce),k.width&&k.width.min!==void 0&&k.integerFormat.mandatoryDigits<k.width.min&&(k.integerFormat.mandatoryDigits=k.width.min),k.component==="Y")if(k.n=-1,k.width&&k.width.max!==void 0)k.n=k.width.max,k.integerFormat.mandatoryDigits=k.n;else{var _=k.integerFormat.mandatoryDigits+k.integerFormat.optionalDigits;_>=2&&(k.n=_)}const ae=m[m.length-1];ae&&ae.integerFormat&&(ae.integerFormat.parseWidth=ae.integerFormat.mandatoryDigits)}(k.component==="Z"||k.component==="z")&&(k.integerFormat=le(k.presentation1)),m.push(k),N=M+1}M++}return D(N,M),h}const se=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ae=["January","February","March","April","May","June","July","August","September","October","November","December"],$e=1e3*60*60*24,de=function(p){const m=Date.UTC(p.year,p.month);var h=new Date(m).getUTCDay();return h===0&&(h=7),h>4?m+(8-h)*$e:m-(h-1)*$e},te=function(p,m){return{year:p,month:m,nextMonth:function(){return m===11?te(p+1,0):te(p,m+1)},previousMonth:function(){return m===0?te(p-1,11):te(p,m-1)},nextYear:function(){return te(p+1,m)},previousYear:function(){return te(p-1,m)}}},qe=function(p,m){return(m-p)/($e*7)+1},K=(p,m)=>{let h;switch(m){case"Y":h=p.getUTCFullYear();break;case"M":h=p.getUTCMonth()+1;break;case"D":h=p.getUTCDate();break;case"d":{const D=Date.UTC(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),N=Date.UTC(p.getUTCFullYear(),0);h=(D-N)/$e+1;break}case"F":h=p.getUTCDay(),h===0&&(h=7);break;case"W":{const D=te(p.getUTCFullYear(),0),N=de(D),M=Date.UTC(D.year,p.getUTCMonth(),p.getUTCDate());let k=qe(N,M);if(k>52){const F=de(D.nextYear());M>=F&&(k=1)}else if(k<1){const F=de(D.previousYear());k=qe(F,M)}h=Math.floor(k);break}case"w":{const D=te(p.getUTCFullYear(),p.getUTCMonth()),N=de(D),M=Date.UTC(D.year,D.month,p.getUTCDate());let k=qe(N,M);if(k>4){const F=de(D.nextMonth());M>=F&&(k=1)}else if(k<1){const F=de(D.previousMonth());k=qe(F,M)}h=Math.floor(k);break}case"X":{const D=te(p.getUTCFullYear(),0),N=de(D),M=de(D.nextYear()),k=p.getTime();k<N?h=D.year-1:k>=M?h=D.year+1:h=D.year;break}case"x":{const D=te(p.getUTCFullYear(),p.getUTCMonth()),N=de(D),M=D.nextMonth(),k=de(M),F=p.getTime();F<N?h=D.previousMonth().month+1:F>=k?h=M.month+1:h=D.month+1;break}case"H":h=p.getUTCHours();break;case"h":h=p.getUTCHours(),h=h%12,h===0&&(h=12);break;case"P":h=p.getUTCHours()>=12?"pm":"am";break;case"m":h=p.getUTCMinutes();break;case"s":h=p.getUTCSeconds();break;case"f":h=p.getUTCMilliseconds();break;case"Z":case"z":break;case"C":h="ISO";break;case"E":h="ISO";break}return h};let Se=null;function He(p,m,h){var D=0,N=0;if(typeof h<"u"){const ce=parseInt(h);D=Math.floor(ce/100),N=ce%100}var M=function(ce,_){var Y=K(ce,_.component);if("YMDdFWwXxHhms".indexOf(_.component)!==-1)if(_.component==="Y"&&_.n!==-1&&(Y=Y%Math.pow(10,_.n)),_.names){if(_.component==="M"||_.component==="x")Y=Ae[Y-1];else if(_.component==="F")Y=se[Y];else throw{code:"D3133",value:_.component};_.names===j.UPPER?Y=Y.toUpperCase():_.names===j.LOWER&&(Y=Y.toLowerCase()),_.width&&Y.length>_.width.max&&(Y=Y.substring(0,_.width.max))}else Y=R(Y,_.integerFormat);else if(_.component==="f")Y=R(Y,_.integerFormat);else if(_.component==="Z"||_.component==="z"){const ae=D*100+N;if(_.integerFormat.regular)Y=R(ae,_.integerFormat);else{const H=_.integerFormat.mandatoryDigits;if(H===1||H===2)Y=R(D,_.integerFormat),N!==0&&(Y+=":"+B(N,"00"));else if(H===3||H===4)Y=R(ae,_.integerFormat);else throw{code:"D3134",value:H}}ae>=0&&(Y="+"+Y),_.component==="z"&&(Y="GMT"+Y),ae===0&&_.presentation2==="t"&&(Y="Z")}else _.component==="P"&&_.names===j.UPPER&&(Y=Y.toUpperCase());return Y};let k;typeof m>"u"?(Se===null&&(Se=ye("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),k=Se):k=ye(m);const F=(60*D+N)*60*1e3,W=new Date(p+F);let ie="";return k.parts.forEach(function(ce){ce.type==="literal"?ie+=ce.value:ie+=M(W,ce)}),ie}function a(p){var m={};if(p.type==="datetime")m.type="datetime",m.parts=p.parts.map(function(h){var D={};if(h.type==="literal")D.regex=h.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(h.component==="Z"||h.component==="z"){let M;Array.isArray(h.integerFormat.groupingSeparators)||(M=h.integerFormat.groupingSeparators),D.regex="",h.component==="z"&&(D.regex="GMT"),D.regex+="[-+][0-9]+",M&&(D.regex+=M.character+"[0-9]+"),D.parse=function(k){h.component==="z"&&(k=k.substring(3));let F=0,W=0;return M?(F=Number.parseInt(k.substring(0,k.indexOf(M.character))),W=Number.parseInt(k.substring(k.indexOf(M.character)+1))):k.length-1<=2?F=Number.parseInt(k):(F=Number.parseInt(k.substring(0,3)),W=Number.parseInt(k.substring(3))),F*60+W}}else if(h.integerFormat)D=a(h.integerFormat);else{D.regex="[a-zA-Z]+";var N={};if(h.component==="M"||h.component==="x")Ae.forEach(function(M,k){h.width&&h.width.max?N[M.substring(0,h.width.max)]=k+1:N[M]=k+1});else if(h.component==="F")se.forEach(function(M,k){k>0&&(h.width&&h.width.max?N[M.substring(0,h.width.max)]=k:N[M]=k)});else if(h.component==="P")N={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:h.component};D.parse=function(M){return N[M]}}return D.component=h.component,D});else{m.type="integer";const h=p.case===j.UPPER;switch(p.primary){case g.LETTERS:m.regex=h?"[A-Z]+":"[a-z]+",m.parse=function(D){return J(D,h?"A":"a")};break;case g.ROMAN:m.regex=h?"[MDCLXVI]+":"[mdclxvi]+",m.parse=function(D){return Z(h?D:D.toUpperCase())};break;case g.WORDS:m.regex="(?:"+Object.keys(A).concat("and","[\\-, ]").join("|")+")+",m.parse=function(D){return U(D.toLowerCase())};break;case g.DECIMAL:m.regex="[0-9]",p.parseWidth?m.regex+=`{${p.parseWidth}}`:m.regex+="+",p.ordinal&&(m.regex+="(?:th|st|nd|rd)"),m.parse=function(D){let N=D;return p.ordinal&&(N=D.substring(0,D.length-2)),p.regular?N=N.split(",").join(""):p.groupingSeparators.forEach(M=>{N=N.split(M.character).join("")}),p.zeroCode!==48&&(N=N.split("").map(M=>String.fromCodePoint(M.codePointAt(0)-p.zeroCode+48)).join("")),parseInt(N)};break;case g.SEQUENCE:throw{code:"D3130",value:p.token}}}return m}function s(p,m){if(typeof p>"u")return;const h=le(m);return a(h).parse(p)}function L(p,m){const h=ye(m),D=a(h),N="^"+D.parts.map(W=>"("+W.regex+")").join("")+"$";var k=new RegExp(N,"i").exec(p);if(k!==null){const H={};for(let me=1;me<k.length;me++){const r=D.parts[me-1];r.parse&&(H[r.component]=r.parse(k[me]))}if(Object.getOwnPropertyNames(H).length===0)return;let Ce=0;const _e=me=>{Ce<<=1,Ce+=me?1:0},Ue=me=>!(~me&Ce)&&!!(me&Ce);"YXMxWwdD".split("").forEach(me=>_e(H[me]));const je=!Ue(161)&&Ue(130),Xe=Ue(84),et=!Xe&&Ue(72);Ce=0,"PHhmsf".split("").forEach(me=>_e(H[me]));const tt=!Ue(23)&&Ue(47),ct=(je?"YD":Xe?"XxwF":et?"XWF":"YMD")+(tt?"Phmsf":"Hmsf"),Ve=this.environment.timestamp;let ot=!1,Je=!1;if(ct.split("").forEach(me=>{if(typeof H[me]>"u")ot?(H[me]="MDd".indexOf(me)!==-1?1:0,Je=!0):H[me]=K(Ve,me);else if(ot=!0,Je)throw{code:"D3136"}}),H.M>0?H.M-=1:H.M=0,je){const me=Date.UTC(H.Y,0),r=(H.d-1)*1e3*60*60*24,o=new Date(me+r);H.M=o.getUTCMonth(),H.D=o.getUTCDate()}if(Xe)throw{code:"D3136"};if(et)throw{code:"D3136"};tt&&(H.H=H.h===12?0:H.h,H.P===1&&(H.H+=12));var F=Date.UTC(H.Y,H.M,H.D,H.H,H.m,H.s,H.f);return(H.Z||H.z)&&(F-=(H.Z||H.z)*60*1e3),F}}var re=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 we(p,m){if(!(typeof p>"u"))if(typeof m>"u"){if(!re.test(p))throw{stack:new Error().stack,code:"D3110",value:p};return Date.parse(p)}else return L.call(this,p,m)}function pe(p,m,h){if(!(typeof p>"u"))return He.call(this,p,m,h)}return{formatInteger:B,parseInteger:s,fromMillis:pe,toMillis:we}})();E.exports=l},{"./utils":6}],2:[function(y,E,b){(function(T){(function(){var l=y("./utils");const x=(()=>{var $=l.isNumeric,z=l.isArrayOfStrings,X=l.isArrayOfNumbers,S=l.createSequence,w=l.isSequence,A=l.isFunction,U=l.isLambda,Q=l.isPromise,ue=l.getFunctionArity,ge=l.isDeepEqual,Z=l.stringToArray;function P(e){if(!(typeof e>"u")){var t=0;return e.forEach(function(n){t+=n}),t}}function J(e){return typeof e>"u"?0:e.length}function B(e){if(!(typeof e>"u"||e.length===0))return Math.max.apply(Math,e)}function g(e){if(!(typeof e>"u"||e.length===0))return Math.min.apply(Math,e)}function j(e){if(!(typeof e>"u"||e.length===0)){var t=0;return e.forEach(function(n){t+=n}),t/e.length}}function R(e,t=!1){if(!(typeof e>"u")){var n;if(typeof e=="string")n=e;else if(A(e))n="";else{if(typeof e=="number"&&!isFinite(e))throw{code:"D3001",value:e,stack:new Error().stack};var f=t?2:0;Array.isArray(e)&&e.outerWrapper&&(e=e[0]),n=JSON.stringify(e,function(i,v){return typeof v<"u"&&v!==null&&v.toPrecision&&$(v)?Number(v.toPrecision(15)):v&&A(v)?"":v},f)}return n}}function ne(e,t,n){if(!(typeof e>"u")){var f=Z(e),i=f.length;if(i+t<0&&(t=0),typeof n<"u"){if(n<=0)return"";var v=t>=0?t+n:i+t+n;return f.slice(t,v).join("")}return f.slice(t).join("")}}function le(e,t){if(!(typeof e>"u")){var n=e.indexOf(t);return n>-1?e.substr(0,n):e}}function he(e,t){if(!(typeof e>"u")){var n=e.indexOf(t);return n>-1?e.substr(n+t.length):e}}function ye(e){if(!(typeof e>"u"))return e.toLowerCase()}function se(e){if(!(typeof e>"u"))return e.toUpperCase()}function Ae(e){if(!(typeof e>"u"))return Z(e).length}function $e(e){if(!(typeof e>"u")){var t=e.replace(/[ \t\n\r]+/gm," ");return t.charAt(0)===" "&&(t=t.substring(1)),t.charAt(t.length-1)===" "&&(t=t.substring(0,t.length-1)),t}}function de(e,t,n){if(!(typeof e>"u")){(typeof n>"u"||n.length===0)&&(n=" ");var f;t=Math.trunc(t);var i=Math.abs(t)-Ae(e);if(i>0){var v=new Array(i+1).join(n);n.length>1&&(v=ne(v,0,i)),t>0?f=e+v:f=v+e}else f=e;return f}}async function te(e,t){var n=e.apply(this,[t]);if(Q(n)&&(n=await n),n&&!(typeof n.start=="number"||n.end==="number"||Array.isArray(n.groups)||A(n.next)))throw{code:"T1010",stack:new Error().stack};return n}async function qe(e,t){if(!(typeof e>"u")){var n;if(typeof t=="string")n=e.indexOf(t)!==-1;else{var f=await te(t,e);n=typeof f<"u"}return n}}async function K(e,t,n){if(!(typeof e>"u")){if(n<0)throw{stack:new Error().stack,value:n,code:"D3040",index:3};var f=S();if(typeof n>"u"||n>0){var i=0,v=await te(t,e);if(typeof v<"u")for(;typeof v<"u"&&(typeof n>"u"||i<n);)f.push({match:v.match,index:v.start,groups:v.groups}),v=await te(v.next),i++}return f}}async function Se(e,t,n,f){if(!(typeof e>"u")){var i=this;if(t==="")throw{code:"D3010",stack:new Error().stack,value:t,index:2};if(f<0)throw{code:"D3011",stack:new Error().stack,value:f,index:4};var v;typeof n=="string"?v=function(ve){for(var Me="",fe=0,xe=n.indexOf("$",fe);xe!==-1&&fe<n.length;){Me+=n.substring(fe,xe),fe=xe+1;var We=n.charAt(fe);if(We==="$")Me+="$",fe++;else if(We==="0")Me+=ve.match,fe++;else{var Fe;if(ve.groups.length===0?Fe=1:Fe=Math.floor(Math.log(ve.groups.length)*Math.LOG10E)+1,xe=parseInt(n.substring(fe,fe+Fe),10),Fe>1&&xe>ve.groups.length&&(xe=parseInt(n.substring(fe,fe+Fe-1),10)),isNaN(xe))Me+="$";else{if(ve.groups.length>0){var it=ve.groups[xe-1];typeof it<"u"&&(Me+=it)}fe+=xe.toString().length}}xe=n.indexOf("$",fe)}return Me+=n.substring(fe),Me}:v=n;var C="",q=0;if(typeof f>"u"||f>0){var V=0;if(typeof t=="string"){for(var be=e.indexOf(t,q);be!==-1&&(typeof f>"u"||V<f);)C+=e.substring(q,be),C+=n,q=be+t.length,V++,be=e.indexOf(t,q);C+=e.substring(q)}else{var oe=await te(t,e);if(typeof oe<"u"){for(;typeof oe<"u"&&(typeof f>"u"||V<f);){C+=e.substring(q,oe.start);var ke=v.apply(i,[oe]);if(Q(ke)&&(ke=await ke),typeof ke=="string")C+=ke;else throw{code:"D3012",stack:new Error().stack,value:ke};q=oe.start+oe.match.length,V++,oe=await te(oe.next)}C+=e.substring(q)}else C=e}}else C=e;return C}}function He(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.btoa:function(n){return new T.Buffer.from(n,"binary").toString("base64")};return t(e)}}function a(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.atob:function(n){return new T.Buffer.from(n,"base64").toString("binary")};return t(e)}}function s(e){if(!(typeof e>"u")){var t;try{t=encodeURIComponent(e)}catch{throw{code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrlComponent"}}return t}}function L(e){if(!(typeof e>"u")){var t;try{t=encodeURI(e)}catch{throw{code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrl"}}return t}}function re(e){if(!(typeof e>"u")){var t;try{t=decodeURIComponent(e)}catch{throw{code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrlComponent"}}return t}}function we(e){if(!(typeof e>"u")){var t;try{t=decodeURI(e)}catch{throw{code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrl"}}return t}}async function pe(e,t,n){if(!(typeof e>"u")){if(n<0)throw{code:"D3020",stack:new Error().stack,value:n,index:3};var f=[];if(typeof n>"u"||n>0)if(typeof t=="string")f=e.split(t,n);else{var i=0,v=await te(t,e);if(typeof v<"u"){for(var C=0;typeof v<"u"&&(typeof n>"u"||i<n);)f.push(e.substring(C,v.start)),C=v.end,v=await te(v.next),i++;(typeof n>"u"||i<n)&&f.push(e.substring(C))}else f.push(e)}return f}}function p(e,t){if(!(typeof e>"u"))return typeof t>"u"&&(t=""),e.join(t)}function m(e,t,n){if(!(typeof e>"u")){var f={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},i=f;typeof n<"u"&&Object.keys(n).forEach(function(G){i[G]=n[G]});for(var v=[],C=i["zero-digit"].charCodeAt(0),q=C;q<C+10;q++)v.push(String.fromCharCode(q));var V=v.concat([i["decimal-separator"],i["exponent-separator"],i["grouping-separator"],i.digit,i["pattern-separator"]]),be=t.split(i["pattern-separator"]);if(be.length>2)throw{code:"D3080",stack:new Error().stack};var oe=function(G){var Te=(function(){for(var Oe,Ze=0;Ze<G.length;Ze++)if(Oe=G.charAt(Ze),V.indexOf(Oe)!==-1&&Oe!==i["exponent-separator"])return G.substring(0,Ze)})(),Ie=(function(){for(var Oe,Ze=G.length-1;Ze>=0;Ze--)if(Oe=G.charAt(Ze),V.indexOf(Oe)!==-1&&Oe!==i["exponent-separator"])return G.substring(Ze+1)})(),Ee=G.substring(Te.length,G.length-Ie.length),Re,rt,Le,at,ze=G.indexOf(i["exponent-separator"],Te.length);ze===-1||ze>G.length-Ie.length?(Re=Ee,rt=void 0):(Re=Ee.substring(0,ze),rt=Ee.substring(ze+1));var Ye=Re.indexOf(i["decimal-separator"]);return Ye===-1?(Le=Re,at=Ie):(Le=Re.substring(0,Ye),at=Re.substring(Ye+1)),{prefix:Te,suffix:Ie,activePart:Ee,mantissaPart:Re,exponentPart:rt,integerPart:Le,fractionalPart:at,subpicture:G}},ke=function(G){var Te,Ie,Ee=G.subpicture,Re=Ee.indexOf(i["decimal-separator"]);Re!==Ee.lastIndexOf(i["decimal-separator"])&&(Te="D3081"),Ee.indexOf(i.percent)!==Ee.lastIndexOf(i.percent)&&(Te="D3082"),Ee.indexOf(i["per-mille"])!==Ee.lastIndexOf(i["per-mille"])&&(Te="D3083"),Ee.indexOf(i.percent)!==-1&&Ee.indexOf(i["per-mille"])!==-1&&(Te="D3084");var rt=!1;for(Ie=0;Ie<G.mantissaPart.length;Ie++){var Le=G.mantissaPart.charAt(Ie);if(v.indexOf(Le)!==-1||Le===i.digit){rt=!0;break}}rt||(Te="D3085");var at=G.activePart.split("").map(function(Oe){return V.indexOf(Oe)===-1?"p":"a"}).join("");at.indexOf("p")!==-1&&(Te="D3086"),Re!==-1?(Ee.charAt(Re-1)===i["grouping-separator"]||Ee.charAt(Re+1)===i["grouping-separator"])&&(Te="D3087"):G.integerPart.charAt(G.integerPart.length-1)===i["grouping-separator"]&&(Te="D3088"),Ee.indexOf(i["grouping-separator"]+i["grouping-separator"])!==-1&&(Te="D3089");var ze=G.integerPart.indexOf(i.digit);ze!==-1&&G.integerPart.substring(0,ze).split("").filter(function(Oe){return v.indexOf(Oe)>-1}).length>0&&(Te="D3090"),ze=G.fractionalPart.lastIndexOf(i.digit),ze!==-1&&G.fractionalPart.substring(ze).split("").filter(function(Oe){return v.indexOf(Oe)>-1}).length>0&&(Te="D3091");var Ye=typeof G.exponentPart=="string";if(Ye&&G.exponentPart.length>0&&(Ee.indexOf(i.percent)!==-1||Ee.indexOf(i["per-mille"])!==-1)&&(Te="D3092"),Ye&&(G.exponentPart.length===0||G.exponentPart.split("").filter(function(Oe){return v.indexOf(Oe)===-1}).length>0)&&(Te="D3093"),Te)throw{code:Te,stack:new Error().stack}},ve=function(G){var Te=function(Ne,gt){for(var dt=[],Qe=Ne.indexOf(i["grouping-separator"]);Qe!==-1;){var mt=(gt?Ne.substring(0,Qe):Ne.substring(Qe)).split("").filter(function(ut){return v.indexOf(ut)!==-1||ut===i.digit}).length;dt.push(mt),Qe=G.integerPart.indexOf(i["grouping-separator"],Qe+1)}return dt},Ie=Te(G.integerPart),Ee=function(Ne){if(Ne.length===0)return 0;for(var gt=function(mt,ut){return ut===0?mt:gt(ut,mt%ut)},dt=Ne.reduce(gt),Qe=1;Qe<=Ne.length;Qe++)if(Ne.indexOf(Qe*dt)===-1)return 0;return dt},Re=Ee(Ie),rt=Te(G.fractionalPart,!0),Le=G.integerPart.split("").filter(function(Ne){return v.indexOf(Ne)!==-1}).length,at=Le,ze=G.fractionalPart.split(""),Ye=ze.filter(function(Ne){return v.indexOf(Ne)!==-1}).length,Oe=ze.filter(function(Ne){return v.indexOf(Ne)!==-1||Ne===i.digit}).length,Ze=typeof G.exponentPart=="string";Le===0&&Oe===0&&(Ze?(Ye=1,Oe=1):Le=1),Ze&&Le===0&&G.integerPart.indexOf(i.digit)!==-1&&(Le=1),Le===0&&Ye===0&&(Ye=1);var Ot=0;return Ze&&(Ot=G.exponentPart.split("").filter(function(Ne){return v.indexOf(Ne)!==-1}).length),{integerPartGroupingPositions:Ie,regularGrouping:Re,minimumIntegerPartSize:Le,scalingFactor:at,prefix:G.prefix,fractionalPartGroupingPositions:rt,minimumFactionalPartSize:Ye,maximumFactionalPartSize:Oe,minimumExponentSize:Ot,suffix:G.suffix,picture:G.subpicture}},Me=be.map(oe);Me.forEach(ke);var fe=Me.map(ve),xe=i["minus-sign"],We=i["zero-digit"],Fe=i["decimal-separator"],it=i["grouping-separator"];fe.length===1&&(fe.push(JSON.parse(JSON.stringify(fe[0]))),fe[1].prefix=xe+fe[1].prefix);var De;e>=0?De=fe[0]:De=fe[1];var ft;De.picture.indexOf(i.percent)!==-1?ft=e*100:De.picture.indexOf(i["per-mille"])!==-1?ft=e*1e3:ft=e;var nt,st;if(De.minimumExponentSize===0)nt=ft;else{var Rt=Math.pow(10,De.scalingFactor),Lt=Math.pow(10,De.scalingFactor-1);for(nt=ft,st=0;nt<Lt;)nt*=10,st-=1;for(;nt>Rt;)nt/=10,st+=1}var $t=F(nt,De.maximumFactionalPartSize),Dt=function(G,Te){var Ie=Math.abs(G).toFixed(Te);return We!=="0"&&(Ie=Ie.split("").map(function(Ee){return Ee>="0"&&Ee<="9"?v[Ee.charCodeAt(0)-48]:Ee}).join("")),Ie},ee=Dt($t,De.maximumFactionalPartSize),Be=ee.indexOf(".");for(Be===-1?ee=ee+Fe:ee=ee.replace(".",Fe);ee.charAt(0)===We;)ee=ee.substring(1);for(;ee.charAt(ee.length-1)===We;)ee=ee.substring(0,ee.length-1);Be=ee.indexOf(Fe);var lt=De.minimumIntegerPartSize-Be,Pt=De.minimumFactionalPartSize-(ee.length-Be-1);if(ee=(lt>0?new Array(lt+1).join(We):"")+ee,ee=ee+(Pt>0?new Array(Pt+1).join(We):""),Be=ee.indexOf(Fe),De.regularGrouping>0)for(var qt=Math.floor((Be-1)/De.regularGrouping),yt=1;yt<=qt;yt++)ee=[ee.slice(0,Be-yt*De.regularGrouping),it,ee.slice(Be-yt*De.regularGrouping)].join("");else De.integerPartGroupingPositions.forEach(function(G){ee=[ee.slice(0,Be-G),it,ee.slice(Be-G)].join(""),Be++});if(Be=ee.indexOf(Fe),De.fractionalPartGroupingPositions.forEach(function(G){ee=[ee.slice(0,G+Be+1),it,ee.slice(G+Be+1)].join("")}),Be=ee.indexOf(Fe),(De.picture.indexOf(Fe)===-1||Be===ee.length-1)&&(ee=ee.substring(0,ee.length-1)),typeof st<"u"){var vt=Dt(st,0);lt=De.minimumExponentSize-vt.length,lt>0&&(vt=new Array(lt+1).join(We)+vt),ee=ee+i["exponent-separator"]+(st<0?xe:"")+vt}return ee=De.prefix+ee+De.suffix,ee}}function h(e,t){if(!(typeof e>"u")){if(e=F(e),typeof t>"u"?t=10:t=F(t),t<2||t>36)throw{code:"D3100",stack:new Error().stack,value:t};var n=e.toString(t);return n}}function D(e){var t;if(!(typeof e>"u")){if(typeof e=="number")t=e;else if(typeof e=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(e)&&!isNaN(parseFloat(e))&&isFinite(e))t=parseFloat(e);else if(typeof e=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(e))t=Number(e);else if(e===!0)t=1;else if(e===!1)t=0;else throw{code:"D3030",value:e,stack:new Error().stack,index:1};return t}}function N(e){var t;if(!(typeof e>"u"))return t=Math.abs(e),t}function M(e){var t;if(!(typeof e>"u"))return t=Math.floor(e),t}function k(e){var t;if(!(typeof e>"u"))return t=Math.ceil(e),t}function F(e,t){var n;if(!(typeof e>"u")){if(t){var f=e.toString().split("e");e=+(f[0]+"e"+(f[1]?+f[1]+t:t))}n=Math.round(e);var i=n-e;return Math.abs(i)===.5&&Math.abs(n%2)===1&&(n=n-1),t&&(f=n.toString().split("e"),n=+(f[0]+"e"+(f[1]?+f[1]-t:-t))),Object.is(n,-0)&&(n=0),n}}function W(e){var t;if(!(typeof e>"u")){if(e<0)throw{stack:new Error().stack,code:"D3060",index:1,value:e};return t=Math.sqrt(e),t}}function ie(e,t){var n;if(!(typeof e>"u")){if(n=Math.pow(e,t),!isFinite(n))throw{stack:new Error().stack,code:"D3061",index:1,value:e,exp:t};return n}}function ce(){return Math.random()}function _(e){if(!(typeof e>"u")){var t=!1;if(Array.isArray(e)){if(e.length===1)t=_(e[0]);else if(e.length>1){var n=e.filter(function(f){return _(f)});t=n.length>0}}else typeof e=="string"?e.length>0&&(t=!0):$(e)?e!==0&&(t=!0):e!==null&&typeof e=="object"&&!A(e)?Object.keys(e).length>0&&(t=!0):typeof e=="boolean"&&e===!0&&(t=!0);return t}}function Y(e){if(!(typeof e>"u"))return!_(e)}function ae(e,t,n,f){var i=[t],v=ue(e);return v>=2&&i.push(n),v>=3&&i.push(f),i}async function H(e,t){if(!(typeof e>"u")){for(var n=S(),f=0;f<e.length;f++){var i=ae(t,e[f],f,e),v=await t.apply(this,i);typeof v<"u"&&n.push(v)}return n}}async function Ce(e,t){if(!(typeof e>"u")){for(var n=S(),f=0;f<e.length;f++){var i=e[f],v=ae(t,i,f,e),C=await t.apply(this,v);_(C)&&n.push(i)}return n}}async function _e(e,t){if(!(typeof e>"u")){for(var n=!1,f,i=0;i<e.length;i++){var v=e[i],C=!0;if(typeof t<"u"){var q=ae(t,v,i,e),V=await t.apply(this,q);C=_(V)}if(C)if(!n)f=v,n=!0;else throw{stack:new Error().stack,code:"D3138",index:i}}if(!n)throw{stack:new Error().stack,code:"D3139"};return f}}function Ue(){for(var e=[],t=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,t.map(function(v){return Array.isArray(v)?v.length:0})),f=0;f<n;f++){var i=t.map(v=>v[f]);e.push(i)}return e}async function Pe(e,t,n){if(!(typeof e>"u")){var f,i=ue(t);if(i<2)throw{stack:new Error().stack,code:"D3050",index:1};var v;for(typeof n>"u"&&e.length>0?(f=e[0],v=1):(f=n,v=0);v<e.length;){var C=[f,e[v]];i>=3&&C.push(v),i>=4&&C.push(e),f=await t.apply(this,C),v++}return f}}function je(e){var t=S();if(Array.isArray(e)){var n={};e.forEach(function(f){var i=je(f);i.forEach(function(v){n[v]=!0})}),t=je(n)}else e!==null&&typeof e=="object"&&!A(e)&&Object.keys(e).forEach(f=>t.push(f));return t}function Xe(e,t){var n;if(Array.isArray(e)){n=S();for(var f=0;f<e.length;f++){var i=Xe(e[f],t);typeof i<"u"&&(Array.isArray(i)?i.forEach(v=>n.push(v)):n.push(i))}}else e!==null&&typeof e=="object"&&!A(e)&&(n=e[t]);return n}function et(e,t){return typeof e>"u"?t:typeof t>"u"?e:(Array.isArray(e)||(e=S(e)),Array.isArray(t)||(t=[t]),e.concat(t))}function pt(e){return!(typeof e>"u")}function tt(e){var t=S();if(Array.isArray(e))e.forEach(function(i){t=et(t,tt(i))});else if(e!==null&&typeof e=="object"&&!U(e))for(var n in e){var f={};f[n]=e[n],t.push(f)}else t=e;return t}function I(e){if(!(typeof e>"u")){var t={};return e.forEach(function(n){for(var f in n)t[f]=n[f]}),t}}function ht(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=e.length,n=new Array(t),f=0;f<t;f++)n[t-f-1]=e[f];return n}}async function ct(e,t){var n=S();for(var f in e){var i=ae(t,e[f],f,e),v=await t.apply(this,i);typeof v<"u"&&n.push(v)}return n}function Ve(e){throw{code:"D3137",stack:new Error().stack,message:e||"$error() function evaluated"}}function ot(e,t){if(!e)throw{code:"D3141",stack:new Error().stack,message:t||"$assert() statement failed"}}function Je(e){if(e!==void 0)return e===null?"null":$(e)?"number":typeof e=="string"?"string":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":A(e)?"function":"object"}async function me(e,t){if(!(typeof e>"u")){if(e.length<=1)return e;var n;if(typeof t>"u"){if(!X(e)&&!z(e))throw{stack:new Error().stack,code:"D3070",index:1};n=async function(C,q){return C>q}}else n=t;var f=async function(C,q){var V=async function(oe,ke,ve){ke.length===0?Array.prototype.push.apply(oe,ve):ve.length===0?Array.prototype.push.apply(oe,ke):await n(ke[0],ve[0])?(oe.push(ve[0]),await V(oe,ke,ve.slice(1))):(oe.push(ke[0]),await V(oe,ke.slice(1),ve))},be=[];return await V(be,C,q),be},i=async function(C){if(!Array.isArray(C)||C.length<=1)return C;var q=Math.floor(C.length/2),V=C.slice(0,q),be=C.slice(q);return V=await i(V),be=await i(be),await f(V,be)},v=await i(e);return v}}function r(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=new Array(e.length),n=0;n<e.length;n++){var f=Math.floor(Math.random()*(n+1));n!==f&&(t[n]=t[f]),t[f]=e[n]}return t}}function o(e){if(!(typeof e>"u")){if(!Array.isArray(e)||e.length<=1)return e;for(var t=w(e)?S():[],n=0;n<e.length;n++){for(var f=e[n],i=!1,v=0;v<t.length;v++)if(ge(f,t[v])){i=!0;break}i||t.push(f)}return t}}async function u(e,t){var n={};for(var f in e){var i=e[f],v=ae(t,i,f,e),C=await t.apply(this,v);_(C)&&(n[f]=i)}return Object.keys(n).length===0&&(n=void 0),n}return{sum:P,count:J,max:B,min:g,average:j,string:R,substring:ne,substringBefore:le,substringAfter:he,lowercase:ye,uppercase:se,length:Ae,trim:$e,pad:de,match:K,contains:qe,replace:Se,split:pe,join:p,formatNumber:m,formatBase:h,number:D,floor:M,ceil:k,round:F,abs:N,sqrt:W,power:ie,random:ce,boolean:_,not:Y,map:H,zip:Ue,filter:Ce,single:_e,foldLeft:Pe,sift:u,keys:je,lookup:Xe,append:et,exists:pt,spread:tt,merge:I,reverse:ht,each:ct,error:Ve,assert:ot,type:Je,sort:me,shuffle:r,distinct:o,base64encode:He,base64decode:a,encodeUrlComponent:s,encodeUrl:L,decodeUrlComponent:re,decodeUrl:we}})();E.exports=x}).call(this)}).call(this,typeof Ft<"u"?Ft:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(y,E,b){var T=y("./datetime"),l=y("./functions"),x=y("./utils"),$=y("./parser"),z=y("./signature"),X=(function(){var S=x.isNumeric,w=x.isArrayOfStrings,A=x.isArrayOfNumbers,U=x.createSequence,Q=x.isSequence,ue=x.isFunction,ge=x.isLambda,Z=x.isIterable,P=x.isPromise,J=x.getFunctionArity,B=x.isDeepEqual,g=Ve(null);async function j(r,o,u){var e,t=u.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(t&&await t(r,o,u),r.type){case"path":e=await R(r,o,u);break;case"binary":e=await Ae(r,o,u);break;case"unary":e=await $e(r,o,u);break;case"name":e=de(r,o);break;case"string":case"number":case"value":e=te(r);break;case"wildcard":e=qe(r,o);break;case"descendant":e=Se(r,o);break;case"parent":e=u.lookup(r.slot.label);break;case"condition":e=await M(r,o,u);break;case"block":e=await k(r,o,u);break;case"bind":e=await N(r,o,u);break;case"regex":e=F(r);break;case"function":e=await ae(r,o,u);break;case"variable":e=W(r,o,u);break;case"lambda":e=_e(r,o,u);break;case"partial":e=await Ue(r,o,u);break;case"apply":e=await Y(r,o,u);break;case"transform":e=ce(r,o,u);break}if(Object.prototype.hasOwnProperty.call(r,"predicate"))for(var n=0;n<r.predicate.length;n++)e=await se(r.predicate[n].expr,e,u);r.type!=="path"&&Object.prototype.hasOwnProperty.call(r,"group")&&(e=await m(r.group,e,u));var f=u.lookup(Symbol.for("jsonata.__evaluate_exit"));return f&&await f(r,o,u,e),e&&Q(e)&&!e.tupleStream&&(r.keepArray&&(e.keepSingleton=!0),e.length===0?e=void 0:e.length===1&&(e=e.keepSingleton?e:e[0])),e}async function R(r,o,u){var e;Array.isArray(o)&&r.steps[0].type!=="variable"?e=o:e=U(o);for(var t,n=!1,f=void 0,i=0;i<r.steps.length;i++){var v=r.steps[i];if(v.tuple&&(n=!0),i===0&&v.consarray?t=await j(v,e,u):n?f=await ye(v,e,f,u):t=await le(v,e,u,i===r.steps.length-1),!n&&(typeof t>"u"||t.length===0))break;typeof v.focus>"u"&&(e=t)}if(n)if(r.tuple)t=f;else for(t=U(),i=0;i<f.length;i++)t.push(f[i]["@"]);return r.keepSingletonArray&&(Array.isArray(t)&&t.cons&&!t.sequence&&(t=U(t)),t.keepSingleton=!0),r.hasOwnProperty("group")&&(t=await m(r.group,n?f:t,u)),t}function ne(r,o){var u=Ve(r);for(const e in o)u.bind(e,o[e]);return u}async function le(r,o,u,e){var t;if(r.type==="sort")return t=await ie(r,o,u),r.stages&&(t=await he(r.stages,t,u)),t;t=U();for(var n=0;n<o.length;n++){var f=await j(r,o[n],u);if(r.stages)for(var i=0;i<r.stages.length;i++)f=await se(r.stages[i].expr,f,u);typeof f<"u"&&t.push(f)}var v=U();return e&&t.length===1&&Array.isArray(t[0])&&!Q(t[0])?v=t[0]:t.forEach(function(C){!Array.isArray(C)||C.cons?v.push(C):C.forEach(q=>v.push(q))}),v}async function he(r,o,u){for(var e=o,t=0;t<r.length;t++){var n=r[t];switch(n.type){case"filter":e=await se(n.expr,e,u);break;case"index":for(var f=0;f<e.length;f++){var i=e[f];i[n.value]=f}break}}return e}async function ye(r,o,u,e){var t;if(r.type==="sort"){if(u)t=await ie(r,u,e);else{var n=await ie(r,o,e);t=U(),t.tupleStream=!0;for(var f=0;f<n.length;f++){var i={"@":n[f]};i[r.index]=f,t.push(i)}}return r.stages&&(t=await he(r.stages,t,e)),t}t=U(),t.tupleStream=!0;var v=e;u===void 0&&(u=o.map(be=>({"@":be})));for(var C=0;C<u.length;C++){v=ne(e,u[C]);var q=await j(r,u[C]["@"],v);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var V=0;V<q.length;V++)i={},Object.assign(i,u[C]),q.tupleStream?Object.assign(i,q[V]):(r.focus?(i[r.focus]=q[V],i["@"]=u[C]["@"]):i["@"]=q[V],r.index&&(i[r.index]=V),r.ancestor&&(i[r.ancestor.label]=u[C]["@"])),t.push(i)}}return r.stages&&(t=await he(r.stages,t,e)),t}async function se(r,o,u){var e=U();if(o&&o.tupleStream&&(e.tupleStream=!0),Array.isArray(o)||(o=U(o)),r.type==="number"){var t=Math.floor(r.value);t<0&&(t=o.length+t);var n=await o[t];typeof n<"u"&&(Array.isArray(n)?e=n:e.push(n))}else for(t=0;t<o.length;t++){var n=o[t],f=n,i=u;o.tupleStream&&(f=n["@"],i=ne(u,n));var v=await j(r,f,i);S(v)&&(v=[v]),A(v)?v.forEach(function(q){var V=Math.floor(q);V<0&&(V=o.length+V),V===t&&e.push(n)}):l.boolean(v)&&e.push(n)}return e}async function Ae(r,o,u){var e,t=await j(r.lhs,o,u),n=r.value,f=async()=>await j(r.rhs,o,u);if(n==="and"||n==="or")try{return await we(t,f,n)}catch(v){throw v.position=r.position,v.token=n,v}var i=await f();try{switch(n){case"+":case"-":case"*":case"/":case"%":e=a(t,i,n);break;case"=":case"!=":e=s(t,i,n);break;case"<":case"<=":case">":case">=":e=L(t,i,n);break;case"&":e=p(t,i);break;case"..":e=D(t,i);break;case"in":e=re(t,i);break}}catch(v){throw v.position=r.position,v.token=n,v}return e}async function $e(r,o,u){var e;switch(r.value){case"-":if(e=await j(r.expression,o,u),typeof e>"u")e=void 0;else if(S(e))e=-e;else throw{code:"D1002",stack:new Error().stack,position:r.position,token:r.value,value:e};break;case"[":e=[];let f=await Promise.all(r.expressions.map(async(i,v)=>(u.isParallelCall=v>0,[i,await j(i,o,u)])));for(let i of f){var[t,n]=i;typeof n<"u"&&(t.value==="["?e.push(n):e=l.append(e,n))}r.consarray&&Object.defineProperty(e,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":e=await m(r,o,u);break}return e}function de(r,o,u){return l.lookup(o,r.value)}function te(r){return r.value}function qe(r,o){var u=U();return Array.isArray(o)&&o.outerWrapper&&o.length>0&&(o=o[0]),o!==null&&typeof o=="object"&&Object.keys(o).forEach(function(e){var t=o[e];Array.isArray(t)?(t=K(t),u=l.append(u,t)):u.push(t)}),u}function K(r,o){return typeof o>"u"&&(o=[]),Array.isArray(r)?r.forEach(function(u){K(u,o)}):o.push(r),o}function Se(r,o){var u,e=U();return typeof o<"u"&&(He(o,e),e.length===1?u=e[0]:u=e),u}function He(r,o){Array.isArray(r)||o.push(r),Array.isArray(r)?r.forEach(function(u){He(u,o)}):r!==null&&typeof r=="object"&&Object.keys(r).forEach(function(u){He(r[u],o)})}function a(r,o,u){var e;if(typeof r<"u"&&!S(r))throw{code:"T2001",stack:new Error().stack,value:r};if(typeof o<"u"&&!S(o))throw{code:"T2002",stack:new Error().stack,value:o};if(typeof r>"u"||typeof o>"u")return e;switch(u){case"+":e=r+o;break;case"-":e=r-o;break;case"*":e=r*o;break;case"/":e=r/o;break;case"%":e=r%o;break}return e}function s(r,o,u){var e,t=typeof r,n=typeof o;if(t==="undefined"||n==="undefined")return!1;switch(u){case"=":e=B(r,o);break;case"!=":e=!B(r,o);break}return e}function L(r,o,u){var e,t=typeof r,n=typeof o,f=t==="undefined"||t==="string"||t==="number",i=n==="undefined"||n==="string"||n==="number";if(!f||!i)throw{code:"T2010",stack:new Error().stack,value:t==="string"||t==="number"?o:r};if(!(t==="undefined"||n==="undefined")){if(t!==n)throw{code:"T2009",stack:new Error().stack,value:r,value2:o};switch(u){case"<":e=r<o;break;case"<=":e=r<=o;break;case">":e=r>o;break;case">=":e=r>=o;break}return e}}function re(r,o){var u=!1;if(typeof r>"u"||typeof o>"u")return!1;Array.isArray(o)||(o=[o]);for(var e=0;e<o.length;e++)if(o[e]===r){u=!0;break}return u}async function we(r,o,u){var e,t=pe(r);switch(u){case"and":e=t&&pe(await o());break;case"or":e=t||pe(await o());break}return e}function pe(r){var o=l.boolean(r);return typeof o>"u"?!1:o}function p(r,o){var u,e="",t="";return typeof r<"u"&&(e=l.string(r)),typeof o<"u"&&(t=l.string(o)),u=e.concat(t),u}async function m(r,o,u){var e={},t={},n=!!(o&&o.tupleStream);Array.isArray(o)||(o=U(o)),o.length===0&&o.push(void 0);for(var f=0;f<o.length;f++)for(var i=o[f],v=n?ne(u,i):u,C=0;C<r.lhs.length;C++){var q=r.lhs[C],V=await j(q[0],n?i["@"]:i,v);if(typeof V!="string"&&V!==void 0)throw{code:"T1003",stack:new Error().stack,position:r.position,value:V};if(V!==void 0){var be={data:i,exprIndex:C};if(t.hasOwnProperty(V)){if(t[V].exprIndex!==C)throw{code:"D1009",stack:new Error().stack,position:r.position,value:V};t[V].data=l.append(t[V].data,i)}else t[V]=be}}let oe=await Promise.all(Object.keys(t).map(async(ve,Me)=>{let fe=t[ve];var xe=fe.data,We=u;if(n){var Fe=h(fe.data);xe=Fe["@"],delete Fe["@"],We=ne(u,Fe)}return u.isParallelCall=Me>0,[ve,await j(r.lhs[fe.exprIndex][1],xe,We)]}));for(let ve of oe){var[V,ke]=await ve;typeof ke<"u"&&(e[V]=ke)}return e}function h(r){if(!Array.isArray(r))return r;var o={};Object.assign(o,r[0]);for(var u=1;u<r.length;u++)for(const e in r[u])o[e]=l.append(o[e],r[u][e]);return o}function D(r,o){var u;if(typeof r<"u"&&!Number.isInteger(r))throw{code:"T2003",stack:new Error().stack,value:r};if(typeof o<"u"&&!Number.isInteger(o))throw{code:"T2004",stack:new Error().stack,value:o};if(typeof r>"u"||typeof o>"u"||r>o)return u;var e=o-r+1;if(e>1e7)throw{code:"D2014",stack:new Error().stack,value:e};u=new Array(e);for(var t=r,n=0;t<=o;t++,n++)u[n]=t;return u.sequence=!0,u}async function N(r,o,u){var e=await j(r.rhs,o,u);return u.bind(r.lhs.value,e),e}async function M(r,o,u){var e,t=await j(r.condition,o,u);return l.boolean(t)?e=await j(r.then,o,u):typeof r.else<"u"&&(e=await j(r.else,o,u)),e}async function k(r,o,u){for(var e,t=Ve(u),n=0;n<r.expressions.length;n++)e=await j(r.expressions[n],o,t);return e}function F(r){var o=new me.RegexEngine(r.value),u=function(e,t){var n;o.lastIndex=t||0;var f=o.exec(e);if(f!==null){if(n={match:f[0],start:f.index,end:f.index+f[0].length,groups:[]},f.length>1)for(var i=1;i<f.length;i++)n.groups.push(f[i]);n.next=function(){if(!(o.lastIndex>=e.length)){var v=u(e,o.lastIndex);if(v&&v.match==="")throw{code:"D1004",stack:new Error().stack,position:r.position,value:r.value.source};return v}}}return n};return u}function W(r,o,u){var e;return r.value===""?e=o&&o.outerWrapper?o[0]:o:e=u.lookup(r.value),e}async function ie(r,o,u){var e,t=o,n=!!o.tupleStream,f=async function(v,C){for(var q=0,V=0;q===0&&V<r.terms.length;V++){var be=r.terms[V],oe=v,ke=u;n&&(oe=v["@"],ke=ne(u,v));var ve=await j(be.expression,oe,ke);oe=C,ke=u,n&&(oe=C["@"],ke=ne(u,C));var Me=await j(be.expression,oe,ke),fe=typeof ve,xe=typeof Me;if(fe==="undefined"){q=xe==="undefined"?0:1;continue}if(xe==="undefined"){q=-1;continue}if(!(fe==="string"||fe==="number")||!(xe==="string"||xe==="number"))throw{code:"T2008",stack:new Error().stack,position:r.position,value:fe==="string"||fe==="number"?Me:ve};if(fe!==xe)throw{code:"T2007",stack:new Error().stack,position:r.position,value:ve,value2:Me};ve!==Me&&(ve<Me?q=-1:q=1,be.descending===!0&&(q=-q))}return q===1},i={environment:u,input:o};return e=await l.sort.apply(i,[t,f]),e}function ce(r,o,u){var e=async function(t){if(!(typeof t>"u")){var n=u.lookup("clone");if(!ue(n))throw{code:"T2013",stack:new Error().stack,position:r.position};var f=await H(n,[t],null,u),i=await j(r.pattern,f,u);if(typeof i<"u"){Array.isArray(i)||(i=[i]);for(var v=0;v<i.length;v++){var C=i[v];if(C&&(C.isPrototypeOf(f)||C instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:r.position};var q=await j(r.update,C,u),V=typeof q;if(V!=="undefined"){if(V!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:r.update.position,value:q};for(var be in q)C[be]=q[be]}if(typeof r.delete<"u"){var oe=await j(r.delete,C,u);if(typeof oe<"u"){var ke=oe;if(Array.isArray(oe)||(oe=[oe]),!w(oe))throw{code:"T2012",stack:new Error().stack,position:r.delete.position,value:ke};for(var ve=0;ve<oe.length;ve++)typeof C=="object"&&C!==null&&delete C[oe[ve]]}}}}return f}};return I(e,"<(oa):o>")}var _=$("function($f, $g) { function($x){ $g($f($x)) } }");async function Y(r,o,u){var e,t=await j(r.lhs,o,u);if(r.rhs.type==="function")e=await ae(r.rhs,o,u,{context:t});else{var n=await j(r.rhs,o,u);if(!ue(n))throw{code:"T2006",stack:new Error().stack,position:r.position,value:n};if(ue(t)){var f=await j(_,null,u);e=await H(f,[t,n],null,u)}else e=await H(n,[t],null,u)}return e}async function ae(r,o,u,e){var t,n=await j(r.procedure,o,u);if(typeof n>"u"&&r.procedure.type==="path"&&u.lookup(r.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:r.position,token:r.procedure.steps[0].value};var f=[];typeof e<"u"&&f.push(e.context);for(var i=0;i<r.arguments.length;i++){const C=await j(r.arguments[i],o,u);if(ue(C)){const q=async function(...V){return await H(C,V,null,u)};q.arity=J(C),f.push(q)}else f.push(C)}var v=r.procedure.type==="path"?r.procedure.steps[0].value:r.procedure.value;try{typeof n=="object"&&(n.token=v,n.position=r.position),t=await H(n,f,o,u)}catch(C){throw C.position||(C.position=r.position),C.token||(C.token=v),C}return t}async function H(r,o,u,e){var t;for(t=await Ce(r,o,u,e);ge(t)&&t.thunk===!0;){var n=await j(t.body.procedure,t.input,t.environment);t.body.procedure.type==="variable"&&(n.token=t.body.procedure.value),n.position=t.body.procedure.position;for(var f=[],i=0;i<t.body.arguments.length;i++)f.push(await j(t.body.arguments[i],t.input,t.environment));t=await Ce(n,f,u,e)}return t}async function Ce(r,o,u,e){var t;try{var n=o;if(r&&(n=Pe(r.signature,o,u)),ge(r))t=await je(r,n);else if(r&&r._jsonata_function===!0){var f={environment:e,input:u};t=r.implementation.apply(f,n),Z(t)&&(t=t.next().value),P(t)&&(t=await t)}else if(typeof r=="function")t=r.apply(u,n),P(t)&&(t=await t);else throw{code:"T1006",stack:new Error().stack}}catch(i){throw r&&(typeof i.token>"u"&&typeof r.token<"u"&&(i.token=r.token),i.position=r.position||i.position),i}return t}function _e(r,o,u){var e={_jsonata_lambda:!0,input:o,environment:u,arguments:r.arguments,signature:r.signature,body:r.body};return r.thunk===!0&&(e.thunk=!0),e.apply=async function(t,n){return await H(e,n,o,t?t.environment:u)},e}async function Ue(r,o,u){for(var e,t=[],n=0;n<r.arguments.length;n++){var f=r.arguments[n];f.type==="operator"&&f.value==="?"?t.push(f):t.push(await j(f,o,u))}var i=await j(r.procedure,o,u);if(typeof i>"u"&&r.procedure.type==="path"&&u.lookup(r.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:r.position,token:r.procedure.steps[0].value};if(ge(i))e=Xe(i,t);else if(i&&i._jsonata_function===!0)e=et(i.implementation,t);else if(typeof i=="function")e=et(i,t);else throw{code:"T1008",stack:new Error().stack,position:r.position,token:r.procedure.type==="path"?r.procedure.steps[0].value:r.procedure.value};return e}function Pe(r,o,u){if(typeof r>"u")return o;var e=r.validate(o,u);return e}async function je(r,o){var u,e=Ve(r.environment);return r.arguments.forEach(function(t,n){e.bind(t.value,o[n])}),typeof r.body=="function"?u=await pt(r.body,e):u=await j(r.body,r.input,e),u}function Xe(r,o){var u=Ve(r.environment),e=[];r.arguments.forEach(function(n,f){var i=o[f];i&&i.type==="operator"&&i.value==="?"?e.push(n):u.bind(n.value,i)});var t={_jsonata_lambda:!0,input:r.input,environment:u,arguments:e,body:r.body};return t}function et(r,o){var u=tt(r);u=u.map(function(f){return"$"+f.trim()});var e="function("+u.join(", ")+"){ _ }",t=$(e);t.body=r;var n=Xe(t,o);return n}async function pt(r,o){var u=tt(r),e=u.map(function(f){return o.lookup(f.trim())}),t={environment:o},n=r.apply(t,e);return P(n)&&(n=await n),n}function tt(r){var o=r.toString(),u=/\(([^)]*)\)/.exec(o)[1],e=u.split(",");return e}function I(r,o){var u={_jsonata_function:!0,implementation:r};return typeof o<"u"&&(u.signature=z(o)),u}async function ht(r,o){if(!(typeof r>"u")){var u=this.input;typeof o<"u"&&(u=o,Array.isArray(u)&&!Q(u)&&(u=U(u),u.outerWrapper=!0));try{var e=$(r,!1)}catch(n){throw Je(n),{stack:new Error().stack,code:"D3120",value:n.message,error:n}}try{var t=await j(e,u,this.environment)}catch(n){throw Je(n),{stack:new Error().stack,code:"D3121",value:n.message,error:n}}return t}}function ct(r){if(!(typeof r>"u"))return JSON.parse(l.string(r))}function Ve(r){var o={};const u={bind:function(t,n){o[t]=n},lookup:function(t){var n;return o.hasOwnProperty(t)?n=o[t]:r&&(n=r.lookup(t)),n},timestamp:r?r.timestamp:null,async:r?r.async:!1,isParallelCall:r?r.isParallelCall:!1,global:r?r.global:{ancestry:[null]}};if(r){var e=r.lookup(Symbol.for("jsonata.__createFrame_push"));e&&e(r,u)}return u}g.bind("sum",I(l.sum,"<a<n>:n>")),g.bind("count",I(l.count,"<a:n>")),g.bind("max",I(l.max,"<a<n>:n>")),g.bind("min",I(l.min,"<a<n>:n>")),g.bind("average",I(l.average,"<a<n>:n>")),g.bind("string",I(l.string,"<x-b?:s>")),g.bind("substring",I(l.substring,"<s-nn?:s>")),g.bind("substringBefore",I(l.substringBefore,"<s-s:s>")),g.bind("substringAfter",I(l.substringAfter,"<s-s:s>")),g.bind("lowercase",I(l.lowercase,"<s-:s>")),g.bind("uppercase",I(l.uppercase,"<s-:s>")),g.bind("length",I(l.length,"<s-:n>")),g.bind("trim",I(l.trim,"<s-:s>")),g.bind("pad",I(l.pad,"<s-ns?:s>")),g.bind("match",I(l.match,"<s-f<s:o>n?:a<o>>")),g.bind("contains",I(l.contains,"<s-(sf):b>")),g.bind("replace",I(l.replace,"<s-(sf)(sf)n?:s>")),g.bind("split",I(l.split,"<s-(sf)n?:a<s>>")),g.bind("join",I(l.join,"<a<s>s?:s>")),g.bind("formatNumber",I(l.formatNumber,"<n-so?:s>")),g.bind("formatBase",I(l.formatBase,"<n-n?:s>")),g.bind("formatInteger",I(T.formatInteger,"<n-s:s>")),g.bind("parseInteger",I(T.parseInteger,"<s-s:n>")),g.bind("number",I(l.number,"<(nsb)-:n>")),g.bind("floor",I(l.floor,"<n-:n>")),g.bind("ceil",I(l.ceil,"<n-:n>")),g.bind("round",I(l.round,"<n-n?:n>")),g.bind("abs",I(l.abs,"<n-:n>")),g.bind("sqrt",I(l.sqrt,"<n-:n>")),g.bind("power",I(l.power,"<n-n:n>")),g.bind("random",I(l.random,"<:n>")),g.bind("boolean",I(l.boolean,"<x-:b>")),g.bind("not",I(l.not,"<x-:b>")),g.bind("map",I(l.map,"<af>")),g.bind("zip",I(l.zip,"<a+>")),g.bind("filter",I(l.filter,"<af>")),g.bind("single",I(l.single,"<af?>")),g.bind("reduce",I(l.foldLeft,"<afj?:j>")),g.bind("sift",I(l.sift,"<o-f?:o>")),g.bind("keys",I(l.keys,"<x-:a<s>>")),g.bind("lookup",I(l.lookup,"<x-s:x>")),g.bind("append",I(l.append,"<xx:a>")),g.bind("exists",I(l.exists,"<x:b>")),g.bind("spread",I(l.spread,"<x-:a<o>>")),g.bind("merge",I(l.merge,"<a<o>:o>")),g.bind("reverse",I(l.reverse,"<a:a>")),g.bind("each",I(l.each,"<o-f:a>")),g.bind("error",I(l.error,"<s?:x>")),g.bind("assert",I(l.assert,"<bs?:x>")),g.bind("type",I(l.type,"<x:s>")),g.bind("sort",I(l.sort,"<af?:a>")),g.bind("shuffle",I(l.shuffle,"<a:a>")),g.bind("distinct",I(l.distinct,"<x:x>")),g.bind("base64encode",I(l.base64encode,"<s-:s>")),g.bind("base64decode",I(l.base64decode,"<s-:s>")),g.bind("encodeUrlComponent",I(l.encodeUrlComponent,"<s-:s>")),g.bind("encodeUrl",I(l.encodeUrl,"<s-:s>")),g.bind("decodeUrlComponent",I(l.decodeUrlComponent,"<s-:s>")),g.bind("decodeUrl",I(l.decodeUrl,"<s-:s>")),g.bind("eval",I(ht,"<sx?:x>")),g.bind("toMillis",I(T.toMillis,"<s-s?:n>")),g.bind("fromMillis",I(T.fromMillis,"<n-s?s?:s>")),g.bind("clone",I(ct,"<(oa)-:o>"));var ot={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 Je(r){var o=ot[r.code];if(typeof o<"u"){var u=o.replace(/\{\{\{([^}]+)}}}/g,function(){return r[arguments[1]]});u=u.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(r[arguments[1]])}),r.message=u}}function me(r,o){var u,e;try{u=$(r,o&&o.recover),e=u.errors,delete u.errors}catch(f){throw Je(f),f}var t=Ve(g),n=new Date;return t.bind("now",I(function(f,i){return T.fromMillis(n.getTime(),f,i)},"<s?s?:s>")),t.bind("millis",I(function(){return n.getTime()},"<:n>")),o&&o.RegexEngine?me.RegexEngine=o.RegexEngine:me.RegexEngine=RegExp,{evaluate:async function(f,i,v){if(typeof e<"u"){var C={code:"S0500",position:0};throw Je(C),C}if(typeof i<"u"){var q;q=Ve(t);for(var V in i)q.bind(V,i[V])}else q=t;q.bind("$",f),n=new Date,q.timestamp=n,Array.isArray(f)&&!Q(f)&&(f=U(f),f.outerWrapper=!0);var be;try{return be=await j(u,f,q),typeof v=="function"&&v(null,be),be}catch(oe){throw Je(oe),oe}},assign:function(f,i){t.bind(f,i)},registerFunction:function(f,i,v){var C=I(i,v);t.bind(f,C)},ast:function(){return u},errors:function(){return e}}}return me.parser=$,me})();E.exports=X},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(y,E,b){var T=y("./signature");const l=(()=>{var x={".":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},$={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},z=function(S){var w=0,A=S.length,U=function(ge,Z){var P={type:ge,value:Z,position:w};return P},Q=function(){for(var ge=w,Z=0,P,J,B=function(j){if(S.charAt(j)==="/"&&Z===0){for(var R=0;S.charAt(j-(R+1))==="\\";)R++;if(R%2===0)return!0}return!1};w<A;){var g=S.charAt(w);if(B(w)){if(P=S.substring(ge,w),P==="")throw{code:"S0301",stack:new Error().stack,position:w};for(w++,g=S.charAt(w),ge=w;g==="i"||g==="m";)w++,g=S.charAt(w);return J=S.substring(ge,w)+"g",new RegExp(P,J)}(g==="("||g==="["||g==="{")&&S.charAt(w-1)!=="\\"&&Z++,(g===")"||g==="]"||g==="}")&&S.charAt(w-1)!=="\\"&&Z--,w++}throw{code:"S0302",stack:new Error().stack,position:w}},ue=function(ge){if(w>=A)return null;for(var Z=S.charAt(w);w<A&&`
3
+ \r\v`.indexOf(Z)>-1;)w++,Z=S.charAt(w);if(Z==="/"&&S.charAt(w+1)==="*"){var P=w;for(w+=2,Z=S.charAt(w);!(Z==="*"&&S.charAt(w+1)==="/");)if(Z=S.charAt(++w),w>=A)throw{code:"S0106",stack:new Error().stack,position:P};return w+=2,Z=S.charAt(w),ue(ge)}if(ge!==!0&&Z==="/")return w++,U("regex",Q());if(Z==="."&&S.charAt(w+1)===".")return w+=2,U("operator","..");if(Z===":"&&S.charAt(w+1)==="=")return w+=2,U("operator",":=");if(Z==="!"&&S.charAt(w+1)==="=")return w+=2,U("operator","!=");if(Z===">"&&S.charAt(w+1)==="=")return w+=2,U("operator",">=");if(Z==="<"&&S.charAt(w+1)==="=")return w+=2,U("operator","<=");if(Z==="*"&&S.charAt(w+1)==="*")return w+=2,U("operator","**");if(Z==="~"&&S.charAt(w+1)===">")return w+=2,U("operator","~>");if(Z==="?"&&S.charAt(w+1)===":")return w+=2,U("operator","?:");if(Z==="?"&&S.charAt(w+1)==="?")return w+=2,U("operator","??");if(Object.prototype.hasOwnProperty.call(x,Z))return w++,U("operator",Z);if(Z==='"'||Z==="'"){var J=Z;w++;for(var B="";w<A;){if(Z=S.charAt(w),Z==="\\")if(w++,Z=S.charAt(w),Object.prototype.hasOwnProperty.call($,Z))B+=$[Z];else if(Z==="u"){var g=S.substr(w+1,4);if(/^[0-9a-fA-F]+$/.test(g)){var j=parseInt(g,16);B+=String.fromCharCode(j),w+=4}else throw{code:"S0104",stack:new Error().stack,position:w}}else throw{code:"S0103",stack:new Error().stack,position:w,token:Z};else{if(Z===J)return w++,U("string",B);B+=Z}w++}throw{code:"S0101",stack:new Error().stack,position:w}}var R=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,ne=R.exec(S.substring(w));if(ne!==null){var le=parseFloat(ne[0]);if(!isNaN(le)&&isFinite(le))return w+=ne[0].length,U("number",le);throw{code:"S0102",stack:new Error().stack,position:w,token:ne[0]}}var he;if(Z==="`"){w++;var ye=S.indexOf("`",w);if(ye!==-1)return he=S.substring(w,ye),w=ye+1,U("name",he);throw w=A,{code:"S0105",stack:new Error().stack,position:w}}for(var se=w,Ae;;)if(Ae=S.charAt(se),se===A||`
4
+ \r\v`.indexOf(Ae)>-1||Object.prototype.hasOwnProperty.call(x,Ae)){if(S.charAt(w)==="$")return he=S.substring(w+1,se),w=se,U("variable",he);switch(he=S.substring(w,se),w=se,he){case"or":case"in":case"and":return U("operator",he);case"true":return U("value",!0);case"false":return U("value",!1);case"null":return U("value",null);default:return w===A&&he===""?null:U("name",he)}}else se++};return ue},X=function(S,w){var A,U,Q={},ue=[],ge=function(){var a=[];A.id!=="(end)"&&a.push({type:A.type,value:A.value,position:A.position});for(var s=U();s!==null;)a.push(s),s=U();return a},Z={nud:function(){var a={code:"S0211",token:this.value,position:this.position};if(w)return a.remaining=ge(),a.type="error",ue.push(a),a;throw a.stack=new Error().stack,a}},P=function(a,s){var L=Q[a];return s=s||0,L?s>=L.lbp&&(L.lbp=s):(L=Object.create(Z),L.id=L.value=a,L.lbp=s,Q[a]=L),L},J=function(a){if(w){a.remaining=ge(),ue.push(a);var s=Q["(error)"];return A=Object.create(s),A.error=a,A.type="(error)",A}else throw a.stack=new Error().stack,a},B=function(a,s){if(a&&A.id!==a){var L;A.id==="(end)"?L="S0203":L="S0202";var re={code:L,position:A.position,token:A.value,value:a};return J(re)}var we=U(s);if(we===null)return A=Q["(end)"],A.position=S.length,A;var pe=we.value,p=we.type,m;switch(p){case"name":case"variable":m=Q["(name)"];break;case"operator":if(m=Q[pe],!m)return J({code:"S0204",stack:new Error().stack,position:we.position,token:pe});break;case"string":case"number":case"value":m=Q["(literal)"];break;case"regex":p="regex",m=Q["(regex)"];break;default:return J({code:"S0205",stack:new Error().stack,position:we.position,token:pe})}return A=Object.create(m),A.value=pe,A.type=p,A.position=we.position,A},g=function(a){var s,L=A;for(B(null,!0),s=L.nud();a<A.lbp;)L=A,B(),s=L.led(s);return s},j=function(a){var s=P(a,0);s.nud=function(){return this}},R=function(a,s,L){var re=s||x[a],we=P(a,re);return we.led=L||function(pe){return this.lhs=pe,this.rhs=g(re),this.type="binary",this},we},ne=function(a,s,L){var re=P(a,s);return re.led=L,re},le=function(a,s){var L=P(a);return L.nud=s||function(){return this.expression=g(70),this.type="unary",this},L};j("(end)"),j("(name)"),j("(literal)"),j("(regex)"),P(":"),P(";"),P(","),P(")"),P("]"),P("}"),P(".."),R("."),R("+"),R("-"),R("*"),R("/"),R("%"),R("="),R("<"),R(">"),R("!="),R("<="),R(">="),R("&"),R("and"),R("or"),R("in"),j("and"),j("or"),j("in"),le("-"),R("~>"),R("??",x["??"],function(a){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[a]},this.then=a,this.else=g(0),this}),ne("(error)",10,function(a){return this.lhs=a,this.error=A.error,this.remaining=ge(),this.type="error",this}),le("*",function(){return this.type="wildcard",this}),le("**",function(){return this.type="descendant",this}),le("%",function(){return this.type="parent",this}),R("(",x["("],function(a){if(this.procedure=a,this.type="function",this.arguments=[],A.id!==")")for(;A.type==="operator"&&A.id==="?"?(this.type="partial",this.arguments.push(A),B("?")):this.arguments.push(g(0)),A.id===",";)B(",");if(B(")",!0),a.type==="name"&&(a.value==="function"||a.value==="λ")){if(this.arguments.forEach(function(pe,p){if(pe.type!=="variable")return J({code:"S0208",stack:new Error().stack,position:pe.position,token:pe.value,value:p+1})}),this.type="lambda",A.id==="<"){for(var s=A.position,L=1,re="<";L>0&&A.id!=="{"&&A.id!=="(end)";){var we=B();we.id===">"?L--:we.id==="<"&&L++,re+=we.value}B(">");try{this.signature=T(re)}catch(pe){return pe.position=s+pe.offset,J(pe)}}B("{"),this.body=g(0),B("}")}return this}),le("(",function(){for(var a=[];A.id!==")"&&(a.push(g(0)),A.id===";");)B(";");return B(")",!0),this.type="block",this.expressions=a,this}),le("[",function(){var a=[];if(A.id!=="]")for(;;){var s=g(0);if(A.id===".."){var L={type:"binary",value:"..",position:A.position,lhs:s};B(".."),L.rhs=g(0),s=L}if(a.push(s),A.id!==",")break;B(",")}return B("]",!0),this.expressions=a,this.type="unary",this}),R("[",x["["],function(a){if(A.id==="]"){for(var s=a;s&&s.type==="binary"&&s.value==="[";)s=s.lhs;return s.keepArray=!0,B("]"),a}else return this.lhs=a,this.rhs=g(x["]"]),this.type="binary",B("]",!0),this}),R("^",x["^"],function(a){B("(");for(var s=[];;){var L={descending:!1};if(A.id==="<"?B("<"):A.id===">"&&(L.descending=!0,B(">")),L.expression=g(0),s.push(L),A.id!==",")break;B(",")}return B(")"),this.lhs=a,this.rhs=s,this.type="binary",this});var he=function(a){var s=[];if(A.id!=="}")for(;;){var L=g(0);B(":");var re=g(0);if(s.push([L,re]),A.id!==",")break;B(",")}return B("}",!0),typeof a>"u"?(this.lhs=s,this.type="unary"):(this.lhs=a,this.rhs=s,this.type="binary"),this};le("{",he),R("{",x["{"],he),ne(":=",x[":="],function(a){return a.type!=="variable"?J({code:"S0212",stack:new Error().stack,position:a.position,token:a.value}):(this.lhs=a,this.rhs=g(x[":="]-1),this.type="binary",this)}),R("@",x["@"],function(a){return this.lhs=a,this.rhs=g(x["@"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),R("#",x["#"],function(a){return this.lhs=a,this.rhs=g(x["#"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),R("?",x["?"],function(a){return this.type="condition",this.condition=a,this.then=g(0),A.id===":"&&(B(":"),this.else=g(0)),this}),R("?:",x["?:"],function(a){return this.type="condition",this.condition=a,this.then=a,this.else=g(0),this}),le("|",function(){return this.type="transform",this.pattern=g(0),B("|"),this.update=g(0),A.id===","&&(B(","),this.delete=g(0)),B("|"),this});var ye=function(a){var s;if(a.type==="function"&&!a.predicate){var L={type:"lambda",thunk:!0,arguments:[],position:a.position};L.body=a,s=L}else if(a.type==="condition")a.then=ye(a.then),typeof a.else<"u"&&(a.else=ye(a.else)),s=a;else if(a.type==="block"){var re=a.expressions.length;re>0&&(a.expressions[re-1]=ye(a.expressions[re-1])),s=a}else s=a;return s},se=0,Ae=0,$e=[],de=function(a,s){switch(a.type){case"name":case"wildcard":s.level--,s.level===0&&(typeof a.ancestor>"u"||($e[s.index].slot.label=a.ancestor.label),a.ancestor=s,a.tuple=!0);break;case"parent":s.level++;break;case"block":a.expressions.length>0&&(a.tuple=!0,s=de(a.expressions[a.expressions.length-1],s));break;case"path":a.tuple=!0;var L=a.steps.length-1;for(s=de(a.steps[L--],s);s.level>0&&L>=0;)s=de(a.steps[L--],s);break;default:throw{code:"S0217",token:a.type,position:a.position}}return s},te=function(a,s){if(typeof s.seekingParent<"u"||s.type==="parent"){var L=typeof s.seekingParent<"u"?s.seekingParent:[];s.type==="parent"&&L.push(s.slot),typeof a.seekingParent>"u"?a.seekingParent=L:Array.prototype.push.apply(a.seekingParent,L)}},qe=function(a){var s=a.steps.length-1,L=a.steps[s],re=typeof L.seekingParent<"u"?L.seekingParent:[];L.type==="parent"&&re.push(L.slot);for(var we=0;we<re.length;we++){var pe=re[we];for(s=a.steps.length-2;pe.level>0;){if(s<0){typeof a.seekingParent>"u"?a.seekingParent=[pe]:a.seekingParent.push(pe);break}for(var p=a.steps[s--];s>=0&&p.focus&&a.steps[s].focus;)p=a.steps[s--];pe=de(p,pe)}}},K=function(a){var s;switch(a.type){case"binary":switch(a.value){case".":var L=K(a.lhs);L.type==="path"?s=L:s={type:"path",steps:[L]},L.type==="parent"&&(s.seekingParent=[L.slot]);var re=K(a.rhs);re.type==="function"&&re.procedure.type==="path"&&re.procedure.steps.length===1&&re.procedure.steps[0].type==="name"&&s.steps[s.steps.length-1].type==="function"&&(s.steps[s.steps.length-1].nextFunction=re.procedure.steps[0].value),re.type==="path"?Array.prototype.push.apply(s.steps,re.steps):(typeof re.predicate<"u"&&(re.stages=re.predicate,delete re.predicate),s.steps.push(re)),s.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),s.steps.filter(function(F){return F.keepArray===!0}).length>0&&(s.keepSingletonArray=!0);var we=s.steps[0];we.type==="unary"&&we.value==="["&&(we.consarray=!0);var pe=s.steps[s.steps.length-1];pe.type==="unary"&&pe.value==="["&&(pe.consarray=!0),qe(s);break;case"[":s=K(a.lhs);var p=s,m="predicate";if(s.type==="path"&&(p=s.steps[s.steps.length-1],m="stages"),typeof p.group<"u")throw{code:"S0209",stack:new Error().stack,position:a.position};typeof p[m]>"u"&&(p[m]=[]);var h=K(a.rhs);typeof h.seekingParent<"u"&&(h.seekingParent.forEach(F=>{F.level===1?de(p,F):F.level--}),te(p,h)),p[m].push({type:"filter",expr:h,position:a.position});break;case"{":if(s=K(a.lhs),typeof s.group<"u")throw{code:"S0210",stack:new Error().stack,position:a.position};s.group={lhs:a.rhs.map(function(F){return[K(F[0]),K(F[1])]}),position:a.position};break;case"^":s=K(a.lhs),s.type!=="path"&&(s={type:"path",steps:[s]});var D={type:"sort",position:a.position};D.terms=a.rhs.map(function(F){var W=K(F.expression);return te(D,W),{descending:F.descending,expression:W}}),s.steps.push(D),qe(s);break;case":=":s={type:"bind",value:a.value,position:a.position},s.lhs=K(a.lhs),s.rhs=K(a.rhs),te(s,s.rhs);break;case"@":if(s=K(a.lhs),p=s,s.type==="path"&&(p=s.steps[s.steps.length-1]),typeof p.stages<"u"||typeof p.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:a.position};if(p.type==="sort")throw{code:"S0216",stack:new Error().stack,position:a.position};a.keepArray&&(p.keepArray=!0),p.focus=a.rhs.value,p.tuple=!0;break;case"#":s=K(a.lhs),p=s,s.type==="path"?p=s.steps[s.steps.length-1]:(s={type:"path",steps:[s]},typeof p.predicate<"u"&&(p.stages=p.predicate,delete p.predicate)),typeof p.stages>"u"?p.index=a.rhs.value:p.stages.push({type:"index",value:a.rhs.value,position:a.position}),p.tuple=!0;break;case"~>":s={type:"apply",value:a.value,position:a.position},s.lhs=K(a.lhs),s.rhs=K(a.rhs),s.keepArray=s.lhs.keepArray||s.rhs.keepArray;break;default:s={type:a.type,value:a.value,position:a.position},s.lhs=K(a.lhs),s.rhs=K(a.rhs),te(s,s.lhs),te(s,s.rhs)}break;case"unary":s={type:a.type,value:a.value,position:a.position},a.value==="["?s.expressions=a.expressions.map(function(F){var W=K(F);return te(s,W),W}):a.value==="{"?s.lhs=a.lhs.map(function(F){var W=K(F[0]);te(s,W);var ie=K(F[1]);return te(s,ie),[W,ie]}):(s.expression=K(a.expression),a.value==="-"&&s.expression.type==="number"?(s=s.expression,s.value=-s.value):te(s,s.expression));break;case"function":case"partial":s={type:a.type,name:a.name,value:a.value,position:a.position},s.arguments=a.arguments.map(function(F){var W=K(F);return te(s,W),W}),s.procedure=K(a.procedure);break;case"lambda":s={type:a.type,arguments:a.arguments,signature:a.signature,position:a.position};var N=K(a.body);s.body=ye(N);break;case"condition":s={type:a.type,position:a.position},s.condition=K(a.condition),te(s,s.condition),s.then=K(a.then),te(s,s.then),typeof a.else<"u"&&(s.else=K(a.else),te(s,s.else));break;case"transform":s={type:a.type,position:a.position},s.pattern=K(a.pattern),s.update=K(a.update),typeof a.delete<"u"&&(s.delete=K(a.delete));break;case"block":s={type:a.type,position:a.position},s.expressions=a.expressions.map(function(F){var W=K(F);return te(s,W),(W.consarray||W.type==="path"&&W.steps[0].consarray)&&(s.consarray=!0),W});break;case"name":s={type:"path",steps:[a]},a.keepArray&&(s.keepSingletonArray=!0);break;case"parent":s={type:"parent",slot:{label:"!"+se++,level:1,index:Ae++}},$e.push(s);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":s=a;break;case"operator":if(a.value==="and"||a.value==="or"||a.value==="in")a.type="name",s=K(a);else if(a.value==="?")s=a;else throw{code:"S0201",stack:new Error().stack,position:a.position,token:a.value};break;case"error":s=a,a.lhs&&(s=K(a.lhs));break;default:var M="S0206";a.id==="(end)"&&(M="S0207");var k={code:M,position:a.position,token:a.value};if(w)return ue.push(k),{type:"error",error:k};throw k.stack=new Error().stack,k}return a.keepArray&&(s.keepArray=!0),s};U=z(S),B();var Se=g(0);if(A.id!=="(end)"){var He={code:"S0201",position:A.position,token:A.value};J(He)}if(Se=K(Se),Se.type==="parent"||typeof Se.seekingParent<"u")throw{code:"S0217",token:Se.type,position:Se.position};return ue.length>0&&(Se.errors=ue),Se};return X})();E.exports=l},{"./signature":5}],5:[function(y,E,b){var T=y("./utils");const l=(()=>{var x={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function $(z){for(var X=1,S=[],w={},A=w;X<z.length;){var U=z.charAt(X);if(U===":")break;var Q=function(){S.push(w),A=w,w={}},ue=function(R,ne,le,he){for(var ye=1,se=ne;se<R.length;)if(se++,U=R.charAt(se),U===he){if(ye--,ye===0)break}else U===le&&ye++;return se};switch(U){case"s":case"n":case"b":case"l":case"o":w.regex="["+U+"m]",w.type=U,Q();break;case"a":w.regex="[asnblfom]",w.type=U,w.array=!0,Q();break;case"f":w.regex="f",w.type=U,Q();break;case"j":w.regex="[asnblom]",w.type=U,Q();break;case"x":w.regex="[asnblfom]",w.type=U,Q();break;case"-":A.context=!0,A.contextRegex=new RegExp(A.regex),A.regex+="?";break;case"?":case"+":A.regex+=U;break;case"(":var ge=ue(z,X,"(",")"),Z=z.substring(X+1,ge);if(Z.indexOf("<")===-1)w.regex="["+Z+"m]";else throw{code:"S0402",stack:new Error().stack,value:Z,offset:X};w.type="("+Z+")",X=ge,Q();break;case"<":if(A.type==="a"||A.type==="f"){var P=ue(z,X,"<",">");A.subtype=z.substring(X+1,P),X=P}else throw{code:"S0401",stack:new Error().stack,value:A.type,offset:X};break}X++}var J="^"+S.map(function(R){return"("+R.regex+")"}).join("")+"$",B=new RegExp(J),g=function(R){var ne;if(T.isFunction(R))ne="f";else{var le=typeof R;switch(le){case"string":ne="s";break;case"number":ne="n";break;case"boolean":ne="b";break;case"object":R===null?ne="l":Array.isArray(R)?ne="a":ne="o";break;case"undefined":default:ne="m"}}return ne},j=function(R,ne){for(var le="^",he=0,ye=0;ye<S.length;ye++){le+=S[ye].regex;var se=ne.match(le);if(se===null)throw{code:"T0410",stack:new Error().stack,value:R[he],index:he+1};he=se[0].length}throw{code:"T0410",stack:new Error().stack,value:R[he],index:he+1}};return{definition:z,validate:function(R,ne){var le="";R.forEach(function(Ae){le+=g(Ae)});var he=B.exec(le);if(he){var ye=[],se=0;return S.forEach(function(Ae,$e){var de=R[se],te=he[$e+1];if(te==="")if(Ae.context&&Ae.contextRegex){var qe=g(ne);if(Ae.contextRegex.test(qe))ye.push(ne);else throw{code:"T0411",stack:new Error().stack,value:ne,index:se+1}}else ye.push(de),se++;else te.split("").forEach(function(K){if(Ae.type==="a"){if(K==="m")de=void 0;else{de=R[se];var Se=!0;if(typeof Ae.subtype<"u"){if(K!=="a"&&te!==Ae.subtype)Se=!1;else if(K==="a"&&de.length>0){var He=g(de[0]);if(He!==Ae.subtype.charAt(0))Se=!1;else{var a=de.filter(function(s){return g(s)!==He});Se=a.length===0}}}if(!Se)throw{code:"T0412",stack:new Error().stack,value:de,index:se+1,type:x[Ae.subtype]};K!=="a"&&(de=[de])}ye.push(de),se++}else ye.push(de),se++})}),ye}j(R,le)}}}return $})();E.exports=l},{"./utils":6}],6:[function(y,E,b){const T=(()=>{function l(P){var J=!1;if(typeof P=="number"&&(J=!isNaN(P),J&&!isFinite(P)))throw{code:"D1001",value:P,stack:new Error().stack};return J}function x(P){var J=!1;return Array.isArray(P)&&(J=P.filter(function(B){return typeof B!="string"}).length===0),J}function $(P){var J=!1;return Array.isArray(P)&&(J=P.filter(function(B){return!l(B)}).length===0),J}function z(){var P=[];return P.sequence=!0,arguments.length===1&&P.push(arguments[0]),P}function X(P){return P.sequence===!0&&Array.isArray(P)}function S(P){return P&&(P._jsonata_function===!0||P._jsonata_lambda===!0)||typeof P=="function"}function w(P){var J=typeof P.arity=="number"?P.arity:typeof P.implementation=="function"?P.implementation.length:typeof P.length=="number"?P.length:P.arguments.length;return J}function A(P){return P&&P._jsonata_lambda===!0}var U=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function Q(P){return typeof P=="object"&&P!==null&&U in P&&"next"in P&&typeof P.next=="function"}function ue(P,J){if(P===J)return!0;if(typeof P=="object"&&typeof J=="object"&&P!==null&&J!==null){if(Array.isArray(P)&&Array.isArray(J)){if(P.length!==J.length)return!1;for(var B=0;B<P.length;B++)if(!ue(P[B],J[B]))return!1;return!0}var g=Object.getOwnPropertyNames(P),j=Object.getOwnPropertyNames(J);if(g.length!==j.length)return!1;for(g=g.sort(),j=j.sort(),B=0;B<g.length;B++)if(g[B]!==j[B])return!1;for(B=0;B<g.length;B++){var R=g[B];if(!ue(P[R],J[R]))return!1}return!0}return!1}function ge(P){return typeof P=="object"&&P!==null&&"then"in P&&typeof P.then=="function"}function Z(P){var J=[];for(let B of P)J.push(B);return J}return{isNumeric:l,isArrayOfStrings:x,isArrayOfNumbers:$,createSequence:z,isSequence:X,isFunction:S,isLambda:A,isIterable:Q,getFunctionArity:w,isDeepEqual:ue,stringToArray:Z,isPromise:ge}})();E.exports=T},{}]},{},[3])(3)})})(At)),At.exports}var Za=za();const Ha=Cn(Za),_a=O.object({name:O.literal("data-extract"),code:O.string(),inputData:O.any().optional()});function Wa(d){return _a.parse(d)}async function Va(d){try{console.log("[DataExtractBlock] Executing JSONata query:",d.code);const y=await Ha(d.code).evaluate(d.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:y}}catch(c){return console.error("[DataExtractBlock] Data extraction error:",c),{hasError:!0,message:c instanceof Error?c.message:"Unknown error in data extraction",data:void 0}}}class Ga{static async executeBlock(c){try{switch(c.name){case"get-text":{const y=Hn(c);return await _n(y)}case"attribute-value":{const y=Yn(c);return await Gn(y)}case"get-value-form":{const y=Kn(c);return await Xn(y)}case"set-value-form":{const y=ta(c);return await ra(y)}case"clear-value-form":{const y=oa(c);return await ia(y)}case"element-exists":{const y=ca(c);return await fa(y)}case"event-click":{const y=da(c);return await pa(y)}case"keypress":{const y=ma(c);return await ba(y)}case"wait":{const y=Ea(c);return await Aa(y)}case"save-assets":{const y=xa(c);return await Sa(y)}case"get-element-data":{const y=Oa(c);return await Ca(y)}case"scroll":{const y=Na(c);return await Ua(y)}case"ai-parse-data":{const y=jn(c);return await Bn(y)}case"fetch-api":{const y=$a(c);return await qa(y)}case"data-extract":{const y=Wa(c);return await Va(y)}default:return{hasError:!0,message:`Unknown block type: ${c.name}`,data:null}}}catch(y){return{hasError:!0,message:y instanceof Error?y.message:"Unknown error in block execution",data:null}}}}export{Un as AiParseDataBlockSchema,Ke as BaseBlockSchema,Ga as BlockHandler,aa as ClearValueFormsBlockSchema,_a as DataExtractBlockSchema,ua as ElementExistsBlockSchema,la as EventClickBlockSchema,La as FetchApiBlockSchema,Vn as GetAttributeValueBlockSchema,Pa as GetElementDataBlockSchema,Zn as GetTextBlockSchema,Jn as GetValueFormsBlockSchema,ga as KeypressBlockSchema,Ta as SaveAssetsBlockSchema,Fa as ScrollBlockSchema,ea as SetValueFormsBlockSchema,ka as WaitBlockSchema};