scordi-extension 1.16.3 → 1.16.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.
- package/README.md +61 -29
- package/dist/blocks/AiParseDataBlock.d.ts.map +1 -1
- package/dist/blocks/EventClickBlock.d.ts.map +1 -1
- package/dist/blocks/ExportDataBlock.d.ts.map +1 -1
- package/dist/blocks/KeypressBlock.d.ts.map +1 -1
- package/dist/blocks/NetworkCatchBlock.d.ts.map +1 -1
- package/dist/blocks/WaitForConditionBlock.d.ts.map +1 -1
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/sdk/EightGClient.d.ts +6 -3
- package/dist/sdk/EightGClient.d.ts.map +1 -1
- package/dist/sdk/index.cjs +2 -2
- package/dist/sdk/index.js +166 -160
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/types/internal-messages.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/binding.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/condition.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/index.d.ts +3 -3
- package/dist/workflow/context/execution-context/index.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/index.d.ts +1 -1
- package/dist/workflow/context/loop-context/index.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/loop-context.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/step-context/index.d.ts +1 -1
- package/dist/workflow/context/step-context/index.d.ts.map +1 -1
- package/dist/workflow/context/step-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/step-context/step-context.d.ts.map +1 -1
- package/dist/workflow/context/var-context/index.d.ts +1 -1
- package/dist/workflow/context/var-context/index.d.ts.map +1 -1
- package/dist/workflow/context/var-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/var-context/var-context.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/.vite/manifest.json +0 -75
- package/dist/assets/index-B45Q7XiR.js +0 -49
- package/dist/assets/index-BqQ8JinV.js +0 -1
- package/dist/assets/index-CVzjlC_s.js +0 -1
- package/dist/assets/index-CYVwV_2L.js +0 -1
- package/dist/assets/index-DkFIvNAm.css +0 -1
- package/dist/assets/index-DxZcS402.js +0 -1
- package/dist/assets/index-tW55lo_h.js +0 -4
- package/dist/assets/index.html-DZ7AUTQZ.js +0 -1
- package/dist/assets/index.ts-2nFLTUkL.js +0 -238
- package/dist/assets/index.ts-BRPHoTRl.js +0 -256
- package/dist/assets/index.ts-C2f2hGoV.js +0 -158
- package/dist/assets/index.ts-CD2jVezi.js +0 -256
- package/dist/assets/index.ts-COMnxBfB.js +0 -238
- package/dist/assets/index.ts-mAOhzdZJ.js +0 -238
- package/dist/assets/internal-messages-BMRA0i8A.js +0 -1
- package/dist/assets/internal-messages-BS1uEgeS.js +0 -1
- package/dist/assets/internal-messages-CP1ANEcL.js +0 -1
- package/dist/assets/internal-messages-Drf0Gb9U.js +0 -1
- package/dist/assets/loading-page-1924caaa.js +0 -51
- package/dist/assets/main.tsx-CHn9k-P7.js +0 -38
- package/dist/assets/main.tsx-DnGNeWWr.js +0 -38
- package/dist/assets/main.tsx-DtStYr-r.js +0 -2
- package/dist/assets/main.tsx-UFslEqbd.js +0 -38
- package/dist/assets/main.tsx-loader-6Ftbg0YS.js +0 -13
- package/dist/assets/main.tsx-loader-ByFSLdJ4.js +0 -13
- package/dist/assets/main.tsx-loader-CuF0J02t.js +0 -13
- package/dist/assets/main.tsx-loader-sjxNXQPw.js +0 -13
- package/dist/assets/types-BId3CBm7.js +0 -1
- package/dist/assets/types-CeXfY5Yv.js +0 -4
- package/dist/assets/types-Dzn4eD9c.js +0 -22
- package/dist/assets/types-q2_wITfk.js +0 -4
- package/dist/blocks/CaptureNetworkBlock.d.ts +0 -75
- package/dist/blocks/CaptureNetworkBlock.d.ts.map +0 -1
- package/dist/blocks/DataExtractBlock.d.ts +0 -23
- package/dist/blocks/DataExtractBlock.d.ts.map +0 -1
- package/dist/blocks/index.cjs +0 -4
- package/dist/blocks/index.js +0 -7839
- package/dist/blocks/logo.png +0 -0
- package/dist/logo.png +0 -0
- package/dist/manifest.json +0 -55
- package/dist/public/logo.png +0 -0
- package/dist/service-worker-loader.js +0 -3
- package/dist/src/blocks/AiParseDataBlock.ts.js +0 -111
- package/dist/src/blocks/CaptureNetworkBlock.ts.js +0 -55
- package/dist/src/blocks/ClearValueFormBlock.ts.js +0 -55
- package/dist/src/blocks/DataExtractBlock.ts.js +0 -28
- package/dist/src/blocks/ElementExistsBlock.ts.js +0 -26
- package/dist/src/blocks/EventClickBlock.ts.js +0 -143
- package/dist/src/blocks/ExportDataBlock.ts.js +0 -47
- package/dist/src/blocks/FetchApiBlock.ts.js +0 -50
- package/dist/src/blocks/GetAttributeValueBlock.ts.js +0 -33
- package/dist/src/blocks/GetElementDataBlock.ts.js +0 -114
- package/dist/src/blocks/GetTextBlock.ts.js +0 -152
- package/dist/src/blocks/GetValueFormBlock.ts.js +0 -52
- package/dist/src/blocks/KeypressBlock.ts.js +0 -89
- package/dist/src/blocks/NavigateBlock.ts.js +0 -48
- package/dist/src/blocks/NetworkCatchBlock.ts.js +0 -61
- package/dist/src/blocks/SaveAssetsBlock.ts.js +0 -35
- package/dist/src/blocks/ScrollBlock.ts.js +0 -111
- package/dist/src/blocks/SetValueFormBlock.ts.js +0 -56
- package/dist/src/blocks/TransformDataBlock.ts.js +0 -42
- package/dist/src/blocks/WaitBlock.ts.js +0 -24
- package/dist/src/blocks/WaitForConditionBlock.ts.js +0 -187
- package/dist/src/blocks/index.ts.js +0 -198
- package/dist/src/blocks/types.ts.js +0 -11
- package/dist/src/content/components/ConfirmationUI.tsx.js +0 -244
- package/dist/src/content/components/ExecutionStatusUI.tsx.js +0 -223
- package/dist/src/content/elements/finders/CssSelector.ts.js +0 -51
- package/dist/src/content/elements/finders/ElementSelector.ts.js +0 -20
- package/dist/src/content/elements/finders/IframeSelector.ts.js +0 -32
- package/dist/src/content/elements/finders/ShadowDOMSelector.ts.js +0 -38
- package/dist/src/content/elements/finders/XPathFinder.ts.js +0 -32
- package/dist/src/content/elements/index.ts.js +0 -26
- package/dist/src/content/elements/utils/CSSSelectorGenerator.ts.js +0 -72
- package/dist/src/content/elements/utils/XPathGenerator.ts.js +0 -62
- package/dist/src/content/handler/ExternalMessageHandler.ts.js +0 -78
- package/dist/src/content/handler/InternalMessageHandler.ts.js +0 -40
- package/dist/src/content/kernel/MessageKernel.ts.js +0 -83
- package/dist/src/content/main.tsx-loader.js +0 -22
- package/dist/src/content/main.tsx.js +0 -50
- package/dist/src/content/utils/index.ts.js +0 -1
- package/dist/src/content/utils/synchronizedLock.ts.js +0 -35
- package/dist/src/popup/index.html +0 -12
- package/dist/src/sdk/types.ts.js +0 -150
- package/dist/src/types/internal-messages.ts.js +0 -27
- package/dist/src/workflow/context/execution-context/types.ts.js +0 -0
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--29d58732.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--34285d49.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--36a0c079.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--7cce5f32.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--8598b0e0.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--9054997c.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--a79cb78d.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--af906259.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e041f26d.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e1405dc4.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e2a1f584.js +0 -45
- package/dist/vendor/.vite-deps-chunk-DC5AMYBS.js__v--87b685c1.js +0 -38
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--29d58732.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--34285d49.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--36a0c079.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--7cce5f32.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--8598b0e0.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--a79cb78d.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--af906259.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e041f26d.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e1405dc4.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e2a1f584.js +0 -975
- package/dist/vendor/.vite-deps-chunk-KDMJ4XM7.js__v--87b685c1.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-MANNBT4V.js__v--87b685c1.js +0 -280
- package/dist/vendor/.vite-deps-chunk-NZP3G7XT.js__v--87b685c1.js +0 -975
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--36a0c079.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--8598b0e0.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--9054997c.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--a79cb78d.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--e041f26d.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--e2a1f584.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--29d58732.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--34285d49.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--7cce5f32.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--af906259.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--e1405dc4.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--29d58732.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--34285d49.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--36a0c079.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--7cce5f32.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--8598b0e0.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--a79cb78d.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--af906259.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e041f26d.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e1405dc4.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e2a1f584.js +0 -280
- package/dist/vendor/.vite-deps-jsonata.js__v--1f855851.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--34285d49.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--370b8ffe.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--7496ecd5.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--7cce5f32.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--8598b0e0.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--989ee283.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--aa4cf553.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--af906259.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--d602c657.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--e041f26d.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--e2a1f584.js +0 -5761
- package/dist/vendor/.vite-deps-react-dom.js__v--1217aa43.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--34285d49.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--36c31e85.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--7cce5f32.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--8313ef2c.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--8598b0e0.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--87af57af.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--9967e564.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--af906259.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--e041f26d.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--e2a1f584.js +0 -6
- package/dist/vendor/.vite-deps-react-dom_client.js__v--05e7db8c.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--34285d49.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--7cce5f32.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--8598b0e0.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--8ec6d0f4.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--a69c8f91.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--aaaed31d.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--af906259.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--e041f26d.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--e2a1f584.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--f80719e9.js +0 -18108
- package/dist/vendor/.vite-deps-react.js__v--1217aa43.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--34285d49.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--36c31e85.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--7cce5f32.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--8313ef2c.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--8598b0e0.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--87af57af.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--9967e564.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--af906259.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--e041f26d.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--e2a1f584.js +0 -5
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--1217aa43.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--34285d49.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--36c31e85.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--7cce5f32.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--8313ef2c.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--8598b0e0.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--87af57af.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--9967e564.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--af906259.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--e041f26d.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--e2a1f584.js +0 -281
- package/dist/vendor/.vite-deps-zod.js__v--34285d49.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--6548a37a.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--706a718e.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--7cce5f32.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--8598b0e0.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--9e0f4cc1.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--af906259.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--b73c580c.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--dc9842e6.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--e041f26d.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--e2a1f584.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--e4714212.js +0 -222
- package/dist/vendor/crx-client-port.js +0 -66
- package/dist/vendor/crx-client-preamble.js +0 -4
- package/dist/vendor/react-refresh.js +0 -670
- package/dist/vendor/vite-client.js +0 -1134
- package/dist/vendor/vite-dist-client-env.mjs.js +0 -24
- package/dist/vendor/webcomponents-custom-elements.js +0 -47
package/dist/sdk/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var jn=Object.defineProperty;var Fn=(t,e,r)=>e in t?jn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ue=(t,e,r)=>Fn(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var we;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return t.objectValues(c)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},t.find=(s,i)=>{for(const c of s)if(i(c))return c},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(we||(we={}));var Ir;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ir||(Ir={}));const W=we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=t=>{switch(typeof t){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(t)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(t)?W.array:t===null?W.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?W.promise:typeof Map<"u"&&t instanceof Map?W.map:typeof Set<"u"&&t instanceof Set?W.set:typeof Date<"u"&&t instanceof Date?W.date:W.object;default:return W.unknown}},P=we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Bn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class st extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(r(c));else{let f=a,v=0;for(;v<c.path.length;){const k=c.path[v];v===c.path.length-1?(f[k]=f[k]||{_errors:[]},f[k]._errors.push(r(c))):f[k]=f[k]||{_errors:[]},f=f[k],v++}}};return s(this),a}static assert(e){if(!(e instanceof st))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,we.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}st.create=t=>new st(t);const Gt=(t,e)=>{let r;switch(t.code){case P.invalid_type:t.received===W.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,we.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${we.joinValues(t.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${we.joinValues(t.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${we.joinValues(t.options)}, received '${t.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:we.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case P.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case P.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=e.defaultError,we.assertNever(t)}return{message:r}};let wn=Gt;function Un(t){wn=t}function xr(){return wn}const _r=t=>{const{data:e,path:r,errorMaps:a,issueData:s}=t,i=[...r,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const v=a.filter(k=>!!k).slice().reverse();for(const k of v)f=k(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},$n=[];function U(t,e){const r=xr(),a=_r({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Gt?void 0:Gt].filter(s=>!!s)});t.common.issues.push(a)}class Ke{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const a=[];for(const s of r){if(s.status==="aborted")return te;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const s of r){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const s of r){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return te;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const te=Object.freeze({status:"aborted"}),qt=t=>({status:"dirty",value:t}),Je=t=>({status:"valid",value:t}),Mr=t=>t.status==="aborted",jr=t=>t.status==="dirty",Ft=t=>t.status==="valid",tr=t=>typeof Promise<"u"&&t instanceof Promise;var Y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,r,a,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hn=(t,e)=>{if(Ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new st(t.common.issues);return this._error=r,this._error}}};function oe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:s}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:v}=t;return c.code==="invalid_enum_value"?{message:v??f.defaultError}:typeof f.data>"u"?{message:v??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:v??r??f.defaultError}},description:s}}class le{get description(){return this._def.description}_getType(e){return _t(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(tr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parseSync({data:e,path:a.path,parent:a});return hn(a,s)}"~validate"(e){var a,s;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return Ft(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Ft(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(tr(s)?s:Promise.resolve(s));return hn(a,i)}refine(e,r){const a=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:P.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(v=>v?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,r){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof r=="function"?r(a,s):r),!1))}_refinement(e){return new ht({schema:this,typeName:ne.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return gt.create(this,this._def)}nullable(){return Rt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return Kt.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ir.create(this,e,this._def)}transform(e){return new ht({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:r,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:r,typeName:ne.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return pr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ln=/^c[^\s-]{8,}$/i,Zn=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Vn=/^[a-z0-9_-]{21}$/i,qn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cr;const Kn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Jn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Xn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ea=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ta=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ra=new RegExp(`^${bn}$`);function kn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function na(t){return new RegExp(`^${kn(t)}$`)}function xn(t){let e=`${bn}T${kn(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function aa(t,e){return!!((e==="v4"||!e)&&Kn.test(t)||(e==="v6"||!e)&&Xn.test(t))}function sa(t,e){if(!qn.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function ia(t,e){return!!((e==="v4"||!e)&&Jn.test(t)||(e==="v6"||!e)&&Qn.test(t))}class ft extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==W.string){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.string,received:i.parsedType}),te}const a=new Ke;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")Gn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Cr||(Cr=new RegExp(Yn,"u")),Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:P.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"regex",code:P.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?xn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?ra.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?na(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?Hn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?aa(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?sa(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?ia(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?ea.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?ta.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.invalid_string,message:i.message}),a.dirty()):we.assertNever(i);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(s=>e.test(s),{validation:r,code:P.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Y.errToObj(r)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ft.create=t=>new ft({checks:[],typeName:ne.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});function oa(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=r>a?r:a,i=Number.parseInt(t.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class Pt extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==W.number){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.number,received:i.parsedType}),te}let a;const s=new Ke;for(const i of this._def.checks)i.kind==="int"?we.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?oa(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_finite,message:i.message}),s.dirty()):we.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,s){return new Pt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Pt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&we.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Pt.create=t=>new Pt({checks:[],typeName:ne.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Ct extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==W.bigint)return this._getInvalidInput(e);let a;const s=new Ke;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):we.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:W.bigint,received:r.parsedType}),te}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,s){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Ct.create=t=>new Ct({checks:[],typeName:ne.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});class rr extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==W.boolean){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.boolean,received:a.parsedType}),te}return Je(e.data)}}rr.create=t=>new rr({typeName:ne.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Bt extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==W.date){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.date,received:i.parsedType}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),te}const a=new Ke;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):we.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Bt.create=t=>new Bt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:ne.ZodDate,...oe(t)});class Er extends le{_parse(e){if(this._getType(e)!==W.symbol){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.symbol,received:a.parsedType}),te}return Je(e.data)}}Er.create=t=>new Er({typeName:ne.ZodSymbol,...oe(t)});class nr extends le{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.undefined,received:a.parsedType}),te}return Je(e.data)}}nr.create=t=>new nr({typeName:ne.ZodUndefined,...oe(t)});class ar extends le{_parse(e){if(this._getType(e)!==W.null){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.null,received:a.parsedType}),te}return Je(e.data)}}ar.create=t=>new ar({typeName:ne.ZodNull,...oe(t)});class Yt extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Yt.create=t=>new Yt({typeName:ne.ZodAny,...oe(t)});class jt extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}jt.create=t=>new jt({typeName:ne.ZodUnknown,...oe(t)});class Et extends le{_parse(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:W.never,received:r.parsedType}),te}}Et.create=t=>new Et({typeName:ne.ZodNever,...oe(t)});class Tr extends le{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.void,received:a.parsedType}),te}return Je(e.data)}}Tr.create=t=>new Tr({typeName:ne.ZodVoid,...oe(t)});class dt extends le{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),s=this._def;if(r.parsedType!==W.array)return U(r,{code:P.invalid_type,expected:W.array,received:r.parsedType}),te;if(s.exactLength!==null){const c=r.data.length>s.exactLength.value,f=r.data.length<s.exactLength.value;(c||f)&&(U(r,{code:c?P.too_big:P.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(U(r,{code:P.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(U(r,{code:P.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((c,f)=>s.type._parseAsync(new vt(r,c,r.path,f)))).then(c=>Ke.mergeArray(a,c));const i=[...r.data].map((c,f)=>s.type._parseSync(new vt(r,c,r.path,f)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,r){return new dt({...this._def,minLength:{value:e,message:Y.toString(r)}})}max(e,r){return new dt({...this._def,maxLength:{value:e,message:Y.toString(r)}})}length(e,r){return new dt({...this._def,exactLength:{value:e,message:Y.toString(r)}})}nonempty(e){return this.min(1,e)}}dt.create=(t,e)=>new dt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray,...oe(e)});function Vt(t){if(t instanceof je){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=gt.create(Vt(a))}return new je({...t._def,shape:()=>e})}else return t instanceof dt?new dt({...t._def,type:Vt(t.element)}):t instanceof gt?gt.create(Vt(t.unwrap())):t instanceof Rt?Rt.create(Vt(t.unwrap())):t instanceof wt?wt.create(t.items.map(e=>Vt(e))):t}class je extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=we.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==W.object){const k=this._getOrReturnCtx(e);return U(k,{code:P.invalid_type,expected:W.object,received:k.parsedType}),te}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const k in s.data)c.includes(k)||f.push(k);const v=[];for(const k of c){const C=i[k],D=s.data[k];v.push({key:{status:"valid",value:k},value:C._parse(new vt(s,D,s.path,k)),alwaysSet:k in s.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const C of f)v.push({key:{status:"valid",value:C},value:{status:"valid",value:s.data[C]}});else if(k==="strict")f.length>0&&(U(s,{code:P.unrecognized_keys,keys:f}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const C of f){const D=s.data[C];v.push({key:{status:"valid",value:C},value:k._parse(new vt(s,D,s.path,C)),alwaysSet:C in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const k=[];for(const C of v){const D=await C.key,x=await C.value;k.push({key:D,value:x,alwaysSet:C.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):Ke.mergeObjectSync(a,v)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ne.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new je({...this._def,catchall:e})}pick(e){const r={};for(const a of we.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}omit(e){const r={};for(const a of we.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}deepPartial(){return Vt(this)}partial(e){const r={};for(const a of we.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?r[a]=s:r[a]=s.optional()}return new je({...this._def,shape:()=>r})}required(e){const r={};for(const a of we.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof gt;)i=i._def.innerType;r[a]=i}return new je({...this._def,shape:()=>r})}keyof(){return _n(we.objectKeys(this.shape))}}je.create=(t,e)=>new je({shape:()=>t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.strictCreate=(t,e)=>new je({shape:()=>t,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.lazycreate=(t,e)=>new je({shape:t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new st(f.ctx.common.issues));return U(r,{code:P.invalid_union,unionErrors:c}),te}if(r.common.async)return Promise.all(a.map(async i=>{const c={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const v of a){const k={...r,common:{...r.common,issues:[]},parent:null},C=v._parseSync({data:r.data,path:r.path,parent:k});if(C.status==="valid")return C;C.status==="dirty"&&!i&&(i={result:C,ctx:k}),k.common.issues.length&&c.push(k.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(v=>new st(v));return U(r,{code:P.invalid_union,unionErrors:f}),te}}get options(){return this._def.options}}sr.create=(t,e)=>new sr({options:t,typeName:ne.ZodUnion,...oe(e)});const xt=t=>t instanceof cr?xt(t.schema):t instanceof ht?xt(t.innerType()):t instanceof ur?[t.value]:t instanceof Nt?t.options:t instanceof lr?we.objectValues(t.enum):t instanceof fr?xt(t._def.innerType):t instanceof nr?[void 0]:t instanceof ar?[null]:t instanceof gt?[void 0,...xt(t.unwrap())]:t instanceof Rt?[null,...xt(t.unwrap())]:t instanceof $r||t instanceof hr?xt(t.unwrap()):t instanceof dr?xt(t._def.innerType):[];class Dr extends le{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.object)return U(r,{code:P.invalid_type,expected:W.object,received:r.parsedType}),te;const a=this.discriminator,s=r.data[a],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(U(r,{code:P.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,a){const s=new Map;for(const i of r){const c=xt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Dr({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...oe(a)})}}function Fr(t,e){const r=_t(t),a=_t(e);if(t===e)return{valid:!0,data:t};if(r===W.object&&a===W.object){const s=we.objectKeys(e),i=we.objectKeys(t).filter(f=>s.indexOf(f)!==-1),c={...t,...e};for(const f of i){const v=Fr(t[f],e[f]);if(!v.valid)return{valid:!1};c[f]=v.data}return{valid:!0,data:c}}else if(r===W.array&&a===W.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const c=t[i],f=e[i],v=Fr(c,f);if(!v.valid)return{valid:!1};s.push(v.data)}return{valid:!0,data:s}}else return r===W.date&&a===W.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ir extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Mr(i)||Mr(c))return te;const f=Fr(i.value,c.value);return f.valid?((jr(i)||jr(c))&&r.dirty(),{status:r.value,value:f.data}):(U(a,{code:P.invalid_intersection_types}),te)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ir.create=(t,e,r)=>new ir({left:t,right:e,typeName:ne.ZodIntersection,...oe(r)});class wt extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return U(a,{code:P.invalid_type,expected:W.array,received:a.parsedType}),te;if(a.data.length<this._def.items.length)return U(a,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),te;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:P.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((c,f)=>{const v=this._def.items[f]||this._def.rest;return v?v._parse(new vt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ke.mergeArray(r,c)):Ke.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new wt({...this._def,rest:e})}}wt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new wt({items:t,typeName:ne.ZodTuple,rest:null,...oe(e)})};class or extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return U(a,{code:P.invalid_type,expected:W.object,received:a.parsedType}),te;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new vt(a,f,a.path,f)),value:c._parse(new vt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ke.mergeObjectAsync(r,s):Ke.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof le?new or({keyType:e,valueType:r,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ft.create(),valueType:e,typeName:ne.ZodRecord,...oe(r)})}}class Ar extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.map)return U(a,{code:P.invalid_type,expected:W.map,received:a.parsedType}),te;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,v],k)=>({key:s._parse(new vt(a,f,a.path,[k,"key"])),value:i._parse(new vt(a,v,a.path,[k,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const v of c){const k=await v.key,C=await v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),f.set(k.value,C.value)}return{status:r.value,value:f}})}else{const f=new Map;for(const v of c){const k=v.key,C=v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),f.set(k.value,C.value)}return{status:r.value,value:f}}}}Ar.create=(t,e,r)=>new Ar({valueType:e,keyType:t,typeName:ne.ZodMap,...oe(r)});class Ut extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return U(a,{code:P.invalid_type,expected:W.set,received:a.parsedType}),te;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:P.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(U(a,{code:P.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const i=this._def.valueType;function c(v){const k=new Set;for(const C of v){if(C.status==="aborted")return te;C.status==="dirty"&&r.dirty(),k.add(C.value)}return{status:r.value,value:k}}const f=[...a.data.values()].map((v,k)=>i._parse(new vt(a,v,a.path,k)));return a.common.async?Promise.all(f).then(v=>c(v)):c(f)}min(e,r){return new Ut({...this._def,minSize:{value:e,message:Y.toString(r)}})}max(e,r){return new Ut({...this._def,maxSize:{value:e,message:Y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ut.create=(t,e)=>new Ut({valueType:t,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class Ht extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.function)return U(r,{code:P.invalid_type,expected:W.function,received:r.parsedType}),te;function a(f,v){return _r({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:v}})}function s(f,v){return _r({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_return_type,returnTypeError:v}})}const i={errorMap:r.common.contextualErrorMap},c=r.data;if(this._def.returns instanceof Kt){const f=this;return Je(async function(...v){const k=new st([]),C=await f._def.args.parseAsync(v,i).catch(S=>{throw k.addIssue(a(v,S)),k}),D=await Reflect.apply(c,this,C);return await f._def.returns._def.type.parseAsync(D,i).catch(S=>{throw k.addIssue(s(D,S)),k})})}else{const f=this;return Je(function(...v){const k=f._def.args.safeParse(v,i);if(!k.success)throw new st([a(v,k.error)]);const C=Reflect.apply(c,this,k.data),D=f._def.returns.safeParse(C,i);if(!D.success)throw new st([s(C,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ht({...this._def,args:wt.create(e).rest(jt.create())})}returns(e){return new Ht({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new Ht({args:e||wt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends le{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}cr.create=(t,e)=>new cr({getter:t,typeName:ne.ZodLazy,...oe(e)});class ur extends le{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return U(r,{received:r.data,code:P.invalid_literal,expected:this._def.value}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(t,e)=>new ur({value:t,typeName:ne.ZodLiteral,...oe(e)});function _n(t,e){return new Nt({values:t,typeName:ne.ZodEnum,...oe(e)})}class Nt extends le{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{expected:we.joinValues(a),received:r.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{received:r.data,code:P.invalid_enum_value,options:a}),te}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Nt.create(e,{...this._def,...r})}exclude(e,r=this._def){return Nt.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}Nt.create=_n;class lr extends le{_parse(e){const r=we.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const s=we.objectValues(r);return U(a,{expected:we.joinValues(s),received:a.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=we.objectValues(r);return U(a,{received:a.data,code:P.invalid_enum_value,options:s}),te}return Je(e.data)}get enum(){return this._def.values}}lr.create=(t,e)=>new lr({values:t,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends le{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.promise&&r.common.async===!1)return U(r,{code:P.invalid_type,expected:W.promise,received:r.parsedType}),te;const a=r.parsedType===W.promise?r.data:Promise.resolve(r.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Kt.create=(t,e)=>new Kt({type:t,typeName:ne.ZodPromise,...oe(e)});class ht extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{U(a,c),c.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(r.value==="aborted")return te;const v=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return v.status==="aborted"?te:v.status==="dirty"||r.value==="dirty"?qt(v.value):v});{if(r.value==="aborted")return te;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?te:f.status==="dirty"||r.value==="dirty"?qt(f.value):f}}if(s.type==="refinement"){const c=f=>{const v=s.refinement(f,i);if(a.common.async)return Promise.resolve(v);if(v instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?te:(f.status==="dirty"&&r.dirty(),c(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?te:(f.status==="dirty"&&r.dirty(),c(f.value).then(()=>({status:r.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ft(c))return te;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>Ft(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:r.value,value:f})):te);we.assertNever(s)}}ht.create=(t,e,r)=>new ht({schema:t,typeName:ne.ZodEffects,effect:e,...oe(r)});ht.createWithPreprocess=(t,e,r)=>new ht({schema:e,effect:{type:"preprocess",transform:t},typeName:ne.ZodEffects,...oe(r)});class gt extends le{_parse(e){return this._getType(e)===W.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gt.create=(t,e)=>new gt({innerType:t,typeName:ne.ZodOptional,...oe(e)});class Rt extends le{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Rt.create=(t,e)=>new Rt({innerType:t,typeName:ne.ZodNullable,...oe(e)});class fr extends le{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===W.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}fr.create=(t,e)=>new fr({innerType:t,typeName:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new st(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new st(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Sr extends le{_parse(e){if(this._getType(e)!==W.nan){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.nan,received:a.parsedType}),te}return{status:"valid",value:e.data}}}Sr.create=t=>new Sr({typeName:ne.ZodNaN,...oe(t)});const ca=Symbol("zod_brand");class $r extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class pr extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?te:i.status==="dirty"?(r.dirty(),qt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?te:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,r){return new pr({in:e,out:r,typeName:ne.ZodPipeline})}}class hr extends le{_parse(e){const r=this._def.innerType._parse(e),a=s=>(Ft(s)&&(s.value=Object.freeze(s.value)),s);return tr(r)?r.then(s=>a(s)):a(r)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:ne.ZodReadonly,...oe(e)});function pn(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function En(t,e={},r){return t?Yt.create().superRefine((a,s)=>{const i=t(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=pn(e,a),v=f.fatal??r??!0;s.addIssue({code:"custom",...f,fatal:v})}});if(!i){const c=pn(e,a),f=c.fatal??r??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Yt.create()}const ua={object:je.lazycreate};var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const la=(t,e={message:`Input not instance of ${t.name}`})=>En(r=>r instanceof t,e),Pe=ft.create,$t=Pt.create,fa=Sr.create,da=Ct.create,Tt=rr.create,ha=Bt.create,pa=Er.create,ma=nr.create,ya=ar.create,ga=Yt.create,va=jt.create,wa=Et.create,ba=Tr.create,ka=dt.create,At=je.create,xa=je.strictCreate,_a=sr.create,Ea=Dr.create,Ta=ir.create,Aa=wt.create,Sa=or.create,Da=Ar.create,Oa=Ut.create,Pa=Ht.create,Ca=cr.create,Na=ur.create,Lr=Nt.create,Zr=lr.create,Ra=Kt.create,mn=ht.create,Ia=gt.create,Ma=Rt.create,ja=ht.createWithPreprocess,Fa=pr.create,Ba=()=>Pe().optional(),Ua=()=>$t().optional(),$a=()=>Tt().optional(),Br={string:(t=>ft.create({...t,coerce:!0})),number:(t=>Pt.create({...t,coerce:!0})),boolean:(t=>rr.create({...t,coerce:!0})),bigint:(t=>Ct.create({...t,coerce:!0})),date:(t=>Bt.create({...t,coerce:!0}))},La=te,E=Object.freeze(Object.defineProperty({__proto__:null,BRAND:ca,DIRTY:qt,EMPTY_PATH:$n,INVALID:te,NEVER:La,OK:Je,ParseStatus:Ke,Schema:le,ZodAny:Yt,ZodArray:dt,ZodBigInt:Ct,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Nt,ZodError:st,get ZodFirstPartyTypeKind(){return ne},ZodFunction:Ht,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Rt,ZodNumber:Pt,ZodObject:je,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:le,ZodSet:Ut,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:wt,ZodType:le,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Tr,addIssueToContext:U,any:ga,array:ka,bigint:da,boolean:Tt,coerce:Br,custom:En,date:ha,datetimeRegex:xn,defaultErrorMap:Gt,discriminatedUnion:Ea,effect:mn,enum:Lr,function:Pa,getErrorMap:xr,getParsedType:_t,instanceof:la,intersection:Ta,isAborted:Mr,isAsync:tr,isDirty:jr,isValid:Ft,late:ua,lazy:Ca,literal:Na,makeIssue:_r,map:Da,nan:fa,nativeEnum:Zr,never:wa,null:ya,nullable:Ma,number:$t,object:At,get objectUtil(){return Ir},oboolean:$a,onumber:Ua,optional:Ia,ostring:Ba,pipeline:Fa,preprocess:ja,promise:Ra,quotelessJson:Bn,record:Sa,set:Oa,setErrorMap:Un,strictObject:xa,string:Pe,symbol:pa,transformer:mn,tuple:Aa,undefined:ma,union:_a,unknown:va,get util(){return we},void:ba},Symbol.toStringTag,{value:"Module"})),pt=At({name:Pe(),selector:Pe(),findBy:Lr(["cssSelector","xpath"]),option:At({waitForSelector:Tt().optional(),waitSelectorTimeout:$t().optional(),multiple:Tt().optional()})}),Za=E.object({type:E.literal("object"),shape:E.record(E.string(),E.any())}),Wa=E.object({type:E.literal("array"),items:E.any()}),za=E.discriminatedUnion("type",[Za,Wa]),Wr=E.object({name:E.literal("ai-parse-data"),sourceData:E.any().optional(),schemaDefinition:za,prompt:E.string().optional(),model:E.string().optional(),apiKey:E.string().min(1,"AI API key is required"),provider:E.enum(["openai","anthropic"])});function Va(t){return Wr.parse(t)}async function qa(t){try{const{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}=t;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const f=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}});if(f.$isError)throw new Error(f.message||"AI parsing failed");return{data:f.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function Ha(t){return{type:"object",shape:t}}function Ga(t){return{type:"array",items:t}}const Ya={string:t=>({type:"string",...t}),number:t=>({type:"number",...t}),boolean:t=>({type:"boolean",...t}),array:(t,e)=>({type:"array",items:t,...e}),object:(t,e)=>({type:"object",shape:t,...e}),currency:t=>({type:"currency",shape:An,description:(t==null?void 0:t.description)||"Currency information with code, symbol, format, amount, and text",optional:t==null?void 0:t.optional})};class Or{async waitForElement(e,r,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,r);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class Ka extends Or{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,r);return i?Array.from(r.querySelectorAll(c)):r.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,r){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(v=>v.nodeType===Node.TEXT_NODE).map(v=>{var k;return((k=v.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ja extends Or{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(k=>k.trim());if(c.length!==2)return null;const f=c[0],v=c[1];if(!f||!v)return null;try{const k=r.querySelector(f);if(!k||!k.contentDocument)return null;const C=k.contentDocument;return i?Array.from(C.querySelectorAll(v)):C.querySelector(v)}catch(k){return console.error("Iframe Selector error:",k),null}}}class Xa extends Or{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(v=>v.trim());let f=r;try{for(let v=0;v<c.length;v++){const k=c[v],C=v===c.length-1;if(!k)return null;if(C&&i)return Array.from(f.querySelectorAll(k));const D=f.querySelector(k);if(!D)return null;if(C)return D;if(D.shadowRoot)f=D.shadowRoot;else return null}}catch(v){return console.error("Shadow DOM Selector error:",v),null}return null}}class Qa extends Or{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=r.evaluate(a,r,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let v=0;v<c.snapshotLength;v++){const k=c.snapshotItem(v);k&&k.nodeType===Node.ELEMENT_NODE&&f.push(k)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class es{static generate(e){const r=["data-testid","aria-label","title","alt","role"];for(const i of r){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const r=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${r}:nth-child(${c})`}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function mt(t,e=document){const{selector:r,findBy:a="cssSelector",option:s}=t,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=ts(r,a);return i?f.waitForElement(t,e,c):f.find(t,e)}function ts(t,e){return e==="xpath"?new Qa:t.includes(">>")?new Xa:t.includes("|>")?new Ja:new Ka}const zr=pt.extend({name:E.literal("get-text"),includeTags:E.boolean().optional(),useTextContent:E.boolean().optional(),regex:E.string().optional(),prefixText:E.string().optional(),suffixText:E.string().optional(),filterEmpty:E.boolean().optional(),scrollToCollect:E.boolean().optional(),scrollDistance:E.number().optional(),scrollWaitMs:E.number().optional(),maxScrollAttempts:E.number().optional()});function rs(t){return zr.parse(t)}async function ns(t){try{const{selector:e="",includeTags:r=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:v,filterEmpty:k=!0,scrollToCollect:C=!1,scrollDistance:D=500,scrollWaitMs:x=300,maxScrollAttempts:S=100}=t;if(!e)throw new Error("Selector is required for get-text block");if(C&&(v!=null&&v.multiple))return await as({selector:e,findBy:f,option:v,includeTags:r,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:D,scrollWaitMs:x,maxScrollAttempts:S});const M=await mt({selector:e,findBy:f,option:v});if(!M)return{data:""};const ae=Tn(r,a,s,i,c);if(Array.isArray(M)){const Q=M.map(ae);return{data:k?Q.filter(H=>H.trim()!==""):Q}}else return{data:ae(M)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function as(t){const{selector:e,findBy:r,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:v,filterEmpty:k,scrollDistance:C,scrollWaitMs:D,maxScrollAttempts:x}=t,S=Tn(s,i,c,f,v),M=new Set;let ae=0,Q=0;const pe=5;for(;ae<x;){const H=await mt({selector:e,findBy:r,option:a});if(H&&Array.isArray(H)){const L=M.size;if(H.forEach($=>{const z=S($);(!k||z.trim()!=="")&&M.add(z)}),M.size===L){if(Q++,Q>=pe)break}else Q=0}const R=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:C,behavior:"auto"}),await new Promise(L=>setTimeout(L,D)),(window.pageYOffset||document.documentElement.scrollTop)===R)break;ae++}return{data:Array.from(M)}}function Tn(t,e,r,a="",s=""){return i=>{let c="";if(t?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",r){const f=new RegExp(r,"g"),v=c.match(f);c=v?v.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Vr=pt.extend({name:E.literal("attribute-value"),attributeName:E.string()});function ss(t){return Vr.parse(t)}async function is(t){try{const{selector:e="",attributeName:r,findBy:a="cssSelector",option:s}=t;if(!e)throw new Error("Selector is required for attribute-value block");if(!r)throw new Error("Attribute name is required for attribute-value block");const i=await mt({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(r)).filter(f=>f!==null):i.getAttribute(r)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const qr=pt.extend({name:E.literal("get-value-form"),type:E.enum(["text-field","select","checkbox"]).optional()});function os(t){return qr.parse(t)}async function cs(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for get-value-form block");const s=await mt({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return{data:us(s,r)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function us(t,e){switch(e){case"text-field":if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)return t.value;break;case"select":if(t instanceof HTMLSelectElement)return t.value;break;case"checkbox":if(t instanceof HTMLInputElement&&t.type==="checkbox")return t.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Hr=pt.extend({name:E.literal("set-value-form"),setValue:E.string(),type:E.enum(["text-field","select","checkbox"]).optional()});function ls(t){return Hr.parse(t)}async function fs(t){try{const{selector:e="",setValue:r,type:a="text-field",findBy:s="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-value-form block");const i=await mt({selector:e,findBy:s,option:t.option});if(!i)throw new Error("Form element not found");return ds(i,r,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function ds(t,e,r){switch(r){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.value=e,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=e==="true"||e==="checked",t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${r}`)}}const Gr=pt.extend({name:E.literal("clear-value-form"),type:E.enum(["text-field","select","checkbox"]).optional()});function hs(t){return Gr.parse(t)}async function ps(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await mt({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return ms(s,r),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ms(t,e){switch(e){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.selectedIndex=0,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=!1,t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Yr=pt.extend({name:E.literal("element-exists")});function ys(t){return Yr.parse(t)}async function gs(t){try{const{selector:e="",findBy:r="cssSelector",option:a}=t;if(!e)throw new Error("Selector is required for element-exists block");return{data:await mt({selector:e,findBy:r,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Kr=pt.extend({name:E.literal("event-click"),textFilter:E.object({text:E.union([E.string(),E.array(E.string())]),mode:E.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function vs(t){return Kr.parse(t)}async function ws(t){try{const{selector:e="",findBy:r="cssSelector",option:a,textFilter:s}=t;if(!e)throw new Error("Selector is required for event-click block");const i=await mt({selector:e,findBy:r,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=bs(i,s.text,s.mode);if(!f){const v=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${v}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await xs(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function bs(t,e,r){for(const a of t){const s=ks(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(r){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ks(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}async function xs(t){t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),t.focus&&t.focus();const e=t.getBoundingClientRect(),r=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:r,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),t.click&&t.click()}await new Promise(s=>setTimeout(s,50))}const Jr=E.object({name:E.literal("keypress"),key:E.string(),code:E.string().optional(),keyCode:E.number().optional(),modifiers:E.array(E.enum(["Alt","Control","Meta","Shift"])).optional()});function _s(t){return Jr.parse(t)}async function Es(t){try{const{key:e,code:r,keyCode:a,modifiers:s=[]}=t;return await Ts(e,r,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Ts(t,e,r,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:t,code:e||t,keyCode:r||Nr(t),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:t,code:e||t,keyCode:r||Nr(t),bubbles:!0,cancelable:!0,...yn(a)}),c=new KeyboardEvent("keyup",{key:t,code:e||t,keyCode:r||Nr(t),bubbles:!0,cancelable:!0,...yn(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Nr(t){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[t]||0}function yn(t){return{altKey:t.includes("Alt"),ctrlKey:t.includes("Control"),metaKey:t.includes("Meta"),shiftKey:t.includes("Shift")}}const Xr=E.object({name:E.literal("wait"),duration:E.number().min(0)});function As(t){return Xr.parse(t)}async function Ss(t){try{const{duration:e}=t;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(r=>setTimeout(r,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Qr=E.object({name:E.literal("wait-for-condition"),conditions:E.object({urlPattern:E.string().optional(),elementExists:E.object({selector:E.string(),findBy:E.enum(["cssSelector","xpath"])}).optional(),cookieExists:E.string().optional(),storageKey:E.object({type:E.enum(["localStorage","sessionStorage"]),key:E.string()}).optional(),userConfirmation:E.boolean().optional(),message:E.string().optional(),buttonText:E.string().optional()}).refine(t=>t.urlPattern!==void 0||t.elementExists!==void 0||t.cookieExists!==void 0||t.storageKey!==void 0||t.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:E.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:E.number().min(100).optional(),timeoutMs:E.number().min(1e3).optional(),position:E.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ds(t){return Qr.parse(t)}async function Os(t){try{const{conditions:e,mode:r="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=t;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",r,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let v=null,k=null;(r==="manual"||r==="auto-or-manual")&&f&&(v=new Promise(D=>{k=D}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:k}})));const C=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(D){console.warn("[WaitForCondition] Invalid URL pattern:",D)}if(e.elementExists){const{selector:D,findBy:x}=e.elementExists;let S=null;if(x==="cssSelector"?S=document.querySelector(D):x==="xpath"&&(S=document.evaluate(D,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),S)return{success:!0,reason:"elementExists",message:`Element found: ${D}`}}if(e.cookieExists&&document.cookie.split(";").some(S=>{const[M]=S.trim().split("=");return M===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:D,key:x}=e.storageKey;if((D==="localStorage"?window.localStorage:window.sessionStorage).getItem(x)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${D}.${x}`}}return null};return new Promise(D=>{let x=null,S=!1;const M=()=>{x&&(clearInterval(x),x=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{S||(S=!0,M(),console.log("[WaitForCondition] Resolved with:",pe),D({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(r==="auto"||r==="auto-or-manual")&&c&&(x=setInterval(async()=>{const pe=await C();pe&&(clearTimeout(Q),ae(pe))},a)),(r==="manual"||r==="auto-or-manual")&&v&&v.then(()=>{clearTimeout(Q),ae({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const en=E.object({name:E.literal("navigate"),url:E.string().url("Valid URL is required"),waitForLoad:E.boolean().optional(),timeout:E.number().min(0).optional()});function Ps(t){return en.parse(t)}async function Cs(t){try{const{url:e,waitForLoad:r=!0,timeout:a=3e4}=t;return console.log(`[Navigate] Navigating to: ${e}`),r?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const tn=pt.extend({name:E.literal("save-assets")});function Ns(t){return tn.parse(t)}async function Rs(t){try{const{selector:e="img, audio, video, source",findBy:r="cssSelector",option:a}=t,s=await mt({selector:e,findBy:r,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Is{static generate(e){var s;const r=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(v=>v.tagName===a.tagName);if(c.length>1){const v=c.indexOf(a)+1;i+=`[${v}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),r.unshift(i),a=a.parentElement}return"/"+r.join("/")}static getStableAttributes(e){const r=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&r.push(`${s}="${i}"`)}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const rn=pt.extend({name:E.literal("get-element-data"),includeText:E.boolean().optional(),includeTags:E.boolean().optional(),useTextContent:E.boolean().optional(),regex:E.string().optional(),prefixText:E.string().optional(),suffixText:E.string().optional(),attributes:E.array(E.string()).optional(),includeSelector:E.boolean().optional(),includeXPath:E.boolean().optional()});function Ms(t){return rn.parse(t)}async function js(t){try{const{selector:e="",includeText:r=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:v=[],includeSelector:k=!1,includeXPath:C=!1,findBy:D="cssSelector",option:x}=t;if(!e)throw new Error("Selector is required for get-element-data block");if(!r&&v.length===0)throw new Error("Either includeText must be true or attributes must be provided");const S=await mt({selector:e,findBy:D,option:x});if(!S)return{data:Array.isArray(S)?[]:{}};const M=Fs(r,a,s,i,c,f,v,k,C);return Array.isArray(S)?{data:S.map(M)}:{data:M(S)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Fs(t,e,r,a,s="",i="",c=[],f=!1,v=!1){return k=>{const C={};if(t){let D="";if(e?D=k.innerHTML:D=r?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),S=D.match(x);D=S?S.join(" "):""}D.trim()&&(D=s+D.trim()+i),C.text=D}return c.length>0&&(C.attributes={},c.forEach(D=>{let x=k.getAttribute(D);if(x===null){const S=k.querySelector(`[${D}]`);S&&(x=S.getAttribute(D))}C.attributes[D]=x})),f&&(C.selector=es.generate(k)),v&&(C.xpath=Is.generate(k)),C}}const nn=pt.extend({name:E.literal("scroll"),scrollType:E.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:E.number().optional(),behavior:E.enum(["auto","smooth"]).optional(),maxScrolls:E.number().optional(),waitAfterScroll:E.number().optional()});function Bs(t){return nn.parse(t)}async function Us(t){try{const{selector:e="",scrollType:r="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:v}=t;switch(r){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await $s(e,f,v,s);case"toBottom":return await Ls(s,c);case"byDistance":return await Zs(a,s);case"untilLoaded":return await Ws(i,a,s,c);default:throw new Error(`Unknown scroll type: ${r}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function $s(t,e,r,a){const s=await mt({selector:t,findBy:e,option:r});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Ls(t,e){let r=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:t}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===r)break;r=i,a++}return{data:!0}}async function Zs(t,e){return window.scrollBy({top:t,behavior:e}),{data:!0}}async function Ws(t,e,r,a){let s=0,i=document.body.scrollHeight;for(;s<t;){window.scrollBy({top:e,behavior:r}),await new Promise(k=>setTimeout(k,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,v=window.innerHeight;if(f+v>=c-10&&c===i)break;i=c,s++}return{data:!0}}const an=E.object({name:E.literal("fetch-api"),url:E.string(),method:E.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:E.record(E.string(),E.string()).optional(),body:E.record(E.string(),E.any()).optional(),timeout:E.number().min(0).optional(),parseJson:E.boolean().optional(),returnHeaders:E.boolean().optional()});function zs(t){return an.parse(t)}async function Vs(t){try{console.log("[FetchApiBlock] Sending API request to background:",t.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:t.url,method:t.method||"GET",headers:t.headers||{},body:t.body,timeout:t.timeout||3e4,parseJson:t.parseJson??!0,returnHeaders:t.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function kr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Rr={exports:{}},vn;function Hs(){return vn||(vn=1,(function(t,e){(function(r){t.exports=r()})(function(){return(function(){function r(a,s,i){function c(k,C){if(!s[k]){if(!a[k]){var D=typeof kr=="function"&&kr;if(!C&&D)return D(k,!0);if(f)return f(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var S=s[k]={exports:{}};a[k][0].call(S.exports,function(M){var ae=a[k][1][M];return c(ae||M)},S,S.exports,r,a,s,i)}return s[k].exports}for(var f=typeof kr=="function"&&kr,v=0;v<i.length;v++)c(i[v]);return c}return r})()({1:[function(r,a,s){const i=r("./utils"),c=(function(){const f=i.stringToArray,v=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],k=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],C=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],D=["Thousand","Million","Billion","Trillion"];function x(w,A){var b=function(B,j,O){var F="";if(B<=19)F=(j?" and ":"")+(O?k[B]:v[B]);else if(B<100){const ge=Math.floor(B/10),be=B%10;F=(j?" and ":"")+C[ge-2],be>0?F+="-"+b(be,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ge=Math.floor(B/100),be=B%100;F=(j?", ":"")+v[ge]+" Hundred",be>0?F+=b(be,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>D.length&&(J=D.length);const ge=Math.pow(10,J*3),be=Math.floor(B/ge),K=B-be*ge;F=(j?", ":"")+b(be,!1,!1)+" "+D[J-1],K>0?F+=b(K,!0,O):O&&(F+="th")}return F},N=b(w,!1,A);return N}const S={};v.forEach(function(w,A){S[w.toLowerCase()]=A}),k.forEach(function(w,A){S[w.toLowerCase()]=A}),C.forEach(function(w,A){const b=w.toLowerCase();S[b]=(A+2)*10,S[b.substring(0,w.length-1)+"ieth"]=S[b]}),S.hundredth=100,D.forEach(function(w,A){const b=w.toLowerCase(),N=Math.pow(10,(A+1)*3);S[b]=N,S[b+"th"]=N});function M(w){const b=w.split(/,\s|\sand\s|[\s\\-]/).map(j=>S[j]);let N=[0];return b.forEach(j=>{if(j<100){let O=N.pop();O>=1e3&&(N.push(O),O=0),N.push(O+j)}else N.push(N.pop()*j)}),N.reduce((j,O)=>j+O,0)}const ae=[[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"]],Q={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function pe(w){for(var A=0;A<ae.length;A++){const b=ae[A];if(w>=b[0])return b[1]+pe(w-b[0])}return""}function H(w){for(var A=0,b=1,N=w.length-1;N>=0;N--){const B=w[N],j=Q[B];j<b?A-=j:(b=j,A+=j)}return A}function R(w,A){for(var b=[],N=A.charCodeAt(0);w>0;)b.unshift(String.fromCharCode((w-1)%26+N)),w=Math.floor((w-1)/26);return b.join("")}function se(w,A){for(var b=A.charCodeAt(0),N=0,B=0;B<w.length;B++)N+=(w.charCodeAt(w.length-B-1)-b+1)*Math.pow(26,B);return N}function L(w,A){if(typeof w>"u")return;w=Math.floor(w);const b=xe(A);return z(w,b)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(w,A){let b;const N=w<0;switch(w=Math.abs(w),A.primary){case T.LETTERS:b=R(w,A.case===$.UPPER?"A":"a");break;case T.ROMAN:b=pe(w),A.case===$.UPPER&&(b=b.toUpperCase());break;case T.WORDS:b=x(w,A.ordinal),A.case===$.UPPER?b=b.toUpperCase():A.case===$.LOWER&&(b=b.toLowerCase());break;case T.DECIMAL:b=""+w;var B=A.mandatoryDigits-b.length;if(B>0){var j=new Array(B+1).join("0");b=j+b}if(A.zeroCode!==48&&(b=f(b).map(ge=>String.fromCodePoint(ge.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ge=Math.floor((b.length-1)/A.groupingSeparators.position);for(let be=ge;be>0;be--){const K=b.length-be*A.groupingSeparators.position;b=b.substr(0,K)+A.groupingSeparators.character+b.substr(K)}}else A.groupingSeparators.reverse().forEach(ge=>{const be=b.length-ge.position;b=b.substr(0,be)+ge.character+b.substr(be)});if(A.ordinal){var O={1:"st",2:"nd",3:"rd"},F=b[b.length-1],J=O[F];(!J||b.length>1&&b[b.length-2]==="1")&&(J="th"),b=b+J}break;case T.SEQUENCE:throw{code:"D3130",value:A.token}}return N&&(b="-"+b),b}const he=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(w){const A={type:"integer",primary:T.DECIMAL,case:$.LOWER,ordinal:!1};let b,N;const B=w.lastIndexOf(";");switch(B===-1?b=w:(b=w.substring(0,B),N=w.substring(B+1),N[0]==="o"&&(A.ordinal=!0)),b){case"A":A.case=$.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=$.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=$.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=$.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,O=0,F=0,J=[],ge=0;if(f(b).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let ee=!1;for(let me=0;me<he.length;me++){const G=he[me];if(K>=G&&K<=G+9){if(ee=!0,O++,ge++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ge++,F++):J.push({position:ge,character:String.fromCodePoint(K)}))}),O>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=O,A.optionalDigits=F;const ee=function(me){if(me.length===0)return 0;const G=me[0].character;for(let $e=1;$e<me.length;$e++)if(me[$e].character!==G)return 0;const Ze=me.map($e=>$e.position),ot=function($e,He){return He===0?$e:ot(He,$e%He)},qe=Ze.reduce(ot);for(let $e=1;$e<=Ze.length;$e++)if(Ze.indexOf($e*qe)===-1)return 0;return qe}(J);ee>0?(A.regular=!0,A.groupingSeparators={position:ee,character:J[0].character}):(A.regular=!1,A.groupingSeparators=J)}else A.primary=T.SEQUENCE,A.token=b}}return A}const Te={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Ae(w){var A=[];const b={type:"datetime",parts:A},N=function(ee,me){if(me>ee){let G=w.substring(ee,me);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var B=0,j=0;j<w.length;){if(w.charAt(j)==="["){if(w.charAt(j+1)==="["){N(B,j),A.push({type:"literal",value:"["}),j+=2,B=j;continue}if(N(B,j),B=j,j=w.indexOf("]",B),j===-1)throw{code:"D3135"};let ee=w.substring(B+1,j);ee=ee.split(/\s+/).join("");var O={type:"marker",component:ee.charAt(0)},F=ee.lastIndexOf(","),J;if(F!==-1){const me=ee.substring(F+1),G=me.indexOf("-");let Ze,ot;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=me:(Ze=me.substring(0,G),ot=me.substring(G+1));const $e={min:qe(Ze),max:qe(ot)};O.width=$e,J=ee.substring(1,F)}else J=ee.substring(1);if(J.length===1)O.presentation1=J;else if(J.length>1){var ge=J.charAt(J.length-1);"atco".indexOf(ge)!==-1?(O.presentation2=ge,ge==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Te[O.component];if(typeof O.presentation1>"u")throw{code:"D3132",value:O.component};if(O.presentation1[0]==="n")O.names=$.LOWER;else if(O.presentation1[0]==="N")O.presentation1[1]==="n"?O.names=$.TITLE:O.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(O.component)!==-1){var be=O.presentation1;if(O.presentation2&&(be+=";"+O.presentation2),O.integerFormat=xe(be),O.width&&O.width.min!==void 0&&O.integerFormat.mandatoryDigits<O.width.min&&(O.integerFormat.mandatoryDigits=O.width.min),O.component==="Y")if(O.n=-1,O.width&&O.width.max!==void 0)O.n=O.width.max,O.integerFormat.mandatoryDigits=O.n;else{var K=O.integerFormat.mandatoryDigits+O.integerFormat.optionalDigits;K>=2&&(O.n=K)}const me=A[A.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=xe(O.presentation1)),A.push(O),B=j+1}j++}return N(B,j),b}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ie=["January","February","March","April","May","June","July","August","September","October","November","December"],et=1e3*60*60*24,_e=function(w){const A=Date.UTC(w.year,w.month);var b=new Date(A).getUTCDay();return b===0&&(b=7),b>4?A+(8-b)*et:A-(b-1)*et},fe=function(w,A){return{year:w,month:A,nextMonth:function(){return A===11?fe(w+1,0):fe(w,A+1)},previousMonth:function(){return A===0?fe(w-1,11):fe(w,A-1)},nextYear:function(){return fe(w+1,A)},previousYear:function(){return fe(w-1,A)}}},tt=function(w,A){return(A-w)/(et*7)+1},ie=(w,A)=>{let b;switch(A){case"Y":b=w.getUTCFullYear();break;case"M":b=w.getUTCMonth()+1;break;case"D":b=w.getUTCDate();break;case"d":{const N=Date.UTC(w.getUTCFullYear(),w.getUTCMonth(),w.getUTCDate()),B=Date.UTC(w.getUTCFullYear(),0);b=(N-B)/et+1;break}case"F":b=w.getUTCDay(),b===0&&(b=7);break;case"W":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=Date.UTC(N.year,w.getUTCMonth(),w.getUTCDate());let O=tt(B,j);if(O>52){const F=_e(N.nextYear());j>=F&&(O=1)}else if(O<1){const F=_e(N.previousYear());O=tt(F,j)}b=Math.floor(O);break}case"w":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=Date.UTC(N.year,N.month,w.getUTCDate());let O=tt(B,j);if(O>4){const F=_e(N.nextMonth());j>=F&&(O=1)}else if(O<1){const F=_e(N.previousMonth());O=tt(F,j)}b=Math.floor(O);break}case"X":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=_e(N.nextYear()),O=w.getTime();O<B?b=N.year-1:O>=j?b=N.year+1:b=N.year;break}case"x":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=N.nextMonth(),O=_e(j),F=w.getTime();F<B?b=N.previousMonth().month+1:F>=O?b=j.month+1:b=N.month+1;break}case"H":b=w.getUTCHours();break;case"h":b=w.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=w.getUTCHours()>=12?"pm":"am";break;case"m":b=w.getUTCMinutes();break;case"s":b=w.getUTCSeconds();break;case"f":b=w.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Be=null;function it(w,A,b){var N=0,B=0;if(typeof b<"u"){const be=parseInt(b);N=Math.floor(be/100),B=be%100}var j=function(be,K){var ee=ie(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(ee=ee%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")ee=Ie[ee-1];else if(K.component==="F")ee=ve[ee];else throw{code:"D3133",value:K.component};K.names===$.UPPER?ee=ee.toUpperCase():K.names===$.LOWER&&(ee=ee.toLowerCase()),K.width&&ee.length>K.width.max&&(ee=ee.substring(0,K.width.max))}else ee=z(ee,K.integerFormat);else if(K.component==="f")ee=z(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=N*100+B;if(K.integerFormat.regular)ee=z(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=z(N,K.integerFormat),B!==0&&(ee+=":"+L(B,"00"));else if(G===3||G===4)ee=z(me,K.integerFormat);else throw{code:"D3134",value:G}}me>=0&&(ee="+"+ee),K.component==="z"&&(ee="GMT"+ee),me===0&&K.presentation2==="t"&&(ee="Z")}else K.component==="P"&&K.names===$.UPPER&&(ee=ee.toUpperCase());return ee};let O;typeof A>"u"?(Be===null&&(Be=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Be):O=Ae(A);const F=(60*N+B)*60*1e3,J=new Date(w+F);let ge="";return O.parts.forEach(function(be){be.type==="literal"?ge+=be.value:ge+=j(J,be)}),ge}function d(w){var A={};if(w.type==="datetime")A.type="datetime",A.parts=w.parts.map(function(b){var N={};if(b.type==="literal")N.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),N.regex="",b.component==="z"&&(N.regex="GMT"),N.regex+="[-+][0-9]+",j&&(N.regex+=j.character+"[0-9]+"),N.parse=function(O){b.component==="z"&&(O=O.substring(3));let F=0,J=0;return j?(F=Number.parseInt(O.substring(0,O.indexOf(j.character))),J=Number.parseInt(O.substring(O.indexOf(j.character)+1))):O.length-1<=2?F=Number.parseInt(O):(F=Number.parseInt(O.substring(0,3)),J=Number.parseInt(O.substring(3))),F*60+J}}else if(b.integerFormat)N=d(b.integerFormat);else{N.regex="[a-zA-Z]+";var B={};if(b.component==="M"||b.component==="x")Ie.forEach(function(j,O){b.width&&b.width.max?B[j.substring(0,b.width.max)]=O+1:B[j]=O+1});else if(b.component==="F")ve.forEach(function(j,O){O>0&&(b.width&&b.width.max?B[j.substring(0,b.width.max)]=O:B[j]=O)});else if(b.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};N.parse=function(j){return B[j]}}return N.component=b.component,N});else{A.type="integer";const b=w.case===$.UPPER;switch(w.primary){case T.LETTERS:A.regex=b?"[A-Z]+":"[a-z]+",A.parse=function(N){return se(N,b?"A":"a")};break;case T.ROMAN:A.regex=b?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(N){return H(b?N:N.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(S).concat("and","[\\-, ]").join("|")+")+",A.parse=function(N){return M(N.toLowerCase())};break;case T.DECIMAL:A.regex="[0-9]",w.parseWidth?A.regex+=`{${w.parseWidth}}`:A.regex+="+",w.ordinal&&(A.regex+="(?:th|st|nd|rd)"),A.parse=function(N){let B=N;return w.ordinal&&(B=N.substring(0,N.length-2)),w.regular?B=B.split(",").join(""):w.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),w.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-w.zeroCode+48)).join("")),parseInt(B)};break;case T.SEQUENCE:throw{code:"D3130",value:w.token}}}return A}function m(w,A){if(typeof w>"u")return;const b=xe(A);return d(b).parse(w)}function V(w,A){const b=Ae(A),N=d(b),B="^"+N.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp(B,"i").exec(w);if(O!==null){const G={};for(let De=1;De<O.length;De++){const u=N.parts[De-1];u.parse&&(G[u.component]=u.parse(O[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const ot=De=>{Ze<<=1,Ze+=De?1:0},qe=De=>!(~De&Ze)&&!!(De&Ze);"YXMxWwdD".split("").forEach(De=>ot(G[De]));const He=!qe(161)&&qe(130),bt=qe(84),St=!bt&&qe(72);Ze=0,"PHhmsf".split("").forEach(De=>ot(G[De]));const Dt=!qe(23)&&qe(47),Jt=(He?"YD":bt?"XxwF":St?"XWF":"YMD")+(Dt?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Lt=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Lt?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ie(ut,De);else if(Lt=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,He){const De=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(De+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(bt)throw{code:"D3136"};if(St)throw{code:"D3136"};Dt&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var de=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 Ce(w,A){if(!(typeof w>"u"))if(typeof A>"u"){if(!de.test(w))throw{stack:new Error().stack,code:"D3110",value:w};return Date.parse(w)}else return V.call(this,w,A)}function Ee(w,A,b){if(!(typeof w>"u"))return it.call(this,w,A,b)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:Ce}})();a.exports=c},{"./utils":6}],2:[function(r,a,s){(function(i){(function(){var c=r("./utils");const f=(()=>{var v=c.isNumeric,k=c.isArrayOfStrings,C=c.isArrayOfNumbers,D=c.createSequence,x=c.isSequence,S=c.isFunction,M=c.isLambda,ae=c.isPromise,Q=c.getFunctionArity,pe=c.isDeepEqual,H=c.stringToArray;function R(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function se(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function T(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function $(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function z(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(S(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,_){return typeof _<"u"&&_!==null&&_.toPrecision&&v(_)?Number(_.toPrecision(15)):_&&S(_)?"":_},g)}return l}}function he(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var _=o>=0?o+l:p+o+l;return g.slice(o,_).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Ie(n){if(!(typeof n>"u"))return H(n).length}function et(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Ie(n);if(p>0){var _=new Array(p+1).join(l);l.length>1&&(_=he(_,0,p)),o>0?g=n+_:g=_+n}else g=n;return g}}async function fe(n,o){var l=n.apply(this,[o]);if(ae(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||S(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function tt(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await fe(o,n);l=typeof g<"u"}return l}}async function ie(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=D();if(typeof l>"u"||l>0){var p=0,_=await fe(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await fe(_.next),p++}return g}}async function Be(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var _;typeof l=="string"?_=function(Se){for(var We="",ke=0,Fe=l.indexOf("$",ke);Fe!==-1&&ke<l.length;){We+=l.substring(ke,Fe),ke=Fe+1;var ct=l.charAt(ke);if(ct==="$")We+="$",ke++;else if(ct==="0")We+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,Fe=parseInt(l.substring(ke,ke+ze),10),ze>1&&Fe>Se.groups.length&&(Fe=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(Fe))We+="$";else{if(Se.groups.length>0){var Zt=Se.groups[Fe-1];typeof Zt<"u"&&(We+=Zt)}ke+=Fe.toString().length}}Fe=l.indexOf("$",ke)}return We+=l.substring(ke),We}:_=l;var I="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,q);Oe!==-1&&(typeof g>"u"||X<g);)I+=n.substring(q,Oe),I+=l,q=Oe+o.length,X++,Oe=n.indexOf(o,q);I+=n.substring(q)}else{var ye=await fe(o,n);if(typeof ye<"u"){for(;typeof ye<"u"&&(typeof g>"u"||X<g);){I+=n.substring(q,ye.start);var Ne=_.apply(p,[ye]);if(ae(Ne)&&(Ne=await Ne),typeof Ne=="string")I+=Ne;else throw{code:"D3012",stack:new Error().stack,value:Ne};q=ye.start+ye.match.length,X++,ye=await fe(ye.next)}I+=n.substring(q)}else I=n}}else I=n;return I}}function it(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function V(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function de(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function Ce(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,_=await fe(o,n);if(typeof _<"u"){for(var I=0;typeof _<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(I,_.start)),I=_.end,_=await fe(_.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(I))}else g.push(n)}return g}}function w(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function A(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(re){p[re]=l[re]});for(var _=[],I=p["zero-digit"].charCodeAt(0),q=I;q<I+10;q++)_.push(String.fromCharCode(q));var X=_.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var ye=function(re){var Me=(function(){for(var Le,nt=0;nt<re.length;nt++)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(0,nt)})(),Ye=(function(){for(var Le,nt=re.length-1;nt>=0;nt--)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(nt+1)})(),Re=re.substring(Me.length,re.length-Ye.length),Xe,Ot,Qe,Mt,rt=re.indexOf(p["exponent-separator"],Me.length);rt===-1||rt>re.length-Ye.length?(Xe=Re,Ot=void 0):(Xe=Re.substring(0,rt),Ot=Re.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,Mt=Ye):(Qe=Xe.substring(0,lt),Mt=Xe.substring(lt+1)),{prefix:Me,suffix:Ye,activePart:Re,mantissaPart:Xe,exponentPart:Ot,integerPart:Qe,fractionalPart:Mt,subpicture:re}},Ne=function(re){var Me,Ye,Re=re.subpicture,Xe=Re.indexOf(p["decimal-separator"]);Xe!==Re.lastIndexOf(p["decimal-separator"])&&(Me="D3081"),Re.indexOf(p.percent)!==Re.lastIndexOf(p.percent)&&(Me="D3082"),Re.indexOf(p["per-mille"])!==Re.lastIndexOf(p["per-mille"])&&(Me="D3083"),Re.indexOf(p.percent)!==-1&&Re.indexOf(p["per-mille"])!==-1&&(Me="D3084");var Ot=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var Qe=re.mantissaPart.charAt(Ye);if(_.indexOf(Qe)!==-1||Qe===p.digit){Ot=!0;break}}Ot||(Me="D3085");var Mt=re.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Mt.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Re.charAt(Xe-1)===p["grouping-separator"]||Re.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Re.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=re.integerPart.indexOf(p.digit);rt!==-1&&re.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=re.fractionalPart.lastIndexOf(p.digit),rt!==-1&&re.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof re.exponentPart=="string";if(lt&&re.exponentPart.length>0&&(Re.indexOf(p.percent)!==-1||Re.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(re){var Me=function(Ve,wr){for(var er=[],kt=Ve.indexOf(p["grouping-separator"]);kt!==-1;){var br=(wr?Ve.substring(0,kt):Ve.substring(kt)).split("").filter(function(zt){return _.indexOf(zt)!==-1||zt===p.digit}).length;er.push(br),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Me(re.integerPart),Re=function(Ve){if(Ve.length===0)return 0;for(var wr=function(br,zt){return zt===0?br:wr(zt,br%zt)},er=Ve.reduce(wr),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Re(Ye),Ot=Me(re.fractionalPart,!0),Qe=re.integerPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Mt=Qe,rt=re.fractionalPart.split(""),lt=rt.filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Le=rt.filter(function(Ve){return _.indexOf(Ve)!==-1||Ve===p.digit}).length,nt=typeof re.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&re.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&<===0&&(lt=1);var dn=0;return nt&&(dn=re.exponentPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Mt,prefix:re.prefix,fractionalPartGroupingPositions:Ot,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:dn,suffix:re.suffix,picture:re.subpicture}},We=Oe.map(ye);We.forEach(Ne);var ke=We.map(Se),Fe=p["minus-sign"],ct=p["zero-digit"],ze=p["decimal-separator"],Zt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=Fe+ke[1].prefix);var Ue;n>=0?Ue=ke[0]:Ue=ke[1];var Xt;Ue.picture.indexOf(p.percent)!==-1?Xt=n*100:Ue.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var It,Wt;if(Ue.minimumExponentSize===0)It=Xt;else{var Nn=Math.pow(10,Ue.scalingFactor),Rn=Math.pow(10,Ue.scalingFactor-1);for(It=Xt,Wt=0;It<Rn;)It*=10,Wt-=1;for(;It>Nn;)It/=10,Wt+=1}var In=F(It,Ue.maximumFactionalPartSize),ln=function(re,Me){var Ye=Math.abs(re).toFixed(Me);return ct!=="0"&&(Ye=Ye.split("").map(function(Re){return Re>="0"&&Re<="9"?_[Re.charCodeAt(0)-48]:Re}).join("")),Ye},ce=ln(In,Ue.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+ze:ce=ce.replace(".",ze);ce.charAt(0)===ct;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ct;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(ze);var Qt=Ue.minimumIntegerPartSize-Ge,fn=Ue.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ct):"")+ce,ce=ce+(fn>0?new Array(fn+1).join(ct):""),Ge=ce.indexOf(ze),Ue.regularGrouping>0)for(var Mn=Math.floor((Ge-1)/Ue.regularGrouping),gr=1;gr<=Mn;gr++)ce=[ce.slice(0,Ge-gr*Ue.regularGrouping),Zt,ce.slice(Ge-gr*Ue.regularGrouping)].join("");else Ue.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Zt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(ze),Ue.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Zt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(ze),(Ue.picture.indexOf(ze)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Wt<"u"){var vr=ln(Wt,0);Qt=Ue.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ct)+vr),ce=ce+p["exponent-separator"]+(Wt<0?Fe:"")+vr}return ce=Ue.prefix+ce+Ue.suffix,ce}}function b(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function N(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function B(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function O(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function J(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ge(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function be(){return Math.random()}function K(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=K(n[0]);else if(n.length>1){var l=n.filter(function(g){return K(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):v(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!S(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function ee(n){if(!(typeof n>"u"))return!K(n)}function me(n,o,l,g){var p=[o],_=Q(n);return _>=2&&p.push(l),_>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=me(o,n[g],g,n),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}}async function Ze(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=n[g],_=me(o,p,g,n),I=await o.apply(this,_);K(I)&&l.push(p)}return l}}async function ot(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var _=n[p],I=!0;if(typeof o<"u"){var q=me(o,_,p,n),X=await o.apply(this,q);I=K(X)}if(I)if(!l)g=_,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function qe(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(_){return Array.isArray(_)?_.length:0})),g=0;g<l;g++){var p=o.map(_=>_[g]);n.push(p)}return n}async function $e(n,o,l){if(!(typeof n>"u")){var g,p=Q(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var _;for(typeof l>"u"&&n.length>0?(g=n[0],_=1):(g=l,_=0);_<n.length;){var I=[g,n[_]];p>=3&&I.push(_),p>=4&&I.push(n),g=await o.apply(this,I),_++}return g}}function He(n){var o=D();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=He(g);p.forEach(function(_){l[_]=!0})}),o=He(l)}else n!==null&&typeof n=="object"&&!S(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function bt(n,o){var l;if(Array.isArray(n)){l=D();for(var g=0;g<n.length;g++){var p=bt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(_=>l.push(_)):l.push(p))}}else n!==null&&typeof n=="object"&&!S(n)&&(l=n[o]);return l}function St(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=D(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function mr(n){return!(typeof n>"u")}function Dt(n){var o=D();if(Array.isArray(n))n.forEach(function(p){o=St(o,Dt(p))});else if(n!==null&&typeof n=="object"&&!M(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function yr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Jt(n,o){var l=D();for(var g in n){var p=me(o,n[g],g,n),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Lt(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function yt(n){if(n!==void 0)return n===null?"null":v(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":S(n)?"function":"object"}async function De(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!C(n)&&!k(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(I,q){return I>q}}else l=o;var g=async function(I,q){var X=async function(ye,Ne,Se){Ne.length===0?Array.prototype.push.apply(ye,Se):Se.length===0?Array.prototype.push.apply(ye,Ne):await l(Ne[0],Se[0])?(ye.push(Se[0]),await X(ye,Ne,Se.slice(1))):(ye.push(Ne[0]),await X(ye,Ne.slice(1),Se))},Oe=[];return await X(Oe,I,q),Oe},p=async function(I){if(!Array.isArray(I)||I.length<=1)return I;var q=Math.floor(I.length/2),X=I.slice(0,q),Oe=I.slice(q);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},_=await p(n);return _}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=x(n)?D():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,_=0;_<o.length;_++)if(pe(g,o[_])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],_=me(o,p,g,n),I=await o.apply(this,_);K(I)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:R,count:se,max:L,min:T,average:$,string:z,substring:he,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Ie,trim:et,pad:_e,match:ie,contains:tt,replace:Be,split:Ee,join:w,formatNumber:A,formatBase:b,number:N,floor:j,ceil:O,round:F,abs:B,sqrt:J,power:ge,random:be,boolean:K,not:ee,map:G,zip:qe,filter:Ze,single:ot,foldLeft:$e,sift:y,keys:He,lookup:bt,append:St,exists:mr,spread:Dt,merge:Z,reverse:yr,each:Jt,error:ut,assert:Lt,type:yt,sort:De,shuffle:u,distinct:h,base64encode:it,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:de,decodeUrl:Ce}})();a.exports=f}).call(this)}).call(this,typeof gn<"u"?gn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(r,a,s){var i=r("./datetime"),c=r("./functions"),f=r("./utils"),v=r("./parser"),k=r("./signature"),C=(function(){var D=f.isNumeric,x=f.isArrayOfStrings,S=f.isArrayOfNumbers,M=f.createSequence,ae=f.isSequence,Q=f.isFunction,pe=f.isLambda,H=f.isIterable,R=f.isPromise,se=f.getFunctionArity,L=f.isDeepEqual,T=ut(null);async function $(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await z(u,h,y);break;case"binary":n=await Ie(u,h,y);break;case"unary":n=await et(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=fe(u);break;case"wildcard":n=tt(u,h);break;case"descendant":n=Be(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await O(u,h,y);break;case"bind":n=await B(u,h,y);break;case"regex":n=F(u);break;case"function":n=await me(u,h,y);break;case"variable":n=J(u,h,y);break;case"lambda":n=ot(u,h,y);break;case"partial":n=await qe(u,h,y);break;case"apply":n=await ee(u,h,y);break;case"transform":n=be(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await A(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&ae(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function z(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=M(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var _=u.steps[p];if(_.tuple&&(l=!0),p===0&&_.consarray?o=await $(_,n,y):l?g=await Ae(_,n,g,y):o=await xe(_,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof _.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=M(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=M(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await A(u.group,l?g:o,y)),o}function he(u,h){var y=ut(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ge(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=M();for(var l=0;l<h.length;l++){var g=await $(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var _=M();return n&&o.length===1&&Array.isArray(o[0])&&!ae(o[0])?_=o[0]:o.forEach(function(I){!Array.isArray(I)||I.cons?_.push(I):I.forEach(q=>_.push(q))}),_}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ge(u,y,n);else{var l=await ge(u,h,n);o=M(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=M(),o.tupleStream=!0;var _=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var I=0;I<y.length;I++){_=he(n,y[I]);var q=await $(u,y[I]["@"],_);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[I]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[I]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[I]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=M();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=M(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=he(y,l));var _=await $(u,g,p);D(_)&&(_=[_]),S(_)?_.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(_)&&n.push(l)}return n}async function Ie(u,h,y){var n,o=await $(u.lhs,h,y),l=u.value,g=async()=>await $(u.rhs,h,y);if(l==="and"||l==="or")try{return await Ce(o,g,l)}catch(_){throw _.position=u.position,_.token=l,_}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=V(o,p,l);break;case"&":n=w(o,p);break;case"..":n=N(o,p);break;case"in":n=de(o,p);break}}catch(_){throw _.position=u.position,_.token=l,_}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await $(u.expression,h,y),typeof n>"u")n=void 0;else if(D(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,_)=>(y.isParallelCall=_>0,[p,await $(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await A(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function fe(u){return u.value}function tt(u,h){var y=M();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ie(o),y=c.append(y,o)):y.push(o)}),y}function ie(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ie(y,h)}):h.push(u),h}function Be(u,h){var y,n=M();return typeof h<"u"&&(it(h,n),n.length===1?y=n[0]:y=n),y}function it(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){it(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){it(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!D(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!D(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function V(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function de(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function Ce(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function w(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function A(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=M(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],_=l?he(y,p):y,I=0;I<u.lhs.length;I++){var q=u.lhs[I],X=await $(q[0],l?p["@"]:p,_);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:I};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==I)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}let ye=await Promise.all(Object.keys(o).map(async(Se,We)=>{let ke=o[Se];var Fe=ke.data,ct=y;if(l){var ze=b(ke.data);Fe=ze["@"],delete ze["@"],ct=he(y,ze)}return y.isParallelCall=We>0,[Se,await $(u.lhs[ke.exprIndex][1],Fe,ct)]}));for(let Se of ye){var[X,Ne]=await Se;typeof Ne<"u"&&(n[X]=Ne)}return n}function b(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function N(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function B(u,h,y){var n=await $(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await $(u.condition,h,y);return c.boolean(o)?n=await $(u.then,h,y):typeof u.else<"u"&&(n=await $(u.else,h,y)),n}async function O(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await $(u.expressions[l],h,o);return n}function F(u){var h=new De.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var _=y(n,h.lastIndex);if(_&&_.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return _}}}return l};return y}function J(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ge(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(_,I){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var Oe=u.terms[X],ye=_,Ne=y;l&&(ye=_["@"],Ne=he(y,_));var Se=await $(Oe.expression,ye,Ne);ye=I,Ne=y,l&&(ye=I["@"],Ne=he(y,I));var We=await $(Oe.expression,ye,Ne),ke=typeof Se,Fe=typeof We;if(ke==="undefined"){q=Fe==="undefined"?0:1;continue}if(Fe==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(Fe==="string"||Fe==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?We:Se};if(ke!==Fe)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:We};Se!==We&&(Se<We?q=-1:q=1,Oe.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function be(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!Q(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await $(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var _=0;_<p.length;_++){var I=p[_];if(I&&(I.isPrototypeOf(g)||I instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await $(u.update,I,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var Oe in q)I[Oe]=q[Oe]}if(typeof u.delete<"u"){var ye=await $(u.delete,I,y);if(typeof ye<"u"){var Ne=ye;if(Array.isArray(ye)||(ye=[ye]),!x(ye))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ne};for(var Se=0;Se<ye.length;Se++)typeof I=="object"&&I!==null&&delete I[ye[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=v("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(u,h,y){var n,o=await $(u.lhs,h,y);if(u.rhs.type==="function")n=await me(u.rhs,h,y,{context:o});else{var l=await $(u.rhs,h,y);if(!Q(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(Q(o)){var g=await $(K,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function me(u,h,y,n){var o,l=await $(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const I=await $(u.arguments[p],h,y);if(Q(I)){const q=async function(...X){return await G(I,X,null,y)};q.arity=se(I),g.push(q)}else g.push(I)}var _=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=_,l.position=u.position),o=await G(l,g,h,y)}catch(I){throw I.position||(I.position=u.position),I.token||(I.token=_),I}return o}async function G(u,h,y,n){var o;for(o=await Ze(u,h,y,n);pe(o)&&o.thunk===!0;){var l=await $(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await $(o.body.arguments[p],o.input,o.environment));o=await Ze(l,g,y,n)}return o}async function Ze(u,h,y,n){var o;try{var l=h;if(u&&(l=$e(u.signature,h,y)),pe(u))o=await He(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),R(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),R(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function ot(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function qe(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await $(g,h,y))}var p=await $(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(pe(p))n=bt(p,o);else if(p&&p._jsonata_function===!0)n=St(p.implementation,o);else if(typeof p=="function")n=St(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function $e(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function He(u,h){var y,n=ut(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await mr(u.body,n):y=await $(u.body,u.input,n),y}function bt(u,h){var y=ut(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function St(u,h){var y=Dt(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=v(n);o.body=u;var l=bt(o,h);return l}async function mr(u,h){var y=Dt(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return R(l)&&(l=await l),l}function Dt(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=k(h)),y}async function yr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!ae(y)&&(y=M(y),y.outerWrapper=!0));try{var n=v(u,!1)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await $(n,y,this.environment)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Jt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ut(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}T.bind("sum",Z(c.sum,"<a<n>:n>")),T.bind("count",Z(c.count,"<a:n>")),T.bind("max",Z(c.max,"<a<n>:n>")),T.bind("min",Z(c.min,"<a<n>:n>")),T.bind("average",Z(c.average,"<a<n>:n>")),T.bind("string",Z(c.string,"<x-b?:s>")),T.bind("substring",Z(c.substring,"<s-nn?:s>")),T.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),T.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),T.bind("lowercase",Z(c.lowercase,"<s-:s>")),T.bind("uppercase",Z(c.uppercase,"<s-:s>")),T.bind("length",Z(c.length,"<s-:n>")),T.bind("trim",Z(c.trim,"<s-:s>")),T.bind("pad",Z(c.pad,"<s-ns?:s>")),T.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),T.bind("contains",Z(c.contains,"<s-(sf):b>")),T.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),T.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),T.bind("join",Z(c.join,"<a<s>s?:s>")),T.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),T.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),T.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),T.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),T.bind("number",Z(c.number,"<(nsb)-:n>")),T.bind("floor",Z(c.floor,"<n-:n>")),T.bind("ceil",Z(c.ceil,"<n-:n>")),T.bind("round",Z(c.round,"<n-n?:n>")),T.bind("abs",Z(c.abs,"<n-:n>")),T.bind("sqrt",Z(c.sqrt,"<n-:n>")),T.bind("power",Z(c.power,"<n-n:n>")),T.bind("random",Z(c.random,"<:n>")),T.bind("boolean",Z(c.boolean,"<x-:b>")),T.bind("not",Z(c.not,"<x-:b>")),T.bind("map",Z(c.map,"<af>")),T.bind("zip",Z(c.zip,"<a+>")),T.bind("filter",Z(c.filter,"<af>")),T.bind("single",Z(c.single,"<af?>")),T.bind("reduce",Z(c.foldLeft,"<afj?:j>")),T.bind("sift",Z(c.sift,"<o-f?:o>")),T.bind("keys",Z(c.keys,"<x-:a<s>>")),T.bind("lookup",Z(c.lookup,"<x-s:x>")),T.bind("append",Z(c.append,"<xx:a>")),T.bind("exists",Z(c.exists,"<x:b>")),T.bind("spread",Z(c.spread,"<x-:a<o>>")),T.bind("merge",Z(c.merge,"<a<o>:o>")),T.bind("reverse",Z(c.reverse,"<a:a>")),T.bind("each",Z(c.each,"<o-f:a>")),T.bind("error",Z(c.error,"<s?:x>")),T.bind("assert",Z(c.assert,"<bs?:x>")),T.bind("type",Z(c.type,"<x:s>")),T.bind("sort",Z(c.sort,"<af?:a>")),T.bind("shuffle",Z(c.shuffle,"<a:a>")),T.bind("distinct",Z(c.distinct,"<x:x>")),T.bind("base64encode",Z(c.base64encode,"<s-:s>")),T.bind("base64decode",Z(c.base64decode,"<s-:s>")),T.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),T.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),T.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),T.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),T.bind("eval",Z(yr,"<sx?:x>")),T.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),T.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),T.bind("clone",Z(Jt,"<(oa)-:o>"));var Lt={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 yt(u){var h=Lt[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function De(u,h){var y,n;try{y=v(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw yt(g),g}var o=ut(T),l=new Date;return o.bind("now",Z(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",Z(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(g,p,_){if(typeof n<"u"){var I={code:"S0500",position:0};throw yt(I),I}if(typeof p<"u"){var q;q=ut(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!ae(g)&&(g=M(g),g.outerWrapper=!0);var Oe;try{return Oe=await $(y,g,q),typeof _=="function"&&_(null,Oe),Oe}catch(ye){throw yt(ye),ye}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,_){var I=Z(p,_);o.bind(g,I)},ast:function(){return y},errors:function(){return n}}}return De.parser=v,De})();a.exports=C},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(r,a,s){var i=r("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},v={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
1
|
+
"use strict";var jn=Object.defineProperty;var Fn=(t,e,r)=>e in t?jn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ue=(t,e,r)=>Fn(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var we;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return t.objectValues(c)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},t.find=(s,i)=>{for(const c of s)if(i(c))return c},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(we||(we={}));var Mr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Mr||(Mr={}));const W=we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=t=>{switch(typeof t){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(t)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(t)?W.array:t===null?W.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?W.promise:typeof Map<"u"&&t instanceof Map?W.map:typeof Set<"u"&&t instanceof Set?W.set:typeof Date<"u"&&t instanceof Date?W.date:W.object;default:return W.unknown}},P=we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Bn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class st extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(r(c));else{let f=a,v=0;for(;v<c.path.length;){const k=c.path[v];v===c.path.length-1?(f[k]=f[k]||{_errors:[]},f[k]._errors.push(r(c))):f[k]=f[k]||{_errors:[]},f=f[k],v++}}};return s(this),a}static assert(e){if(!(e instanceof st))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,we.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}st.create=t=>new st(t);const Gt=(t,e)=>{let r;switch(t.code){case P.invalid_type:t.received===W.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,we.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${we.joinValues(t.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${we.joinValues(t.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${we.joinValues(t.options)}, received '${t.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:we.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case P.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case P.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=e.defaultError,we.assertNever(t)}return{message:r}};let wn=Gt;function Un(t){wn=t}function _r(){return wn}const Er=t=>{const{data:e,path:r,errorMaps:a,issueData:s}=t,i=[...r,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const v=a.filter(k=>!!k).slice().reverse();for(const k of v)f=k(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},$n=[];function U(t,e){const r=_r(),a=Er({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Gt?void 0:Gt].filter(s=>!!s)});t.common.issues.push(a)}class Ke{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const a=[];for(const s of r){if(s.status==="aborted")return te;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const s of r){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const s of r){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return te;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const te=Object.freeze({status:"aborted"}),qt=t=>({status:"dirty",value:t}),Je=t=>({status:"valid",value:t}),jr=t=>t.status==="aborted",Fr=t=>t.status==="dirty",Ft=t=>t.status==="valid",tr=t=>typeof Promise<"u"&&t instanceof Promise;var Y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,r,a,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hn=(t,e)=>{if(Ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new st(t.common.issues);return this._error=r,this._error}}};function oe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:s}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:v}=t;return c.code==="invalid_enum_value"?{message:v??f.defaultError}:typeof f.data>"u"?{message:v??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:v??r??f.defaultError}},description:s}}class le{get description(){return this._def.description}_getType(e){return _t(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(tr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parseSync({data:e,path:a.path,parent:a});return hn(a,s)}"~validate"(e){var a,s;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return Ft(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Ft(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(tr(s)?s:Promise.resolve(s));return hn(a,i)}refine(e,r){const a=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:P.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(v=>v?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,r){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof r=="function"?r(a,s):r),!1))}_refinement(e){return new ht({schema:this,typeName:ne.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return gt.create(this,this._def)}nullable(){return Nt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return Kt.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ir.create(this,e,this._def)}transform(e){return new ht({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:r,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:r,typeName:ne.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ln=/^c[^\s-]{8,}$/i,Zn=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Vn=/^[a-z0-9_-]{21}$/i,qn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nr;const Kn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Jn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Xn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ea=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ta=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ra=new RegExp(`^${bn}$`);function kn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function na(t){return new RegExp(`^${kn(t)}$`)}function xn(t){let e=`${bn}T${kn(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function aa(t,e){return!!((e==="v4"||!e)&&Kn.test(t)||(e==="v6"||!e)&&Xn.test(t))}function sa(t,e){if(!qn.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function ia(t,e){return!!((e==="v4"||!e)&&Jn.test(t)||(e==="v6"||!e)&&Qn.test(t))}class ft extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==W.string){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.string,received:i.parsedType}),te}const a=new Ke;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")Gn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Nr||(Nr=new RegExp(Yn,"u")),Nr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:P.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"regex",code:P.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?xn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?ra.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?na(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?Hn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?aa(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?sa(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?ia(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?ea.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?ta.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.invalid_string,message:i.message}),a.dirty()):we.assertNever(i);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(s=>e.test(s),{validation:r,code:P.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Y.errToObj(r)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ft.create=t=>new ft({checks:[],typeName:ne.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});function oa(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=r>a?r:a,i=Number.parseInt(t.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class Ot extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==W.number){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.number,received:i.parsedType}),te}let a;const s=new Ke;for(const i of this._def.checks)i.kind==="int"?we.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?oa(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_finite,message:i.message}),s.dirty()):we.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,s){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ot({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&we.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ot.create=t=>new Ot({checks:[],typeName:ne.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Pt extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==W.bigint)return this._getInvalidInput(e);let a;const s=new Ke;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):we.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:W.bigint,received:r.parsedType}),te}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,s){return new Pt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Pt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Pt.create=t=>new Pt({checks:[],typeName:ne.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});class rr extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==W.boolean){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.boolean,received:a.parsedType}),te}return Je(e.data)}}rr.create=t=>new rr({typeName:ne.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Bt extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==W.date){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:W.date,received:i.parsedType}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),te}const a=new Ke;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):we.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Bt.create=t=>new Bt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:ne.ZodDate,...oe(t)});class Tr extends le{_parse(e){if(this._getType(e)!==W.symbol){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.symbol,received:a.parsedType}),te}return Je(e.data)}}Tr.create=t=>new Tr({typeName:ne.ZodSymbol,...oe(t)});class nr extends le{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.undefined,received:a.parsedType}),te}return Je(e.data)}}nr.create=t=>new nr({typeName:ne.ZodUndefined,...oe(t)});class ar extends le{_parse(e){if(this._getType(e)!==W.null){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.null,received:a.parsedType}),te}return Je(e.data)}}ar.create=t=>new ar({typeName:ne.ZodNull,...oe(t)});class Yt extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Yt.create=t=>new Yt({typeName:ne.ZodAny,...oe(t)});class jt extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}jt.create=t=>new jt({typeName:ne.ZodUnknown,...oe(t)});class Et extends le{_parse(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:W.never,received:r.parsedType}),te}}Et.create=t=>new Et({typeName:ne.ZodNever,...oe(t)});class Ar extends le{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.void,received:a.parsedType}),te}return Je(e.data)}}Ar.create=t=>new Ar({typeName:ne.ZodVoid,...oe(t)});class dt extends le{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),s=this._def;if(r.parsedType!==W.array)return U(r,{code:P.invalid_type,expected:W.array,received:r.parsedType}),te;if(s.exactLength!==null){const c=r.data.length>s.exactLength.value,f=r.data.length<s.exactLength.value;(c||f)&&(U(r,{code:c?P.too_big:P.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(U(r,{code:P.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(U(r,{code:P.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((c,f)=>s.type._parseAsync(new vt(r,c,r.path,f)))).then(c=>Ke.mergeArray(a,c));const i=[...r.data].map((c,f)=>s.type._parseSync(new vt(r,c,r.path,f)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,r){return new dt({...this._def,minLength:{value:e,message:Y.toString(r)}})}max(e,r){return new dt({...this._def,maxLength:{value:e,message:Y.toString(r)}})}length(e,r){return new dt({...this._def,exactLength:{value:e,message:Y.toString(r)}})}nonempty(e){return this.min(1,e)}}dt.create=(t,e)=>new dt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray,...oe(e)});function Vt(t){if(t instanceof je){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=gt.create(Vt(a))}return new je({...t._def,shape:()=>e})}else return t instanceof dt?new dt({...t._def,type:Vt(t.element)}):t instanceof gt?gt.create(Vt(t.unwrap())):t instanceof Nt?Nt.create(Vt(t.unwrap())):t instanceof wt?wt.create(t.items.map(e=>Vt(e))):t}class je extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=we.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==W.object){const k=this._getOrReturnCtx(e);return U(k,{code:P.invalid_type,expected:W.object,received:k.parsedType}),te}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const k in s.data)c.includes(k)||f.push(k);const v=[];for(const k of c){const C=i[k],D=s.data[k];v.push({key:{status:"valid",value:k},value:C._parse(new vt(s,D,s.path,k)),alwaysSet:k in s.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const C of f)v.push({key:{status:"valid",value:C},value:{status:"valid",value:s.data[C]}});else if(k==="strict")f.length>0&&(U(s,{code:P.unrecognized_keys,keys:f}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const C of f){const D=s.data[C];v.push({key:{status:"valid",value:C},value:k._parse(new vt(s,D,s.path,C)),alwaysSet:C in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const k=[];for(const C of v){const D=await C.key,x=await C.value;k.push({key:D,value:x,alwaysSet:C.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):Ke.mergeObjectSync(a,v)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ne.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new je({...this._def,catchall:e})}pick(e){const r={};for(const a of we.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}omit(e){const r={};for(const a of we.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}deepPartial(){return Vt(this)}partial(e){const r={};for(const a of we.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?r[a]=s:r[a]=s.optional()}return new je({...this._def,shape:()=>r})}required(e){const r={};for(const a of we.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof gt;)i=i._def.innerType;r[a]=i}return new je({...this._def,shape:()=>r})}keyof(){return _n(we.objectKeys(this.shape))}}je.create=(t,e)=>new je({shape:()=>t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.strictCreate=(t,e)=>new je({shape:()=>t,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.lazycreate=(t,e)=>new je({shape:t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new st(f.ctx.common.issues));return U(r,{code:P.invalid_union,unionErrors:c}),te}if(r.common.async)return Promise.all(a.map(async i=>{const c={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const v of a){const k={...r,common:{...r.common,issues:[]},parent:null},C=v._parseSync({data:r.data,path:r.path,parent:k});if(C.status==="valid")return C;C.status==="dirty"&&!i&&(i={result:C,ctx:k}),k.common.issues.length&&c.push(k.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(v=>new st(v));return U(r,{code:P.invalid_union,unionErrors:f}),te}}get options(){return this._def.options}}sr.create=(t,e)=>new sr({options:t,typeName:ne.ZodUnion,...oe(e)});const xt=t=>t instanceof cr?xt(t.schema):t instanceof ht?xt(t.innerType()):t instanceof ur?[t.value]:t instanceof Ct?t.options:t instanceof lr?we.objectValues(t.enum):t instanceof fr?xt(t._def.innerType):t instanceof nr?[void 0]:t instanceof ar?[null]:t instanceof gt?[void 0,...xt(t.unwrap())]:t instanceof Nt?[null,...xt(t.unwrap())]:t instanceof $r||t instanceof hr?xt(t.unwrap()):t instanceof dr?xt(t._def.innerType):[];class Or extends le{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.object)return U(r,{code:P.invalid_type,expected:W.object,received:r.parsedType}),te;const a=this.discriminator,s=r.data[a],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(U(r,{code:P.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,a){const s=new Map;for(const i of r){const c=xt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Or({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...oe(a)})}}function Br(t,e){const r=_t(t),a=_t(e);if(t===e)return{valid:!0,data:t};if(r===W.object&&a===W.object){const s=we.objectKeys(e),i=we.objectKeys(t).filter(f=>s.indexOf(f)!==-1),c={...t,...e};for(const f of i){const v=Br(t[f],e[f]);if(!v.valid)return{valid:!1};c[f]=v.data}return{valid:!0,data:c}}else if(r===W.array&&a===W.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const c=t[i],f=e[i],v=Br(c,f);if(!v.valid)return{valid:!1};s.push(v.data)}return{valid:!0,data:s}}else return r===W.date&&a===W.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ir extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(jr(i)||jr(c))return te;const f=Br(i.value,c.value);return f.valid?((Fr(i)||Fr(c))&&r.dirty(),{status:r.value,value:f.data}):(U(a,{code:P.invalid_intersection_types}),te)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ir.create=(t,e,r)=>new ir({left:t,right:e,typeName:ne.ZodIntersection,...oe(r)});class wt extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return U(a,{code:P.invalid_type,expected:W.array,received:a.parsedType}),te;if(a.data.length<this._def.items.length)return U(a,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),te;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:P.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((c,f)=>{const v=this._def.items[f]||this._def.rest;return v?v._parse(new vt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ke.mergeArray(r,c)):Ke.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new wt({...this._def,rest:e})}}wt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new wt({items:t,typeName:ne.ZodTuple,rest:null,...oe(e)})};class or extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return U(a,{code:P.invalid_type,expected:W.object,received:a.parsedType}),te;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new vt(a,f,a.path,f)),value:c._parse(new vt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ke.mergeObjectAsync(r,s):Ke.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof le?new or({keyType:e,valueType:r,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ft.create(),valueType:e,typeName:ne.ZodRecord,...oe(r)})}}class Sr extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.map)return U(a,{code:P.invalid_type,expected:W.map,received:a.parsedType}),te;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,v],k)=>({key:s._parse(new vt(a,f,a.path,[k,"key"])),value:i._parse(new vt(a,v,a.path,[k,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const v of c){const k=await v.key,C=await v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),f.set(k.value,C.value)}return{status:r.value,value:f}})}else{const f=new Map;for(const v of c){const k=v.key,C=v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),f.set(k.value,C.value)}return{status:r.value,value:f}}}}Sr.create=(t,e,r)=>new Sr({valueType:e,keyType:t,typeName:ne.ZodMap,...oe(r)});class Ut extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return U(a,{code:P.invalid_type,expected:W.set,received:a.parsedType}),te;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:P.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(U(a,{code:P.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const i=this._def.valueType;function c(v){const k=new Set;for(const C of v){if(C.status==="aborted")return te;C.status==="dirty"&&r.dirty(),k.add(C.value)}return{status:r.value,value:k}}const f=[...a.data.values()].map((v,k)=>i._parse(new vt(a,v,a.path,k)));return a.common.async?Promise.all(f).then(v=>c(v)):c(f)}min(e,r){return new Ut({...this._def,minSize:{value:e,message:Y.toString(r)}})}max(e,r){return new Ut({...this._def,maxSize:{value:e,message:Y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ut.create=(t,e)=>new Ut({valueType:t,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class Ht extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.function)return U(r,{code:P.invalid_type,expected:W.function,received:r.parsedType}),te;function a(f,v){return Er({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_r(),Gt].filter(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:v}})}function s(f,v){return Er({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_r(),Gt].filter(k=>!!k),issueData:{code:P.invalid_return_type,returnTypeError:v}})}const i={errorMap:r.common.contextualErrorMap},c=r.data;if(this._def.returns instanceof Kt){const f=this;return Je(async function(...v){const k=new st([]),C=await f._def.args.parseAsync(v,i).catch(S=>{throw k.addIssue(a(v,S)),k}),D=await Reflect.apply(c,this,C);return await f._def.returns._def.type.parseAsync(D,i).catch(S=>{throw k.addIssue(s(D,S)),k})})}else{const f=this;return Je(function(...v){const k=f._def.args.safeParse(v,i);if(!k.success)throw new st([a(v,k.error)]);const C=Reflect.apply(c,this,k.data),D=f._def.returns.safeParse(C,i);if(!D.success)throw new st([s(C,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ht({...this._def,args:wt.create(e).rest(jt.create())})}returns(e){return new Ht({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new Ht({args:e||wt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends le{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}cr.create=(t,e)=>new cr({getter:t,typeName:ne.ZodLazy,...oe(e)});class ur extends le{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return U(r,{received:r.data,code:P.invalid_literal,expected:this._def.value}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(t,e)=>new ur({value:t,typeName:ne.ZodLiteral,...oe(e)});function _n(t,e){return new Ct({values:t,typeName:ne.ZodEnum,...oe(e)})}class Ct extends le{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{expected:we.joinValues(a),received:r.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{received:r.data,code:P.invalid_enum_value,options:a}),te}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Ct.create(e,{...this._def,...r})}exclude(e,r=this._def){return Ct.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}Ct.create=_n;class lr extends le{_parse(e){const r=we.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const s=we.objectValues(r);return U(a,{expected:we.joinValues(s),received:a.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=we.objectValues(r);return U(a,{received:a.data,code:P.invalid_enum_value,options:s}),te}return Je(e.data)}get enum(){return this._def.values}}lr.create=(t,e)=>new lr({values:t,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends le{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.promise&&r.common.async===!1)return U(r,{code:P.invalid_type,expected:W.promise,received:r.parsedType}),te;const a=r.parsedType===W.promise?r.data:Promise.resolve(r.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Kt.create=(t,e)=>new Kt({type:t,typeName:ne.ZodPromise,...oe(e)});class ht extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{U(a,c),c.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(r.value==="aborted")return te;const v=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return v.status==="aborted"?te:v.status==="dirty"||r.value==="dirty"?qt(v.value):v});{if(r.value==="aborted")return te;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?te:f.status==="dirty"||r.value==="dirty"?qt(f.value):f}}if(s.type==="refinement"){const c=f=>{const v=s.refinement(f,i);if(a.common.async)return Promise.resolve(v);if(v instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?te:(f.status==="dirty"&&r.dirty(),c(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?te:(f.status==="dirty"&&r.dirty(),c(f.value).then(()=>({status:r.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ft(c))return te;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>Ft(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:r.value,value:f})):te);we.assertNever(s)}}ht.create=(t,e,r)=>new ht({schema:t,typeName:ne.ZodEffects,effect:e,...oe(r)});ht.createWithPreprocess=(t,e,r)=>new ht({schema:e,effect:{type:"preprocess",transform:t},typeName:ne.ZodEffects,...oe(r)});class gt extends le{_parse(e){return this._getType(e)===W.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gt.create=(t,e)=>new gt({innerType:t,typeName:ne.ZodOptional,...oe(e)});class Nt extends le{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(t,e)=>new Nt({innerType:t,typeName:ne.ZodNullable,...oe(e)});class fr extends le{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===W.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}fr.create=(t,e)=>new fr({innerType:t,typeName:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new st(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new st(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Dr extends le{_parse(e){if(this._getType(e)!==W.nan){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:W.nan,received:a.parsedType}),te}return{status:"valid",value:e.data}}}Dr.create=t=>new Dr({typeName:ne.ZodNaN,...oe(t)});const ca=Symbol("zod_brand");class $r extends le{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class mr extends le{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?te:i.status==="dirty"?(r.dirty(),qt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?te:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,r){return new mr({in:e,out:r,typeName:ne.ZodPipeline})}}class hr extends le{_parse(e){const r=this._def.innerType._parse(e),a=s=>(Ft(s)&&(s.value=Object.freeze(s.value)),s);return tr(r)?r.then(s=>a(s)):a(r)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:ne.ZodReadonly,...oe(e)});function pn(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function En(t,e={},r){return t?Yt.create().superRefine((a,s)=>{const i=t(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=pn(e,a),v=f.fatal??r??!0;s.addIssue({code:"custom",...f,fatal:v})}});if(!i){const c=pn(e,a),f=c.fatal??r??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Yt.create()}const ua={object:je.lazycreate};var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const la=(t,e={message:`Input not instance of ${t.name}`})=>En(r=>r instanceof t,e),Pe=ft.create,$t=Ot.create,fa=Dr.create,da=Pt.create,Rt=rr.create,ha=Bt.create,pa=Tr.create,ma=nr.create,ya=ar.create,ga=Yt.create,va=jt.create,wa=Et.create,ba=Ar.create,ka=dt.create,Tt=je.create,xa=je.strictCreate,_a=sr.create,Ea=Or.create,Ta=ir.create,Aa=wt.create,Sa=or.create,Da=Sr.create,Oa=Ut.create,Pa=Ht.create,Ca=cr.create,Na=ur.create,Lr=Ct.create,Zr=lr.create,Ra=Kt.create,mn=ht.create,Ia=gt.create,Ma=Nt.create,ja=ht.createWithPreprocess,Fa=mr.create,Ba=()=>Pe().optional(),Ua=()=>$t().optional(),$a=()=>Rt().optional(),pr={string:(t=>ft.create({...t,coerce:!0})),number:(t=>Ot.create({...t,coerce:!0})),boolean:(t=>rr.create({...t,coerce:!0})),bigint:(t=>Pt.create({...t,coerce:!0})),date:(t=>Bt.create({...t,coerce:!0}))},La=te,E=Object.freeze(Object.defineProperty({__proto__:null,BRAND:ca,DIRTY:qt,EMPTY_PATH:$n,INVALID:te,NEVER:La,OK:Je,ParseStatus:Ke,Schema:le,ZodAny:Yt,ZodArray:dt,ZodBigInt:Pt,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Or,ZodEffects:ht,ZodEnum:Ct,ZodError:st,get ZodFirstPartyTypeKind(){return ne},ZodFunction:Ht,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Sr,ZodNaN:Dr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Nt,ZodNumber:Ot,ZodObject:je,ZodOptional:gt,ZodParsedType:W,ZodPipeline:mr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:le,ZodSet:Ut,ZodString:ft,ZodSymbol:Tr,ZodTransformer:ht,ZodTuple:wt,ZodType:le,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Ar,addIssueToContext:U,any:ga,array:ka,bigint:da,boolean:Rt,coerce:pr,custom:En,date:ha,datetimeRegex:xn,defaultErrorMap:Gt,discriminatedUnion:Ea,effect:mn,enum:Lr,function:Pa,getErrorMap:_r,getParsedType:_t,instanceof:la,intersection:Ta,isAborted:jr,isAsync:tr,isDirty:Fr,isValid:Ft,late:ua,lazy:Ca,literal:Na,makeIssue:Er,map:Da,nan:fa,nativeEnum:Zr,never:wa,null:ya,nullable:Ma,number:$t,object:Tt,get objectUtil(){return Mr},oboolean:$a,onumber:Ua,optional:Ia,ostring:Ba,pipeline:Fa,preprocess:ja,promise:Ra,quotelessJson:Bn,record:Sa,set:Oa,setErrorMap:Un,strictObject:xa,string:Pe,symbol:pa,transformer:mn,tuple:Aa,undefined:ma,union:_a,unknown:va,get util(){return we},void:ba},Symbol.toStringTag,{value:"Module"})),pt=Tt({name:Pe(),selector:Pe(),findBy:Lr(["cssSelector","xpath"]),option:Tt({waitForSelector:Rt().optional(),waitSelectorTimeout:$t().optional(),multiple:Rt().optional()})}),Za=E.object({type:E.literal("object"),shape:E.record(E.string(),E.any())}),Wa=E.object({type:E.literal("array"),items:E.any()}),za=E.discriminatedUnion("type",[Za,Wa]),Wr=E.object({name:E.literal("ai-parse-data"),sourceData:E.any().optional(),schemaDefinition:za,prompt:E.string().optional(),model:E.string().optional(),apiKey:E.string().min(1,"AI API key is required"),provider:E.enum(["openai","anthropic"])});function Va(t){return Wr.parse(t)}async function qa(t){try{const{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}=t;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const f=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}});if(f.$isError)throw new Error(f.message||"AI parsing failed");return{data:f.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function Ha(t){return{type:"object",shape:t}}function Ga(t){return{type:"array",items:t}}const Ya={string:t=>({type:"string",...t}),number:t=>({type:"number",...t}),boolean:t=>({type:"boolean",...t}),array:(t,e)=>({type:"array",items:t,...e}),object:(t,e)=>({type:"object",shape:t,...e}),currency:t=>({type:"currency",shape:An,description:(t==null?void 0:t.description)||"Currency information with code, symbol, format, amount, and text",optional:t==null?void 0:t.optional})};class Pr{async waitForElement(e,r,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,r);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class Ka extends Pr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,r);return i?Array.from(r.querySelectorAll(c)):r.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,r){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(v=>v.nodeType===Node.TEXT_NODE).map(v=>{var k;return((k=v.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ja extends Pr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(k=>k.trim());if(c.length!==2)return null;const f=c[0],v=c[1];if(!f||!v)return null;try{const k=r.querySelector(f);if(!k||!k.contentDocument)return null;const C=k.contentDocument;return i?Array.from(C.querySelectorAll(v)):C.querySelector(v)}catch(k){return console.error("Iframe Selector error:",k),null}}}class Xa extends Pr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(v=>v.trim());let f=r;try{for(let v=0;v<c.length;v++){const k=c[v],C=v===c.length-1;if(!k)return null;if(C&&i)return Array.from(f.querySelectorAll(k));const D=f.querySelector(k);if(!D)return null;if(C)return D;if(D.shadowRoot)f=D.shadowRoot;else return null}}catch(v){return console.error("Shadow DOM Selector error:",v),null}return null}}class Qa extends Pr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=r.evaluate(a,r,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let v=0;v<c.snapshotLength;v++){const k=c.snapshotItem(v);k&&k.nodeType===Node.ELEMENT_NODE&&f.push(k)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class es{static generate(e){const r=["data-testid","aria-label","title","alt","role"];for(const i of r){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const r=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${r}:nth-child(${c})`}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function mt(t,e=document){const{selector:r,findBy:a="cssSelector",option:s}=t,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=ts(r,a);return i?f.waitForElement(t,e,c):f.find(t,e)}function ts(t,e){return e==="xpath"?new Qa:t.includes(">>")?new Xa:t.includes("|>")?new Ja:new Ka}const zr=pt.extend({name:E.literal("get-text"),includeTags:E.boolean().optional(),useTextContent:E.boolean().optional(),regex:E.string().optional(),prefixText:E.string().optional(),suffixText:E.string().optional(),filterEmpty:E.boolean().optional(),scrollToCollect:E.boolean().optional(),scrollDistance:E.number().optional(),scrollWaitMs:E.number().optional(),maxScrollAttempts:E.number().optional()});function rs(t){return zr.parse(t)}async function ns(t){try{const{selector:e="",includeTags:r=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:v,filterEmpty:k=!0,scrollToCollect:C=!1,scrollDistance:D=500,scrollWaitMs:x=300,maxScrollAttempts:S=100}=t;if(!e)throw new Error("Selector is required for get-text block");if(C&&(v!=null&&v.multiple))return await as({selector:e,findBy:f,option:v,includeTags:r,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:D,scrollWaitMs:x,maxScrollAttempts:S});const M=await mt({selector:e,findBy:f,option:v});if(!M)return{data:""};const ae=Tn(r,a,s,i,c);if(Array.isArray(M)){const Q=M.map(ae);return{data:k?Q.filter(H=>H.trim()!==""):Q}}else return{data:ae(M)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function as(t){const{selector:e,findBy:r,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:v,filterEmpty:k,scrollDistance:C,scrollWaitMs:D,maxScrollAttempts:x}=t,S=Tn(s,i,c,f,v),M=new Set;let ae=0,Q=0;const pe=5;for(;ae<x;){const H=await mt({selector:e,findBy:r,option:a});if(H&&Array.isArray(H)){const L=M.size;if(H.forEach($=>{const z=S($);(!k||z.trim()!=="")&&M.add(z)}),M.size===L){if(Q++,Q>=pe)break}else Q=0}const R=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:C,behavior:"auto"}),await new Promise(L=>setTimeout(L,D)),(window.pageYOffset||document.documentElement.scrollTop)===R)break;ae++}return{data:Array.from(M)}}function Tn(t,e,r,a="",s=""){return i=>{let c="";if(t?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",r){const f=new RegExp(r,"g"),v=c.match(f);c=v?v.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Vr=pt.extend({name:E.literal("attribute-value"),attributeName:E.string()});function ss(t){return Vr.parse(t)}async function is(t){try{const{selector:e="",attributeName:r,findBy:a="cssSelector",option:s}=t;if(!e)throw new Error("Selector is required for attribute-value block");if(!r)throw new Error("Attribute name is required for attribute-value block");const i=await mt({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(r)).filter(f=>f!==null):i.getAttribute(r)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const qr=pt.extend({name:E.literal("get-value-form"),type:E.enum(["text-field","select","checkbox"]).optional()});function os(t){return qr.parse(t)}async function cs(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for get-value-form block");const s=await mt({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return{data:us(s,r)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function us(t,e){switch(e){case"text-field":if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)return t.value;break;case"select":if(t instanceof HTMLSelectElement)return t.value;break;case"checkbox":if(t instanceof HTMLInputElement&&t.type==="checkbox")return t.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Hr=pt.extend({name:E.literal("set-value-form"),setValue:E.string(),type:E.enum(["text-field","select","checkbox"]).optional()});function ls(t){return Hr.parse(t)}async function fs(t){try{const{selector:e="",setValue:r,type:a="text-field",findBy:s="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-value-form block");const i=await mt({selector:e,findBy:s,option:t.option});if(!i)throw new Error("Form element not found");return ds(i,r,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function ds(t,e,r){switch(r){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.value=e,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=e==="true"||e==="checked",t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${r}`)}}const Gr=pt.extend({name:E.literal("clear-value-form"),type:E.enum(["text-field","select","checkbox"]).optional()});function hs(t){return Gr.parse(t)}async function ps(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await mt({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return ms(s,r),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ms(t,e){switch(e){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.selectedIndex=0,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=!1,t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Yr=pt.extend({name:E.literal("element-exists")});function ys(t){return Yr.parse(t)}async function gs(t){try{const{selector:e="",findBy:r="cssSelector",option:a}=t;if(!e)throw new Error("Selector is required for element-exists block");return{data:await mt({selector:e,findBy:r,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Kr=pt.extend({name:E.literal("event-click"),textFilter:E.object({text:E.union([E.string(),E.array(E.string())]),mode:E.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function vs(t){return Kr.parse(t)}async function ws(t){try{const{selector:e="",findBy:r="cssSelector",option:a,textFilter:s}=t;if(!e)throw new Error("Selector is required for event-click block");const i=await mt({selector:e,findBy:r,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=bs(i,s.text,s.mode);if(!f){const v=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${v}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await xs(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function bs(t,e,r){for(const a of t){const s=ks(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(r){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ks(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}async function xs(t){t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),t.focus&&t.focus();const e=t.getBoundingClientRect(),r=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:r,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),t.click&&t.click()}await new Promise(s=>setTimeout(s,50))}const Jr=E.object({name:E.literal("keypress"),key:E.string(),code:E.string().optional(),keyCode:E.number().optional(),modifiers:E.array(E.enum(["Alt","Control","Meta","Shift"])).optional()});function _s(t){return Jr.parse(t)}async function Es(t){try{const{key:e,code:r,keyCode:a,modifiers:s=[]}=t;return await Ts(e,r,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Ts(t,e,r,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:t,code:e||t,keyCode:r||Rr(t),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...yn(a)}),c=new KeyboardEvent("keyup",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...yn(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Rr(t){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[t]||0}function yn(t){return{altKey:t.includes("Alt"),ctrlKey:t.includes("Control"),metaKey:t.includes("Meta"),shiftKey:t.includes("Shift")}}const Xr=E.object({name:E.literal("wait"),duration:E.number().min(0)});function As(t){return Xr.parse(t)}async function Ss(t){try{const{duration:e}=t;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(r=>setTimeout(r,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Qr=E.object({name:E.literal("wait-for-condition"),conditions:E.object({urlPattern:E.string().optional(),elementExists:E.object({selector:E.string(),findBy:E.enum(["cssSelector","xpath"])}).optional(),cookieExists:E.string().optional(),storageKey:E.object({type:E.enum(["localStorage","sessionStorage"]),key:E.string()}).optional(),userConfirmation:E.boolean().optional(),message:E.string().optional(),buttonText:E.string().optional()}).refine(t=>t.urlPattern!==void 0||t.elementExists!==void 0||t.cookieExists!==void 0||t.storageKey!==void 0||t.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:E.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:E.number().min(100).optional(),timeoutMs:E.number().min(1e3).optional(),position:E.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ds(t){return Qr.parse(t)}async function Os(t){try{const{conditions:e,mode:r="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=t;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",r,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let v=null,k=null;(r==="manual"||r==="auto-or-manual")&&f&&(v=new Promise(D=>{k=D}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:k}})));const C=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(D){console.warn("[WaitForCondition] Invalid URL pattern:",D)}if(e.elementExists){const{selector:D,findBy:x}=e.elementExists;let S=null;if(x==="cssSelector"?S=document.querySelector(D):x==="xpath"&&(S=document.evaluate(D,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),S)return{success:!0,reason:"elementExists",message:`Element found: ${D}`}}if(e.cookieExists&&document.cookie.split(";").some(S=>{const[M]=S.trim().split("=");return M===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:D,key:x}=e.storageKey;if((D==="localStorage"?window.localStorage:window.sessionStorage).getItem(x)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${D}.${x}`}}return null};return new Promise(D=>{let x=null,S=!1;const M=()=>{x&&(clearInterval(x),x=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{S||(S=!0,M(),console.log("[WaitForCondition] Resolved with:",pe),D({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(r==="auto"||r==="auto-or-manual")&&c&&(x=setInterval(async()=>{const pe=await C();pe&&(clearTimeout(Q),ae(pe))},a)),(r==="manual"||r==="auto-or-manual")&&v&&v.then(()=>{clearTimeout(Q),ae({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const en=E.object({name:E.literal("navigate"),url:E.string().url("Valid URL is required"),waitForLoad:E.boolean().optional(),timeout:E.number().min(0).optional()});function Ps(t){return en.parse(t)}async function Cs(t){try{const{url:e,waitForLoad:r=!0,timeout:a=3e4}=t;return console.log(`[Navigate] Navigating to: ${e}`),r?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const tn=pt.extend({name:E.literal("save-assets")});function Ns(t){return tn.parse(t)}async function Rs(t){try{const{selector:e="img, audio, video, source",findBy:r="cssSelector",option:a}=t,s=await mt({selector:e,findBy:r,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Is{static generate(e){var s;const r=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(v=>v.tagName===a.tagName);if(c.length>1){const v=c.indexOf(a)+1;i+=`[${v}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),r.unshift(i),a=a.parentElement}return"/"+r.join("/")}static getStableAttributes(e){const r=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&r.push(`${s}="${i}"`)}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const rn=pt.extend({name:E.literal("get-element-data"),includeText:E.boolean().optional(),includeTags:E.boolean().optional(),useTextContent:E.boolean().optional(),regex:E.string().optional(),prefixText:E.string().optional(),suffixText:E.string().optional(),attributes:E.array(E.string()).optional(),includeSelector:E.boolean().optional(),includeXPath:E.boolean().optional()});function Ms(t){return rn.parse(t)}async function js(t){try{const{selector:e="",includeText:r=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:v=[],includeSelector:k=!1,includeXPath:C=!1,findBy:D="cssSelector",option:x}=t;if(!e)throw new Error("Selector is required for get-element-data block");if(!r&&v.length===0)throw new Error("Either includeText must be true or attributes must be provided");const S=await mt({selector:e,findBy:D,option:x});if(!S)return{data:Array.isArray(S)?[]:{}};const M=Fs(r,a,s,i,c,f,v,k,C);return Array.isArray(S)?{data:S.map(M)}:{data:M(S)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Fs(t,e,r,a,s="",i="",c=[],f=!1,v=!1){return k=>{const C={};if(t){let D="";if(e?D=k.innerHTML:D=r?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),S=D.match(x);D=S?S.join(" "):""}D.trim()&&(D=s+D.trim()+i),C.text=D}return c.length>0&&(C.attributes={},c.forEach(D=>{let x=k.getAttribute(D);if(x===null){const S=k.querySelector(`[${D}]`);S&&(x=S.getAttribute(D))}C.attributes[D]=x})),f&&(C.selector=es.generate(k)),v&&(C.xpath=Is.generate(k)),C}}const nn=pt.extend({name:E.literal("scroll"),scrollType:E.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:E.number().optional(),behavior:E.enum(["auto","smooth"]).optional(),maxScrolls:E.number().optional(),waitAfterScroll:E.number().optional()});function Bs(t){return nn.parse(t)}async function Us(t){try{const{selector:e="",scrollType:r="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:v}=t;switch(r){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await $s(e,f,v,s);case"toBottom":return await Ls(s,c);case"byDistance":return await Zs(a,s);case"untilLoaded":return await Ws(i,a,s,c);default:throw new Error(`Unknown scroll type: ${r}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function $s(t,e,r,a){const s=await mt({selector:t,findBy:e,option:r});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Ls(t,e){let r=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:t}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===r)break;r=i,a++}return{data:!0}}async function Zs(t,e){return window.scrollBy({top:t,behavior:e}),{data:!0}}async function Ws(t,e,r,a){let s=0,i=document.body.scrollHeight;for(;s<t;){window.scrollBy({top:e,behavior:r}),await new Promise(k=>setTimeout(k,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,v=window.innerHeight;if(f+v>=c-10&&c===i)break;i=c,s++}return{data:!0}}const an=E.object({name:E.literal("fetch-api"),url:E.string(),method:E.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:E.record(E.string(),E.string()).optional(),body:E.record(E.string(),E.any()).optional(),timeout:E.number().min(0).optional(),parseJson:E.boolean().optional(),returnHeaders:E.boolean().optional()});function zs(t){return an.parse(t)}async function Vs(t){try{console.log("[FetchApiBlock] Sending API request to background:",t.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:t.url,method:t.method||"GET",headers:t.headers||{},body:t.body,timeout:t.timeout||3e4,parseJson:t.parseJson??!0,returnHeaders:t.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ir={exports:{}},vn;function Hs(){return vn||(vn=1,(function(t,e){(function(r){t.exports=r()})(function(){return(function(){function r(a,s,i){function c(k,C){if(!s[k]){if(!a[k]){var D=typeof xr=="function"&&xr;if(!C&&D)return D(k,!0);if(f)return f(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var S=s[k]={exports:{}};a[k][0].call(S.exports,function(M){var ae=a[k][1][M];return c(ae||M)},S,S.exports,r,a,s,i)}return s[k].exports}for(var f=typeof xr=="function"&&xr,v=0;v<i.length;v++)c(i[v]);return c}return r})()({1:[function(r,a,s){const i=r("./utils"),c=(function(){const f=i.stringToArray,v=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],k=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],C=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],D=["Thousand","Million","Billion","Trillion"];function x(w,A){var b=function(B,j,O){var F="";if(B<=19)F=(j?" and ":"")+(O?k[B]:v[B]);else if(B<100){const ge=Math.floor(B/10),be=B%10;F=(j?" and ":"")+C[ge-2],be>0?F+="-"+b(be,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ge=Math.floor(B/100),be=B%100;F=(j?", ":"")+v[ge]+" Hundred",be>0?F+=b(be,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>D.length&&(J=D.length);const ge=Math.pow(10,J*3),be=Math.floor(B/ge),K=B-be*ge;F=(j?", ":"")+b(be,!1,!1)+" "+D[J-1],K>0?F+=b(K,!0,O):O&&(F+="th")}return F},N=b(w,!1,A);return N}const S={};v.forEach(function(w,A){S[w.toLowerCase()]=A}),k.forEach(function(w,A){S[w.toLowerCase()]=A}),C.forEach(function(w,A){const b=w.toLowerCase();S[b]=(A+2)*10,S[b.substring(0,w.length-1)+"ieth"]=S[b]}),S.hundredth=100,D.forEach(function(w,A){const b=w.toLowerCase(),N=Math.pow(10,(A+1)*3);S[b]=N,S[b+"th"]=N});function M(w){const b=w.split(/,\s|\sand\s|[\s\\-]/).map(j=>S[j]);let N=[0];return b.forEach(j=>{if(j<100){let O=N.pop();O>=1e3&&(N.push(O),O=0),N.push(O+j)}else N.push(N.pop()*j)}),N.reduce((j,O)=>j+O,0)}const ae=[[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"]],Q={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function pe(w){for(var A=0;A<ae.length;A++){const b=ae[A];if(w>=b[0])return b[1]+pe(w-b[0])}return""}function H(w){for(var A=0,b=1,N=w.length-1;N>=0;N--){const B=w[N],j=Q[B];j<b?A-=j:(b=j,A+=j)}return A}function R(w,A){for(var b=[],N=A.charCodeAt(0);w>0;)b.unshift(String.fromCharCode((w-1)%26+N)),w=Math.floor((w-1)/26);return b.join("")}function se(w,A){for(var b=A.charCodeAt(0),N=0,B=0;B<w.length;B++)N+=(w.charCodeAt(w.length-B-1)-b+1)*Math.pow(26,B);return N}function L(w,A){if(typeof w>"u")return;w=Math.floor(w);const b=xe(A);return z(w,b)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(w,A){let b;const N=w<0;switch(w=Math.abs(w),A.primary){case T.LETTERS:b=R(w,A.case===$.UPPER?"A":"a");break;case T.ROMAN:b=pe(w),A.case===$.UPPER&&(b=b.toUpperCase());break;case T.WORDS:b=x(w,A.ordinal),A.case===$.UPPER?b=b.toUpperCase():A.case===$.LOWER&&(b=b.toLowerCase());break;case T.DECIMAL:b=""+w;var B=A.mandatoryDigits-b.length;if(B>0){var j=new Array(B+1).join("0");b=j+b}if(A.zeroCode!==48&&(b=f(b).map(ge=>String.fromCodePoint(ge.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ge=Math.floor((b.length-1)/A.groupingSeparators.position);for(let be=ge;be>0;be--){const K=b.length-be*A.groupingSeparators.position;b=b.substr(0,K)+A.groupingSeparators.character+b.substr(K)}}else A.groupingSeparators.reverse().forEach(ge=>{const be=b.length-ge.position;b=b.substr(0,be)+ge.character+b.substr(be)});if(A.ordinal){var O={1:"st",2:"nd",3:"rd"},F=b[b.length-1],J=O[F];(!J||b.length>1&&b[b.length-2]==="1")&&(J="th"),b=b+J}break;case T.SEQUENCE:throw{code:"D3130",value:A.token}}return N&&(b="-"+b),b}const he=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(w){const A={type:"integer",primary:T.DECIMAL,case:$.LOWER,ordinal:!1};let b,N;const B=w.lastIndexOf(";");switch(B===-1?b=w:(b=w.substring(0,B),N=w.substring(B+1),N[0]==="o"&&(A.ordinal=!0)),b){case"A":A.case=$.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=$.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=$.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=$.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,O=0,F=0,J=[],ge=0;if(f(b).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let ee=!1;for(let me=0;me<he.length;me++){const G=he[me];if(K>=G&&K<=G+9){if(ee=!0,O++,ge++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ge++,F++):J.push({position:ge,character:String.fromCodePoint(K)}))}),O>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=O,A.optionalDigits=F;const ee=function(me){if(me.length===0)return 0;const G=me[0].character;for(let $e=1;$e<me.length;$e++)if(me[$e].character!==G)return 0;const Ze=me.map($e=>$e.position),ot=function($e,He){return He===0?$e:ot(He,$e%He)},qe=Ze.reduce(ot);for(let $e=1;$e<=Ze.length;$e++)if(Ze.indexOf($e*qe)===-1)return 0;return qe}(J);ee>0?(A.regular=!0,A.groupingSeparators={position:ee,character:J[0].character}):(A.regular=!1,A.groupingSeparators=J)}else A.primary=T.SEQUENCE,A.token=b}}return A}const Te={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Ae(w){var A=[];const b={type:"datetime",parts:A},N=function(ee,me){if(me>ee){let G=w.substring(ee,me);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var B=0,j=0;j<w.length;){if(w.charAt(j)==="["){if(w.charAt(j+1)==="["){N(B,j),A.push({type:"literal",value:"["}),j+=2,B=j;continue}if(N(B,j),B=j,j=w.indexOf("]",B),j===-1)throw{code:"D3135"};let ee=w.substring(B+1,j);ee=ee.split(/\s+/).join("");var O={type:"marker",component:ee.charAt(0)},F=ee.lastIndexOf(","),J;if(F!==-1){const me=ee.substring(F+1),G=me.indexOf("-");let Ze,ot;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=me:(Ze=me.substring(0,G),ot=me.substring(G+1));const $e={min:qe(Ze),max:qe(ot)};O.width=$e,J=ee.substring(1,F)}else J=ee.substring(1);if(J.length===1)O.presentation1=J;else if(J.length>1){var ge=J.charAt(J.length-1);"atco".indexOf(ge)!==-1?(O.presentation2=ge,ge==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Te[O.component];if(typeof O.presentation1>"u")throw{code:"D3132",value:O.component};if(O.presentation1[0]==="n")O.names=$.LOWER;else if(O.presentation1[0]==="N")O.presentation1[1]==="n"?O.names=$.TITLE:O.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(O.component)!==-1){var be=O.presentation1;if(O.presentation2&&(be+=";"+O.presentation2),O.integerFormat=xe(be),O.width&&O.width.min!==void 0&&O.integerFormat.mandatoryDigits<O.width.min&&(O.integerFormat.mandatoryDigits=O.width.min),O.component==="Y")if(O.n=-1,O.width&&O.width.max!==void 0)O.n=O.width.max,O.integerFormat.mandatoryDigits=O.n;else{var K=O.integerFormat.mandatoryDigits+O.integerFormat.optionalDigits;K>=2&&(O.n=K)}const me=A[A.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=xe(O.presentation1)),A.push(O),B=j+1}j++}return N(B,j),b}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ie=["January","February","March","April","May","June","July","August","September","October","November","December"],et=1e3*60*60*24,_e=function(w){const A=Date.UTC(w.year,w.month);var b=new Date(A).getUTCDay();return b===0&&(b=7),b>4?A+(8-b)*et:A-(b-1)*et},fe=function(w,A){return{year:w,month:A,nextMonth:function(){return A===11?fe(w+1,0):fe(w,A+1)},previousMonth:function(){return A===0?fe(w-1,11):fe(w,A-1)},nextYear:function(){return fe(w+1,A)},previousYear:function(){return fe(w-1,A)}}},tt=function(w,A){return(A-w)/(et*7)+1},ie=(w,A)=>{let b;switch(A){case"Y":b=w.getUTCFullYear();break;case"M":b=w.getUTCMonth()+1;break;case"D":b=w.getUTCDate();break;case"d":{const N=Date.UTC(w.getUTCFullYear(),w.getUTCMonth(),w.getUTCDate()),B=Date.UTC(w.getUTCFullYear(),0);b=(N-B)/et+1;break}case"F":b=w.getUTCDay(),b===0&&(b=7);break;case"W":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=Date.UTC(N.year,w.getUTCMonth(),w.getUTCDate());let O=tt(B,j);if(O>52){const F=_e(N.nextYear());j>=F&&(O=1)}else if(O<1){const F=_e(N.previousYear());O=tt(F,j)}b=Math.floor(O);break}case"w":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=Date.UTC(N.year,N.month,w.getUTCDate());let O=tt(B,j);if(O>4){const F=_e(N.nextMonth());j>=F&&(O=1)}else if(O<1){const F=_e(N.previousMonth());O=tt(F,j)}b=Math.floor(O);break}case"X":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=_e(N.nextYear()),O=w.getTime();O<B?b=N.year-1:O>=j?b=N.year+1:b=N.year;break}case"x":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=N.nextMonth(),O=_e(j),F=w.getTime();F<B?b=N.previousMonth().month+1:F>=O?b=j.month+1:b=N.month+1;break}case"H":b=w.getUTCHours();break;case"h":b=w.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=w.getUTCHours()>=12?"pm":"am";break;case"m":b=w.getUTCMinutes();break;case"s":b=w.getUTCSeconds();break;case"f":b=w.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Be=null;function it(w,A,b){var N=0,B=0;if(typeof b<"u"){const be=parseInt(b);N=Math.floor(be/100),B=be%100}var j=function(be,K){var ee=ie(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(ee=ee%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")ee=Ie[ee-1];else if(K.component==="F")ee=ve[ee];else throw{code:"D3133",value:K.component};K.names===$.UPPER?ee=ee.toUpperCase():K.names===$.LOWER&&(ee=ee.toLowerCase()),K.width&&ee.length>K.width.max&&(ee=ee.substring(0,K.width.max))}else ee=z(ee,K.integerFormat);else if(K.component==="f")ee=z(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=N*100+B;if(K.integerFormat.regular)ee=z(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=z(N,K.integerFormat),B!==0&&(ee+=":"+L(B,"00"));else if(G===3||G===4)ee=z(me,K.integerFormat);else throw{code:"D3134",value:G}}me>=0&&(ee="+"+ee),K.component==="z"&&(ee="GMT"+ee),me===0&&K.presentation2==="t"&&(ee="Z")}else K.component==="P"&&K.names===$.UPPER&&(ee=ee.toUpperCase());return ee};let O;typeof A>"u"?(Be===null&&(Be=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Be):O=Ae(A);const F=(60*N+B)*60*1e3,J=new Date(w+F);let ge="";return O.parts.forEach(function(be){be.type==="literal"?ge+=be.value:ge+=j(J,be)}),ge}function d(w){var A={};if(w.type==="datetime")A.type="datetime",A.parts=w.parts.map(function(b){var N={};if(b.type==="literal")N.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),N.regex="",b.component==="z"&&(N.regex="GMT"),N.regex+="[-+][0-9]+",j&&(N.regex+=j.character+"[0-9]+"),N.parse=function(O){b.component==="z"&&(O=O.substring(3));let F=0,J=0;return j?(F=Number.parseInt(O.substring(0,O.indexOf(j.character))),J=Number.parseInt(O.substring(O.indexOf(j.character)+1))):O.length-1<=2?F=Number.parseInt(O):(F=Number.parseInt(O.substring(0,3)),J=Number.parseInt(O.substring(3))),F*60+J}}else if(b.integerFormat)N=d(b.integerFormat);else{N.regex="[a-zA-Z]+";var B={};if(b.component==="M"||b.component==="x")Ie.forEach(function(j,O){b.width&&b.width.max?B[j.substring(0,b.width.max)]=O+1:B[j]=O+1});else if(b.component==="F")ve.forEach(function(j,O){O>0&&(b.width&&b.width.max?B[j.substring(0,b.width.max)]=O:B[j]=O)});else if(b.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};N.parse=function(j){return B[j]}}return N.component=b.component,N});else{A.type="integer";const b=w.case===$.UPPER;switch(w.primary){case T.LETTERS:A.regex=b?"[A-Z]+":"[a-z]+",A.parse=function(N){return se(N,b?"A":"a")};break;case T.ROMAN:A.regex=b?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(N){return H(b?N:N.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(S).concat("and","[\\-, ]").join("|")+")+",A.parse=function(N){return M(N.toLowerCase())};break;case T.DECIMAL:A.regex="[0-9]",w.parseWidth?A.regex+=`{${w.parseWidth}}`:A.regex+="+",w.ordinal&&(A.regex+="(?:th|st|nd|rd)"),A.parse=function(N){let B=N;return w.ordinal&&(B=N.substring(0,N.length-2)),w.regular?B=B.split(",").join(""):w.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),w.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-w.zeroCode+48)).join("")),parseInt(B)};break;case T.SEQUENCE:throw{code:"D3130",value:w.token}}}return A}function m(w,A){if(typeof w>"u")return;const b=xe(A);return d(b).parse(w)}function V(w,A){const b=Ae(A),N=d(b),B="^"+N.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp(B,"i").exec(w);if(O!==null){const G={};for(let De=1;De<O.length;De++){const u=N.parts[De-1];u.parse&&(G[u.component]=u.parse(O[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const ot=De=>{Ze<<=1,Ze+=De?1:0},qe=De=>!(~De&Ze)&&!!(De&Ze);"YXMxWwdD".split("").forEach(De=>ot(G[De]));const He=!qe(161)&&qe(130),bt=qe(84),At=!bt&&qe(72);Ze=0,"PHhmsf".split("").forEach(De=>ot(G[De]));const St=!qe(23)&&qe(47),Jt=(He?"YD":bt?"XxwF":At?"XWF":"YMD")+(St?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Lt=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Lt?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ie(ut,De);else if(Lt=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,He){const De=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(De+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(bt)throw{code:"D3136"};if(At)throw{code:"D3136"};St&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var de=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 Ce(w,A){if(!(typeof w>"u"))if(typeof A>"u"){if(!de.test(w))throw{stack:new Error().stack,code:"D3110",value:w};return Date.parse(w)}else return V.call(this,w,A)}function Ee(w,A,b){if(!(typeof w>"u"))return it.call(this,w,A,b)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:Ce}})();a.exports=c},{"./utils":6}],2:[function(r,a,s){(function(i){(function(){var c=r("./utils");const f=(()=>{var v=c.isNumeric,k=c.isArrayOfStrings,C=c.isArrayOfNumbers,D=c.createSequence,x=c.isSequence,S=c.isFunction,M=c.isLambda,ae=c.isPromise,Q=c.getFunctionArity,pe=c.isDeepEqual,H=c.stringToArray;function R(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function se(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function T(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function $(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function z(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(S(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,_){return typeof _<"u"&&_!==null&&_.toPrecision&&v(_)?Number(_.toPrecision(15)):_&&S(_)?"":_},g)}return l}}function he(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var _=o>=0?o+l:p+o+l;return g.slice(o,_).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Ie(n){if(!(typeof n>"u"))return H(n).length}function et(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Ie(n);if(p>0){var _=new Array(p+1).join(l);l.length>1&&(_=he(_,0,p)),o>0?g=n+_:g=_+n}else g=n;return g}}async function fe(n,o){var l=n.apply(this,[o]);if(ae(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||S(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function tt(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await fe(o,n);l=typeof g<"u"}return l}}async function ie(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=D();if(typeof l>"u"||l>0){var p=0,_=await fe(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await fe(_.next),p++}return g}}async function Be(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var _;typeof l=="string"?_=function(Se){for(var We="",ke=0,Fe=l.indexOf("$",ke);Fe!==-1&&ke<l.length;){We+=l.substring(ke,Fe),ke=Fe+1;var ct=l.charAt(ke);if(ct==="$")We+="$",ke++;else if(ct==="0")We+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,Fe=parseInt(l.substring(ke,ke+ze),10),ze>1&&Fe>Se.groups.length&&(Fe=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(Fe))We+="$";else{if(Se.groups.length>0){var Zt=Se.groups[Fe-1];typeof Zt<"u"&&(We+=Zt)}ke+=Fe.toString().length}}Fe=l.indexOf("$",ke)}return We+=l.substring(ke),We}:_=l;var I="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,q);Oe!==-1&&(typeof g>"u"||X<g);)I+=n.substring(q,Oe),I+=l,q=Oe+o.length,X++,Oe=n.indexOf(o,q);I+=n.substring(q)}else{var ye=await fe(o,n);if(typeof ye<"u"){for(;typeof ye<"u"&&(typeof g>"u"||X<g);){I+=n.substring(q,ye.start);var Ne=_.apply(p,[ye]);if(ae(Ne)&&(Ne=await Ne),typeof Ne=="string")I+=Ne;else throw{code:"D3012",stack:new Error().stack,value:Ne};q=ye.start+ye.match.length,X++,ye=await fe(ye.next)}I+=n.substring(q)}else I=n}}else I=n;return I}}function it(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function V(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function de(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function Ce(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,_=await fe(o,n);if(typeof _<"u"){for(var I=0;typeof _<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(I,_.start)),I=_.end,_=await fe(_.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(I))}else g.push(n)}return g}}function w(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function A(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(re){p[re]=l[re]});for(var _=[],I=p["zero-digit"].charCodeAt(0),q=I;q<I+10;q++)_.push(String.fromCharCode(q));var X=_.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var ye=function(re){var Me=(function(){for(var Le,nt=0;nt<re.length;nt++)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(0,nt)})(),Ye=(function(){for(var Le,nt=re.length-1;nt>=0;nt--)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(nt+1)})(),Re=re.substring(Me.length,re.length-Ye.length),Xe,Dt,Qe,Mt,rt=re.indexOf(p["exponent-separator"],Me.length);rt===-1||rt>re.length-Ye.length?(Xe=Re,Dt=void 0):(Xe=Re.substring(0,rt),Dt=Re.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,Mt=Ye):(Qe=Xe.substring(0,lt),Mt=Xe.substring(lt+1)),{prefix:Me,suffix:Ye,activePart:Re,mantissaPart:Xe,exponentPart:Dt,integerPart:Qe,fractionalPart:Mt,subpicture:re}},Ne=function(re){var Me,Ye,Re=re.subpicture,Xe=Re.indexOf(p["decimal-separator"]);Xe!==Re.lastIndexOf(p["decimal-separator"])&&(Me="D3081"),Re.indexOf(p.percent)!==Re.lastIndexOf(p.percent)&&(Me="D3082"),Re.indexOf(p["per-mille"])!==Re.lastIndexOf(p["per-mille"])&&(Me="D3083"),Re.indexOf(p.percent)!==-1&&Re.indexOf(p["per-mille"])!==-1&&(Me="D3084");var Dt=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var Qe=re.mantissaPart.charAt(Ye);if(_.indexOf(Qe)!==-1||Qe===p.digit){Dt=!0;break}}Dt||(Me="D3085");var Mt=re.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Mt.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Re.charAt(Xe-1)===p["grouping-separator"]||Re.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Re.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=re.integerPart.indexOf(p.digit);rt!==-1&&re.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=re.fractionalPart.lastIndexOf(p.digit),rt!==-1&&re.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof re.exponentPart=="string";if(lt&&re.exponentPart.length>0&&(Re.indexOf(p.percent)!==-1||Re.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(re){var Me=function(Ve,br){for(var er=[],kt=Ve.indexOf(p["grouping-separator"]);kt!==-1;){var kr=(br?Ve.substring(0,kt):Ve.substring(kt)).split("").filter(function(zt){return _.indexOf(zt)!==-1||zt===p.digit}).length;er.push(kr),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Me(re.integerPart),Re=function(Ve){if(Ve.length===0)return 0;for(var br=function(kr,zt){return zt===0?kr:br(zt,kr%zt)},er=Ve.reduce(br),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Re(Ye),Dt=Me(re.fractionalPart,!0),Qe=re.integerPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Mt=Qe,rt=re.fractionalPart.split(""),lt=rt.filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Le=rt.filter(function(Ve){return _.indexOf(Ve)!==-1||Ve===p.digit}).length,nt=typeof re.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&re.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&<===0&&(lt=1);var dn=0;return nt&&(dn=re.exponentPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Mt,prefix:re.prefix,fractionalPartGroupingPositions:Dt,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:dn,suffix:re.suffix,picture:re.subpicture}},We=Oe.map(ye);We.forEach(Ne);var ke=We.map(Se),Fe=p["minus-sign"],ct=p["zero-digit"],ze=p["decimal-separator"],Zt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=Fe+ke[1].prefix);var Ue;n>=0?Ue=ke[0]:Ue=ke[1];var Xt;Ue.picture.indexOf(p.percent)!==-1?Xt=n*100:Ue.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var It,Wt;if(Ue.minimumExponentSize===0)It=Xt;else{var Nn=Math.pow(10,Ue.scalingFactor),Rn=Math.pow(10,Ue.scalingFactor-1);for(It=Xt,Wt=0;It<Rn;)It*=10,Wt-=1;for(;It>Nn;)It/=10,Wt+=1}var In=F(It,Ue.maximumFactionalPartSize),ln=function(re,Me){var Ye=Math.abs(re).toFixed(Me);return ct!=="0"&&(Ye=Ye.split("").map(function(Re){return Re>="0"&&Re<="9"?_[Re.charCodeAt(0)-48]:Re}).join("")),Ye},ce=ln(In,Ue.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+ze:ce=ce.replace(".",ze);ce.charAt(0)===ct;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ct;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(ze);var Qt=Ue.minimumIntegerPartSize-Ge,fn=Ue.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ct):"")+ce,ce=ce+(fn>0?new Array(fn+1).join(ct):""),Ge=ce.indexOf(ze),Ue.regularGrouping>0)for(var Mn=Math.floor((Ge-1)/Ue.regularGrouping),vr=1;vr<=Mn;vr++)ce=[ce.slice(0,Ge-vr*Ue.regularGrouping),Zt,ce.slice(Ge-vr*Ue.regularGrouping)].join("");else Ue.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Zt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(ze),Ue.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Zt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(ze),(Ue.picture.indexOf(ze)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Wt<"u"){var wr=ln(Wt,0);Qt=Ue.minimumExponentSize-wr.length,Qt>0&&(wr=new Array(Qt+1).join(ct)+wr),ce=ce+p["exponent-separator"]+(Wt<0?Fe:"")+wr}return ce=Ue.prefix+ce+Ue.suffix,ce}}function b(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function N(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function B(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function O(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function J(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ge(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function be(){return Math.random()}function K(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=K(n[0]);else if(n.length>1){var l=n.filter(function(g){return K(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):v(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!S(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function ee(n){if(!(typeof n>"u"))return!K(n)}function me(n,o,l,g){var p=[o],_=Q(n);return _>=2&&p.push(l),_>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=me(o,n[g],g,n),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}}async function Ze(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=n[g],_=me(o,p,g,n),I=await o.apply(this,_);K(I)&&l.push(p)}return l}}async function ot(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var _=n[p],I=!0;if(typeof o<"u"){var q=me(o,_,p,n),X=await o.apply(this,q);I=K(X)}if(I)if(!l)g=_,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function qe(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(_){return Array.isArray(_)?_.length:0})),g=0;g<l;g++){var p=o.map(_=>_[g]);n.push(p)}return n}async function $e(n,o,l){if(!(typeof n>"u")){var g,p=Q(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var _;for(typeof l>"u"&&n.length>0?(g=n[0],_=1):(g=l,_=0);_<n.length;){var I=[g,n[_]];p>=3&&I.push(_),p>=4&&I.push(n),g=await o.apply(this,I),_++}return g}}function He(n){var o=D();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=He(g);p.forEach(function(_){l[_]=!0})}),o=He(l)}else n!==null&&typeof n=="object"&&!S(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function bt(n,o){var l;if(Array.isArray(n)){l=D();for(var g=0;g<n.length;g++){var p=bt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(_=>l.push(_)):l.push(p))}}else n!==null&&typeof n=="object"&&!S(n)&&(l=n[o]);return l}function At(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=D(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function yr(n){return!(typeof n>"u")}function St(n){var o=D();if(Array.isArray(n))n.forEach(function(p){o=At(o,St(p))});else if(n!==null&&typeof n=="object"&&!M(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function gr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Jt(n,o){var l=D();for(var g in n){var p=me(o,n[g],g,n),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Lt(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function yt(n){if(n!==void 0)return n===null?"null":v(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":S(n)?"function":"object"}async function De(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!C(n)&&!k(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(I,q){return I>q}}else l=o;var g=async function(I,q){var X=async function(ye,Ne,Se){Ne.length===0?Array.prototype.push.apply(ye,Se):Se.length===0?Array.prototype.push.apply(ye,Ne):await l(Ne[0],Se[0])?(ye.push(Se[0]),await X(ye,Ne,Se.slice(1))):(ye.push(Ne[0]),await X(ye,Ne.slice(1),Se))},Oe=[];return await X(Oe,I,q),Oe},p=async function(I){if(!Array.isArray(I)||I.length<=1)return I;var q=Math.floor(I.length/2),X=I.slice(0,q),Oe=I.slice(q);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},_=await p(n);return _}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=x(n)?D():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,_=0;_<o.length;_++)if(pe(g,o[_])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],_=me(o,p,g,n),I=await o.apply(this,_);K(I)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:R,count:se,max:L,min:T,average:$,string:z,substring:he,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Ie,trim:et,pad:_e,match:ie,contains:tt,replace:Be,split:Ee,join:w,formatNumber:A,formatBase:b,number:N,floor:j,ceil:O,round:F,abs:B,sqrt:J,power:ge,random:be,boolean:K,not:ee,map:G,zip:qe,filter:Ze,single:ot,foldLeft:$e,sift:y,keys:He,lookup:bt,append:At,exists:yr,spread:St,merge:Z,reverse:gr,each:Jt,error:ut,assert:Lt,type:yt,sort:De,shuffle:u,distinct:h,base64encode:it,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:de,decodeUrl:Ce}})();a.exports=f}).call(this)}).call(this,typeof gn<"u"?gn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(r,a,s){var i=r("./datetime"),c=r("./functions"),f=r("./utils"),v=r("./parser"),k=r("./signature"),C=(function(){var D=f.isNumeric,x=f.isArrayOfStrings,S=f.isArrayOfNumbers,M=f.createSequence,ae=f.isSequence,Q=f.isFunction,pe=f.isLambda,H=f.isIterable,R=f.isPromise,se=f.getFunctionArity,L=f.isDeepEqual,T=ut(null);async function $(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await z(u,h,y);break;case"binary":n=await Ie(u,h,y);break;case"unary":n=await et(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=fe(u);break;case"wildcard":n=tt(u,h);break;case"descendant":n=Be(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await O(u,h,y);break;case"bind":n=await B(u,h,y);break;case"regex":n=F(u);break;case"function":n=await me(u,h,y);break;case"variable":n=J(u,h,y);break;case"lambda":n=ot(u,h,y);break;case"partial":n=await qe(u,h,y);break;case"apply":n=await ee(u,h,y);break;case"transform":n=be(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await A(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&ae(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function z(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=M(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var _=u.steps[p];if(_.tuple&&(l=!0),p===0&&_.consarray?o=await $(_,n,y):l?g=await Ae(_,n,g,y):o=await xe(_,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof _.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=M(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=M(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await A(u.group,l?g:o,y)),o}function he(u,h){var y=ut(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ge(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=M();for(var l=0;l<h.length;l++){var g=await $(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var _=M();return n&&o.length===1&&Array.isArray(o[0])&&!ae(o[0])?_=o[0]:o.forEach(function(I){!Array.isArray(I)||I.cons?_.push(I):I.forEach(q=>_.push(q))}),_}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ge(u,y,n);else{var l=await ge(u,h,n);o=M(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=M(),o.tupleStream=!0;var _=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var I=0;I<y.length;I++){_=he(n,y[I]);var q=await $(u,y[I]["@"],_);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[I]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[I]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[I]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=M();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=M(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=he(y,l));var _=await $(u,g,p);D(_)&&(_=[_]),S(_)?_.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(_)&&n.push(l)}return n}async function Ie(u,h,y){var n,o=await $(u.lhs,h,y),l=u.value,g=async()=>await $(u.rhs,h,y);if(l==="and"||l==="or")try{return await Ce(o,g,l)}catch(_){throw _.position=u.position,_.token=l,_}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=V(o,p,l);break;case"&":n=w(o,p);break;case"..":n=N(o,p);break;case"in":n=de(o,p);break}}catch(_){throw _.position=u.position,_.token=l,_}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await $(u.expression,h,y),typeof n>"u")n=void 0;else if(D(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,_)=>(y.isParallelCall=_>0,[p,await $(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await A(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function fe(u){return u.value}function tt(u,h){var y=M();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ie(o),y=c.append(y,o)):y.push(o)}),y}function ie(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ie(y,h)}):h.push(u),h}function Be(u,h){var y,n=M();return typeof h<"u"&&(it(h,n),n.length===1?y=n[0]:y=n),y}function it(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){it(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){it(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!D(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!D(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function V(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function de(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function Ce(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function w(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function A(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=M(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],_=l?he(y,p):y,I=0;I<u.lhs.length;I++){var q=u.lhs[I],X=await $(q[0],l?p["@"]:p,_);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:I};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==I)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}let ye=await Promise.all(Object.keys(o).map(async(Se,We)=>{let ke=o[Se];var Fe=ke.data,ct=y;if(l){var ze=b(ke.data);Fe=ze["@"],delete ze["@"],ct=he(y,ze)}return y.isParallelCall=We>0,[Se,await $(u.lhs[ke.exprIndex][1],Fe,ct)]}));for(let Se of ye){var[X,Ne]=await Se;typeof Ne<"u"&&(n[X]=Ne)}return n}function b(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function N(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function B(u,h,y){var n=await $(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await $(u.condition,h,y);return c.boolean(o)?n=await $(u.then,h,y):typeof u.else<"u"&&(n=await $(u.else,h,y)),n}async function O(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await $(u.expressions[l],h,o);return n}function F(u){var h=new De.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var _=y(n,h.lastIndex);if(_&&_.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return _}}}return l};return y}function J(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ge(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(_,I){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var Oe=u.terms[X],ye=_,Ne=y;l&&(ye=_["@"],Ne=he(y,_));var Se=await $(Oe.expression,ye,Ne);ye=I,Ne=y,l&&(ye=I["@"],Ne=he(y,I));var We=await $(Oe.expression,ye,Ne),ke=typeof Se,Fe=typeof We;if(ke==="undefined"){q=Fe==="undefined"?0:1;continue}if(Fe==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(Fe==="string"||Fe==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?We:Se};if(ke!==Fe)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:We};Se!==We&&(Se<We?q=-1:q=1,Oe.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function be(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!Q(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await $(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var _=0;_<p.length;_++){var I=p[_];if(I&&(I.isPrototypeOf(g)||I instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await $(u.update,I,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var Oe in q)I[Oe]=q[Oe]}if(typeof u.delete<"u"){var ye=await $(u.delete,I,y);if(typeof ye<"u"){var Ne=ye;if(Array.isArray(ye)||(ye=[ye]),!x(ye))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ne};for(var Se=0;Se<ye.length;Se++)typeof I=="object"&&I!==null&&delete I[ye[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=v("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(u,h,y){var n,o=await $(u.lhs,h,y);if(u.rhs.type==="function")n=await me(u.rhs,h,y,{context:o});else{var l=await $(u.rhs,h,y);if(!Q(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(Q(o)){var g=await $(K,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function me(u,h,y,n){var o,l=await $(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const I=await $(u.arguments[p],h,y);if(Q(I)){const q=async function(...X){return await G(I,X,null,y)};q.arity=se(I),g.push(q)}else g.push(I)}var _=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=_,l.position=u.position),o=await G(l,g,h,y)}catch(I){throw I.position||(I.position=u.position),I.token||(I.token=_),I}return o}async function G(u,h,y,n){var o;for(o=await Ze(u,h,y,n);pe(o)&&o.thunk===!0;){var l=await $(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await $(o.body.arguments[p],o.input,o.environment));o=await Ze(l,g,y,n)}return o}async function Ze(u,h,y,n){var o;try{var l=h;if(u&&(l=$e(u.signature,h,y)),pe(u))o=await He(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),R(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),R(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function ot(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function qe(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await $(g,h,y))}var p=await $(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(pe(p))n=bt(p,o);else if(p&&p._jsonata_function===!0)n=At(p.implementation,o);else if(typeof p=="function")n=At(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function $e(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function He(u,h){var y,n=ut(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await yr(u.body,n):y=await $(u.body,u.input,n),y}function bt(u,h){var y=ut(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function At(u,h){var y=St(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=v(n);o.body=u;var l=bt(o,h);return l}async function yr(u,h){var y=St(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return R(l)&&(l=await l),l}function St(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=k(h)),y}async function gr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!ae(y)&&(y=M(y),y.outerWrapper=!0));try{var n=v(u,!1)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await $(n,y,this.environment)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Jt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ut(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}T.bind("sum",Z(c.sum,"<a<n>:n>")),T.bind("count",Z(c.count,"<a:n>")),T.bind("max",Z(c.max,"<a<n>:n>")),T.bind("min",Z(c.min,"<a<n>:n>")),T.bind("average",Z(c.average,"<a<n>:n>")),T.bind("string",Z(c.string,"<x-b?:s>")),T.bind("substring",Z(c.substring,"<s-nn?:s>")),T.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),T.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),T.bind("lowercase",Z(c.lowercase,"<s-:s>")),T.bind("uppercase",Z(c.uppercase,"<s-:s>")),T.bind("length",Z(c.length,"<s-:n>")),T.bind("trim",Z(c.trim,"<s-:s>")),T.bind("pad",Z(c.pad,"<s-ns?:s>")),T.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),T.bind("contains",Z(c.contains,"<s-(sf):b>")),T.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),T.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),T.bind("join",Z(c.join,"<a<s>s?:s>")),T.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),T.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),T.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),T.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),T.bind("number",Z(c.number,"<(nsb)-:n>")),T.bind("floor",Z(c.floor,"<n-:n>")),T.bind("ceil",Z(c.ceil,"<n-:n>")),T.bind("round",Z(c.round,"<n-n?:n>")),T.bind("abs",Z(c.abs,"<n-:n>")),T.bind("sqrt",Z(c.sqrt,"<n-:n>")),T.bind("power",Z(c.power,"<n-n:n>")),T.bind("random",Z(c.random,"<:n>")),T.bind("boolean",Z(c.boolean,"<x-:b>")),T.bind("not",Z(c.not,"<x-:b>")),T.bind("map",Z(c.map,"<af>")),T.bind("zip",Z(c.zip,"<a+>")),T.bind("filter",Z(c.filter,"<af>")),T.bind("single",Z(c.single,"<af?>")),T.bind("reduce",Z(c.foldLeft,"<afj?:j>")),T.bind("sift",Z(c.sift,"<o-f?:o>")),T.bind("keys",Z(c.keys,"<x-:a<s>>")),T.bind("lookup",Z(c.lookup,"<x-s:x>")),T.bind("append",Z(c.append,"<xx:a>")),T.bind("exists",Z(c.exists,"<x:b>")),T.bind("spread",Z(c.spread,"<x-:a<o>>")),T.bind("merge",Z(c.merge,"<a<o>:o>")),T.bind("reverse",Z(c.reverse,"<a:a>")),T.bind("each",Z(c.each,"<o-f:a>")),T.bind("error",Z(c.error,"<s?:x>")),T.bind("assert",Z(c.assert,"<bs?:x>")),T.bind("type",Z(c.type,"<x:s>")),T.bind("sort",Z(c.sort,"<af?:a>")),T.bind("shuffle",Z(c.shuffle,"<a:a>")),T.bind("distinct",Z(c.distinct,"<x:x>")),T.bind("base64encode",Z(c.base64encode,"<s-:s>")),T.bind("base64decode",Z(c.base64decode,"<s-:s>")),T.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),T.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),T.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),T.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),T.bind("eval",Z(gr,"<sx?:x>")),T.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),T.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),T.bind("clone",Z(Jt,"<(oa)-:o>"));var Lt={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 yt(u){var h=Lt[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function De(u,h){var y,n;try{y=v(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw yt(g),g}var o=ut(T),l=new Date;return o.bind("now",Z(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",Z(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(g,p,_){if(typeof n<"u"){var I={code:"S0500",position:0};throw yt(I),I}if(typeof p<"u"){var q;q=ut(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!ae(g)&&(g=M(g),g.outerWrapper=!0);var Oe;try{return Oe=await $(y,g,q),typeof _=="function"&&_(null,Oe),Oe}catch(ye){throw yt(ye),ye}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,_){var I=Z(p,_);o.bind(g,I)},ast:function(){return y},errors:function(){return n}}}return De.parser=v,De})();a.exports=C},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(r,a,s){var i=r("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},v={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
2
|
`,r:"\r",t:" "},k=function(D){var x=0,S=D.length,M=function(pe,H){var R={type:pe,value:H,position:x};return R},ae=function(){for(var pe=x,H=0,R,se,L=function($){if(D.charAt($)==="/"&&H===0){for(var z=0;D.charAt($-(z+1))==="\\";)z++;if(z%2===0)return!0}return!1};x<S;){var T=D.charAt(x);if(L(x)){if(R=D.substring(pe,x),R==="")throw{code:"S0301",stack:new Error().stack,position:x};for(x++,T=D.charAt(x),pe=x;T==="i"||T==="m";)x++,T=D.charAt(x);return se=D.substring(pe,x)+"g",new RegExp(R,se)}(T==="("||T==="["||T==="{")&&D.charAt(x-1)!=="\\"&&H++,(T===")"||T==="]"||T==="}")&&D.charAt(x-1)!=="\\"&&H--,x++}throw{code:"S0302",stack:new Error().stack,position:x}},Q=function(pe){if(x>=S)return null;for(var H=D.charAt(x);x<S&&`
|
|
3
3
|
\r\v`.indexOf(H)>-1;)x++,H=D.charAt(x);if(H==="/"&&D.charAt(x+1)==="*"){var R=x;for(x+=2,H=D.charAt(x);!(H==="*"&&D.charAt(x+1)==="/");)if(H=D.charAt(++x),x>=S)throw{code:"S0106",stack:new Error().stack,position:R};return x+=2,H=D.charAt(x),Q(pe)}if(pe!==!0&&H==="/")return x++,M("regex",ae());if(H==="."&&D.charAt(x+1)===".")return x+=2,M("operator","..");if(H===":"&&D.charAt(x+1)==="=")return x+=2,M("operator",":=");if(H==="!"&&D.charAt(x+1)==="=")return x+=2,M("operator","!=");if(H===">"&&D.charAt(x+1)==="=")return x+=2,M("operator",">=");if(H==="<"&&D.charAt(x+1)==="=")return x+=2,M("operator","<=");if(H==="*"&&D.charAt(x+1)==="*")return x+=2,M("operator","**");if(H==="~"&&D.charAt(x+1)===">")return x+=2,M("operator","~>");if(H==="?"&&D.charAt(x+1)===":")return x+=2,M("operator","?:");if(H==="?"&&D.charAt(x+1)==="?")return x+=2,M("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return x++,M("operator",H);if(H==='"'||H==="'"){var se=H;x++;for(var L="";x<S;){if(H=D.charAt(x),H==="\\")if(x++,H=D.charAt(x),Object.prototype.hasOwnProperty.call(v,H))L+=v[H];else if(H==="u"){var T=D.substr(x+1,4);if(/^[0-9a-fA-F]+$/.test(T)){var $=parseInt(T,16);L+=String.fromCharCode($),x+=4}else throw{code:"S0104",stack:new Error().stack,position:x}}else throw{code:"S0103",stack:new Error().stack,position:x,token:H};else{if(H===se)return x++,M("string",L);L+=H}x++}throw{code:"S0101",stack:new Error().stack,position:x}}var z=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,he=z.exec(D.substring(x));if(he!==null){var xe=parseFloat(he[0]);if(!isNaN(xe)&&isFinite(xe))return x+=he[0].length,M("number",xe);throw{code:"S0102",stack:new Error().stack,position:x,token:he[0]}}var Te;if(H==="`"){x++;var Ae=D.indexOf("`",x);if(Ae!==-1)return Te=D.substring(x,Ae),x=Ae+1,M("name",Te);throw x=S,{code:"S0105",stack:new Error().stack,position:x}}for(var ve=x,Ie;;)if(Ie=D.charAt(ve),ve===S||`
|
|
4
|
-
\r\v`.indexOf(Ie)>-1||Object.prototype.hasOwnProperty.call(f,Ie)){if(D.charAt(x)==="$")return Te=D.substring(x+1,ve),x=ve,M("variable",Te);switch(Te=D.substring(x,ve),x=ve,Te){case"or":case"in":case"and":return M("operator",Te);case"true":return M("value",!0);case"false":return M("value",!1);case"null":return M("value",null);default:return x===S&&Te===""?null:M("name",Te)}}else ve++};return Q},C=function(D,x){var S,M,ae={},Q=[],pe=function(){var d=[];S.id!=="(end)"&&d.push({type:S.type,value:S.value,position:S.position});for(var m=M();m!==null;)d.push(m),m=M();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(x)return d.remaining=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},R=function(d,m){var V=ae[d];return m=m||0,V?m>=V.lbp&&(V.lbp=m):(V=Object.create(H),V.id=V.value=d,V.lbp=m,ae[d]=V),V},se=function(d){if(x){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return S=Object.create(m),S.error=d,S.type="(error)",S}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&S.id!==d){var V;S.id==="(end)"?V="S0203":V="S0202";var de={code:V,position:S.position,token:S.value,value:d};return se(de)}var Ce=M(m);if(Ce===null)return S=ae["(end)"],S.position=D.length,S;var Ee=Ce.value,w=Ce.type,A;switch(w){case"name":case"variable":A=ae["(name)"];break;case"operator":if(A=ae[Ee],!A)return se({code:"S0204",stack:new Error().stack,position:Ce.position,token:Ee});break;case"string":case"number":case"value":A=ae["(literal)"];break;case"regex":w="regex",A=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Ce.position,token:Ee})}return S=Object.create(A),S.value=Ee,S.type=w,S.position=Ce.position,S},T=function(d){var m,V=S;for(L(null,!0),m=V.nud();d<S.lbp;)V=S,L(),m=V.led(m);return m},$=function(d){var m=R(d,0);m.nud=function(){return this}},z=function(d,m,V){var de=m||f[d],Ce=R(d,de);return Ce.led=V||function(Ee){return this.lhs=Ee,this.rhs=T(de),this.type="binary",this},Ce},he=function(d,m,V){var de=R(d,m);return de.led=V,de},xe=function(d,m){var V=R(d);return V.nud=m||function(){return this.expression=T(70),this.type="unary",this},V};$("(end)"),$("(name)"),$("(literal)"),$("(regex)"),R(":"),R(";"),R(","),R(")"),R("]"),R("}"),R(".."),z("."),z("+"),z("-"),z("*"),z("/"),z("%"),z("="),z("<"),z(">"),z("!="),z("<="),z(">="),z("&"),z("and"),z("or"),z("in"),$("and"),$("or"),$("in"),xe("-"),z("~>"),z("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=T(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=S.error,this.remaining=pe(),this.type="error",this}),xe("*",function(){return this.type="wildcard",this}),xe("**",function(){return this.type="descendant",this}),xe("%",function(){return this.type="parent",this}),z("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],S.id!==")")for(;S.type==="operator"&&S.id==="?"?(this.type="partial",this.arguments.push(S),L("?")):this.arguments.push(T(0)),S.id===",";)L(",");if(L(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,w){if(Ee.type!=="variable")return se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:w+1})}),this.type="lambda",S.id==="<"){for(var m=S.position,V=1,de="<";V>0&&S.id!=="{"&&S.id!=="(end)";){var Ce=L();Ce.id===">"?V--:Ce.id==="<"&&V++,de+=Ce.value}L(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}L("{"),this.body=T(0),L("}")}return this}),xe("(",function(){for(var d=[];S.id!==")"&&(d.push(T(0)),S.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(S.id!=="]")for(;;){var m=T(0);if(S.id===".."){var V={type:"binary",value:"..",position:S.position,lhs:m};L(".."),V.rhs=T(0),m=V}if(d.push(m),S.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),z("[",f["["],function(d){if(S.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,L("]"),d}else return this.lhs=d,this.rhs=T(f["]"]),this.type="binary",L("]",!0),this}),z("^",f["^"],function(d){L("(");for(var m=[];;){var V={descending:!1};if(S.id==="<"?L("<"):S.id===">"&&(V.descending=!0,L(">")),V.expression=T(0),m.push(V),S.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(S.id!=="}")for(;;){var V=T(0);L(":");var de=T(0);if(m.push([V,de]),S.id!==",")break;L(",")}return L("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Te),z("{",f["{"],Te),he(":=",f[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=T(f[":="]-1),this.type="binary",this)}),z("@",f["@"],function(d){return this.lhs=d,this.rhs=T(f["@"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),z("#",f["#"],function(d){return this.lhs=d,this.rhs=T(f["#"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),z("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=T(0),S.id===":"&&(L(":"),this.else=T(0)),this}),z("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=T(0),this}),xe("|",function(){return this.type="transform",this.pattern=T(0),L("|"),this.update=T(0),S.id===","&&(L(","),this.delete=T(0)),L("|"),this});var Ae=function(d){var m;if(d.type==="function"&&!d.predicate){var V={type:"lambda",thunk:!0,arguments:[],position:d.position};V.body=d,m=V}else if(d.type==="condition")d.then=Ae(d.then),typeof d.else<"u"&&(d.else=Ae(d.else)),m=d;else if(d.type==="block"){var de=d.expressions.length;de>0&&(d.expressions[de-1]=Ae(d.expressions[de-1])),m=d}else m=d;return m},ve=0,Ie=0,et=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(et[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var V=d.steps.length-1;for(m=_e(d.steps[V--],m);m.level>0&&V>=0;)m=_e(d.steps[V--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},fe=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var V=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&V.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=V:Array.prototype.push.apply(d.seekingParent,V)}},tt=function(d){var m=d.steps.length-1,V=d.steps[m],de=typeof V.seekingParent<"u"?V.seekingParent:[];V.type==="parent"&&de.push(V.slot);for(var Ce=0;Ce<de.length;Ce++){var Ee=de[Ce];for(m=d.steps.length-2;Ee.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[Ee]:d.seekingParent.push(Ee);break}for(var w=d.steps[m--];m>=0&&w.focus&&d.steps[m].focus;)w=d.steps[m--];Ee=_e(w,Ee)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var V=ie(d.lhs);V.type==="path"?m=V:m={type:"path",steps:[V]},V.type==="parent"&&(m.seekingParent=[V.slot]);var de=ie(d.rhs);de.type==="function"&&de.procedure.type==="path"&&de.procedure.steps.length===1&&de.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=de.procedure.steps[0].value),de.type==="path"?Array.prototype.push.apply(m.steps,de.steps):(typeof de.predicate<"u"&&(de.stages=de.predicate,delete de.predicate),m.steps.push(de)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var Ce=m.steps[0];Ce.type==="unary"&&Ce.value==="["&&(Ce.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),tt(m);break;case"[":m=ie(d.lhs);var w=m,A="predicate";if(m.type==="path"&&(w=m.steps[m.steps.length-1],A="stages"),typeof w.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof w[A]>"u"&&(w[A]=[]);var b=ie(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?_e(w,F):F.level--}),fe(w,b)),w[A].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ie(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ie(F[0]),ie(F[1])]}),position:d.position};break;case"^":m=ie(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var N={type:"sort",position:d.position};N.terms=d.rhs.map(function(F){var J=ie(F.expression);return fe(N,J),{descending:F.descending,expression:J}}),m.steps.push(N),tt(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.rhs);break;case"@":if(m=ie(d.lhs),w=m,m.type==="path"&&(w=m.steps[m.steps.length-1]),typeof w.stages<"u"||typeof w.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(w.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(w.keepArray=!0),w.focus=d.rhs.value,w.tuple=!0;break;case"#":m=ie(d.lhs),w=m,m.type==="path"?w=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof w.predicate<"u"&&(w.stages=w.predicate,delete w.predicate)),typeof w.stages>"u"?w.index=d.rhs.value:w.stages.push({type:"index",value:d.rhs.value,position:d.position}),w.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.lhs),fe(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ie(F[0]);fe(m,J);var ge=ie(F[1]);return fe(m,ge),[J,ge]}):(m.expression=ie(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):fe(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var J=ie(F);return fe(m,J),J}),m.procedure=ie(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var B=ie(d.body);m.body=Ae(B);break;case"condition":m={type:d.type,position:d.position},m.condition=ie(d.condition),fe(m,m.condition),m.then=ie(d.then),fe(m,m.then),typeof d.else<"u"&&(m.else=ie(d.else),fe(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ie(d.pattern),m.update=ie(d.update),typeof d.delete<"u"&&(m.delete=ie(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(m,J),(J.consarray||J.type==="path"&&J.steps[0].consarray)&&(m.consarray=!0),J});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ve++,level:1,index:Ie++}},et.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ie(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ie(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var O={code:j,position:d.position,token:d.value};if(x)return Q.push(O),{type:"error",error:O};throw O.stack=new Error().stack,O}return d.keepArray&&(m.keepArray=!0),m};M=k(D),L();var Be=T(0);if(S.id!=="(end)"){var it={code:"S0201",position:S.position,token:S.value};se(it)}if(Be=ie(Be),Be.type==="parent"||typeof Be.seekingParent<"u")throw{code:"S0217",token:Be.type,position:Be.position};return Q.length>0&&(Be.errors=Q),Be};return C})();a.exports=c},{"./signature":5}],5:[function(r,a,s){var i=r("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function v(k){for(var C=1,D=[],x={},S=x;C<k.length;){var M=k.charAt(C);if(M===":")break;var ae=function(){D.push(x),S=x,x={}},Q=function(z,he,xe,Te){for(var Ae=1,ve=he;ve<z.length;)if(ve++,M=z.charAt(ve),M===Te){if(Ae--,Ae===0)break}else M===xe&&Ae++;return ve};switch(M){case"s":case"n":case"b":case"l":case"o":x.regex="["+M+"m]",x.type=M,ae();break;case"a":x.regex="[asnblfom]",x.type=M,x.array=!0,ae();break;case"f":x.regex="f",x.type=M,ae();break;case"j":x.regex="[asnblom]",x.type=M,ae();break;case"x":x.regex="[asnblfom]",x.type=M,ae();break;case"-":S.context=!0,S.contextRegex=new RegExp(S.regex),S.regex+="?";break;case"?":case"+":S.regex+=M;break;case"(":var pe=Q(k,C,"(",")"),H=k.substring(C+1,pe);if(H.indexOf("<")===-1)x.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:C};x.type="("+H+")",C=pe,ae();break;case"<":if(S.type==="a"||S.type==="f"){var R=Q(k,C,"<",">");S.subtype=k.substring(C+1,R),C=R}else throw{code:"S0401",stack:new Error().stack,value:S.type,offset:C};break}C++}var se="^"+D.map(function(z){return"("+z.regex+")"}).join("")+"$",L=new RegExp(se),T=function(z){var he;if(i.isFunction(z))he="f";else{var xe=typeof z;switch(xe){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":z===null?he="l":Array.isArray(z)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(z,he){for(var xe="^",Te=0,Ae=0;Ae<D.length;Ae++){xe+=D[Ae].regex;var ve=he.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1}};return{definition:k,validate:function(z,he){var xe="";z.forEach(function(Ie){xe+=T(Ie)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return D.forEach(function(Ie,et){var _e=z[ve],fe=Te[et+1];if(fe==="")if(Ie.context&&Ie.contextRegex){var tt=T(he);if(Ie.contextRegex.test(tt))Ae.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Ae.push(_e),ve++;else fe.split("").forEach(function(ie){if(Ie.type==="a"){if(ie==="m")_e=void 0;else{_e=z[ve];var Be=!0;if(typeof Ie.subtype<"u"){if(ie!=="a"&&fe!==Ie.subtype)Be=!1;else if(ie==="a"&&_e.length>0){var it=T(_e[0]);if(it!==Ie.subtype.charAt(0))Be=!1;else{var d=_e.filter(function(m){return T(m)!==it});Be=d.length===0}}}if(!Be)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Ie.subtype]};ie!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}$(z,xe)}}}return v})();a.exports=c},{"./utils":6}],6:[function(r,a,s){const i=(()=>{function c(R){var se=!1;if(typeof R=="number"&&(se=!isNaN(R),se&&!isFinite(R)))throw{code:"D1001",value:R,stack:new Error().stack};return se}function f(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(L){return typeof L!="string"}).length===0),se}function v(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(L){return!c(L)}).length===0),se}function k(){var R=[];return R.sequence=!0,arguments.length===1&&R.push(arguments[0]),R}function C(R){return R.sequence===!0&&Array.isArray(R)}function D(R){return R&&(R._jsonata_function===!0||R._jsonata_lambda===!0)||typeof R=="function"}function x(R){var se=typeof R.arity=="number"?R.arity:typeof R.implementation=="function"?R.implementation.length:typeof R.length=="number"?R.length:R.arguments.length;return se}function S(R){return R&&R._jsonata_lambda===!0}var M=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(R){return typeof R=="object"&&R!==null&&M in R&&"next"in R&&typeof R.next=="function"}function Q(R,se){if(R===se)return!0;if(typeof R=="object"&&typeof se=="object"&&R!==null&&se!==null){if(Array.isArray(R)&&Array.isArray(se)){if(R.length!==se.length)return!1;for(var L=0;L<R.length;L++)if(!Q(R[L],se[L]))return!1;return!0}var T=Object.getOwnPropertyNames(R),$=Object.getOwnPropertyNames(se);if(T.length!==$.length)return!1;for(T=T.sort(),$=$.sort(),L=0;L<T.length;L++)if(T[L]!==$[L])return!1;for(L=0;L<T.length;L++){var z=T[L];if(!Q(R[z],se[z]))return!1}return!0}return!1}function pe(R){return typeof R=="object"&&R!==null&&"then"in R&&typeof R.then=="function"}function H(R){var se=[];for(let L of R)se.push(L);return se}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:v,createSequence:k,isSequence:C,isFunction:D,isLambda:S,isIterable:ae,getFunctionArity:x,isDeepEqual:Q,stringToArray:H,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Rr)),Rr.exports}var Gs=Hs();const Ys=qs(Gs),sn=E.object({name:E.literal("transform-data"),sourceData:E.any().optional(),expression:E.string().min(1,"JSONata expression is required")});function Ks(t){return sn.parse(t)}async function Js(t){try{const{sourceData:e,expression:r}=t,a=e??{};let s;try{s=Ys(r)}catch(c){throw new Error(`Invalid JSONata expression: ${c instanceof Error?c.message:"Unknown error"}`)}let i;try{i=await s.evaluate(a)}catch(c){throw console.error("JSONata evaluation failed:",c),new Error(`JSONata evaluation failed: ${c instanceof Error?c.message:"Unknown error"}`)}return{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in transform-data handler",data:null}}}const on=E.object({name:E.literal("export-data"),data:E.any(),format:E.enum(["json","csv","xlsx"]),filename:E.string().optional(),csvOptions:E.object({delimiter:E.string().optional(),includeHeaders:E.boolean().optional()}).optional()});function Xs(t){return on.parse(t)}async function Qs(t){try{const{data:e,format:r,filename:a,csvOptions:s}=t;console.log("[ExportDataBlock] Sending export request to background:",r);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:r,filename:a,csvOptions:s}});return i.$isError?{hasError:!0,message:i.message||"Export failed",data:void 0}:(console.log("[ExportDataBlock] Export successful:",i.data.filename),{data:i.data})}catch(e){return console.error("[ExportDataBlock] Export error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in export-data handler",data:void 0}}}const cn=E.object({name:E.literal("network-catch"),urlPattern:E.string().optional(),method:E.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),status:E.union([E.number(),E.object({min:E.number().optional(),max:E.number().optional()})]).optional(),mimeType:E.string().optional(),requestBodyPattern:E.union([E.string(),E.record(E.any())]).optional(),waitForRequest:E.boolean().optional(),waitTimeout:E.number().min(0).optional(),returnAll:E.boolean().optional(),includeHeaders:E.boolean().optional()});function ei(t){return cn.parse(t)}async function ti(t){try{console.log("[NetworkCatchBlock] Fetching network requests with pattern:",t.urlPattern);const e=await chrome.runtime.sendMessage({type:"NETWORK_CATCH",data:{urlPattern:t.urlPattern,method:t.method,status:t.status,mimeType:t.mimeType,requestBodyPattern:t.requestBodyPattern,waitForRequest:t.waitForRequest||!1,waitTimeout:t.waitTimeout||5e3,returnAll:t.returnAll||!1,includeHeaders:t.includeHeaders||!1}});return e.$isError?{hasError:!0,message:e.message||"Failed to fetch network data",data:void 0}:(console.log("[NetworkCatchBlock] Retrieved network data:",e.data),{data:e.data})}catch(e){return console.error("[NetworkCatchBlock] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Failed to fetch network data"}}}const ri={"get-text":zr,"attribute-value":Vr,"get-value-form":qr,"set-value-form":Hr,"clear-value-form":Gr,"element-exists":Yr,"event-click":Kr,keypress:Jr,wait:Xr,"wait-for-condition":Qr,navigate:en,"save-assets":tn,"get-element-data":rn,scroll:nn,"ai-parse-data":Wr,"fetch-api":an,"transform-data":sn,"export-data":on,"network-catch":cn};class ni{static async executeBlock(e){try{switch(e.name){case"get-text":{const r=rs(e);return await ns(r)}case"attribute-value":{const r=ss(e);return await is(r)}case"get-value-form":{const r=os(e);return await cs(r)}case"set-value-form":{const r=ls(e);return await fs(r)}case"clear-value-form":{const r=hs(e);return await ps(r)}case"element-exists":{const r=ys(e);return await gs(r)}case"event-click":{const r=vs(e);return await ws(r)}case"keypress":{const r=_s(e);return await Es(r)}case"wait":{const r=As(e);return await Ss(r)}case"wait-for-condition":{const r=Ds(e);return await Os(r)}case"navigate":{const r=Ps(e);return await Cs(r)}case"save-assets":{const r=Ns(e);return await Rs(r)}case"get-element-data":{const r=Ms(e);return await js(r)}case"scroll":{const r=Bs(e);return await Us(r)}case"ai-parse-data":{const r=Va(e);return await qa(r)}case"fetch-api":{const r=zs(e);return await Vs(r)}case"transform-data":{const r=Ks(e);return await Js(r)}case"export-data":{const r=Xs(e);return await Qs(r)}case"network-catch":{const r=ei(e);return await ti(r)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(r){return{hasError:!0,message:r instanceof Error?r.message:"Unknown error in block execution",data:null}}}}class ai{constructor(){ue(this,"expr");ue(this,"json")}}class si{constructor(){ue(this,"template");ue(this,"valueFrom");ue(this,"default")}}class ii{constructor(){ue(this,"id");ue(this,"title");ue(this,"when");ue(this,"block");ue(this,"repeat");ue(this,"next");ue(this,"onSuccess");ue(this,"onFailure");ue(this,"switch");ue(this,"timeoutMs");ue(this,"retry");ue(this,"delayAfterMs")}}class oi{constructor(){ue(this,"version");ue(this,"id");ue(this,"title");ue(this,"description");ue(this,"start");ue(this,"steps");ue(this,"vars");ue(this,"defaultDelayMs")}}class ci{constructor(){ue(this,"stepId");ue(this,"skipped");ue(this,"success");ue(this,"message");ue(this,"result");ue(this,"startedAt");ue(this,"finishedAt");ue(this,"attempts")}}class ui{constructor(){ue(this,"success");ue(this,"steps");ue(this,"context");ue(this,"targetUrl");ue(this,"timestamp");ue(this,"error")}}var Pr=(t=>(t.USD="USD",t.KRW="KRW",t.EUR="EUR",t.GBP="GBP",t.CAD="CAD",t.CNY="CNY",t.JPY="JPY",t.VND="VND",t.ARS="ARS",t.INR="INR",t.TWD="TWD",t.AUD="AUD",t.HKD="HKD",t.IDR="IDR",t.MXN="MXN",t.NZD="NZD",t.SGD="SGD",t.CHF="CHF",t.THB="THB",t.BRL="BRL",t.TRY="TRY",t.RUB="RUB",t.NOK="NOK",t.DKK="DKK",t.SEK="SEK",t.ILS="ILS",t.ZAR="ZAR",t.PLN="PLN",t.PHP="PHP",t.CZK="CZK",t.CLP="CLP",t.COP="COP",t.EGP="EGP",t.MYR="MYR",t.HUF="HUF",t.AED="AED",t.SAR="SAR",t.RON="RON",t.BGN="BGN",t))(Pr||{});const An={code:{type:"string",enum:Object.values(Pr),description:"Currency code"},symbol:{type:"string",enum:["$","₩","€","£","¥","₫","₹","NT$","Rp","₣","฿","R$","₺","₽","kr","₪","R","zł","₱","Kč","E£","RM","Ft","د.إ","﷼","L","лв"],description:"Currency symbol"},format:{type:"string",enum:["%s%u","%s%n","%u%s","%n%s","%s %u","%s %n","%u %s","%n %s"],description:"Display format (%s: symbol, %u/%n: amount)"},amount:{type:"number",description:"Actual amount value"},text:{type:"string",description:"Formatted display text (e.g., US$57.75)"}};class at extends Error{constructor(e,r,a){super(e),this.code=r,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new at("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new at(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new at(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const r=Math.floor(e/1e3);return new at(`Request timeout - Extension did not respond within ${r} seconds`,"REQUEST_TIMEOUT")}}function li(t){return t&&t.type==="8G_EXTENSION_RESPONSE"}const Sn=At({id:Pe(),slug:Pe(),name:Pe(),image:Pe(),memberCount:$t(),isAdmin:Tt().nullable().optional()}),Dn=At({slug:Pe(),displayName:Pe(),profileImageUrl:Pe(),description:Pe(),publicEmail:Pe(),billingEmail:Pe(),orgPageUrl:Pe()});var un=(t=>(t.monthly="MONTHLY",t.yearly="YEARLY",t))(un||{});const Ur=At({code:Zr(Pr),symbol:Pe(),format:Pe(),amount:$t(),text:Pe().optional()}),On=At({planName:Pe(),currentCycleBillAmount:Ur,nextPaymentDue:Pe(),cycleTerm:Zr(un).nullable(),isFreeTier:Tt(),isPerUser:Tt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Ur.nullable(),cardNumber:Pe(),cardName:Pe()}),Pn=At({uid:Pe(),issuedDate:Br.date(),paidDate:Br.date().nullable().optional(),paymentMethod:Pe(),amount:Ur,isSuccessfulPaid:Tt(),receiptUrl:Pe()}),Cn=At({name:Pe(),email:Pe().email(),profileImageUrl:Pe(),role:Pe(),isPaid:Tt().nullable().optional(),subscriptionSeatStatus:Lr(["NONE","FREE","PAID","QUIT"]).nullable().optional()});class fi{constructor(){}async checkExtension(){return new Promise((e,r)=>{const a=setTimeout(()=>{r(at.extensionNotInstalled())},5e3),s=i=>{li(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((r,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,c=setTimeout(()=>{a(at.requestTimeout(i))},i),f=v=>{var k,C,D,x,S,M,ae;if(((k=v.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&v.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const Q=v.data,pe=((C=Q==null?void 0:Q.result)==null?void 0:C.steps)??((x=(D=Q==null?void 0:Q.result)==null?void 0:D.result)==null?void 0:x.steps)??[],H=((S=Q==null?void 0:Q.result)==null?void 0:S.context)??((ae=(M=Q==null?void 0:Q.result)==null?void 0:M.result)==null?void 0:ae.context)??{steps:{},vars:{}};r({success:Q.success,steps:pe,context:H,error:Q.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,c;const r=await this.collectWorkflow(e);if(!r.success)throw new at("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(c=(i=r.steps[r.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{...r,data:[],isSuccess:!1};const s=[];for(const f of a){const v=Sn.safeParse(f);v.success?s.push(v.data):console.warn("Invalid workspace data:",f,v.error)}return{...r,data:s,isSuccess:!0}}async getWorkspaceDetail(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspaces","GET_WORKSPACES_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i)return{...s};const c=Dn.safeParse(i);if(c.success){const k=c.data;return{...s,data:k}}else return console.warn("Invalid workspace detail data:",i,c.error),{...s,data:void 0}}async getWorkspaceBilling(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i)return{...s};const c=On.safeParse(i);if(c.success){const k=c.data;return{...s,data:k}}else return console.warn("Invalid workspace billing data:",i,c.error),{...s,data:void 0}}async getWorkspaceBillingHistories(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...s,data:[]};const c=[];for(const k of i){const C=Pn.safeParse(k);C.success?c.push(C.data):console.warn("Invalid workspace billing history data:",k,C.error)}return{...s,data:c}}async getWorkspaceMembers(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...s,data:[]};const c=[];for(const k of i){const C=Cn.safeParse(k);C.success?c.push(C.data):console.warn("Invalid workspace member data:",k,C.error)}return{...s,data:c}}static getFromContext(e,r){const a=r.split(".");let s=e;for(const i of a){if(s==null)return;s=s[i]}return s}static getStepResult(e,r){return e.steps[r]}static getStepData(e,r){var a,s;return(s=(a=e.steps[r])==null?void 0:a.result)==null?void 0:s.data}static getVar(e,r){return e.vars[r]}}exports.AiParseDataBlockSchema=Wr;exports.AllBlockSchemas=ri;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=un;exports.Binding=si;exports.BlockHandler=ni;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=ui;exports.Condition=ai;exports.CurrencyCode=Pr;exports.CurrencyInfoSchema=An;exports.EightGClient=fi;exports.EightGError=at;exports.ElementExistsBlockSchema=Yr;exports.EventClickBlockSchema=Kr;exports.ExportDataBlockSchema=on;exports.FetchApiBlockSchema=an;exports.GetAttributeValueBlockSchema=Vr;exports.GetElementDataBlockSchema=rn;exports.GetTextBlockSchema=zr;exports.GetValueFormsBlockSchema=qr;exports.KeypressBlockSchema=Jr;exports.NavigateBlockSchema=en;exports.NetworkCatchBlockSchema=cn;exports.SaveAssetsBlockSchema=tn;exports.Schema=Ya;exports.ScrollBlockSchema=nn;exports.SetValueFormsBlockSchema=Hr;exports.TransformDataBlockSchema=sn;exports.WaitBlockSchema=Xr;exports.WaitForConditionBlockSchema=Qr;exports.Workflow=oi;exports.WorkflowStep=ii;exports.WorkflowStepRunResult=ci;exports.WorkspaceBillingHistorySchema=Pn;exports.WorkspaceBillingSchema=On;exports.WorkspaceDetailItemSchema=Dn;exports.WorkspaceItemSchema=Sn;exports.WorkspaceMemberSchema=Cn;exports.createArraySchema=Ga;exports.createSchema=Ha;
|
|
4
|
+
\r\v`.indexOf(Ie)>-1||Object.prototype.hasOwnProperty.call(f,Ie)){if(D.charAt(x)==="$")return Te=D.substring(x+1,ve),x=ve,M("variable",Te);switch(Te=D.substring(x,ve),x=ve,Te){case"or":case"in":case"and":return M("operator",Te);case"true":return M("value",!0);case"false":return M("value",!1);case"null":return M("value",null);default:return x===S&&Te===""?null:M("name",Te)}}else ve++};return Q},C=function(D,x){var S,M,ae={},Q=[],pe=function(){var d=[];S.id!=="(end)"&&d.push({type:S.type,value:S.value,position:S.position});for(var m=M();m!==null;)d.push(m),m=M();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(x)return d.remaining=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},R=function(d,m){var V=ae[d];return m=m||0,V?m>=V.lbp&&(V.lbp=m):(V=Object.create(H),V.id=V.value=d,V.lbp=m,ae[d]=V),V},se=function(d){if(x){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return S=Object.create(m),S.error=d,S.type="(error)",S}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&S.id!==d){var V;S.id==="(end)"?V="S0203":V="S0202";var de={code:V,position:S.position,token:S.value,value:d};return se(de)}var Ce=M(m);if(Ce===null)return S=ae["(end)"],S.position=D.length,S;var Ee=Ce.value,w=Ce.type,A;switch(w){case"name":case"variable":A=ae["(name)"];break;case"operator":if(A=ae[Ee],!A)return se({code:"S0204",stack:new Error().stack,position:Ce.position,token:Ee});break;case"string":case"number":case"value":A=ae["(literal)"];break;case"regex":w="regex",A=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Ce.position,token:Ee})}return S=Object.create(A),S.value=Ee,S.type=w,S.position=Ce.position,S},T=function(d){var m,V=S;for(L(null,!0),m=V.nud();d<S.lbp;)V=S,L(),m=V.led(m);return m},$=function(d){var m=R(d,0);m.nud=function(){return this}},z=function(d,m,V){var de=m||f[d],Ce=R(d,de);return Ce.led=V||function(Ee){return this.lhs=Ee,this.rhs=T(de),this.type="binary",this},Ce},he=function(d,m,V){var de=R(d,m);return de.led=V,de},xe=function(d,m){var V=R(d);return V.nud=m||function(){return this.expression=T(70),this.type="unary",this},V};$("(end)"),$("(name)"),$("(literal)"),$("(regex)"),R(":"),R(";"),R(","),R(")"),R("]"),R("}"),R(".."),z("."),z("+"),z("-"),z("*"),z("/"),z("%"),z("="),z("<"),z(">"),z("!="),z("<="),z(">="),z("&"),z("and"),z("or"),z("in"),$("and"),$("or"),$("in"),xe("-"),z("~>"),z("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=T(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=S.error,this.remaining=pe(),this.type="error",this}),xe("*",function(){return this.type="wildcard",this}),xe("**",function(){return this.type="descendant",this}),xe("%",function(){return this.type="parent",this}),z("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],S.id!==")")for(;S.type==="operator"&&S.id==="?"?(this.type="partial",this.arguments.push(S),L("?")):this.arguments.push(T(0)),S.id===",";)L(",");if(L(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,w){if(Ee.type!=="variable")return se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:w+1})}),this.type="lambda",S.id==="<"){for(var m=S.position,V=1,de="<";V>0&&S.id!=="{"&&S.id!=="(end)";){var Ce=L();Ce.id===">"?V--:Ce.id==="<"&&V++,de+=Ce.value}L(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}L("{"),this.body=T(0),L("}")}return this}),xe("(",function(){for(var d=[];S.id!==")"&&(d.push(T(0)),S.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(S.id!=="]")for(;;){var m=T(0);if(S.id===".."){var V={type:"binary",value:"..",position:S.position,lhs:m};L(".."),V.rhs=T(0),m=V}if(d.push(m),S.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),z("[",f["["],function(d){if(S.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,L("]"),d}else return this.lhs=d,this.rhs=T(f["]"]),this.type="binary",L("]",!0),this}),z("^",f["^"],function(d){L("(");for(var m=[];;){var V={descending:!1};if(S.id==="<"?L("<"):S.id===">"&&(V.descending=!0,L(">")),V.expression=T(0),m.push(V),S.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(S.id!=="}")for(;;){var V=T(0);L(":");var de=T(0);if(m.push([V,de]),S.id!==",")break;L(",")}return L("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Te),z("{",f["{"],Te),he(":=",f[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=T(f[":="]-1),this.type="binary",this)}),z("@",f["@"],function(d){return this.lhs=d,this.rhs=T(f["@"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),z("#",f["#"],function(d){return this.lhs=d,this.rhs=T(f["#"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),z("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=T(0),S.id===":"&&(L(":"),this.else=T(0)),this}),z("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=T(0),this}),xe("|",function(){return this.type="transform",this.pattern=T(0),L("|"),this.update=T(0),S.id===","&&(L(","),this.delete=T(0)),L("|"),this});var Ae=function(d){var m;if(d.type==="function"&&!d.predicate){var V={type:"lambda",thunk:!0,arguments:[],position:d.position};V.body=d,m=V}else if(d.type==="condition")d.then=Ae(d.then),typeof d.else<"u"&&(d.else=Ae(d.else)),m=d;else if(d.type==="block"){var de=d.expressions.length;de>0&&(d.expressions[de-1]=Ae(d.expressions[de-1])),m=d}else m=d;return m},ve=0,Ie=0,et=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(et[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var V=d.steps.length-1;for(m=_e(d.steps[V--],m);m.level>0&&V>=0;)m=_e(d.steps[V--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},fe=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var V=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&V.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=V:Array.prototype.push.apply(d.seekingParent,V)}},tt=function(d){var m=d.steps.length-1,V=d.steps[m],de=typeof V.seekingParent<"u"?V.seekingParent:[];V.type==="parent"&&de.push(V.slot);for(var Ce=0;Ce<de.length;Ce++){var Ee=de[Ce];for(m=d.steps.length-2;Ee.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[Ee]:d.seekingParent.push(Ee);break}for(var w=d.steps[m--];m>=0&&w.focus&&d.steps[m].focus;)w=d.steps[m--];Ee=_e(w,Ee)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var V=ie(d.lhs);V.type==="path"?m=V:m={type:"path",steps:[V]},V.type==="parent"&&(m.seekingParent=[V.slot]);var de=ie(d.rhs);de.type==="function"&&de.procedure.type==="path"&&de.procedure.steps.length===1&&de.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=de.procedure.steps[0].value),de.type==="path"?Array.prototype.push.apply(m.steps,de.steps):(typeof de.predicate<"u"&&(de.stages=de.predicate,delete de.predicate),m.steps.push(de)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var Ce=m.steps[0];Ce.type==="unary"&&Ce.value==="["&&(Ce.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),tt(m);break;case"[":m=ie(d.lhs);var w=m,A="predicate";if(m.type==="path"&&(w=m.steps[m.steps.length-1],A="stages"),typeof w.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof w[A]>"u"&&(w[A]=[]);var b=ie(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?_e(w,F):F.level--}),fe(w,b)),w[A].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ie(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ie(F[0]),ie(F[1])]}),position:d.position};break;case"^":m=ie(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var N={type:"sort",position:d.position};N.terms=d.rhs.map(function(F){var J=ie(F.expression);return fe(N,J),{descending:F.descending,expression:J}}),m.steps.push(N),tt(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.rhs);break;case"@":if(m=ie(d.lhs),w=m,m.type==="path"&&(w=m.steps[m.steps.length-1]),typeof w.stages<"u"||typeof w.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(w.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(w.keepArray=!0),w.focus=d.rhs.value,w.tuple=!0;break;case"#":m=ie(d.lhs),w=m,m.type==="path"?w=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof w.predicate<"u"&&(w.stages=w.predicate,delete w.predicate)),typeof w.stages>"u"?w.index=d.rhs.value:w.stages.push({type:"index",value:d.rhs.value,position:d.position}),w.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.lhs),fe(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ie(F[0]);fe(m,J);var ge=ie(F[1]);return fe(m,ge),[J,ge]}):(m.expression=ie(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):fe(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var J=ie(F);return fe(m,J),J}),m.procedure=ie(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var B=ie(d.body);m.body=Ae(B);break;case"condition":m={type:d.type,position:d.position},m.condition=ie(d.condition),fe(m,m.condition),m.then=ie(d.then),fe(m,m.then),typeof d.else<"u"&&(m.else=ie(d.else),fe(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ie(d.pattern),m.update=ie(d.update),typeof d.delete<"u"&&(m.delete=ie(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(m,J),(J.consarray||J.type==="path"&&J.steps[0].consarray)&&(m.consarray=!0),J});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ve++,level:1,index:Ie++}},et.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ie(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ie(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var O={code:j,position:d.position,token:d.value};if(x)return Q.push(O),{type:"error",error:O};throw O.stack=new Error().stack,O}return d.keepArray&&(m.keepArray=!0),m};M=k(D),L();var Be=T(0);if(S.id!=="(end)"){var it={code:"S0201",position:S.position,token:S.value};se(it)}if(Be=ie(Be),Be.type==="parent"||typeof Be.seekingParent<"u")throw{code:"S0217",token:Be.type,position:Be.position};return Q.length>0&&(Be.errors=Q),Be};return C})();a.exports=c},{"./signature":5}],5:[function(r,a,s){var i=r("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function v(k){for(var C=1,D=[],x={},S=x;C<k.length;){var M=k.charAt(C);if(M===":")break;var ae=function(){D.push(x),S=x,x={}},Q=function(z,he,xe,Te){for(var Ae=1,ve=he;ve<z.length;)if(ve++,M=z.charAt(ve),M===Te){if(Ae--,Ae===0)break}else M===xe&&Ae++;return ve};switch(M){case"s":case"n":case"b":case"l":case"o":x.regex="["+M+"m]",x.type=M,ae();break;case"a":x.regex="[asnblfom]",x.type=M,x.array=!0,ae();break;case"f":x.regex="f",x.type=M,ae();break;case"j":x.regex="[asnblom]",x.type=M,ae();break;case"x":x.regex="[asnblfom]",x.type=M,ae();break;case"-":S.context=!0,S.contextRegex=new RegExp(S.regex),S.regex+="?";break;case"?":case"+":S.regex+=M;break;case"(":var pe=Q(k,C,"(",")"),H=k.substring(C+1,pe);if(H.indexOf("<")===-1)x.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:C};x.type="("+H+")",C=pe,ae();break;case"<":if(S.type==="a"||S.type==="f"){var R=Q(k,C,"<",">");S.subtype=k.substring(C+1,R),C=R}else throw{code:"S0401",stack:new Error().stack,value:S.type,offset:C};break}C++}var se="^"+D.map(function(z){return"("+z.regex+")"}).join("")+"$",L=new RegExp(se),T=function(z){var he;if(i.isFunction(z))he="f";else{var xe=typeof z;switch(xe){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":z===null?he="l":Array.isArray(z)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(z,he){for(var xe="^",Te=0,Ae=0;Ae<D.length;Ae++){xe+=D[Ae].regex;var ve=he.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1}};return{definition:k,validate:function(z,he){var xe="";z.forEach(function(Ie){xe+=T(Ie)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return D.forEach(function(Ie,et){var _e=z[ve],fe=Te[et+1];if(fe==="")if(Ie.context&&Ie.contextRegex){var tt=T(he);if(Ie.contextRegex.test(tt))Ae.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Ae.push(_e),ve++;else fe.split("").forEach(function(ie){if(Ie.type==="a"){if(ie==="m")_e=void 0;else{_e=z[ve];var Be=!0;if(typeof Ie.subtype<"u"){if(ie!=="a"&&fe!==Ie.subtype)Be=!1;else if(ie==="a"&&_e.length>0){var it=T(_e[0]);if(it!==Ie.subtype.charAt(0))Be=!1;else{var d=_e.filter(function(m){return T(m)!==it});Be=d.length===0}}}if(!Be)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Ie.subtype]};ie!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}$(z,xe)}}}return v})();a.exports=c},{"./utils":6}],6:[function(r,a,s){const i=(()=>{function c(R){var se=!1;if(typeof R=="number"&&(se=!isNaN(R),se&&!isFinite(R)))throw{code:"D1001",value:R,stack:new Error().stack};return se}function f(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(L){return typeof L!="string"}).length===0),se}function v(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(L){return!c(L)}).length===0),se}function k(){var R=[];return R.sequence=!0,arguments.length===1&&R.push(arguments[0]),R}function C(R){return R.sequence===!0&&Array.isArray(R)}function D(R){return R&&(R._jsonata_function===!0||R._jsonata_lambda===!0)||typeof R=="function"}function x(R){var se=typeof R.arity=="number"?R.arity:typeof R.implementation=="function"?R.implementation.length:typeof R.length=="number"?R.length:R.arguments.length;return se}function S(R){return R&&R._jsonata_lambda===!0}var M=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(R){return typeof R=="object"&&R!==null&&M in R&&"next"in R&&typeof R.next=="function"}function Q(R,se){if(R===se)return!0;if(typeof R=="object"&&typeof se=="object"&&R!==null&&se!==null){if(Array.isArray(R)&&Array.isArray(se)){if(R.length!==se.length)return!1;for(var L=0;L<R.length;L++)if(!Q(R[L],se[L]))return!1;return!0}var T=Object.getOwnPropertyNames(R),$=Object.getOwnPropertyNames(se);if(T.length!==$.length)return!1;for(T=T.sort(),$=$.sort(),L=0;L<T.length;L++)if(T[L]!==$[L])return!1;for(L=0;L<T.length;L++){var z=T[L];if(!Q(R[z],se[z]))return!1}return!0}return!1}function pe(R){return typeof R=="object"&&R!==null&&"then"in R&&typeof R.then=="function"}function H(R){var se=[];for(let L of R)se.push(L);return se}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:v,createSequence:k,isSequence:C,isFunction:D,isLambda:S,isIterable:ae,getFunctionArity:x,isDeepEqual:Q,stringToArray:H,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Ir)),Ir.exports}var Gs=Hs();const Ys=qs(Gs),sn=E.object({name:E.literal("transform-data"),sourceData:E.any().optional(),expression:E.string().min(1,"JSONata expression is required")});function Ks(t){return sn.parse(t)}async function Js(t){try{const{sourceData:e,expression:r}=t,a=e??{};let s;try{s=Ys(r)}catch(c){throw new Error(`Invalid JSONata expression: ${c instanceof Error?c.message:"Unknown error"}`)}let i;try{i=await s.evaluate(a)}catch(c){throw console.error("JSONata evaluation failed:",c),new Error(`JSONata evaluation failed: ${c instanceof Error?c.message:"Unknown error"}`)}return{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in transform-data handler",data:null}}}const on=E.object({name:E.literal("export-data"),data:E.any(),format:E.enum(["json","csv","xlsx"]),filename:E.string().optional(),csvOptions:E.object({delimiter:E.string().optional(),includeHeaders:E.boolean().optional()}).optional()});function Xs(t){return on.parse(t)}async function Qs(t){try{const{data:e,format:r,filename:a,csvOptions:s}=t;console.log("[ExportDataBlock] Sending export request to background:",r);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:r,filename:a,csvOptions:s}});return i.$isError?{hasError:!0,message:i.message||"Export failed",data:void 0}:(console.log("[ExportDataBlock] Export successful:",i.data.filename),{data:i.data})}catch(e){return console.error("[ExportDataBlock] Export error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in export-data handler",data:void 0}}}const cn=E.object({name:E.literal("network-catch"),urlPattern:E.string().optional(),method:E.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),status:E.union([E.number(),E.object({min:E.number().optional(),max:E.number().optional()})]).optional(),mimeType:E.string().optional(),requestBodyPattern:E.union([E.string(),E.record(E.any())]).optional(),waitForRequest:E.boolean().optional(),waitTimeout:E.number().min(0).optional(),returnAll:E.boolean().optional(),includeHeaders:E.boolean().optional()});function ei(t){return cn.parse(t)}async function ti(t){try{console.log("[NetworkCatchBlock] Fetching network requests with pattern:",t.urlPattern);const e=await chrome.runtime.sendMessage({type:"NETWORK_CATCH",data:{urlPattern:t.urlPattern,method:t.method,status:t.status,mimeType:t.mimeType,requestBodyPattern:t.requestBodyPattern,waitForRequest:t.waitForRequest||!1,waitTimeout:t.waitTimeout||5e3,returnAll:t.returnAll||!1,includeHeaders:t.includeHeaders||!1}});return e.$isError?{hasError:!0,message:e.message||"Failed to fetch network data",data:void 0}:(console.log("[NetworkCatchBlock] Retrieved network data:",e.data),{data:e.data})}catch(e){return console.error("[NetworkCatchBlock] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Failed to fetch network data"}}}const ri={"get-text":zr,"attribute-value":Vr,"get-value-form":qr,"set-value-form":Hr,"clear-value-form":Gr,"element-exists":Yr,"event-click":Kr,keypress:Jr,wait:Xr,"wait-for-condition":Qr,navigate:en,"save-assets":tn,"get-element-data":rn,scroll:nn,"ai-parse-data":Wr,"fetch-api":an,"transform-data":sn,"export-data":on,"network-catch":cn};class ni{static async executeBlock(e){try{switch(e.name){case"get-text":{const r=rs(e);return await ns(r)}case"attribute-value":{const r=ss(e);return await is(r)}case"get-value-form":{const r=os(e);return await cs(r)}case"set-value-form":{const r=ls(e);return await fs(r)}case"clear-value-form":{const r=hs(e);return await ps(r)}case"element-exists":{const r=ys(e);return await gs(r)}case"event-click":{const r=vs(e);return await ws(r)}case"keypress":{const r=_s(e);return await Es(r)}case"wait":{const r=As(e);return await Ss(r)}case"wait-for-condition":{const r=Ds(e);return await Os(r)}case"navigate":{const r=Ps(e);return await Cs(r)}case"save-assets":{const r=Ns(e);return await Rs(r)}case"get-element-data":{const r=Ms(e);return await js(r)}case"scroll":{const r=Bs(e);return await Us(r)}case"ai-parse-data":{const r=Va(e);return await qa(r)}case"fetch-api":{const r=zs(e);return await Vs(r)}case"transform-data":{const r=Ks(e);return await Js(r)}case"export-data":{const r=Xs(e);return await Qs(r)}case"network-catch":{const r=ei(e);return await ti(r)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(r){return{hasError:!0,message:r instanceof Error?r.message:"Unknown error in block execution",data:null}}}}class ai{constructor(){ue(this,"expr");ue(this,"json")}}class si{constructor(){ue(this,"template");ue(this,"valueFrom");ue(this,"default")}}class ii{constructor(){ue(this,"id");ue(this,"title");ue(this,"when");ue(this,"block");ue(this,"repeat");ue(this,"next");ue(this,"onSuccess");ue(this,"onFailure");ue(this,"switch");ue(this,"timeoutMs");ue(this,"retry");ue(this,"delayAfterMs")}}class oi{constructor(){ue(this,"version");ue(this,"id");ue(this,"title");ue(this,"description");ue(this,"start");ue(this,"steps");ue(this,"vars");ue(this,"defaultDelayMs")}}class ci{constructor(){ue(this,"stepId");ue(this,"skipped");ue(this,"success");ue(this,"message");ue(this,"result");ue(this,"startedAt");ue(this,"finishedAt");ue(this,"attempts")}}class ui{constructor(){ue(this,"success");ue(this,"steps");ue(this,"context");ue(this,"targetUrl");ue(this,"timestamp");ue(this,"error")}}var Cr=(t=>(t.USD="USD",t.KRW="KRW",t.EUR="EUR",t.GBP="GBP",t.CAD="CAD",t.CNY="CNY",t.JPY="JPY",t.VND="VND",t.ARS="ARS",t.INR="INR",t.TWD="TWD",t.AUD="AUD",t.HKD="HKD",t.IDR="IDR",t.MXN="MXN",t.NZD="NZD",t.SGD="SGD",t.CHF="CHF",t.THB="THB",t.BRL="BRL",t.TRY="TRY",t.RUB="RUB",t.NOK="NOK",t.DKK="DKK",t.SEK="SEK",t.ILS="ILS",t.ZAR="ZAR",t.PLN="PLN",t.PHP="PHP",t.CZK="CZK",t.CLP="CLP",t.COP="COP",t.EGP="EGP",t.MYR="MYR",t.HUF="HUF",t.AED="AED",t.SAR="SAR",t.RON="RON",t.BGN="BGN",t))(Cr||{});const An={code:{type:"string",enum:Object.values(Cr),description:"Currency code"},symbol:{type:"string",enum:["$","₩","€","£","¥","₫","₹","NT$","Rp","₣","฿","R$","₺","₽","kr","₪","R","zł","₱","Kč","E£","RM","Ft","د.إ","﷼","L","лв"],description:"Currency symbol"},format:{type:"string",enum:["%s%u","%s%n","%u%s","%n%s","%s %u","%s %n","%u %s","%n %s"],description:"Display format (%s: symbol, %u/%n: amount)"},amount:{type:"number",description:"Actual amount value"},text:{type:"string",description:"Formatted display text (e.g., US$57.75)"}};class at extends Error{constructor(e,r,a){super(e),this.code=r,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new at("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new at(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new at(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const r=Math.floor(e/1e3);return new at(`Request timeout - Extension did not respond within ${r} seconds`,"REQUEST_TIMEOUT")}}function li(t){return t&&t.type==="8G_EXTENSION_RESPONSE"}const Sn=Tt({id:Pe(),slug:Pe(),name:Pe(),image:Pe(),memberCount:$t(),isAdmin:Rt().nullable().optional()}),Dn=Tt({slug:Pe(),displayName:Pe(),profileImageUrl:Pe(),description:Pe(),publicEmail:Pe(),billingEmail:Pe(),orgPageUrl:Pe()});var un=(t=>(t.monthly="MONTHLY",t.yearly="YEARLY",t))(un||{});const Ur=Tt({code:Zr(Cr),symbol:Pe(),format:Pe(),amount:$t(),text:Pe().optional()}),On=Tt({planName:Pe(),currentCycleBillAmount:Ur,nextPaymentDue:Pe(),cycleTerm:Zr(un).nullable(),isFreeTier:Rt(),isPerUser:Rt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Ur.nullable(),cardNumber:Pe(),cardName:Pe()}),Pn=Tt({uid:Pe(),issuedDate:pr.date(),paidDate:pr.date().nullable().optional(),paymentMethod:Pe(),amount:Ur,isSuccessfulPaid:Rt(),receiptUrl:Pe()}),Cn=Tt({name:Pe(),email:Pe().email(),profileImageUrl:Pe(),role:Pe(),subscriptionSeatStatus:Lr(["NONE","FREE","PAID","QUIT"]).nullable().optional(),startedAt:pr.date().nullable().optional(),deletedAt:pr.date().nullable().optional()});class fi{constructor(){}async checkExtension(){return new Promise((e,r)=>{const a=setTimeout(()=>{r(at.extensionNotInstalled())},5e3),s=i=>{li(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((r,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,c=setTimeout(()=>{a(at.requestTimeout(i))},i),f=v=>{var k,C,D,x,S,M,ae;if(((k=v.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&v.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const Q=v.data,pe=((C=Q==null?void 0:Q.result)==null?void 0:C.steps)??((x=(D=Q==null?void 0:Q.result)==null?void 0:D.result)==null?void 0:x.steps)??[],H=((S=Q==null?void 0:Q.result)==null?void 0:S.context)??((ae=(M=Q==null?void 0:Q.result)==null?void 0:M.result)==null?void 0:ae.context)??{steps:{},vars:{}};r({success:Q.success,steps:pe,context:H,error:Q.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,c;const r=await this.collectWorkflow(e);if(!r.success)throw new at("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(c=(i=r.steps[r.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{...r,data:[],isSuccess:!1};const s=[];for(const f of a){const v=Sn.safeParse(f);v.success?s.push(v.data):console.warn("Invalid workspace data:",f,v.error)}return{...r,data:s,isSuccess:!0}}async getWorkspaceDetail(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspaces","GET_WORKSPACES_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i)return{...s};const c=Dn.safeParse(i);if(c.success){const k=c.data;return{...s,data:k}}else return console.warn("Invalid workspace detail data:",i,c.error),{...s,data:void 0}}async getWorkspaceBilling(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i)return{...s};const c=On.safeParse(i);if(c.success){const k=c.data;return{...s,data:k}}else return console.warn("Invalid workspace billing data:",i,c.error),{...s,data:void 0}}async getWorkspaceBillingHistories(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...s,data:[]};const c=[];for(const k of i){const C=Pn.safeParse(k);C.success?c.push(C.data):console.warn("Invalid workspace billing history data:",k,C.error)}return{...s,data:c}}async getWorkspaceMembers(e,r,a){var f,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const s=await this.collectWorkflow(a);if(!s.success)throw new at("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const i=(v=(f=s.steps[s.steps.length-1])==null?void 0:f.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...s,data:[]};const c=[];for(const k of i){const C=Cn.safeParse(k);C.success?c.push(C.data):console.warn("Invalid workspace member data:",k,C.error)}return{...s,data:c}}static getFromContext(e,r){const a=r.split(".");let s=e;for(const i of a){if(s==null)return;s=s[i]}return s}static getStepResult(e,r){return e.steps[r]}static getStepData(e,r){var a,s;return(s=(a=e.steps[r])==null?void 0:a.result)==null?void 0:s.data}static getVar(e,r){return e.vars[r]}}exports.AiParseDataBlockSchema=Wr;exports.AllBlockSchemas=ri;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=un;exports.Binding=si;exports.BlockHandler=ni;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=ui;exports.Condition=ai;exports.CurrencyCode=Cr;exports.CurrencyInfoSchema=An;exports.EightGClient=fi;exports.EightGError=at;exports.ElementExistsBlockSchema=Yr;exports.EventClickBlockSchema=Kr;exports.ExportDataBlockSchema=on;exports.FetchApiBlockSchema=an;exports.GetAttributeValueBlockSchema=Vr;exports.GetElementDataBlockSchema=rn;exports.GetTextBlockSchema=zr;exports.GetValueFormsBlockSchema=qr;exports.KeypressBlockSchema=Jr;exports.NavigateBlockSchema=en;exports.NetworkCatchBlockSchema=cn;exports.SaveAssetsBlockSchema=tn;exports.Schema=Ya;exports.ScrollBlockSchema=nn;exports.SetValueFormsBlockSchema=Hr;exports.TransformDataBlockSchema=sn;exports.WaitBlockSchema=Xr;exports.WaitForConditionBlockSchema=Qr;exports.Workflow=oi;exports.WorkflowStep=ii;exports.WorkflowStepRunResult=ci;exports.WorkspaceBillingHistorySchema=Pn;exports.WorkspaceBillingSchema=On;exports.WorkspaceDetailItemSchema=Dn;exports.WorkspaceItemSchema=Sn;exports.WorkspaceMemberSchema=Cn;exports.createArraySchema=Ga;exports.createSchema=Ha;
|