scordi-extension 1.14.10 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.json +1 -1
- package/dist/sdk/EightGClient.d.ts +68 -0
- package/dist/sdk/EightGClient.d.ts.map +1 -1
- package/dist/sdk/index.cjs +8 -4
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +5732 -4115
- package/dist/src/blocks/AiParseDataBlock.ts.js +1 -1
- package/dist/src/blocks/ClearValueFormBlock.ts.js +1 -1
- package/dist/src/blocks/DataExtractBlock.ts.js +2 -2
- package/dist/src/blocks/ElementExistsBlock.ts.js +1 -1
- package/dist/src/blocks/EventClickBlock.ts.js +1 -1
- package/dist/src/blocks/FetchApiBlock.ts.js +1 -1
- package/dist/src/blocks/GetAttributeValueBlock.ts.js +1 -1
- package/dist/src/blocks/GetElementDataBlock.ts.js +1 -1
- package/dist/src/blocks/GetTextBlock.ts.js +1 -1
- package/dist/src/blocks/GetValueFormBlock.ts.js +1 -1
- package/dist/src/blocks/KeypressBlock.ts.js +1 -1
- package/dist/src/blocks/NavigateBlock.ts.js +1 -1
- package/dist/src/blocks/SaveAssetsBlock.ts.js +1 -1
- package/dist/src/blocks/ScrollBlock.ts.js +1 -1
- package/dist/src/blocks/SetValueFormBlock.ts.js +1 -1
- package/dist/src/blocks/WaitBlock.ts.js +1 -1
- package/dist/src/blocks/WaitForConditionBlock.ts.js +1 -1
- package/dist/src/blocks/types.ts.js +1 -1
- package/dist/src/content/components/ConfirmationUI.tsx.js +16 -8
- package/dist/src/content/main.tsx.js +2 -2
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--36a0c079.js +45 -0
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e041f26d.js +45 -0
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--36a0c079.js +975 -0
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e041f26d.js +975 -0
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--36a0c079.js +4158 -0
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--e041f26d.js +4158 -0
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--36a0c079.js +280 -0
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e041f26d.js +280 -0
- package/dist/vendor/.vite-deps-jsonata.js__v--989ee283.js +5761 -0
- package/dist/vendor/.vite-deps-jsonata.js__v--e041f26d.js +5761 -0
- package/dist/vendor/.vite-deps-react-dom.js__v--8313ef2c.js +6 -0
- package/dist/vendor/.vite-deps-react-dom.js__v--e041f26d.js +6 -0
- package/dist/vendor/.vite-deps-react-dom_client.js__v--a69c8f91.js +18108 -0
- package/dist/vendor/.vite-deps-react-dom_client.js__v--e041f26d.js +18108 -0
- package/dist/vendor/.vite-deps-react.js__v--8313ef2c.js +5 -0
- package/dist/vendor/.vite-deps-react.js__v--e041f26d.js +5 -0
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--8313ef2c.js +281 -0
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--e041f26d.js +281 -0
- package/dist/vendor/.vite-deps-zod.js__v--b73c580c.js +219 -0
- package/dist/vendor/.vite-deps-zod.js__v--e041f26d.js +219 -0
- package/dist/vendor/vite-client.js +1 -1
- package/package.json +3 -1
package/dist/sdk/index.cjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";var _n=Object.defineProperty;var En=(r,e,t)=>e in r?_n(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>En(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class At extends Error{constructor(e,t,a){super(e),this.code=t,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new At("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new At(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new At(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const t=Math.floor(e/1e3);return new At(`Request timeout - Extension did not respond within ${t} seconds`,"REQUEST_TIMEOUT")}}function Tn(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}class An{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(At.extensionNotInstalled())},5e3),s=i=>{Tn(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((t,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,c=setTimeout(()=>{a(At.requestTimeout(i))},i),f=w=>{var _,R,S,k;if(((_=w.data)==null?void 0:_.type)==="8G_COLLECT_RESPONSE"&&w.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const E=w.data,I=((R=E==null?void 0:E.result)==null?void 0:R.steps)??((k=(S=E==null?void 0:E.result)==null?void 0:S.result)==null?void 0:k.steps)??[];t({success:E.success,steps:I,error:E.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}}var be;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},r.find=(s,i)=>{for(const c of s)if(i(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}r.joinValues=a,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Pr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pr||(Pr={}));const z=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),kt=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=be.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Sn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class nt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(t(c));else{let f=a,w=0;for(;w<c.path.length;){const _=c.path[w];w===c.path.length-1?(f[_]=f[_]||{_errors:[]},f[_]._errors.push(t(c))):f[_]=f[_]||{_errors:[]},f=f[_],w++}}};return s(this),a}static assert(e){if(!(e instanceof nt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];t[i]=t[i]||[],t[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}nt.create=r=>new nt(r);const Vt=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let fn=Vt;function Cn(r){fn=r}function vr(){return fn}const br=r=>{const{data:e,path:t,errorMaps:a,issueData:s}=r,i=[...t,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const w=a.filter(_=>!!_).slice().reverse();for(const _ of w)f=_(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},On=[];function U(r,e){const t=vr(),a=br({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vt?void 0:Vt].filter(s=>!!s)});r.common.issues.push(a)}class Ye{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const s of t){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const s of t){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ye.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const s of t){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Zt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Nr=r=>r.status==="aborted",Mr=r=>r.status==="dirty",Rt=r=>r.status==="valid",Kt=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class yt{constructor(e,t,a,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const an=(r,e)=>{if(Rt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new nt(r.common.issues);return this._error=t,this._error}}};function ie(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:a,description:s}=r;if(e&&(t||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:w}=r;return c.code==="invalid_enum_value"?{message:w??f.defaultError}:typeof f.data>"u"?{message:w??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:w??t??f.defaultError}},description:s}}class ce{get description(){return this._def.description}_getType(e){return kt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:kt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ye,ctx:{common:e.parent.common,data:e.data,parsedType:kt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Kt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)},s=this._parseSync({data:e,path:a.path,parent:a});return an(a,s)}"~validate"(e){var a,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return Rt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>Rt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:kt(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(Kt(s)?s:Promise.resolve(s));return an(a,i)}refine(e,t){const a=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:D.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(w=>w?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,t){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof t=="function"?t(a,s):t),!1))}_refinement(e){return new ft({schema:this,typeName:re.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return mt.create(this,this._def)}nullable(){return Dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this)}promise(){return qt.create(this,this._def)}or(e){return tr.create([this,e],this._def)}and(e){return rr.create(this,e,this._def)}transform(e){return new ft({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new or({...ie(this._def),innerType:this,defaultValue:t,typeName:re.ZodDefault})}brand(){return new jr({typeName:re.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new cr({...ie(this._def),innerType:this,catchValue:t,typeName:re.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return lr.create(this,e)}readonly(){return ur.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Dn=/^c[^\s-]{8,}$/i,Pn=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Mn=/^[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,Rn=/^[a-z0-9_-]{21}$/i,In=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jn=/^[-+]?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)?)??$/,Fn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cr;const Un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bn=/^(?:(?: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])$/,Ln=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Zn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dn="((\\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])))",Wn=new RegExp(`^${dn}$`);function hn(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function qn(r){return new RegExp(`^${hn(r)}$`)}function pn(r){let e=`${dn}T${hn(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Hn(r,e){return!!((e==="v4"||!e)&&Un.test(r)||(e==="v6"||!e)&&Ln.test(r))}function Gn(r,e){if(!In.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Yn(r,e){return!!((e==="v4"||!e)&&Bn.test(r)||(e==="v6"||!e)&&Zn.test(r))}class ut extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.string,received:i.parsedType}),ee}const a=new Ye;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?U(s,{code:D.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:D.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Cr||(Cr=new RegExp($n,"u")),Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Dn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Pn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:D.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:D.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"regex",code:D.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?pn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?qn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:D.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?jn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?Hn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?Gn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?Yn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:D.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:D.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,t,a){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ut({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ut({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ut({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ut({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ut.create=r=>new ut({checks:[],typeName:re.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function Jn(r,e){const t=(r.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=t>a?t:a,i=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class St extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.number,received:i.parsedType}),ee}let a;const s=new Ye;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:D.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Jn(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_finite,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new St({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new St({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(t===null||a.value>t)&&(t=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}St.create=r=>new St({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ct extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let a;const s=new Ye;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),U(a,{code:D.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return U(t,{code:D.invalid_type,expected:z.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ct.create=r=>new Ct({checks:[],typeName:re.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class Xt extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.boolean,received:a.parsedType}),ee}return Je(e.data)}}Xt.create=r=>new Xt({typeName:re.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class It extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_type,expected:z.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:D.invalid_date}),ee}const a=new Ye;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:D.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):be.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new It({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}It.create=r=>new It({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:re.ZodDate,...ie(r)});class wr extends ce{_parse(e){if(this._getType(e)!==z.symbol){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.symbol,received:a.parsedType}),ee}return Je(e.data)}}wr.create=r=>new wr({typeName:re.ZodSymbol,...ie(r)});class Qt extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.undefined,received:a.parsedType}),ee}return Je(e.data)}}Qt.create=r=>new Qt({typeName:re.ZodUndefined,...ie(r)});class er extends ce{_parse(e){if(this._getType(e)!==z.null){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.null,received:a.parsedType}),ee}return Je(e.data)}}er.create=r=>new er({typeName:re.ZodNull,...ie(r)});class Wt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Wt.create=r=>new Wt({typeName:re.ZodAny,...ie(r)});class Mt extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}Mt.create=r=>new Mt({typeName:re.ZodUnknown,...ie(r)});class xt extends ce{_parse(e){const t=this._getOrReturnCtx(e);return U(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),ee}}xt.create=r=>new xt({typeName:re.ZodNever,...ie(r)});class kr extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.void,received:a.parsedType}),ee}return Je(e.data)}}kr.create=r=>new kr({typeName:re.ZodVoid,...ie(r)});class lt extends ce{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return U(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),ee;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,f=t.data.length<s.exactLength.value;(c||f)&&(U(t,{code:c?D.too_big:D.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(U(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(U(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((c,f)=>s.type._parseAsync(new yt(t,c,t.path,f)))).then(c=>Ye.mergeArray(a,c));const i=[...t.data].map((c,f)=>s.type._parseSync(new yt(t,c,t.path,f)));return Ye.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new lt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new lt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new lt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}lt.create=(r,e)=>new lt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function Lt(r){if(r instanceof Ie){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=mt.create(Lt(a))}return new Ie({...r._def,shape:()=>e})}else return r instanceof lt?new lt({...r._def,type:Lt(r.element)}):r instanceof mt?mt.create(Lt(r.unwrap())):r instanceof Dt?Dt.create(Lt(r.unwrap())):r instanceof gt?gt.create(r.items.map(e=>Lt(e))):r}class Ie extends ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=be.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==z.object){const _=this._getOrReturnCtx(e);return U(_,{code:D.invalid_type,expected:z.object,received:_.parsedType}),ee}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof xt&&this._def.unknownKeys==="strip"))for(const _ in s.data)c.includes(_)||f.push(_);const w=[];for(const _ of c){const R=i[_],S=s.data[_];w.push({key:{status:"valid",value:_},value:R._parse(new yt(s,S,s.path,_)),alwaysSet:_ in s.data})}if(this._def.catchall instanceof xt){const _=this._def.unknownKeys;if(_==="passthrough")for(const R of f)w.push({key:{status:"valid",value:R},value:{status:"valid",value:s.data[R]}});else if(_==="strict")f.length>0&&(U(s,{code:D.unrecognized_keys,keys:f}),a.dirty());else if(_!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const _=this._def.catchall;for(const R of f){const S=s.data[R];w.push({key:{status:"valid",value:R},value:_._parse(new yt(s,S,s.path,R)),alwaysSet:R in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const _=[];for(const R of w){const S=await R.key,k=await R.value;_.push({key:S,value:k,alwaysSet:R.alwaysSet})}return _}).then(_=>Ye.mergeObjectSync(a,_)):Ye.mergeObjectSync(a,w)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Ie({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,t,a).message)??a.defaultError;return t.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ie({...this._def,unknownKeys:"strip"})}passthrough(){return new Ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ie({...this._def,catchall:e})}pick(e){const t={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of be.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}deepPartial(){return Lt(this)}partial(e){const t={};for(const a of be.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new Ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof mt;)i=i._def.innerType;t[a]=i}return new Ie({...this._def,shape:()=>t})}keyof(){return mn(be.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:xt.create(),typeName:re.ZodObject,...ie(e)});class tr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return t.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new nt(f.ctx.common.issues));return U(t,{code:D.invalid_union,unionErrors:c}),ee}if(t.common.async)return Promise.all(a.map(async i=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const w of a){const _={...t,common:{...t.common,issues:[]},parent:null},R=w._parseSync({data:t.data,path:t.path,parent:_});if(R.status==="valid")return R;R.status==="dirty"&&!i&&(i={result:R,ctx:_}),_.common.issues.length&&c.push(_.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(w=>new nt(w));return U(t,{code:D.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}tr.create=(r,e)=>new tr({options:r,typeName:re.ZodUnion,...ie(e)});const wt=r=>r instanceof ar?wt(r.schema):r instanceof ft?wt(r.innerType()):r instanceof sr?[r.value]:r instanceof Ot?r.options:r instanceof ir?be.objectValues(r.enum):r instanceof or?wt(r._def.innerType):r instanceof Qt?[void 0]:r instanceof er?[null]:r instanceof mt?[void 0,...wt(r.unwrap())]:r instanceof Dt?[null,...wt(r.unwrap())]:r instanceof jr||r instanceof ur?wt(r.unwrap()):r instanceof cr?wt(r._def.innerType):[];class Ar extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return U(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),ee;const a=this.discriminator,s=t.data[a],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(U(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const s=new Map;for(const i of t){const c=wt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Ar({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ie(a)})}}function Rr(r,e){const t=kt(r),a=kt(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&a===z.object){const s=be.objectKeys(e),i=be.objectKeys(r).filter(f=>s.indexOf(f)!==-1),c={...r,...e};for(const f of i){const w=Rr(r[f],e[f]);if(!w.valid)return{valid:!1};c[f]=w.data}return{valid:!0,data:c}}else if(t===z.array&&a===z.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const c=r[i],f=e[i],w=Rr(c,f);if(!w.valid)return{valid:!1};s.push(w.data)}return{valid:!0,data:s}}else return t===z.date&&a===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class rr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Nr(i)||Nr(c))return ee;const f=Rr(i.value,c.value);return f.valid?((Mr(i)||Mr(c))&&t.dirty(),{status:t.value,value:f.data}):(U(a,{code:D.invalid_intersection_types}),ee)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}rr.create=(r,e,t)=>new rr({left:r,right:e,typeName:re.ZodIntersection,...ie(t)});class gt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.array)return U(a,{code:D.invalid_type,expected:z.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return U(a,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...a.data].map((c,f)=>{const w=this._def.items[f]||this._def.rest;return w?w._parse(new yt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ye.mergeArray(t,c)):Ye.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new gt({...this._def,rest:e})}}gt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gt({items:r,typeName:re.ZodTuple,rest:null,...ie(e)})};class nr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.object)return U(a,{code:D.invalid_type,expected:z.object,received:a.parsedType}),ee;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new yt(a,f,a.path,f)),value:c._parse(new yt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ye.mergeObjectAsync(t,s):Ye.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof ce?new nr({keyType:e,valueType:t,typeName:re.ZodRecord,...ie(a)}):new nr({keyType:ut.create(),valueType:e,typeName:re.ZodRecord,...ie(t)})}}class xr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.map)return U(a,{code:D.invalid_type,expected:z.map,received:a.parsedType}),ee;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,w],_)=>({key:s._parse(new yt(a,f,a.path,[_,"key"])),value:i._parse(new yt(a,w,a.path,[_,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const w of c){const _=await w.key,R=await w.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const w of c){const _=w.key,R=w.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}}}}xr.create=(r,e,t)=>new xr({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class jt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.set)return U(a,{code:D.invalid_type,expected:z.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(U(a,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function c(w){const _=new Set;for(const R of w){if(R.status==="aborted")return ee;R.status==="dirty"&&t.dirty(),_.add(R.value)}return{status:t.value,value:_}}const f=[...a.data.values()].map((w,_)=>i._parse(new yt(a,w,a.path,_)));return a.common.async?Promise.all(f).then(w=>c(w)):c(f)}min(e,t){return new jt({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new jt({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}jt.create=(r,e)=>new jt({valueType:r,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class zt extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return U(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),ee;function a(f,w){return br({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vr(),Vt].filter(_=>!!_),issueData:{code:D.invalid_arguments,argumentsError:w}})}function s(f,w){return br({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vr(),Vt].filter(_=>!!_),issueData:{code:D.invalid_return_type,returnTypeError:w}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof qt){const f=this;return Je(async function(...w){const _=new nt([]),R=await f._def.args.parseAsync(w,i).catch(E=>{throw _.addIssue(a(w,E)),_}),S=await Reflect.apply(c,this,R);return await f._def.returns._def.type.parseAsync(S,i).catch(E=>{throw _.addIssue(s(S,E)),_})})}else{const f=this;return Je(function(...w){const _=f._def.args.safeParse(w,i);if(!_.success)throw new nt([a(w,_.error)]);const R=Reflect.apply(c,this,_.data),S=f._def.returns.safeParse(R,i);if(!S.success)throw new nt([s(R,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new zt({...this._def,args:gt.create(e).rest(Mt.create())})}returns(e){return new zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new zt({args:e||gt.create([]).rest(Mt.create()),returns:t||Mt.create(),typeName:re.ZodFunction,...ie(a)})}}class ar extends ce{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ar.create=(r,e)=>new ar({getter:r,typeName:re.ZodLazy,...ie(e)});class sr extends ce{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return U(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}sr.create=(r,e)=>new sr({value:r,typeName:re.ZodLiteral,...ie(e)});function mn(r,e){return new Ot({values:r,typeName:re.ZodEnum,...ie(e)})}class Ot extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{expected:be.joinValues(a),received:t.parsedType,code:D.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{received:t.data,code:D.invalid_enum_value,options:a}),ee}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ot.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ot.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ot.create=mn;class ir extends ce{_parse(e){const t=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==z.string&&a.parsedType!==z.number){const s=be.objectValues(t);return U(a,{expected:be.joinValues(s),received:a.parsedType,code:D.invalid_type}),ee}if(this._cache||(this._cache=new Set(be.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=be.objectValues(t);return U(a,{received:a.data,code:D.invalid_enum_value,options:s}),ee}return Je(e.data)}get enum(){return this._def.values}}ir.create=(r,e)=>new ir({values:r,typeName:re.ZodNativeEnum,...ie(e)});class qt extends ce{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return U(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),ee;const a=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qt.create=(r,e)=>new qt({type:r,typeName:re.ZodPromise,...ie(e)});class ft extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{U(a,c),c.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(t.value==="aborted")return ee;const w=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return w.status==="aborted"?ee:w.status==="dirty"||t.value==="dirty"?Zt(w.value):w});{if(t.value==="aborted")return ee;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?ee:f.status==="dirty"||t.value==="dirty"?Zt(f.value):f}}if(s.type==="refinement"){const c=f=>{const w=s.refinement(f,i);if(a.common.async)return Promise.resolve(w);if(w instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value),{status:t.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value).then(()=>({status:t.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Rt(c))return ee;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>Rt(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):ee);be.assertNever(s)}}ft.create=(r,e,t)=>new ft({schema:r,typeName:re.ZodEffects,effect:e,...ie(t)});ft.createWithPreprocess=(r,e,t)=>new ft({schema:e,effect:{type:"preprocess",transform:r},typeName:re.ZodEffects,...ie(t)});class mt extends ce{_parse(e){return this._getType(e)===z.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mt.create=(r,e)=>new mt({innerType:r,typeName:re.ZodOptional,...ie(e)});class Dt extends ce{_parse(e){return this._getType(e)===z.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Dt.create=(r,e)=>new Dt({innerType:r,typeName:re.ZodNullable,...ie(e)});class or extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===z.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}or.create=(r,e)=>new or({innerType:r,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class cr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Kt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new nt(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new nt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}cr.create=(r,e)=>new cr({innerType:r,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class _r extends ce{_parse(e){if(this._getType(e)!==z.nan){const a=this._getOrReturnCtx(e);return U(a,{code:D.invalid_type,expected:z.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}_r.create=r=>new _r({typeName:re.ZodNaN,...ie(r)});const Kn=Symbol("zod_brand");class jr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class lr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(t.dirty(),Zt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,t){return new lr({in:e,out:t,typeName:re.ZodPipeline})}}class ur extends ce{_parse(e){const t=this._def.innerType._parse(e),a=s=>(Rt(s)&&(s.value=Object.freeze(s.value)),s);return Kt(t)?t.then(s=>a(s)):a(t)}unwrap(){return this._def.innerType}}ur.create=(r,e)=>new ur({innerType:r,typeName:re.ZodReadonly,...ie(e)});function sn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function yn(r,e={},t){return r?Wt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=sn(e,a),w=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:w})}});if(!i){const c=sn(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Wt.create()}const Xn={object:Ie.lazycreate};var re;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(re||(re={}));const Qn=(r,e={message:`Input not instance of ${r.name}`})=>yn(t=>t instanceof r,e),Er=ut.create,Fr=St.create,ea=_r.create,ta=Ct.create,Tr=Xt.create,ra=It.create,na=wr.create,aa=Qt.create,sa=er.create,ia=Wt.create,oa=Mt.create,ca=xt.create,ua=kr.create,la=lt.create,Ir=Ie.create,fa=Ie.strictCreate,da=tr.create,ha=Ar.create,pa=rr.create,ma=gt.create,ya=nr.create,ga=xr.create,va=jt.create,ba=zt.create,wa=ar.create,ka=sr.create,gn=Ot.create,xa=ir.create,_a=qt.create,on=ft.create,Ea=mt.create,Ta=Dt.create,Aa=ft.createWithPreprocess,Sa=lr.create,Ca=()=>Er().optional(),Oa=()=>Fr().optional(),Da=()=>Tr().optional(),Pa={string:(r=>ut.create({...r,coerce:!0})),number:(r=>St.create({...r,coerce:!0})),boolean:(r=>Xt.create({...r,coerce:!0})),bigint:(r=>Ct.create({...r,coerce:!0})),date:(r=>It.create({...r,coerce:!0}))},Na=ee,O=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Kn,DIRTY:Zt,EMPTY_PATH:On,INVALID:ee,NEVER:Na,OK:Je,ParseStatus:Ye,Schema:ce,ZodAny:Wt,ZodArray:lt,ZodBigInt:Ct,ZodBoolean:Xt,ZodBranded:jr,ZodCatch:cr,ZodDate:It,ZodDefault:or,ZodDiscriminatedUnion:Ar,ZodEffects:ft,ZodEnum:Ot,ZodError:nt,get ZodFirstPartyTypeKind(){return re},ZodFunction:zt,ZodIntersection:rr,ZodIssueCode:D,ZodLazy:ar,ZodLiteral:sr,ZodMap:xr,ZodNaN:_r,ZodNativeEnum:ir,ZodNever:xt,ZodNull:er,ZodNullable:Dt,ZodNumber:St,ZodObject:Ie,ZodOptional:mt,ZodParsedType:z,ZodPipeline:lr,ZodPromise:qt,ZodReadonly:ur,ZodRecord:nr,ZodSchema:ce,ZodSet:jt,ZodString:ut,ZodSymbol:wr,ZodTransformer:ft,ZodTuple:gt,ZodType:ce,ZodUndefined:Qt,ZodUnion:tr,ZodUnknown:Mt,ZodVoid:kr,addIssueToContext:U,any:ia,array:la,bigint:ta,boolean:Tr,coerce:Pa,custom:yn,date:ra,datetimeRegex:pn,defaultErrorMap:Vt,discriminatedUnion:ha,effect:on,enum:gn,function:ba,getErrorMap:vr,getParsedType:kt,instanceof:Qn,intersection:pa,isAborted:Nr,isAsync:Kt,isDirty:Mr,isValid:Rt,late:Xn,lazy:wa,literal:ka,makeIssue:br,map:ga,nan:ea,nativeEnum:xa,never:ca,null:sa,nullable:Ta,number:Fr,object:Ir,get objectUtil(){return Pr},oboolean:Da,onumber:Oa,optional:Ea,ostring:Ca,pipeline:Sa,preprocess:Aa,promise:_a,quotelessJson:Sn,record:ya,set:va,setErrorMap:Cn,strictObject:fa,string:Er,symbol:na,transformer:on,tuple:ma,undefined:aa,union:da,unknown:oa,get util(){return be},void:ua},Symbol.toStringTag,{value:"Module"})),dt=Ir({name:Er(),selector:Er(),findBy:gn(["cssSelector","xpath"]),option:Ir({waitForSelector:Tr().optional(),waitSelectorTimeout:Fr().optional(),multiple:Tr().optional()})}),Ma=O.object({type:O.literal("object"),shape:O.record(O.string(),O.any())}),Ra=O.object({type:O.literal("array"),items:O.any()}),Ia=O.discriminatedUnion("type",[Ma,Ra]),$r=O.object({name:O.literal("ai-parse-data"),sourceData:O.any().optional(),schemaDefinition:Ia,prompt:O.string().optional(),model:O.string().optional(),apiKey:O.string().min(1,"OpenAI API key is required")});function ja(r){return $r.parse(r)}async function Fa(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s="gpt-4o-mini",apiKey:i}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const c=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i}});if(c.$isError)throw new Error(c.message||"AI parsing failed");return{data:c.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function $a(r){return{type:"object",shape:r}}function Ua(r){return{type:"array",items:r}}const Ba={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e})};class Sr{async waitForElement(e,t,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,t);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class La extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,t);return i?Array.from(t.querySelectorAll(c)):t.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(w=>w.nodeType===Node.TEXT_NODE).map(w=>{var _;return((_=w.textContent)==null?void 0:_.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Za extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(_=>_.trim());if(c.length!==2)return null;const f=c[0],w=c[1];if(!f||!w)return null;try{const _=t.querySelector(f);if(!_||!_.contentDocument)return null;const R=_.contentDocument;return i?Array.from(R.querySelectorAll(w)):R.querySelector(w)}catch(_){return console.error("Iframe Selector error:",_),null}}}class za extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(w=>w.trim());let f=t;try{for(let w=0;w<c.length;w++){const _=c[w],R=w===c.length-1;if(!_)return null;if(R&&i)return Array.from(f.querySelectorAll(_));const S=f.querySelector(_);if(!S)return null;if(R)return S;if(S.shadowRoot)f=S.shadowRoot;else return null}}catch(w){return console.error("Shadow DOM Selector error:",w),null}return null}}class Va extends Sr{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=t.evaluate(a,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let w=0;w<c.snapshotLength;w++){const _=c.snapshotItem(w);_&&_.nodeType===Node.ELEMENT_NODE&&f.push(_)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class Wa{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${c})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function ht(r,e=document){const{selector:t,findBy:a="cssSelector",option:s}=r,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=qa(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function qa(r,e){return e==="xpath"?new Va:r.includes(">>")?new za:r.includes("|>")?new Za:new La}const Ur=dt.extend({name:O.literal("get-text"),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),filterEmpty:O.boolean().optional(),scrollToCollect:O.boolean().optional(),scrollDistance:O.number().optional(),scrollWaitMs:O.number().optional(),maxScrollAttempts:O.number().optional()});function Ha(r){return Ur.parse(r)}async function Ga(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:w,filterEmpty:_=!0,scrollToCollect:R=!1,scrollDistance:S=500,scrollWaitMs:k=300,maxScrollAttempts:E=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(R&&(w!=null&&w.multiple))return await Ya({selector:e,findBy:f,option:w,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:_,scrollDistance:S,scrollWaitMs:k,maxScrollAttempts:E});const I=await ht({selector:e,findBy:f,option:w});if(!I)return{data:""};const se=vn(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:_?me.filter(H=>H.trim()!==""):me}}else return{data:se(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function Ya(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:w,filterEmpty:_,scrollDistance:R,scrollWaitMs:S,maxScrollAttempts:k}=r,E=vn(s,i,c,f,w),I=new Set;let se=0,me=0;const ge=5;for(;se<k;){const H=await ht({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const L=I.size;if(H.forEach(B=>{const V=E(B);(!_||V.trim()!=="")&&I.add(V)}),I.size===L){if(me++,me>=ge)break}else me=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:R,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function vn(r,e,t,a="",s=""){return i=>{let c="";if(r?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",t){const f=new RegExp(t,"g"),w=c.match(f);c=w?w.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Br=dt.extend({name:O.literal("attribute-value"),attributeName:O.string()});function Ja(r){return Br.parse(r)}async function Ka(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:s}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await ht({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(t)).filter(f=>f!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Lr=dt.extend({name:O.literal("get-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function Xa(r){return Lr.parse(r)}async function Qa(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const s=await ht({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return{data:es(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function es(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Zr=dt.extend({name:O.literal("set-value-form"),setValue:O.string(),type:O.enum(["text-field","select","checkbox"]).optional()});function ts(r){return Zr.parse(r)}async function rs(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:s="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await ht({selector:e,findBy:s,option:r.option});if(!i)throw new Error("Form element not found");return ns(i,t,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function ns(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const zr=dt.extend({name:O.literal("clear-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function as(r){return zr.parse(r)}async function ss(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await ht({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return is(s,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function is(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Vr=dt.extend({name:O.literal("element-exists")});function os(r){return Vr.parse(r)}async function cs(r){try{const{selector:e="",findBy:t="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await ht({selector:e,findBy:t,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Wr=dt.extend({name:O.literal("event-click"),textFilter:O.object({text:O.union([O.string(),O.array(O.string())]),mode:O.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function us(r){return Wr.parse(r)}async function ls(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:s}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await ht({selector:e,findBy:t,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=fs(i,s.text,s.mode);if(!f){const w=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${w}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await hs(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 fs(r,e,t){for(const a of r){const s=ds(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(t){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ds(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const a=r.getAttribute("aria-label");return a?a.trim():""}async function hs(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),r.click&&r.click()}await new Promise(s=>setTimeout(s,50))}const qr=O.object({name:O.literal("keypress"),key:O.string(),code:O.string().optional(),keyCode:O.number().optional(),modifiers:O.array(O.enum(["Alt","Control","Meta","Shift"])).optional()});function ps(r){return qr.parse(r)}async function ms(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await ys(e,t,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function ys(r,e,t,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Or(r),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Or(r),bubbles:!0,cancelable:!0,...cn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Or(r),bubbles:!0,cancelable:!0,...cn(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Or(r){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[r]||0}function cn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Hr=O.object({name:O.literal("wait"),duration:O.number().min(0)});function gs(r){return Hr.parse(r)}async function vs(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Gr=O.object({name:O.literal("wait-for-condition"),conditions:O.object({urlPattern:O.string().optional(),elementExists:O.object({selector:O.string(),findBy:O.enum(["cssSelector","xpath"])}).optional(),cookieExists:O.string().optional(),storageKey:O.object({type:O.enum(["localStorage","sessionStorage"]),key:O.string()}).optional(),userConfirmation:O.boolean().optional(),message:O.string().optional(),buttonText:O.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:O.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:O.number().min(100).optional(),timeoutMs:O.number().min(1e3).optional(),position:O.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function bs(r){return Gr.parse(r)}async function ws(r){try{const{conditions:e,mode:t="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=r;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",t,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let w=null,_=null;(t==="manual"||t==="auto-or-manual")&&f&&(w=new Promise(S=>{_=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:_}})));const R=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(S){console.warn("[WaitForCondition] Invalid URL pattern:",S)}if(e.elementExists){const{selector:S,findBy:k}=e.elementExists;let E=null;if(k==="cssSelector"?E=document.querySelector(S):k==="xpath"&&(E=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),E)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(E=>{const[I]=E.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:S,key:k}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(k)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${k}`}}return null};return new Promise(S=>{let k=null,E=!1;const I=()=>{k&&(clearInterval(k),k=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},se=ge=>{E||(E=!0,I(),console.log("[WaitForCondition] Resolved with:",ge),S({data:ge}))},me=setTimeout(()=>{se({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(k=setInterval(async()=>{const ge=await R();ge&&(clearTimeout(me),se(ge))},a)),(t==="manual"||t==="auto-or-manual")&&w&&w.then(()=>{clearTimeout(me),se({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const Yr=O.object({name:O.literal("navigate"),url:O.string().url("Valid URL is required"),waitForLoad:O.boolean().optional(),timeout:O.number().min(0).optional()});function ks(r){return Yr.parse(r)}async function xs(r){try{const{url:e,waitForLoad:t=!0,timeout:a=3e4}=r;return console.log(`[Navigate] Navigating to: ${e}`),t?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 Jr=dt.extend({name:O.literal("save-assets")});function _s(r){return Jr.parse(r)}async function Es(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,s=await ht({selector:e,findBy:t,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Ts{static generate(e){var s;const t=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(w=>w.tagName===a.tagName);if(c.length>1){const w=c.indexOf(a)+1;i+=`[${w}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),t.unshift(i),a=a.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&t.push(`${s}="${i}"`)}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const Kr=dt.extend({name:O.literal("get-element-data"),includeText:O.boolean().optional(),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),attributes:O.array(O.string()).optional(),includeSelector:O.boolean().optional(),includeXPath:O.boolean().optional()});function As(r){return Kr.parse(r)}async function Ss(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:w=[],includeSelector:_=!1,includeXPath:R=!1,findBy:S="cssSelector",option:k}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&w.length===0)throw new Error("Either includeText must be true or attributes must be provided");const E=await ht({selector:e,findBy:S,option:k});if(!E)return{data:Array.isArray(E)?[]:{}};const I=Cs(t,a,s,i,c,f,w,_,R);return Array.isArray(E)?{data:E.map(I)}:{data:I(E)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Cs(r,e,t,a,s="",i="",c=[],f=!1,w=!1){return _=>{const R={};if(r){let S="";if(e?S=_.innerHTML:S=t?_.textContent||"":_.innerText||"",a){const k=new RegExp(a,"g"),E=S.match(k);S=E?E.join(" "):""}S.trim()&&(S=s+S.trim()+i),R.text=S}return c.length>0&&(R.attributes={},c.forEach(S=>{let k=_.getAttribute(S);if(k===null){const E=_.querySelector(`[${S}]`);E&&(k=E.getAttribute(S))}R.attributes[S]=k})),f&&(R.selector=Wa.generate(_)),w&&(R.xpath=Ts.generate(_)),R}}const Xr=dt.extend({name:O.literal("scroll"),scrollType:O.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:O.number().optional(),behavior:O.enum(["auto","smooth"]).optional(),maxScrolls:O.number().optional(),waitAfterScroll:O.number().optional()});function Os(r){return Xr.parse(r)}async function Ds(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:w}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Ps(e,f,w,s);case"toBottom":return await Ns(s,c);case"byDistance":return await Ms(a,s);case"untilLoaded":return await Rs(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Ps(r,e,t,a){const s=await ht({selector:r,findBy:e,option:t});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Ns(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function Ms(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Rs(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(_=>setTimeout(_,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,w=window.innerHeight;if(f+w>=c-10&&c===i)break;i=c,s++}return{data:!0}}const Qr=O.object({name:O.literal("fetch-api"),url:O.string(),method:O.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:O.record(O.string(),O.string()).optional(),body:O.record(O.string(),O.any()).optional(),timeout:O.number().min(0).optional(),parseJson:O.boolean().optional(),returnHeaders:O.boolean().optional()});function Is(r){return Qr.parse(r)}async function js(r){try{console.log("[FetchApiBlock] Sending API request to background:",r.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:r.url,method:r.method||"GET",headers:r.headers||{},body:r.body,timeout:r.timeout||3e4,parseJson:r.parseJson??!0,returnHeaders:r.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var un=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function gr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Dr={exports:{}},ln;function $s(){return ln||(ln=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(_,R){if(!s[_]){if(!a[_]){var S=typeof gr=="function"&&gr;if(!R&&S)return S(_,!0);if(f)return f(_,!0);var k=new Error("Cannot find module '"+_+"'");throw k.code="MODULE_NOT_FOUND",k}var E=s[_]={exports:{}};a[_][0].call(E.exports,function(I){var se=a[_][1][I];return c(se||I)},E,E.exports,t,a,s,i)}return s[_].exports}for(var f=typeof gr=="function"&&gr,w=0;w<i.length;w++)c(i[w]);return c}return t})()({1:[function(t,a,s){const i=t("./utils"),c=(function(){const f=i.stringToArray,w=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],_=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],R=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function k(v,A){var b=function($,j,C){var F="";if($<=19)F=(j?" and ":"")+(C?_[$]:w[$]);else if($<100){const ye=Math.floor($/10),we=$%10;F=(j?" and ":"")+R[ye-2],we>0?F+="-"+b(we,!1,C):C&&(F=F.substring(0,F.length-1)+"ieth")}else if($<1e3){const ye=Math.floor($/100),we=$%100;F=(j?", ":"")+w[ye]+" Hundred",we>0?F+=b(we,!0,C):C&&(F+="th")}else{var K=Math.floor(Math.log10($)/3);K>S.length&&(K=S.length);const ye=Math.pow(10,K*3),we=Math.floor($/ye),J=$-we*ye;F=(j?", ":"")+b(we,!1,!1)+" "+S[K-1],J>0?F+=b(J,!0,C):C&&(F+="th")}return F},P=b(v,!1,A);return P}const E={};w.forEach(function(v,A){E[v.toLowerCase()]=A}),_.forEach(function(v,A){E[v.toLowerCase()]=A}),R.forEach(function(v,A){const b=v.toLowerCase();E[b]=(A+2)*10,E[b.substring(0,v.length-1)+"ieth"]=E[b]}),E.hundredth=100,S.forEach(function(v,A){const b=v.toLowerCase(),P=Math.pow(10,(A+1)*3);E[b]=P,E[b+"th"]=P});function I(v){const b=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>E[j]);let P=[0];return b.forEach(j=>{if(j<100){let C=P.pop();C>=1e3&&(P.push(C),C=0),P.push(C+j)}else P.push(P.pop()*j)}),P.reduce((j,C)=>j+C,0)}const se=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],me={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ge(v){for(var A=0;A<se.length;A++){const b=se[A];if(v>=b[0])return b[1]+ge(v-b[0])}return""}function H(v){for(var A=0,b=1,P=v.length-1;P>=0;P--){const $=v[P],j=me[$];j<b?A-=j:(b=j,A+=j)}return A}function N(v,A){for(var b=[],P=A.charCodeAt(0);v>0;)b.unshift(String.fromCharCode((v-1)%26+P)),v=Math.floor((v-1)/26);return b.join("")}function ne(v,A){for(var b=A.charCodeAt(0),P=0,$=0;$<v.length;$++)P+=(v.charCodeAt(v.length-$-1)-b+1)*Math.pow(26,$);return P}function L(v,A){if(typeof v>"u")return;v=Math.floor(v);const b=xe(A);return V(v,b)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},B={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(v,A){let b;const P=v<0;switch(v=Math.abs(v),A.primary){case T.LETTERS:b=N(v,A.case===B.UPPER?"A":"a");break;case T.ROMAN:b=ge(v),A.case===B.UPPER&&(b=b.toUpperCase());break;case T.WORDS:b=k(v,A.ordinal),A.case===B.UPPER?b=b.toUpperCase():A.case===B.LOWER&&(b=b.toLowerCase());break;case T.DECIMAL:b=""+v;var $=A.mandatoryDigits-b.length;if($>0){var j=new Array($+1).join("0");b=j+b}if(A.zeroCode!==48&&(b=f(b).map(ye=>String.fromCodePoint(ye.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ye=Math.floor((b.length-1)/A.groupingSeparators.position);for(let we=ye;we>0;we--){const J=b.length-we*A.groupingSeparators.position;b=b.substr(0,J)+A.groupingSeparators.character+b.substr(J)}}else A.groupingSeparators.reverse().forEach(ye=>{const we=b.length-ye.position;b=b.substr(0,we)+ye.character+b.substr(we)});if(A.ordinal){var C={1:"st",2:"nd",3:"rd"},F=b[b.length-1],K=C[F];(!K||b.length>1&&b[b.length-2]==="1")&&(K="th"),b=b+K}break;case T.SEQUENCE:throw{code:"D3130",value:A.token}}return P&&(b="-"+b),b}const de=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(v){const A={type:"integer",primary:T.DECIMAL,case:B.LOWER,ordinal:!1};let b,P;const $=v.lastIndexOf(";");switch($===-1?b=v:(b=v.substring(0,$),P=v.substring($+1),P[0]==="o"&&(A.ordinal=!0)),b){case"A":A.case=B.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=B.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=B.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=B.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,C=0,F=0,K=[],ye=0;if(f(b).map(J=>J.codePointAt(0)).reverse().forEach(J=>{let Q=!1;for(let he=0;he<de.length;he++){const G=de[he];if(J>=G&&J<=G+9){if(Q=!0,C++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(J===35?(ye++,F++):K.push({position:ye,character:String.fromCodePoint(J)}))}),C>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=C,A.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let Ue=1;Ue<he.length;Ue++)if(he[Ue].character!==G)return 0;const Le=he.map(Ue=>Ue.position),st=function(Ue,qe){return qe===0?Ue:st(qe,Ue%qe)},We=Le.reduce(st);for(let Ue=1;Ue<=Le.length;Ue++)if(Le.indexOf(Ue*We)===-1)return 0;return We}(K);Q>0?(A.regular=!0,A.groupingSeparators={position:Q,character:K[0].character}):(A.regular=!1,A.groupingSeparators=K)}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(v){var A=[];const b={type:"datetime",parts:A},P=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var $=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){P($,j),A.push({type:"literal",value:"["}),j+=2,$=j;continue}if(P($,j),$=j,j=v.indexOf("]",$),j===-1)throw{code:"D3135"};let Q=v.substring($+1,j);Q=Q.split(/\s+/).join("");var C={type:"marker",component:Q.charAt(0)},F=Q.lastIndexOf(","),K;if(F!==-1){const he=Q.substring(F+1),G=he.indexOf("-");let Le,st;const We=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Le=he:(Le=he.substring(0,G),st=he.substring(G+1));const Ue={min:We(Le),max:We(st)};C.width=Ue,K=Q.substring(1,F)}else K=Q.substring(1);if(K.length===1)C.presentation1=K;else if(K.length>1){var ye=K.charAt(K.length-1);"atco".indexOf(ye)!==-1?(C.presentation2=ye,ye==="o"&&(C.ordinal=!0),C.presentation1=K.substring(0,K.length-1)):C.presentation1=K}else C.presentation1=Te[C.component];if(typeof C.presentation1>"u")throw{code:"D3132",value:C.component};if(C.presentation1[0]==="n")C.names=B.LOWER;else if(C.presentation1[0]==="N")C.presentation1[1]==="n"?C.names=B.TITLE:C.names=B.UPPER;else if("YMDdFWwXxHhmsf".indexOf(C.component)!==-1){var we=C.presentation1;if(C.presentation2&&(we+=";"+C.presentation2),C.integerFormat=xe(we),C.width&&C.width.min!==void 0&&C.integerFormat.mandatoryDigits<C.width.min&&(C.integerFormat.mandatoryDigits=C.width.min),C.component==="Y")if(C.n=-1,C.width&&C.width.max!==void 0)C.n=C.width.max,C.integerFormat.mandatoryDigits=C.n;else{var J=C.integerFormat.mandatoryDigits+C.integerFormat.optionalDigits;J>=2&&(C.n=J)}const he=A[A.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(C.component==="Z"||C.component==="z")&&(C.integerFormat=xe(C.presentation1)),A.push(C),$=j+1}j++}return P($,j),b}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],Qe=1e3*60*60*24,_e=function(v){const A=Date.UTC(v.year,v.month);var b=new Date(A).getUTCDay();return b===0&&(b=7),b>4?A+(8-b)*Qe:A-(b-1)*Qe},ue=function(v,A){return{year:v,month:A,nextMonth:function(){return A===11?ue(v+1,0):ue(v,A+1)},previousMonth:function(){return A===0?ue(v-1,11):ue(v,A-1)},nextYear:function(){return ue(v+1,A)},previousYear:function(){return ue(v-1,A)}}},et=function(v,A){return(A-v)/(Qe*7)+1},ae=(v,A)=>{let b;switch(A){case"Y":b=v.getUTCFullYear();break;case"M":b=v.getUTCMonth()+1;break;case"D":b=v.getUTCDate();break;case"d":{const P=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),$=Date.UTC(v.getUTCFullYear(),0);b=(P-$)/Qe+1;break}case"F":b=v.getUTCDay(),b===0&&(b=7);break;case"W":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=Date.UTC(P.year,v.getUTCMonth(),v.getUTCDate());let C=et($,j);if(C>52){const F=_e(P.nextYear());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousYear());C=et(F,j)}b=Math.floor(C);break}case"w":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=Date.UTC(P.year,P.month,v.getUTCDate());let C=et($,j);if(C>4){const F=_e(P.nextMonth());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousMonth());C=et(F,j)}b=Math.floor(C);break}case"X":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=_e(P.nextYear()),C=v.getTime();C<$?b=P.year-1:C>=j?b=P.year+1:b=P.year;break}case"x":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=P.nextMonth(),C=_e(j),F=v.getTime();F<$?b=P.previousMonth().month+1:F>=C?b=j.month+1:b=P.month+1;break}case"H":b=v.getUTCHours();break;case"h":b=v.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=v.getUTCHours()>=12?"pm":"am";break;case"m":b=v.getUTCMinutes();break;case"s":b=v.getUTCSeconds();break;case"f":b=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Fe=null;function at(v,A,b){var P=0,$=0;if(typeof b<"u"){const we=parseInt(b);P=Math.floor(we/100),$=we%100}var j=function(we,J){var Q=ae(we,J.component);if("YMDdFWwXxHhms".indexOf(J.component)!==-1)if(J.component==="Y"&&J.n!==-1&&(Q=Q%Math.pow(10,J.n)),J.names){if(J.component==="M"||J.component==="x")Q=Me[Q-1];else if(J.component==="F")Q=ve[Q];else throw{code:"D3133",value:J.component};J.names===B.UPPER?Q=Q.toUpperCase():J.names===B.LOWER&&(Q=Q.toLowerCase()),J.width&&Q.length>J.width.max&&(Q=Q.substring(0,J.width.max))}else Q=V(Q,J.integerFormat);else if(J.component==="f")Q=V(Q,J.integerFormat);else if(J.component==="Z"||J.component==="z"){const he=P*100+$;if(J.integerFormat.regular)Q=V(he,J.integerFormat);else{const G=J.integerFormat.mandatoryDigits;if(G===1||G===2)Q=V(P,J.integerFormat),$!==0&&(Q+=":"+L($,"00"));else if(G===3||G===4)Q=V(he,J.integerFormat);else throw{code:"D3134",value:G}}he>=0&&(Q="+"+Q),J.component==="z"&&(Q="GMT"+Q),he===0&&J.presentation2==="t"&&(Q="Z")}else J.component==="P"&&J.names===B.UPPER&&(Q=Q.toUpperCase());return Q};let C;typeof A>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),C=Fe):C=Ae(A);const F=(60*P+$)*60*1e3,K=new Date(v+F);let ye="";return C.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(K,we)}),ye}function d(v){var A={};if(v.type==="datetime")A.type="datetime",A.parts=v.parts.map(function(b){var P={};if(b.type==="literal")P.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),P.regex="",b.component==="z"&&(P.regex="GMT"),P.regex+="[-+][0-9]+",j&&(P.regex+=j.character+"[0-9]+"),P.parse=function(C){b.component==="z"&&(C=C.substring(3));let F=0,K=0;return j?(F=Number.parseInt(C.substring(0,C.indexOf(j.character))),K=Number.parseInt(C.substring(C.indexOf(j.character)+1))):C.length-1<=2?F=Number.parseInt(C):(F=Number.parseInt(C.substring(0,3)),K=Number.parseInt(C.substring(3))),F*60+K}}else if(b.integerFormat)P=d(b.integerFormat);else{P.regex="[a-zA-Z]+";var $={};if(b.component==="M"||b.component==="x")Me.forEach(function(j,C){b.width&&b.width.max?$[j.substring(0,b.width.max)]=C+1:$[j]=C+1});else if(b.component==="F")ve.forEach(function(j,C){C>0&&(b.width&&b.width.max?$[j.substring(0,b.width.max)]=C:$[j]=C)});else if(b.component==="P")$={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};P.parse=function(j){return $[j]}}return P.component=b.component,P});else{A.type="integer";const b=v.case===B.UPPER;switch(v.primary){case T.LETTERS:A.regex=b?"[A-Z]+":"[a-z]+",A.parse=function(P){return ne(P,b?"A":"a")};break;case T.ROMAN:A.regex=b?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(P){return H(b?P:P.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",A.parse=function(P){return I(P.toLowerCase())};break;case T.DECIMAL:A.regex="[0-9]",v.parseWidth?A.regex+=`{${v.parseWidth}}`:A.regex+="+",v.ordinal&&(A.regex+="(?:th|st|nd|rd)"),A.parse=function(P){let $=P;return v.ordinal&&($=P.substring(0,P.length-2)),v.regular?$=$.split(",").join(""):v.groupingSeparators.forEach(j=>{$=$.split(j.character).join("")}),v.zeroCode!==48&&($=$.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt($)};break;case T.SEQUENCE:throw{code:"D3130",value:v.token}}}return A}function m(v,A){if(typeof v>"u")return;const b=xe(A);return d(b).parse(v)}function W(v,A){const b=Ae(A),P=d(b),$="^"+P.parts.map(K=>"("+K.regex+")").join("")+"$";var C=new RegExp($,"i").exec(v);if(C!==null){const G={};for(let Ce=1;Ce<C.length;Ce++){const u=P.parts[Ce-1];u.parse&&(G[u.component]=u.parse(C[Ce]))}if(Object.getOwnPropertyNames(G).length===0)return;let Le=0;const st=Ce=>{Le<<=1,Le+=Ce?1:0},We=Ce=>!(~Ce&Le)&&!!(Ce&Le);"YXMxWwdD".split("").forEach(Ce=>st(G[Ce]));const qe=!We(161)&&We(130),vt=We(84),_t=!vt&&We(72);Le=0,"PHhmsf".split("").forEach(Ce=>st(G[Ce]));const Et=!We(23)&&We(47),Ht=(qe?"YD":vt?"XxwF":_t?"XWF":"YMD")+(Et?"Phmsf":"Hmsf"),ot=this.environment.timestamp;let Ft=!1,pt=!1;if(Ht.split("").forEach(Ce=>{if(typeof G[Ce]>"u")Ft?(G[Ce]="MDd".indexOf(Ce)!==-1?1:0,pt=!0):G[Ce]=ae(ot,Ce);else if(Ft=!0,pt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const Ce=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(Ce+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(vt)throw{code:"D3136"};if(_t)throw{code:"D3136"};Et&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var le=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function De(v,A){if(!(typeof v>"u"))if(typeof A>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return W.call(this,v,A)}function Ee(v,A,b){if(!(typeof v>"u"))return at.call(this,v,A,b)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:De}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var w=c.isNumeric,_=c.isArrayOfStrings,R=c.isArrayOfNumbers,S=c.createSequence,k=c.isSequence,E=c.isFunction,I=c.isLambda,se=c.isPromise,me=c.getFunctionArity,ge=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function ne(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function T(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function B(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function V(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(E(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,x){return typeof x<"u"&&x!==null&&x.toPrecision&&w(x)?Number(x.toPrecision(15)):x&&E(x)?"":x},g)}return l}}function de(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var x=o>=0?o+l:p+o+l;return g.slice(o,x).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Me(n){if(!(typeof n>"u"))return H(n).length}function Qe(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Me(n);if(p>0){var x=new Array(p+1).join(l);l.length>1&&(x=de(x,0,p)),o>0?g=n+x:g=x+n}else g=n;return g}}async function ue(n,o){var l=n.apply(this,[o]);if(se(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||E(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function et(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await ue(o,n);l=typeof g<"u"}return l}}async function ae(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=S();if(typeof l>"u"||l>0){var p=0,x=await ue(o,n);if(typeof x<"u")for(;typeof x<"u"&&(typeof l>"u"||p<l);)g.push({match:x.match,index:x.start,groups:x.groups}),x=await ue(x.next),p++}return g}}async function Fe(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var x;typeof l=="string"?x=function(Se){for(var Ze="",ke=0,je=l.indexOf("$",ke);je!==-1&&ke<l.length;){Ze+=l.substring(ke,je),ke=je+1;var it=l.charAt(ke);if(it==="$")Ze+="$",ke++;else if(it==="0")Ze+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(ke,ke+ze),10),ze>1&&je>Se.groups.length&&(je=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(je))Ze+="$";else{if(Se.groups.length>0){var $t=Se.groups[je-1];typeof $t<"u"&&(Ze+=$t)}ke+=je.toString().length}}je=l.indexOf("$",ke)}return Ze+=l.substring(ke),Ze}:x=l;var M="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,q);Oe!==-1&&(typeof g>"u"||X<g);)M+=n.substring(q,Oe),M+=l,q=Oe+o.length,X++,Oe=n.indexOf(o,q);M+=n.substring(q)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){M+=n.substring(q,pe.start);var Pe=x.apply(p,[pe]);if(se(Pe)&&(Pe=await Pe),typeof Pe=="string")M+=Pe;else throw{code:"D3012",stack:new Error().stack,value:Pe};q=pe.start+pe.match.length,X++,pe=await ue(pe.next)}M+=n.substring(q)}else M=n}}else M=n;return M}}function at(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function W(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function le(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function De(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,x=await ue(o,n);if(typeof x<"u"){for(var M=0;typeof x<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(M,x.start)),M=x.end,x=await ue(x.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(M))}else g.push(n)}return g}}function v(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function 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(te){p[te]=l[te]});for(var x=[],M=p["zero-digit"].charCodeAt(0),q=M;q<M+10;q++)x.push(String.fromCharCode(q));var X=x.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Re=(function(){for(var Be,rt=0;rt<te.length;rt++)if(Be=te.charAt(rt),X.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(0,rt)})(),Ge=(function(){for(var Be,rt=te.length-1;rt>=0;rt--)if(Be=te.charAt(rt),X.indexOf(Be)!==-1&&Be!==p["exponent-separator"])return te.substring(rt+1)})(),Ne=te.substring(Re.length,te.length-Ge.length),Ke,Tt,Xe,Nt,tt=te.indexOf(p["exponent-separator"],Re.length);tt===-1||tt>te.length-Ge.length?(Ke=Ne,Tt=void 0):(Ke=Ne.substring(0,tt),Tt=Ne.substring(tt+1));var ct=Ke.indexOf(p["decimal-separator"]);return ct===-1?(Xe=Ke,Nt=Ge):(Xe=Ke.substring(0,ct),Nt=Ke.substring(ct+1)),{prefix:Re,suffix:Ge,activePart:Ne,mantissaPart:Ke,exponentPart:Tt,integerPart:Xe,fractionalPart:Nt,subpicture:te}},Pe=function(te){var Re,Ge,Ne=te.subpicture,Ke=Ne.indexOf(p["decimal-separator"]);Ke!==Ne.lastIndexOf(p["decimal-separator"])&&(Re="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Re="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Re="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Re="D3084");var Tt=!1;for(Ge=0;Ge<te.mantissaPart.length;Ge++){var Xe=te.mantissaPart.charAt(Ge);if(x.indexOf(Xe)!==-1||Xe===p.digit){Tt=!0;break}}Tt||(Re="D3085");var Nt=te.activePart.split("").map(function(Be){return X.indexOf(Be)===-1?"p":"a"}).join("");Nt.indexOf("p")!==-1&&(Re="D3086"),Ke!==-1?(Ne.charAt(Ke-1)===p["grouping-separator"]||Ne.charAt(Ke+1)===p["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Re="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Re="D3089");var tt=te.integerPart.indexOf(p.digit);tt!==-1&&te.integerPart.substring(0,tt).split("").filter(function(Be){return x.indexOf(Be)>-1}).length>0&&(Re="D3090"),tt=te.fractionalPart.lastIndexOf(p.digit),tt!==-1&&te.fractionalPart.substring(tt).split("").filter(function(Be){return x.indexOf(Be)>-1}).length>0&&(Re="D3091");var ct=typeof te.exponentPart=="string";if(ct&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Re="D3092"),ct&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Be){return x.indexOf(Be)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Se=function(te){var Re=function(Ve,mr){for(var Jt=[],bt=Ve.indexOf(p["grouping-separator"]);bt!==-1;){var yr=(mr?Ve.substring(0,bt):Ve.substring(bt)).split("").filter(function(Bt){return x.indexOf(Bt)!==-1||Bt===p.digit}).length;Jt.push(yr),bt=te.integerPart.indexOf(p["grouping-separator"],bt+1)}return Jt},Ge=Re(te.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var mr=function(yr,Bt){return Bt===0?yr:mr(Bt,yr%Bt)},Jt=Ve.reduce(mr),bt=1;bt<=Ve.length;bt++)if(Ve.indexOf(bt*Jt)===-1)return 0;return Jt},Ke=Ne(Ge),Tt=Re(te.fractionalPart,!0),Xe=te.integerPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Nt=Xe,tt=te.fractionalPart.split(""),ct=tt.filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Be=tt.filter(function(Ve){return x.indexOf(Ve)!==-1||Ve===p.digit}).length,rt=typeof te.exponentPart=="string";Xe===0&&Be===0&&(rt?(ct=1,Be=1):Xe=1),rt&&Xe===0&&te.integerPart.indexOf(p.digit)!==-1&&(Xe=1),Xe===0&&ct===0&&(ct=1);var nn=0;return rt&&(nn=te.exponentPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ge,regularGrouping:Ke,minimumIntegerPartSize:Xe,scalingFactor:Nt,prefix:te.prefix,fractionalPartGroupingPositions:Tt,minimumFactionalPartSize:ct,maximumFactionalPartSize:Be,minimumExponentSize:nn,suffix:te.suffix,picture:te.subpicture}},Ze=Oe.map(pe);Ze.forEach(Pe);var ke=Ze.map(Se),je=p["minus-sign"],it=p["zero-digit"],ze=p["decimal-separator"],$t=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=je+ke[1].prefix);var $e;n>=0?$e=ke[0]:$e=ke[1];var Gt;$e.picture.indexOf(p.percent)!==-1?Gt=n*100:$e.picture.indexOf(p["per-mille"])!==-1?Gt=n*1e3:Gt=n;var Pt,Ut;if($e.minimumExponentSize===0)Pt=Gt;else{var bn=Math.pow(10,$e.scalingFactor),wn=Math.pow(10,$e.scalingFactor-1);for(Pt=Gt,Ut=0;Pt<wn;)Pt*=10,Ut-=1;for(;Pt>bn;)Pt/=10,Ut+=1}var kn=F(Pt,$e.maximumFactionalPartSize),tn=function(te,Re){var Ge=Math.abs(te).toFixed(Re);return it!=="0"&&(Ge=Ge.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?x[Ne.charCodeAt(0)-48]:Ne}).join("")),Ge},oe=tn(kn,$e.maximumFactionalPartSize),He=oe.indexOf(".");for(He===-1?oe=oe+ze:oe=oe.replace(".",ze);oe.charAt(0)===it;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===it;)oe=oe.substring(0,oe.length-1);He=oe.indexOf(ze);var Yt=$e.minimumIntegerPartSize-He,rn=$e.minimumFactionalPartSize-(oe.length-He-1);if(oe=(Yt>0?new Array(Yt+1).join(it):"")+oe,oe=oe+(rn>0?new Array(rn+1).join(it):""),He=oe.indexOf(ze),$e.regularGrouping>0)for(var xn=Math.floor((He-1)/$e.regularGrouping),hr=1;hr<=xn;hr++)oe=[oe.slice(0,He-hr*$e.regularGrouping),$t,oe.slice(He-hr*$e.regularGrouping)].join("");else $e.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,He-te),$t,oe.slice(He-te)].join(""),He++});if(He=oe.indexOf(ze),$e.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+He+1),$t,oe.slice(te+He+1)].join("")}),He=oe.indexOf(ze),($e.picture.indexOf(ze)===-1||He===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Ut<"u"){var pr=tn(Ut,0);Yt=$e.minimumExponentSize-pr.length,Yt>0&&(pr=new Array(Yt+1).join(it)+pr),oe=oe+p["exponent-separator"]+(Ut<0?je:"")+pr}return oe=$e.prefix+oe+$e.suffix,oe}}function b(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function P(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function $(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function C(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function K(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ye(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function we(){return Math.random()}function J(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=J(n[0]);else if(n.length>1){var l=n.filter(function(g){return J(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):w(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!E(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function Q(n){if(!(typeof n>"u"))return!J(n)}function he(n,o,l,g){var p=[o],x=me(n);return x>=2&&p.push(l),x>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}}async function Le(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);J(M)&&l.push(p)}return l}}async function st(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var x=n[p],M=!0;if(typeof o<"u"){var q=he(o,x,p,n),X=await o.apply(this,q);M=J(X)}if(M)if(!l)g=x,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function We(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(x){return Array.isArray(x)?x.length:0})),g=0;g<l;g++){var p=o.map(x=>x[g]);n.push(p)}return n}async function Ue(n,o,l){if(!(typeof n>"u")){var g,p=me(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var x;for(typeof l>"u"&&n.length>0?(g=n[0],x=1):(g=l,x=0);x<n.length;){var M=[g,n[x]];p>=3&&M.push(x),p>=4&&M.push(n),g=await o.apply(this,M),x++}return g}}function qe(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=qe(g);p.forEach(function(x){l[x]=!0})}),o=qe(l)}else n!==null&&typeof n=="object"&&!E(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function vt(n,o){var l;if(Array.isArray(n)){l=S();for(var g=0;g<n.length;g++){var p=vt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(x=>l.push(x)):l.push(p))}}else n!==null&&typeof n=="object"&&!E(n)&&(l=n[o]);return l}function _t(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=S(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function fr(n){return!(typeof n>"u")}function Et(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=_t(o,Et(p))});else if(n!==null&&typeof n=="object"&&!I(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function dr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Ht(n,o){var l=S();for(var g in n){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}function ot(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Ft(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function pt(n){if(n!==void 0)return n===null?"null":w(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":E(n)?"function":"object"}async function Ce(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!R(n)&&!_(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(M,q){return M>q}}else l=o;var g=async function(M,q){var X=async function(pe,Pe,Se){Pe.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Pe):await l(Pe[0],Se[0])?(pe.push(Se[0]),await X(pe,Pe,Se.slice(1))):(pe.push(Pe[0]),await X(pe,Pe.slice(1),Se))},Oe=[];return await X(Oe,M,q),Oe},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var q=Math.floor(M.length/2),X=M.slice(0,q),Oe=M.slice(q);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},x=await p(n);return x}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=k(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,x=0;x<o.length;x++)if(ge(g,o[x])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);J(M)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:T,average:B,string:V,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Me,trim:Qe,pad:_e,match:ae,contains:et,replace:Fe,split:Ee,join:v,formatNumber:A,formatBase:b,number:P,floor:j,ceil:C,round:F,abs:$,sqrt:K,power:ye,random:we,boolean:J,not:Q,map:G,zip:We,filter:Le,single:st,foldLeft:Ue,sift:y,keys:qe,lookup:vt,append:_t,exists:fr,spread:Et,merge:Z,reverse:dr,each:Ht,error:ot,assert:Ft,type:pt,sort:Ce,shuffle:u,distinct:h,base64encode:at,base64decode:d,encodeUrlComponent:m,encodeUrl:W,decodeUrlComponent:le,decodeUrl:De}})();a.exports=f}).call(this)}).call(this,typeof un<"u"?un:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,a,s){var i=t("./datetime"),c=t("./functions"),f=t("./utils"),w=t("./parser"),_=t("./signature"),R=(function(){var S=f.isNumeric,k=f.isArrayOfStrings,E=f.isArrayOfNumbers,I=f.createSequence,se=f.isSequence,me=f.isFunction,ge=f.isLambda,H=f.isIterable,N=f.isPromise,ne=f.getFunctionArity,L=f.isDeepEqual,T=ot(null);async function B(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await V(u,h,y);break;case"binary":n=await Me(u,h,y);break;case"unary":n=await Qe(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=et(u,h);break;case"descendant":n=Fe(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await C(u,h,y);break;case"bind":n=await $(u,h,y);break;case"regex":n=F(u);break;case"function":n=await he(u,h,y);break;case"variable":n=K(u,h,y);break;case"lambda":n=st(u,h,y);break;case"partial":n=await We(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=we(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await A(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&se(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function V(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=I(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var x=u.steps[p];if(x.tuple&&(l=!0),p===0&&x.consarray?o=await B(x,n,y):l?g=await Ae(x,n,g,y):o=await xe(x,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof x.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=I(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=I(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await A(u.group,l?g:o,y)),o}function de(u,h){var y=ot(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ye(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=I();for(var l=0;l<h.length;l++){var g=await B(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var x=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?x=o[0]:o.forEach(function(M){!Array.isArray(M)||M.cons?x.push(M):M.forEach(q=>x.push(q))}),x}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ye(u,y,n);else{var l=await ye(u,h,n);o=I(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=I(),o.tupleStream=!0;var x=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var M=0;M<y.length;M++){x=de(n,y[M]);var q=await B(u,y[M]["@"],x);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[M]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[M]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[M]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=I();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=I(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=de(y,l));var x=await B(u,g,p);S(x)&&(x=[x]),E(x)?x.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(x)&&n.push(l)}return n}async function Me(u,h,y){var n,o=await B(u.lhs,h,y),l=u.value,g=async()=>await B(u.rhs,h,y);if(l==="and"||l==="or")try{return await De(o,g,l)}catch(x){throw x.position=u.position,x.token=l,x}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=W(o,p,l);break;case"&":n=v(o,p);break;case"..":n=P(o,p);break;case"in":n=le(o,p);break}}catch(x){throw x.position=u.position,x.token=l,x}return n}async function Qe(u,h,y){var n;switch(u.value){case"-":if(n=await B(u.expression,h,y),typeof n>"u")n=void 0;else if(S(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,x)=>(y.isParallelCall=x>0,[p,await B(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await A(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function et(u,h){var y=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ae(o),y=c.append(y,o)):y.push(o)}),y}function ae(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ae(y,h)}):h.push(u),h}function Fe(u,h){var y,n=I();return typeof h<"u"&&(at(h,n),n.length===1?y=n[0]:y=n),y}function at(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){at(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){at(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!S(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!S(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function W(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function le(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function De(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function v(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function A(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],x=l?de(y,p):y,M=0;M<u.lhs.length;M++){var q=u.lhs[M],X=await B(q[0],l?p["@"]:p,x);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:M};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}let pe=await Promise.all(Object.keys(o).map(async(Se,Ze)=>{let ke=o[Se];var je=ke.data,it=y;if(l){var ze=b(ke.data);je=ze["@"],delete ze["@"],it=de(y,ze)}return y.isParallelCall=Ze>0,[Se,await B(u.lhs[ke.exprIndex][1],je,it)]}));for(let Se of pe){var[X,Pe]=await Se;typeof Pe<"u"&&(n[X]=Pe)}return n}function b(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function P(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function $(u,h,y){var n=await B(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await B(u.condition,h,y);return c.boolean(o)?n=await B(u.then,h,y):typeof u.else<"u"&&(n=await B(u.else,h,y)),n}async function C(u,h,y){for(var n,o=ot(y),l=0;l<u.expressions.length;l++)n=await B(u.expressions[l],h,o);return n}function F(u){var h=new Ce.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var x=y(n,h.lastIndex);if(x&&x.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return x}}}return l};return y}function K(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ye(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(x,M){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var Oe=u.terms[X],pe=x,Pe=y;l&&(pe=x["@"],Pe=de(y,x));var Se=await B(Oe.expression,pe,Pe);pe=M,Pe=y,l&&(pe=M["@"],Pe=de(y,M));var Ze=await B(Oe.expression,pe,Pe),ke=typeof Se,je=typeof Ze;if(ke==="undefined"){q=je==="undefined"?0:1;continue}if(je==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?Ze:Se};if(ke!==je)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:Ze};Se!==Ze&&(Se<Ze?q=-1:q=1,Oe.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function we(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!me(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await B(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var x=0;x<p.length;x++){var M=p[x];if(M&&(M.isPrototypeOf(g)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await B(u.update,M,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var Oe in q)M[Oe]=q[Oe]}if(typeof u.delete<"u"){var pe=await B(u.delete,M,y);if(typeof pe<"u"){var Pe=pe;if(Array.isArray(pe)||(pe=[pe]),!k(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Pe};for(var Se=0;Se<pe.length;Se++)typeof M=="object"&&M!==null&&delete M[pe[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var J=w("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await B(u.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await B(u.rhs,h,y);if(!me(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(me(o)){var g=await B(J,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function he(u,h,y,n){var o,l=await B(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const M=await B(u.arguments[p],h,y);if(me(M)){const q=async function(...X){return await G(M,X,null,y)};q.arity=ne(M),g.push(q)}else g.push(M)}var x=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=x,l.position=u.position),o=await G(l,g,h,y)}catch(M){throw M.position||(M.position=u.position),M.token||(M.token=x),M}return o}async function G(u,h,y,n){var o;for(o=await Le(u,h,y,n);ge(o)&&o.thunk===!0;){var l=await B(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await B(o.body.arguments[p],o.input,o.environment));o=await Le(l,g,y,n)}return o}async function Le(u,h,y,n){var o;try{var l=h;if(u&&(l=Ue(u.signature,h,y)),ge(u))o=await qe(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),N(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),N(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function st(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function We(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await B(g,h,y))}var p=await B(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(ge(p))n=vt(p,o);else if(p&&p._jsonata_function===!0)n=_t(p.implementation,o);else if(typeof p=="function")n=_t(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function Ue(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function qe(u,h){var y,n=ot(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await fr(u.body,n):y=await B(u.body,u.input,n),y}function vt(u,h){var y=ot(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function _t(u,h){var y=Et(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=w(n);o.body=u;var l=vt(o,h);return l}async function fr(u,h){var y=Et(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return N(l)&&(l=await l),l}function Et(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=_(h)),y}async function dr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=I(y),y.outerWrapper=!0));try{var n=w(u,!1)}catch(l){throw pt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await B(n,y,this.environment)}catch(l){throw pt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Ht(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ot(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}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(dr,"<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(Ht,"<(oa)-:o>"));var Ft={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function pt(u){var h=Ft[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function Ce(u,h){var y,n;try{y=w(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw pt(g),g}var o=ot(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?Ce.RegexEngine=h.RegexEngine:Ce.RegexEngine=RegExp,{evaluate:async function(g,p,x){if(typeof n<"u"){var M={code:"S0500",position:0};throw pt(M),M}if(typeof p<"u"){var q;q=ot(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!se(g)&&(g=I(g),g.outerWrapper=!0);var Oe;try{return Oe=await B(y,g,q),typeof x=="function"&&x(null,Oe),Oe}catch(pe){throw pt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,x){var M=Z(p,x);o.bind(g,M)},ast:function(){return y},errors:function(){return n}}}return Ce.parser=w,Ce})();a.exports=R},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,a,s){var i=t("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},w={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
\r\v`.indexOf(Me)>-1||Object.prototype.hasOwnProperty.call(f,Me)){if(S.charAt(k)==="$")return Te=S.substring(k+1,ve),k=ve,I("variable",Te);switch(Te=S.substring(k,ve),k=ve,Te){case"or":case"in":case"and":return I("operator",Te);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return k===E&&Te===""?null:I("name",Te)}}else ve++};return me},R=function(S,k){var E,I,se={},me=[],ge=function(){var d=[];E.id!=="(end)"&&d.push({type:E.type,value:E.value,position:E.position});for(var m=I();m!==null;)d.push(m),m=I();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(k)return d.remaining=ge(),d.type="error",me.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var W=se[d];return m=m||0,W?m>=W.lbp&&(W.lbp=m):(W=Object.create(H),W.id=W.value=d,W.lbp=m,se[d]=W),W},ne=function(d){if(k){d.remaining=ge(),me.push(d);var m=se["(error)"];return E=Object.create(m),E.error=d,E.type="(error)",E}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&E.id!==d){var W;E.id==="(end)"?W="S0203":W="S0202";var le={code:W,position:E.position,token:E.value,value:d};return ne(le)}var De=I(m);if(De===null)return E=se["(end)"],E.position=S.length,E;var Ee=De.value,v=De.type,A;switch(v){case"name":case"variable":A=se["(name)"];break;case"operator":if(A=se[Ee],!A)return ne({code:"S0204",stack:new Error().stack,position:De.position,token:Ee});break;case"string":case"number":case"value":A=se["(literal)"];break;case"regex":v="regex",A=se["(regex)"];break;default:return ne({code:"S0205",stack:new Error().stack,position:De.position,token:Ee})}return E=Object.create(A),E.value=Ee,E.type=v,E.position=De.position,E},T=function(d){var m,W=E;for(L(null,!0),m=W.nud();d<E.lbp;)W=E,L(),m=W.led(m);return m},B=function(d){var m=N(d,0);m.nud=function(){return this}},V=function(d,m,W){var le=m||f[d],De=N(d,le);return De.led=W||function(Ee){return this.lhs=Ee,this.rhs=T(le),this.type="binary",this},De},de=function(d,m,W){var le=N(d,m);return le.led=W,le},xe=function(d,m){var W=N(d);return W.nud=m||function(){return this.expression=T(70),this.type="unary",this},W};B("(end)"),B("(name)"),B("(literal)"),B("(regex)"),N(":"),N(";"),N(","),N(")"),N("]"),N("}"),N(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),B("and"),B("or"),B("in"),xe("-"),V("~>"),V("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=T(0),this}),de("(error)",10,function(d){return this.lhs=d,this.error=E.error,this.remaining=ge(),this.type="error",this}),xe("*",function(){return this.type="wildcard",this}),xe("**",function(){return this.type="descendant",this}),xe("%",function(){return this.type="parent",this}),V("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],E.id!==")")for(;E.type==="operator"&&E.id==="?"?(this.type="partial",this.arguments.push(E),L("?")):this.arguments.push(T(0)),E.id===",";)L(",");if(L(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,v){if(Ee.type!=="variable")return ne({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:v+1})}),this.type="lambda",E.id==="<"){for(var m=E.position,W=1,le="<";W>0&&E.id!=="{"&&E.id!=="(end)";){var De=L();De.id===">"?W--:De.id==="<"&&W++,le+=De.value}L(">");try{this.signature=i(le)}catch(Ee){return Ee.position=m+Ee.offset,ne(Ee)}}L("{"),this.body=T(0),L("}")}return this}),xe("(",function(){for(var d=[];E.id!==")"&&(d.push(T(0)),E.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(E.id!=="]")for(;;){var m=T(0);if(E.id===".."){var W={type:"binary",value:"..",position:E.position,lhs:m};L(".."),W.rhs=T(0),m=W}if(d.push(m),E.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),V("[",f["["],function(d){if(E.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}),V("^",f["^"],function(d){L("(");for(var m=[];;){var W={descending:!1};if(E.id==="<"?L("<"):E.id===">"&&(W.descending=!0,L(">")),W.expression=T(0),m.push(W),E.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(E.id!=="}")for(;;){var W=T(0);L(":");var le=T(0);if(m.push([W,le]),E.id!==",")break;L(",")}return L("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Te),V("{",f["{"],Te),de(":=",f[":="],function(d){return d.type!=="variable"?ne({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=T(f[":="]-1),this.type="binary",this)}),V("@",f["@"],function(d){return this.lhs=d,this.rhs=T(f["@"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),V("#",f["#"],function(d){return this.lhs=d,this.rhs=T(f["#"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),V("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=T(0),E.id===":"&&(L(":"),this.else=T(0)),this}),V("?:",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),E.id===","&&(L(","),this.delete=T(0)),L("|"),this});var Ae=function(d){var m;if(d.type==="function"&&!d.predicate){var W={type:"lambda",thunk:!0,arguments:[],position:d.position};W.body=d,m=W}else if(d.type==="condition")d.then=Ae(d.then),typeof d.else<"u"&&(d.else=Ae(d.else)),m=d;else if(d.type==="block"){var le=d.expressions.length;le>0&&(d.expressions[le-1]=Ae(d.expressions[le-1])),m=d}else m=d;return m},ve=0,Me=0,Qe=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(Qe[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var W=d.steps.length-1;for(m=_e(d.steps[W--],m);m.level>0&&W>=0;)m=_e(d.steps[W--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},ue=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var W=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&W.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=W:Array.prototype.push.apply(d.seekingParent,W)}},et=function(d){var m=d.steps.length-1,W=d.steps[m],le=typeof W.seekingParent<"u"?W.seekingParent:[];W.type==="parent"&&le.push(W.slot);for(var De=0;De<le.length;De++){var Ee=le[De];for(m=d.steps.length-2;Ee.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[Ee]:d.seekingParent.push(Ee);break}for(var v=d.steps[m--];m>=0&&v.focus&&d.steps[m].focus;)v=d.steps[m--];Ee=_e(v,Ee)}}},ae=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var W=ae(d.lhs);W.type==="path"?m=W:m={type:"path",steps:[W]},W.type==="parent"&&(m.seekingParent=[W.slot]);var le=ae(d.rhs);le.type==="function"&&le.procedure.type==="path"&&le.procedure.steps.length===1&&le.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=le.procedure.steps[0].value),le.type==="path"?Array.prototype.push.apply(m.steps,le.steps):(typeof le.predicate<"u"&&(le.stages=le.predicate,delete le.predicate),m.steps.push(le)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var De=m.steps[0];De.type==="unary"&&De.value==="["&&(De.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),et(m);break;case"[":m=ae(d.lhs);var v=m,A="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],A="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[A]>"u"&&(v[A]=[]);var b=ae(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?_e(v,F):F.level--}),ue(v,b)),v[A].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ae(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ae(F[0]),ae(F[1])]}),position:d.position};break;case"^":m=ae(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var P={type:"sort",position:d.position};P.terms=d.rhs.map(function(F){var K=ae(F.expression);return ue(P,K),{descending:F.descending,expression:K}}),m.steps.push(P),et(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.rhs);break;case"@":if(m=ae(d.lhs),v=m,m.type==="path"&&(v=m.steps[m.steps.length-1]),typeof v.stages<"u"||typeof v.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(v.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(v.keepArray=!0),v.focus=d.rhs.value,v.tuple=!0;break;case"#":m=ae(d.lhs),v=m,m.type==="path"?v=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof v.predicate<"u"&&(v.stages=v.predicate,delete v.predicate)),typeof v.stages>"u"?v.index=d.rhs.value:v.stages.push({type:"index",value:d.rhs.value,position:d.position}),v.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.lhs),ue(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var K=ae(F);return ue(m,K),K}):d.value==="{"?m.lhs=d.lhs.map(function(F){var K=ae(F[0]);ue(m,K);var ye=ae(F[1]);return ue(m,ye),[K,ye]}):(m.expression=ae(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):ue(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var K=ae(F);return ue(m,K),K}),m.procedure=ae(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var $=ae(d.body);m.body=Ae($);break;case"condition":m={type:d.type,position:d.position},m.condition=ae(d.condition),ue(m,m.condition),m.then=ae(d.then),ue(m,m.then),typeof d.else<"u"&&(m.else=ae(d.else),ue(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ae(d.pattern),m.update=ae(d.update),typeof d.delete<"u"&&(m.delete=ae(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var K=ae(F);return ue(m,K),(K.consarray||K.type==="path"&&K.steps[0].consarray)&&(m.consarray=!0),K});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ve++,level:1,index:Me++}},Qe.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ae(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ae(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var C={code:j,position:d.position,token:d.value};if(k)return me.push(C),{type:"error",error:C};throw C.stack=new Error().stack,C}return d.keepArray&&(m.keepArray=!0),m};I=_(S),L();var Fe=T(0);if(E.id!=="(end)"){var at={code:"S0201",position:E.position,token:E.value};ne(at)}if(Fe=ae(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return me.length>0&&(Fe.errors=me),Fe};return R})();a.exports=c},{"./signature":5}],5:[function(t,a,s){var i=t("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function w(_){for(var R=1,S=[],k={},E=k;R<_.length;){var I=_.charAt(R);if(I===":")break;var se=function(){S.push(k),E=k,k={}},me=function(V,de,xe,Te){for(var Ae=1,ve=de;ve<V.length;)if(ve++,I=V.charAt(ve),I===Te){if(Ae--,Ae===0)break}else I===xe&&Ae++;return ve};switch(I){case"s":case"n":case"b":case"l":case"o":k.regex="["+I+"m]",k.type=I,se();break;case"a":k.regex="[asnblfom]",k.type=I,k.array=!0,se();break;case"f":k.regex="f",k.type=I,se();break;case"j":k.regex="[asnblom]",k.type=I,se();break;case"x":k.regex="[asnblfom]",k.type=I,se();break;case"-":E.context=!0,E.contextRegex=new RegExp(E.regex),E.regex+="?";break;case"?":case"+":E.regex+=I;break;case"(":var ge=me(_,R,"(",")"),H=_.substring(R+1,ge);if(H.indexOf("<")===-1)k.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:R};k.type="("+H+")",R=ge,se();break;case"<":if(E.type==="a"||E.type==="f"){var N=me(_,R,"<",">");E.subtype=_.substring(R+1,N),R=N}else throw{code:"S0401",stack:new Error().stack,value:E.type,offset:R};break}R++}var ne="^"+S.map(function(V){return"("+V.regex+")"}).join("")+"$",L=new RegExp(ne),T=function(V){var de;if(i.isFunction(V))de="f";else{var xe=typeof V;switch(xe){case"string":de="s";break;case"number":de="n";break;case"boolean":de="b";break;case"object":V===null?de="l":Array.isArray(V)?de="a":de="o";break;case"undefined":default:de="m"}}return de},B=function(V,de){for(var xe="^",Te=0,Ae=0;Ae<S.length;Ae++){xe+=S[Ae].regex;var ve=de.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:V[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:V[Te],index:Te+1}};return{definition:_,validate:function(V,de){var xe="";V.forEach(function(Me){xe+=T(Me)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Me,Qe){var _e=V[ve],ue=Te[Qe+1];if(ue==="")if(Me.context&&Me.contextRegex){var et=T(de);if(Me.contextRegex.test(et))Ae.push(de);else throw{code:"T0411",stack:new Error().stack,value:de,index:ve+1}}else Ae.push(_e),ve++;else ue.split("").forEach(function(ae){if(Me.type==="a"){if(ae==="m")_e=void 0;else{_e=V[ve];var Fe=!0;if(typeof Me.subtype<"u"){if(ae!=="a"&&ue!==Me.subtype)Fe=!1;else if(ae==="a"&&_e.length>0){var at=T(_e[0]);if(at!==Me.subtype.charAt(0))Fe=!1;else{var d=_e.filter(function(m){return T(m)!==at});Fe=d.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Me.subtype]};ae!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}B(V,xe)}}}return w})();a.exports=c},{"./utils":6}],6:[function(t,a,s){const i=(()=>{function c(N){var ne=!1;if(typeof N=="number"&&(ne=!isNaN(N),ne&&!isFinite(N)))throw{code:"D1001",value:N,stack:new Error().stack};return ne}function f(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return typeof L!="string"}).length===0),ne}function w(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return!c(L)}).length===0),ne}function _(){var N=[];return N.sequence=!0,arguments.length===1&&N.push(arguments[0]),N}function R(N){return N.sequence===!0&&Array.isArray(N)}function S(N){return N&&(N._jsonata_function===!0||N._jsonata_lambda===!0)||typeof N=="function"}function k(N){var ne=typeof N.arity=="number"?N.arity:typeof N.implementation=="function"?N.implementation.length:typeof N.length=="number"?N.length:N.arguments.length;return ne}function E(N){return N&&N._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function se(N){return typeof N=="object"&&N!==null&&I in N&&"next"in N&&typeof N.next=="function"}function me(N,ne){if(N===ne)return!0;if(typeof N=="object"&&typeof ne=="object"&&N!==null&&ne!==null){if(Array.isArray(N)&&Array.isArray(ne)){if(N.length!==ne.length)return!1;for(var L=0;L<N.length;L++)if(!me(N[L],ne[L]))return!1;return!0}var T=Object.getOwnPropertyNames(N),B=Object.getOwnPropertyNames(ne);if(T.length!==B.length)return!1;for(T=T.sort(),B=B.sort(),L=0;L<T.length;L++)if(T[L]!==B[L])return!1;for(L=0;L<T.length;L++){var V=T[L];if(!me(N[V],ne[V]))return!1}return!0}return!1}function ge(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function H(N){var ne=[];for(let L of N)ne.push(L);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:w,createSequence:_,isSequence:R,isFunction:S,isLambda:E,isIterable:se,getFunctionArity:k,isDeepEqual:me,stringToArray:H,isPromise:ge}})();a.exports=i},{}]},{},[3])(3)})})(Dr)),Dr.exports}var Us=$s();const Bs=Fs(Us),en=O.object({name:O.literal("data-extract"),code:O.string(),inputData:O.any().optional()});function Ls(r){return en.parse(r)}async function Zs(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Bs(r.code).evaluate(r.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:t}}catch(e){return console.error("[DataExtractBlock] Data extraction error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in data extraction",data:void 0}}}const zs={"get-text":Ur,"attribute-value":Br,"get-value-form":Lr,"set-value-form":Zr,"clear-value-form":zr,"element-exists":Vr,"event-click":Wr,keypress:qr,wait:Hr,"wait-for-condition":Gr,navigate:Yr,"save-assets":Jr,"get-element-data":Kr,scroll:Xr,"ai-parse-data":$r,"fetch-api":Qr,"data-extract":en};class Vs{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=Ha(e);return await Ga(t)}case"attribute-value":{const t=Ja(e);return await Ka(t)}case"get-value-form":{const t=Xa(e);return await Qa(t)}case"set-value-form":{const t=ts(e);return await rs(t)}case"clear-value-form":{const t=as(e);return await ss(t)}case"element-exists":{const t=os(e);return await cs(t)}case"event-click":{const t=us(e);return await ls(t)}case"keypress":{const t=ps(e);return await ms(t)}case"wait":{const t=gs(e);return await vs(t)}case"wait-for-condition":{const t=bs(e);return await ws(t)}case"navigate":{const t=ks(e);return await xs(t)}case"save-assets":{const t=_s(e);return await Es(t)}case"get-element-data":{const t=As(e);return await Ss(t)}case"scroll":{const t=Os(e);return await Ds(t)}case"ai-parse-data":{const t=ja(e);return await Fa(t)}case"fetch-api":{const t=Is(e);return await js(t)}case"data-extract":{const t=Ls(e);return await Zs(t)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(t){return{hasError:!0,message:t instanceof Error?t.message:"Unknown error in block execution",data:null}}}}class Ws{constructor(){fe(this,"expr");fe(this,"json")}}class qs{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class Hs{constructor(){fe(this,"id");fe(this,"title");fe(this,"when");fe(this,"block");fe(this,"repeat");fe(this,"next");fe(this,"onSuccess");fe(this,"onFailure");fe(this,"switch");fe(this,"timeoutMs");fe(this,"retry");fe(this,"delayAfterMs")}}class Gs{constructor(){fe(this,"version");fe(this,"id");fe(this,"title");fe(this,"description");fe(this,"start");fe(this,"steps");fe(this,"vars");fe(this,"defaultDelayMs")}}class Ys{constructor(){fe(this,"stepId");fe(this,"skipped");fe(this,"success");fe(this,"message");fe(this,"result");fe(this,"startedAt");fe(this,"finishedAt");fe(this,"attempts")}}class Js{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}exports.AiParseDataBlockSchema=$r;exports.AllBlockSchemas=zs;exports.BaseBlockSchema=dt;exports.Binding=qs;exports.BlockHandler=Vs;exports.ClearValueFormsBlockSchema=zr;exports.CollectWorkflowResult=Js;exports.Condition=Ws;exports.DataExtractBlockSchema=en;exports.EightGClient=An;exports.EightGError=At;exports.ElementExistsBlockSchema=Vr;exports.EventClickBlockSchema=Wr;exports.FetchApiBlockSchema=Qr;exports.GetAttributeValueBlockSchema=Br;exports.GetElementDataBlockSchema=Kr;exports.GetTextBlockSchema=Ur;exports.GetValueFormsBlockSchema=Lr;exports.KeypressBlockSchema=qr;exports.NavigateBlockSchema=Yr;exports.SaveAssetsBlockSchema=Jr;exports.Schema=Ba;exports.ScrollBlockSchema=Xr;exports.SetValueFormsBlockSchema=Zr;exports.WaitBlockSchema=Hr;exports.WaitForConditionBlockSchema=Gr;exports.Workflow=Gs;exports.WorkflowStep=Hs;exports.WorkflowStepRunResult=Ys;exports.createArraySchema=Ua;exports.createSchema=$a;
|
|
1
|
+
"use strict";var Ea=Object.defineProperty;var Sa=(r,e,t)=>e in r?Ea(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var G=(r,e,t)=>Sa(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class pt extends Error{constructor(e,t,n){super(e),this.code=t,this.details=n,this.name="EightGError"}static extensionNotInstalled(){return new pt("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new pt(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new pt(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const t=Math.floor(e/1e3);return new pt(`Request timeout - Extension did not respond within ${t} seconds`,"REQUEST_TIMEOUT")}}function Aa(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}var ve;(function(r){r[r.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",r[r.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",r[r.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(ve||(ve={}));var Ta=(function(){function r(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return r.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},r.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},r.prototype.findTransformMetadatas=function(e,t,n){return this.findMetadatas(this._transformMetadatas,e,t).filter(function(a){return!a.options||a.options.toClassOnly===!0&&a.options.toPlainOnly===!0?!0:a.options.toClassOnly===!0?n===ve.CLASS_TO_CLASS||n===ve.PLAIN_TO_CLASS:a.options.toPlainOnly===!0?n===ve.CLASS_TO_PLAIN:!0})},r.prototype.findExcludeMetadata=function(e,t){return this.findMetadata(this._excludeMetadatas,e,t)},r.prototype.findExposeMetadata=function(e,t){return this.findMetadata(this._exposeMetadatas,e,t)},r.prototype.findExposeMetadataByCustomName=function(e,t){return this.getExposedMetadatas(e).find(function(n){return n.options&&n.options.name===t})},r.prototype.findTypeMetadata=function(e,t){return this.findMetadata(this._typeMetadatas,e,t)},r.prototype.getStrategy=function(e){var t=this._excludeMetadatas.get(e),n=t&&t.get(void 0),a=this._exposeMetadatas.get(e),i=a&&a.get(void 0);return n&&i||!n&&!i?"none":n?"excludeAll":"exposeAll"},r.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},r.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},r.prototype.getExposedProperties=function(e,t){return this.getExposedMetadatas(e).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?t===ve.CLASS_TO_CLASS||t===ve.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?t===ve.CLASS_TO_PLAIN:!0}).map(function(n){return n.propertyName})},r.prototype.getExcludedProperties=function(e,t){return this.getExcludedMetadatas(e).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?t===ve.CLASS_TO_CLASS||t===ve.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?t===ve.CLASS_TO_PLAIN:!0}).map(function(n){return n.propertyName})},r.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},r.prototype.getMetadata=function(e,t){var n=e.get(t),a;n&&(a=Array.from(n.values()).filter(function(w){return w.propertyName!==void 0}));for(var i=[],o=0,c=this.getAncestors(t);o<c.length;o++){var d=c[o],p=e.get(d);if(p){var S=Array.from(p.values()).filter(function(w){return w.propertyName!==void 0});i.push.apply(i,S)}}return i.concat(a||[])},r.prototype.findMetadata=function(e,t,n){var a=e.get(t);if(a){var i=a.get(n);if(i)return i}for(var o=0,c=this.getAncestors(t);o<c.length;o++){var d=c[o],p=e.get(d);if(p){var S=p.get(n);if(S)return S}}},r.prototype.findMetadatas=function(e,t,n){var a=e.get(t),i;a&&(i=a.get(n));for(var o=[],c=0,d=this.getAncestors(t);c<d.length;c++){var p=d[c],S=e.get(p);S&&S.has(n)&&o.push.apply(o,S.get(n))}return o.slice().reverse().concat((i||[]).slice().reverse())},r.prototype.getAncestors=function(e){if(!e)return[];if(!this._ancestorsMap.has(e)){for(var t=[],n=Object.getPrototypeOf(e.prototype.constructor);typeof n.prototype<"u";n=Object.getPrototypeOf(n.prototype.constructor))t.push(n);this._ancestorsMap.set(e,t)}return this._ancestorsMap.get(e)},r})(),Qe=new Ta;function Oa(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self}function Ca(r){return r!==null&&typeof r=="object"&&typeof r.then=="function"}var Vn=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))};function Da(r){var e=new r;return!(e instanceof Set)&&!("push"in e)?[]:e}var Jt=(function(){function r(e,t){this.transformationType=e,this.options=t,this.recursionStack=new Set}return r.prototype.transform=function(e,t,n,a,i,o){var c=this;if(o===void 0&&(o=0),Array.isArray(t)||t instanceof Set){var d=a&&this.transformationType===ve.PLAIN_TO_CLASS?Da(a):[];return t.forEach(function(q,ee){var $=e?e[ee]:void 0;if(!c.options.enableCircularCheck||!c.isCircular(q)){var C=void 0;if(typeof n!="function"&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(c.transformationType===ve.PLAIN_TO_CLASS){C=n.options.discriminator.subTypes.find(function(j){return j.name===q[n.options.discriminator.property]});var M={newObject:d,object:q,property:void 0},D=n.typeFunction(M);C===void 0?C=D:C=C.value,n.options.keepDiscriminatorProperty||delete q[n.options.discriminator.property]}c.transformationType===ve.CLASS_TO_CLASS&&(C=q.constructor),c.transformationType===ve.CLASS_TO_PLAIN&&(q[n.options.discriminator.property]=n.options.discriminator.subTypes.find(function(j){return j.value===q.constructor}).name)}else C=n;var x=c.transform($,q,C,void 0,q instanceof Map,o+1);d instanceof Set?d.add(x):d.push(x)}else c.transformationType===ve.CLASS_TO_CLASS&&(d instanceof Set?d.add(q):d.push(q))}),d}else{if(n===String&&!i)return t==null?t:String(t);if(n===Number&&!i)return t==null?t:Number(t);if(n===Boolean&&!i)return t==null?t:!!t;if((n===Date||t instanceof Date)&&!i)return t instanceof Date?new Date(t.valueOf()):t==null?t:new Date(t);if(Oa().Buffer&&(n===Buffer||t instanceof Buffer)&&!i)return t==null?t:Buffer.from(t);if(Ca(t)&&!i)return new Promise(function(q,ee){t.then(function($){return q(c.transform(void 0,$,n,void 0,void 0,o+1))},ee)});if(!i&&t!==null&&typeof t=="object"&&typeof t.then=="function")return t;if(typeof t=="object"&&t!==null){!n&&t.constructor!==Object&&(!Array.isArray(t)&&t.constructor===Array||(n=t.constructor)),!n&&e&&(n=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(t);var p=this.getKeys(n,t,i),S=e||{};!e&&(this.transformationType===ve.PLAIN_TO_CLASS||this.transformationType===ve.CLASS_TO_CLASS)&&(i?S=new Map:n?S=new n:S={});for(var w=function(q){if(q==="__proto__"||q==="constructor")return"continue";var ee=q,$=q,C=q;if(!h.options.ignoreDecorators&&n){if(h.transformationType===ve.PLAIN_TO_CLASS){var M=Qe.findExposeMetadataByCustomName(n,q);M&&(C=M.propertyName,$=M.propertyName)}else if(h.transformationType===ve.CLASS_TO_PLAIN||h.transformationType===ve.CLASS_TO_CLASS){var M=Qe.findExposeMetadata(n,q);M&&M.options&&M.options.name&&($=M.options.name)}}var D=void 0;h.transformationType===ve.PLAIN_TO_CLASS?D=t[ee]:t instanceof Map?D=t.get(ee):t[ee]instanceof Function?D=t[ee]():D=t[ee];var x=void 0,j=D instanceof Map;if(n&&i)x=n;else if(n){var F=Qe.findTypeMetadata(n,C);if(F){var fe={newObject:S,object:t,property:C},ie=F.typeFunction?F.typeFunction(fe):F.reflectedType;F.options&&F.options.discriminator&&F.options.discriminator.property&&F.options.discriminator.subTypes?t[ee]instanceof Array?x=F:(h.transformationType===ve.PLAIN_TO_CLASS&&(x=F.options.discriminator.subTypes.find(function(se){if(D&&D instanceof Object&&F.options.discriminator.property in D)return se.name===D[F.options.discriminator.property]}),x===void 0?x=ie:x=x.value,F.options.keepDiscriminatorProperty||D&&D instanceof Object&&F.options.discriminator.property in D&&delete D[F.options.discriminator.property]),h.transformationType===ve.CLASS_TO_CLASS&&(x=D.constructor),h.transformationType===ve.CLASS_TO_PLAIN&&D&&(D[F.options.discriminator.property]=F.options.discriminator.subTypes.find(function(se){return se.value===D.constructor}).name)):x=ie,j=j||F.reflectedType===Map}else if(h.options.targetMaps)h.options.targetMaps.filter(function(se){return se.target===n&&!!se.properties[C]}).forEach(function(se){return x=se.properties[C]});else if(h.options.enableImplicitConversion&&h.transformationType===ve.PLAIN_TO_CLASS){var be=Reflect.getMetadata("design:type",n.prototype,C);be&&(x=be)}}var xe=Array.isArray(t[ee])?h.getReflectedType(n,C):void 0,he=e?e[ee]:void 0;if(S.constructor.prototype){var Oe=Object.getOwnPropertyDescriptor(S.constructor.prototype,$);if((h.transformationType===ve.PLAIN_TO_CLASS||h.transformationType===ve.CLASS_TO_CLASS)&&(Oe&&!Oe.set||S[$]instanceof Function))return"continue"}if(!h.options.enableCircularCheck||!h.isCircular(D)){var Ue=h.transformationType===ve.PLAIN_TO_CLASS?$:q,te=void 0;h.transformationType===ve.CLASS_TO_PLAIN?(te=t[Ue],te=h.applyCustomTransformations(te,n,Ue,t,h.transformationType),te=t[Ue]===te?D:te,te=h.transform(he,te,x,xe,j,o+1)):D===void 0&&h.options.exposeDefaultValues?te=S[$]:(te=h.transform(he,D,x,xe,j,o+1),te=h.applyCustomTransformations(te,n,Ue,t,h.transformationType)),(te!==void 0||h.options.exposeUnsetFields)&&(S instanceof Map?S.set($,te):S[$]=te)}else if(h.transformationType===ve.CLASS_TO_CLASS){var te=D;te=h.applyCustomTransformations(te,n,q,t,h.transformationType),(te!==void 0||h.options.exposeUnsetFields)&&(S instanceof Map?S.set($,te):S[$]=te)}},h=this,_=0,I=p;_<I.length;_++){var Q=I[_];w(Q)}return this.options.enableCircularCheck&&this.recursionStack.delete(t),S}else return t}},r.prototype.applyCustomTransformations=function(e,t,n,a,i){var o=this,c=Qe.findTransformMetadatas(t,n,this.transformationType);return this.options.version!==void 0&&(c=c.filter(function(d){return d.options?o.checkVersion(d.options.since,d.options.until):!0})),this.options.groups&&this.options.groups.length?c=c.filter(function(d){return d.options?o.checkGroups(d.options.groups):!0}):c=c.filter(function(d){return!d.options||!d.options.groups||!d.options.groups.length}),c.forEach(function(d){e=d.transformFn({value:e,key:n,obj:a,type:i,options:o.options})}),e},r.prototype.isCircular=function(e){return this.recursionStack.has(e)},r.prototype.getReflectedType=function(e,t){if(e){var n=Qe.findTypeMetadata(e,t);return n?n.reflectedType:void 0}},r.prototype.getKeys=function(e,t,n){var a=this,i=Qe.getStrategy(e);i==="none"&&(i=this.options.strategy||"exposeAll");var o=[];if((i==="exposeAll"||n)&&(t instanceof Map?o=Array.from(t.keys()):o=Object.keys(t)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&e){var c=Qe.getExposedProperties(e,this.transformationType),d=Qe.getExcludedProperties(e,this.transformationType);o=Vn(Vn([],c,!0),d,!0)}if(!this.options.ignoreDecorators&&e){var c=Qe.getExposedProperties(e,this.transformationType);this.transformationType===ve.PLAIN_TO_CLASS&&(c=c.map(function(w){var h=Qe.findExposeMetadata(e,w);return h&&h.options&&h.options.name?h.options.name:w})),this.options.excludeExtraneousValues?o=c:o=o.concat(c);var p=Qe.getExcludedProperties(e,this.transformationType);p.length>0&&(o=o.filter(function(w){return!p.includes(w)})),this.options.version!==void 0&&(o=o.filter(function(w){var h=Qe.findExposeMetadata(e,w);return!h||!h.options?!0:a.checkVersion(h.options.since,h.options.until)})),this.options.groups&&this.options.groups.length?o=o.filter(function(w){var h=Qe.findExposeMetadata(e,w);return!h||!h.options?!0:a.checkGroups(h.options.groups)}):o=o.filter(function(w){var h=Qe.findExposeMetadata(e,w);return!h||!h.options||!h.options.groups||!h.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter(function(S){return a.options.excludePrefixes.every(function(w){return S.substr(0,w.length)!==w})})),o=o.filter(function(S,w,h){return h.indexOf(S)===w}),o},r.prototype.checkVersion=function(e,t){var n=!0;return n&&e&&(n=this.options.version>=e),n&&t&&(n=this.options.version<t),n},r.prototype.checkGroups=function(e){return e?this.options.groups.some(function(t){return e.includes(t)}):!0},r})(),Kt={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},it=function(){return it=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a])}return r},it.apply(this,arguments)},Ma=(function(){function r(){}return r.prototype.instanceToPlain=function(e,t){var n=new Jt(ve.CLASS_TO_PLAIN,it(it({},Kt),t));return n.transform(void 0,e,void 0,void 0,void 0,void 0)},r.prototype.classToPlainFromExist=function(e,t,n){var a=new Jt(ve.CLASS_TO_PLAIN,it(it({},Kt),n));return a.transform(t,e,void 0,void 0,void 0,void 0)},r.prototype.plainToInstance=function(e,t,n){var a=new Jt(ve.PLAIN_TO_CLASS,it(it({},Kt),n));return a.transform(void 0,t,e,void 0,void 0,void 0)},r.prototype.plainToClassFromExist=function(e,t,n){var a=new Jt(ve.PLAIN_TO_CLASS,it(it({},Kt),n));return a.transform(e,t,void 0,void 0,void 0,void 0)},r.prototype.instanceToInstance=function(e,t){var n=new Jt(ve.CLASS_TO_CLASS,it(it({},Kt),t));return n.transform(void 0,e,void 0,void 0,void 0,void 0)},r.prototype.classToClassFromExist=function(e,t,n){var a=new Jt(ve.CLASS_TO_CLASS,it(it({},Kt),n));return a.transform(t,e,void 0,void 0,void 0,void 0)},r.prototype.serialize=function(e,t){return JSON.stringify(this.instanceToPlain(e,t))},r.prototype.deserialize=function(e,t,n){var a=JSON.parse(t);return this.plainToInstance(e,a,n)},r.prototype.deserializeArray=function(e,t,n){var a=JSON.parse(t);return this.plainToInstance(e,a,n)},r})();function Ar(r,e){return e===void 0&&(e={}),function(t,n){var a=Reflect.getMetadata("design:type",t,n);Qe.addTypeMetadata({target:t.constructor,propertyName:n,reflectedType:a,typeFunction:r,options:e})}}var Pa=new Ma;function Fr(r,e,t){return Pa.plainToInstance(r,e,t)}var en=(function(){function r(e){this.groups=[],this.each=!1,this.context=void 0,this.type=e.type,this.name=e.name,this.target=e.target,this.propertyName=e.propertyName,this.constraints=e==null?void 0:e.constraints,this.constraintCls=e.constraintCls,this.validationTypeOptions=e.validationTypeOptions,e.validationOptions&&(this.message=e.validationOptions.message,this.groups=e.validationOptions.groups,this.always=e.validationOptions.always,this.each=e.validationOptions.each,this.context=e.validationOptions.context)}return r})(),Na=(function(){function r(){}return r.prototype.transform=function(e){var t=[];return Object.keys(e.properties).forEach(function(n){e.properties[n].forEach(function(a){var i={message:a.message,groups:a.groups,always:a.always,each:a.each},o={type:a.type,name:a.name,target:e.name,propertyName:n,constraints:a.constraints,validationTypeOptions:a.options,validationOptions:i};t.push(new en(o))})}),t},r})();function Ia(r){return r instanceof Map?Array.from(r.values()):Array.isArray(r)?r:Array.from(r)}function Fa(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self}function an(r){return r!==null&&typeof r=="object"&&typeof r.then=="function"}var La=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Zn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(c){o={error:c}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return i},Ra=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))},oa=(function(){function r(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(r.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),r.prototype.addValidationSchema=function(e){var t=this,n=new Na().transform(e);n.forEach(function(a){return t.addValidationMetadata(a)})},r.prototype.addValidationMetadata=function(e){var t=this.validationMetadatas.get(e.target);t?t.push(e):this.validationMetadatas.set(e.target,[e])},r.prototype.addConstraintMetadata=function(e){var t=this.constraintMetadatas.get(e.target);t?t.push(e):this.constraintMetadatas.set(e.target,[e])},r.prototype.groupByPropertyName=function(e){var t={};return e.forEach(function(n){t[n.propertyName]||(t[n.propertyName]=[]),t[n.propertyName].push(n)}),t},r.prototype.getTargetValidationMetadatas=function(e,t,n,a,i){var o,c,d=function(M){return typeof M.always<"u"?M.always:M.groups&&M.groups.length?!1:n},p=function(M){return!!(a&&(!i||!i.length)&&M.groups&&M.groups.length)},S=this.validationMetadatas.get(e)||[],w=S.filter(function(M){return M.target!==e&&M.target!==t?!1:d(M)?!0:p(M)?!1:i&&i.length>0?M.groups&&!!M.groups.find(function(D){return i.indexOf(D)!==-1}):!0}),h=[];try{for(var _=La(this.validationMetadatas.entries()),I=_.next();!I.done;I=_.next()){var Q=Zn(I.value,2),q=Q[0],ee=Q[1];e.prototype instanceof q&&h.push.apply(h,Ra([],Zn(ee),!1))}}catch(M){o={error:M}}finally{try{I&&!I.done&&(c=_.return)&&c.call(_)}finally{if(o)throw o.error}}var $=h.filter(function(M){return typeof M.target=="string"||M.target===e||M.target instanceof Function&&!(e.prototype instanceof M.target)?!1:d(M)?!0:p(M)?!1:i&&i.length>0?M.groups&&!!M.groups.find(function(D){return i.indexOf(D)!==-1}):!0}),C=$.filter(function(M){return!w.find(function(D){return D.propertyName===M.propertyName&&D.type===M.type})});return w.concat(C)},r.prototype.getTargetValidatorConstraints=function(e){return this.constraintMetadatas.get(e)||[]},r})();function dr(){var r=Fa();return r.classValidatorMetadataStorage||(r.classValidatorMetadataStorage=new oa),r.classValidatorMetadataStorage}var Wn=(function(){function r(){}return r.prototype.toString=function(e,t,n,a){var i=this;e===void 0&&(e=!1),t===void 0&&(t=!1),n===void 0&&(n=""),a===void 0&&(a=!1);var o=e?"\x1B[1m":"",c=e?"\x1B[22m":"",d=function(){var w;return(a?Object.values:Object.keys)((w=i.constraints)!==null&&w!==void 0?w:{}).join(", ")},p=function(w){return" - property ".concat(o).concat(n).concat(w).concat(c," has failed the following constraints: ").concat(o).concat(d()).concat(c,`
|
|
2
|
+
`)};if(t){var S=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?p(S):this.children?this.children.map(function(w){return w.toString(e,!0,"".concat(n).concat(S),a)}).join(""):""}else return"An instance of ".concat(o).concat(this.target?this.target.constructor.name:"an object").concat(c,` has failed the validation:
|
|
3
|
+
`)+(this.constraints?p(this.property):"")+(this.children?this.children.map(function(w){return w.toString(e,!0,i.property,a)}).join(""):"")},r})(),et=(function(){function r(){}return r.isValid=function(e){var t=this;return e!=="isValid"&&e!=="getMessage"&&Object.keys(this).map(function(n){return t[n]}).indexOf(e)!==-1},r.CUSTOM_VALIDATION="customValidation",r.NESTED_VALIDATION="nestedValidation",r.PROMISE_VALIDATION="promiseValidation",r.CONDITIONAL_VALIDATION="conditionalValidation",r.WHITELIST="whitelistValidation",r.IS_DEFINED="isDefined",r})();function ja(r){return Array.isArray(r)?r.join(", "):(typeof r=="symbol"&&(r=r.description),"".concat(r))}var $a=(function(){function r(){}return r.replaceMessageSpecialTokens=function(e,t){var n;return e instanceof Function?n=e(t):typeof e=="string"&&(n=e),n&&Array.isArray(t.constraints)&&t.constraints.forEach(function(a,i){n=n.replace(new RegExp("\\$constraint".concat(i+1),"g"),ja(a))}),n&&t.value!==void 0&&t.value!==null&&["string","boolean","number"].includes(typeof t.value)&&(n=n.replace(/\$value/g,t.value)),n&&(n=n.replace(/\$property/g,t.property)),n&&(n=n.replace(/\$target/g,t.targetName)),n},r})(),fr=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(c){o={error:c}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return i},zn=(function(){function r(e,t){this.validator=e,this.validatorOptions=t,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=dr()}return r.prototype.execute=function(e,t,n){var a=this,i,o;!this.metadataStorage.hasValidationMetaData&&((i=this.validatorOptions)===null||i===void 0?void 0:i.enableDebugMessages)===!0&&console.warn(`No validation metadata found. No validation will be performed. There are multiple possible reasons:
|
|
4
|
+
- There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.
|
|
5
|
+
- This validation runs before any file with validation decorator was parsed by NodeJS.`);var c=this.validatorOptions?this.validatorOptions.groups:void 0,d=this.validatorOptions&&this.validatorOptions.strictGroups||!1,p=this.validatorOptions&&this.validatorOptions.always||!1,S=((o=this.validatorOptions)===null||o===void 0?void 0:o.forbidUnknownValues)===void 0||this.validatorOptions.forbidUnknownValues!==!1,w=this.metadataStorage.getTargetValidationMetadatas(e.constructor,t,p,d,c),h=this.metadataStorage.groupByPropertyName(w);if(S&&!w.length){var _=new Wn;(!this.validatorOptions||!this.validatorOptions.validationError||this.validatorOptions.validationError.target===void 0||this.validatorOptions.validationError.target===!0)&&(_.target=e),_.value=void 0,_.property=void 0,_.children=[],_.constraints={unknownValue:"an unknown value was passed to the validate function"},n.push(_);return}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(e,h,n),Object.keys(h).forEach(function(I){var Q=e[I],q=h[I].filter(function($){return $.type===et.IS_DEFINED}),ee=h[I].filter(function($){return $.type!==et.IS_DEFINED&&$.type!==et.WHITELIST});Q instanceof Promise&&ee.find(function($){return $.type===et.PROMISE_VALIDATION})?a.awaitingPromises.push(Q.then(function($){a.performValidations(e,$,I,q,ee,n)})):a.performValidations(e,Q,I,q,ee,n)})},r.prototype.whitelist=function(e,t,n){var a=this,i=[];Object.keys(e).forEach(function(o){(!t[o]||t[o].length===0)&&i.push(o)}),i.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?i.forEach(function(o){var c,d=a.generateValidationError(e,e[o],o);d.constraints=(c={},c[et.WHITELIST]="property ".concat(o," should not exist"),c),d.children=void 0,n.push(d)}):i.forEach(function(o){return delete e[o]}))},r.prototype.stripEmptyErrors=function(e){var t=this;return e.filter(function(n){if(n.children&&(n.children=t.stripEmptyErrors(n.children)),Object.keys(n.constraints).length===0){if(n.children.length===0)return!1;delete n.constraints}return!0})},r.prototype.performValidations=function(e,t,n,a,i,o){var c=i.filter(function(h){return h.type===et.CUSTOM_VALIDATION}),d=i.filter(function(h){return h.type===et.NESTED_VALIDATION}),p=i.filter(function(h){return h.type===et.CONDITIONAL_VALIDATION}),S=this.generateValidationError(e,t,n);o.push(S);var w=this.conditionalValidations(e,t,p);w&&(this.customValidations(e,t,a,S),this.mapContexts(e,t,a,S),!(t===void 0&&this.validatorOptions&&this.validatorOptions.skipUndefinedProperties===!0)&&(t===null&&this.validatorOptions&&this.validatorOptions.skipNullProperties===!0||t==null&&this.validatorOptions&&this.validatorOptions.skipMissingProperties===!0||(this.customValidations(e,t,c,S),this.nestedValidations(t,d,S),this.mapContexts(e,t,i,S),this.mapContexts(e,t,c,S))))},r.prototype.generateValidationError=function(e,t,n){var a=new Wn;return(!this.validatorOptions||!this.validatorOptions.validationError||this.validatorOptions.validationError.target===void 0||this.validatorOptions.validationError.target===!0)&&(a.target=e),(!this.validatorOptions||!this.validatorOptions.validationError||this.validatorOptions.validationError.value===void 0||this.validatorOptions.validationError.value===!0)&&(a.value=t),a.property=n,a.children=[],a.constraints={},a},r.prototype.conditionalValidations=function(e,t,n){return n.map(function(a){return a.constraints[0](e,t)}).reduce(function(a,i){return a&&i},!0)},r.prototype.customValidations=function(e,t,n,a){var i=this;n.forEach(function(o){i.metadataStorage.getTargetValidatorConstraints(o.constraintCls).forEach(function(c){if(!(c.async&&i.ignoreAsyncValidations)&&!(i.validatorOptions&&i.validatorOptions.stopAtFirstError&&Object.keys(a.constraints||{}).length>0)){var d={targetName:e.constructor?e.constructor.name:void 0,property:o.propertyName,object:e,value:t,constraints:o.constraints};if(!o.each||!(Array.isArray(t)||t instanceof Set||t instanceof Map)){var p=c.instance.validate(t,d);if(an(p)){var S=p.then(function(D){if(!D){var x=fr(i.createValidationError(e,t,o,c),2),j=x[0],F=x[1];a.constraints[j]=F,o.context&&(a.contexts||(a.contexts={}),a.contexts[j]=Object.assign(a.contexts[j]||{},o.context))}});i.awaitingPromises.push(S)}else if(!p){var w=fr(i.createValidationError(e,t,o,c),2),h=w[0],_=w[1];a.constraints[h]=_}return}var I=Ia(t),Q=I.map(function(D){return c.instance.validate(D,d)}),q=Q.some(function(D){return an(D)});if(q){var ee=Q.map(function(D){return an(D)?D:Promise.resolve(D)}),$=Promise.all(ee).then(function(D){var x=D.every(function(ie){return ie});if(!x){var j=fr(i.createValidationError(e,t,o,c),2),F=j[0],fe=j[1];a.constraints[F]=fe,o.context&&(a.contexts||(a.contexts={}),a.contexts[F]=Object.assign(a.contexts[F]||{},o.context))}});i.awaitingPromises.push($);return}var C=Q.every(function(D){return D});if(!C){var M=fr(i.createValidationError(e,t,o,c),2),h=M[0],_=M[1];a.constraints[h]=_}}})})},r.prototype.nestedValidations=function(e,t,n){var a=this;e!==void 0&&t.forEach(function(i){if(!(i.type!==et.NESTED_VALIDATION&&i.type!==et.PROMISE_VALIDATION)&&!(a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(e)||e instanceof Set||e instanceof Map){var o=e instanceof Set?Array.from(e):e;o.forEach(function(w,h){a.performValidations(e,w,h.toString(),[],t,n.children)})}else if(e instanceof Object){var c=typeof i.target=="string"?i.target:i.target.name;a.execute(e,c,n.children)}else{var d=fr(a.createValidationError(i.target,e,i),2),p=d[0],S=d[1];n.constraints[p]=S}})},r.prototype.mapContexts=function(e,t,n,a){var i=this;return n.forEach(function(o){if(o.context){var c=void 0;if(o.type===et.CUSTOM_VALIDATION){var d=i.metadataStorage.getTargetValidatorConstraints(o.constraintCls);c=d[0]}var p=i.getConstraintType(o,c);a.constraints[p]&&(a.contexts||(a.contexts={}),a.contexts[p]=Object.assign(a.contexts[p]||{},o.context))}})},r.prototype.createValidationError=function(e,t,n,a){var i=e.constructor?e.constructor.name:void 0,o=this.getConstraintType(n,a),c={targetName:i,property:n.propertyName,object:e,value:t,constraints:n.constraints},d=n.message||"";!n.message&&(!this.validatorOptions||this.validatorOptions&&!this.validatorOptions.dismissDefaultMessages)&&a&&a.instance.defaultMessage instanceof Function&&(d=a.instance.defaultMessage(c));var p=$a.replaceMessageSpecialTokens(d,c);return[o,p]},r.prototype.getConstraintType=function(e,t){var n=t&&t.name?t.name:e.type;return n},r})(),Ba=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function c(S){try{p(n.next(S))}catch(w){o(w)}}function d(S){try{p(n.throw(S))}catch(w){o(w)}}function p(S){S.done?i(S.value):a(S.value).then(c,d)}p((n=n.apply(r,e||[])).next())})},Ua=function(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,a,i,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(p){return function(S){return d([p,S])}}function d(p){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,p[0]&&(t=0)),t;)try{if(n=1,a&&(i=p[0]&2?a.return:p[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,p[1])).done)return i;switch(a=0,i&&(p=[p[0]&2,i.value]),p[0]){case 0:case 1:i=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,a=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!i||p[1]>i[0]&&p[1]<i[3])){t.label=p[1];break}if(p[0]===6&&t.label<i[1]){t.label=i[1],i=p;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(p);break}i[2]&&t.ops.pop(),t.trys.pop();continue}p=e.call(r,t)}catch(S){p=[6,S],a=0}finally{n=i=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},qn=(function(){function r(){}return r.prototype.validate=function(e,t,n){return this.coreValidate(e,t,n)},r.prototype.validateOrReject=function(e,t,n){return Ba(this,void 0,void 0,function(){var a;return Ua(this,function(i){switch(i.label){case 0:return[4,this.coreValidate(e,t,n)];case 1:return a=i.sent(),a.length?[2,Promise.reject(a)]:[2]}})})},r.prototype.validateSync=function(e,t,n){var a=typeof e=="string"?t:e,i=typeof e=="string"?n:t,o=typeof e=="string"?e:void 0,c=new zn(this,i);c.ignoreAsyncValidations=!0;var d=[];return c.execute(a,o,d),c.stripEmptyErrors(d)},r.prototype.coreValidate=function(e,t,n){var a=typeof e=="string"?t:e,i=typeof e=="string"?n:t,o=typeof e=="string"?e:void 0,c=new zn(this,i),d=[];return c.execute(a,o,d),Promise.all(c.awaitingPromises).then(function(){return c.stripEmptyErrors(d)})},r})(),Va=new((function(){function r(){this.instances=[]}return r.prototype.get=function(e){var t=this.instances.find(function(n){return n.type===e});return t||(t={type:e,object:new e},this.instances.push(t)),t.object},r})());function zr(r){return Va.get(r)}var Za=(function(){function r(e,t,n){n===void 0&&(n=!1),this.target=e,this.name=t,this.async=n}return Object.defineProperty(r.prototype,"instance",{get:function(){return zr(this.target)},enumerable:!1,configurable:!0}),r})();function Wa(r){var e;if(r.validator instanceof Function){e=r.validator;var t=zr(oa).getTargetValidatorConstraints(r.validator);if(t.length>1)throw"More than one implementation of ValidatorConstraintInterface found for validator on: ".concat(r.target.name,":").concat(r.propertyName)}else{var n=r.validator;e=(function(){function i(){}return i.prototype.validate=function(o,c){return n.validate(o,c)},i.prototype.defaultMessage=function(o){return n.defaultMessage?n.defaultMessage(o):""},i})(),dr().addConstraintMetadata(new Za(e,r.name,r.async))}var a={type:r.name&&et.isValid(r.name)?r.name:et.CUSTOM_VALIDATION,name:r.name,target:r.target,propertyName:r.propertyName,validationOptions:r.options,constraintCls:e,constraints:r.constraints};dr().addValidationMetadata(new en(a))}function ar(r,e){return function(t){var n="";return r(n,t)}}function ir(r,e){return function(t,n){Wa({name:r.name,target:t.constructor,propertyName:n,options:e,constraints:r.constraints,validator:r.validator})}}var za="isOptional";function mn(r){return function(e,t){var n={type:et.CONDITIONAL_VALIDATION,name:za,target:e.constructor,propertyName:t,constraints:[function(a,i){return a[t]!==null&&a[t]!==void 0}],validationOptions:r};dr().addValidationMetadata(new en(n))}}var un=function(){return un=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a])}return r},un.apply(this,arguments)};function yn(r){var e=un({},r),t=e.each?"each value in ":"";return e.message=e.message||t+"nested property $property must be either object or array",function(n,a){var i={type:et.NESTED_VALIDATION,target:n.constructor,propertyName:a,validationOptions:e};dr().addValidationMetadata(new en(i))}}var Hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ca(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Lr={exports:{}},Gn;function tn(){return Gn||(Gn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){if(n==null)throw new TypeError("Expected a string but received a ".concat(n));if(n.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(n.constructor.name))}r.exports=e.default,r.exports.default=e.default})(Lr,Lr.exports)),Lr.exports}var Rr={exports:{}},Yn;function ua(){return Yn||(Yn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;for(var i in a)typeof n[i]>"u"&&(n[i]=a[i]);return n}r.exports=e.default,r.exports.default=e.default})(Rr,Rr.exports)),Rr.exports}var jr={exports:{}},Jn;function qa(){return Jn||(Jn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var t=n(tn());function n(o){return o&&o.__esModule?o:{default:o}}function a(o){"@babel/helpers - typeof";return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},a(o)}function i(o,c){(0,t.default)(o);var d,p;a(c)==="object"?(d=c.min||0,p=c.max):(d=arguments[1],p=arguments[2]);var S=encodeURI(o).split(/%..|./).length-1;return S>=d&&(typeof p>"u"||S<=p)}r.exports=e.default,r.exports.default=e.default})(jr,jr.exports)),jr.exports}var $r={exports:{}},Br={exports:{}},Kn;function Ha(){return Kn||(Kn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=n;function t(a){return Object.prototype.toString.call(a)==="[object RegExp]"}function n(a,i){for(var o=0;o<i.length;o++){var c=i[o];if(a===c||t(c)&&c.test(a))return!0}return!1}r.exports=e.default,r.exports.default=e.default})(Br,Br.exports)),Br.exports}var Ur={exports:{}},Xn;function Ga(){return Xn||(Xn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var t=a(tn()),n=a(ua());function a(c){return c&&c.__esModule?c:{default:c}}var i={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function o(c,d){(0,t.default)(c),d=(0,n.default)(d,i),d.allow_trailing_dot&&c[c.length-1]==="."&&(c=c.substring(0,c.length-1)),d.allow_wildcard===!0&&c.indexOf("*.")===0&&(c=c.substring(2));var p=c.split("."),S=p[p.length-1];return d.require_tld&&(p.length<2||!d.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(S)||/\s/.test(S))||!d.allow_numeric_tld&&/^\d+$/.test(S)?!1:p.every(function(w){return!(w.length>63&&!d.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(w)||/[\uff01-\uff5e]/.test(w)||/^-|-$/.test(w)||!d.allow_underscores&&/_/.test(w))})}r.exports=e.default,r.exports.default=e.default})(Ur,Ur.exports)),Ur.exports}var Vr={exports:{}},Qn;function Ya(){return Qn||(Qn=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=S;var t=n(tn());function n(w){return w&&w.__esModule?w:{default:w}}function a(w){"@babel/helpers - typeof";return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},a(w)}var i="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",o="(".concat(i,"[.]){3}").concat(i),c=new RegExp("^".concat(o,"$")),d="(?:[0-9a-fA-F]{1,4})",p=new RegExp("^("+"(?:".concat(d,":){7}(?:").concat(d,"|:)|")+"(?:".concat(d,":){6}(?:").concat(o,"|:").concat(d,"|:)|")+"(?:".concat(d,":){5}(?::").concat(o,"|(:").concat(d,"){1,2}|:)|")+"(?:".concat(d,":){4}(?:(:").concat(d,"){0,1}:").concat(o,"|(:").concat(d,"){1,3}|:)|")+"(?:".concat(d,":){3}(?:(:").concat(d,"){0,2}:").concat(o,"|(:").concat(d,"){1,4}|:)|")+"(?:".concat(d,":){2}(?:(:").concat(d,"){0,3}:").concat(o,"|(:").concat(d,"){1,5}|:)|")+"(?:".concat(d,":){1}(?:(:").concat(d,"){0,4}:").concat(o,"|(:").concat(d,"){1,6}|:)|")+"(?::((?::".concat(d,"){0,5}:").concat(o,"|(?::").concat(d,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function S(w){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,t.default)(w);var _=(a(h)==="object"?h.version:arguments[1])||"";return _?_.toString()==="4"?c.test(w):_.toString()==="6"?p.test(w):!1:S(w,{version:4})||S(w,{version:6})}r.exports=e.default,r.exports.default=e.default})(Vr,Vr.exports)),Vr.exports}var ea;function Ja(){return ea||(ea=1,(function(r,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=$;var t=d(tn()),n=d(Ha()),a=d(qa()),i=d(Ga()),o=d(Ya()),c=d(ua());function d(C){return C&&C.__esModule?C:{default:C}}var p={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},S=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,w=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,h=/^[a-z\d]+$/,_=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,I=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,Q=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,q=254;function ee(C){var M=C.replace(/^"(.+)"$/,"$1");if(!M.trim())return!1;var D=/[\.";<>]/.test(M);if(D){if(M===C)return!1;var x=M.split('"').length===M.split('\\"').length;if(!x)return!1}return!0}function $(C,M){if((0,t.default)(C),M=(0,c.default)(M,p),M.require_display_name||M.allow_display_name){var D=C.match(S);if(D){var x=D[1];if(C=C.replace(x,"").replace(/(^<|>$)/g,""),x.endsWith(" ")&&(x=x.slice(0,-1)),!ee(x))return!1}else if(M.require_display_name)return!1}if(!M.ignore_max_length&&C.length>q)return!1;var j=C.split("@"),F=j.pop(),fe=F.toLowerCase();if(M.host_blacklist.length>0&&(0,n.default)(fe,M.host_blacklist)||M.host_whitelist.length>0&&!(0,n.default)(fe,M.host_whitelist))return!1;var ie=j.join("@");if(M.domain_specific_validation&&(fe==="gmail.com"||fe==="googlemail.com")){ie=ie.toLowerCase();var be=ie.split("+")[0];if(!(0,a.default)(be.replace(/\./g,""),{min:6,max:30}))return!1;for(var xe=be.split("."),he=0;he<xe.length;he++)if(!h.test(xe[he]))return!1}if(M.ignore_max_length===!1&&(!(0,a.default)(ie,{max:64})||!(0,a.default)(F,{max:254})))return!1;if(!(0,i.default)(F,{require_tld:M.require_tld,ignore_max_length:M.ignore_max_length,allow_underscores:M.allow_underscores})){if(!M.allow_ip_domain)return!1;if(!(0,o.default)(F)){if(!F.startsWith("[")||!F.endsWith("]"))return!1;var Oe=F.slice(1,-1);if(Oe.length===0||!(0,o.default)(Oe))return!1}}if(M.blacklisted_chars&&ie.search(new RegExp("[".concat(M.blacklisted_chars,"]+"),"g"))!==-1)return!1;if(ie[0]==='"'&&ie[ie.length-1]==='"')return ie=ie.slice(1,ie.length-1),M.allow_utf8_local_part?Q.test(ie):_.test(ie);for(var Ue=M.allow_utf8_local_part?I:w,te=ie.split("."),se=0;se<te.length;se++)if(!Ue.test(te[se]))return!1;return!0}r.exports=e.default,r.exports.default=e.default})($r,$r.exports)),$r.exports}var Ka=Ja();const Xa=ca(Ka);var Qa="isEmail";function ei(r,e){return typeof r=="string"&&Xa(r,e)}function ti(r,e){return ir({name:Qa,constraints:[r],validator:{validate:function(t,n){return ei(t,n==null?void 0:n.constraints[0])},defaultMessage:ar(function(t){return t+"$property must be an email"})}},e)}var ri="isBoolean";function ni(r){return r instanceof Boolean||typeof r=="boolean"}function gn(r){return ir({name:ri,validator:{validate:function(e,t){return ni(e)},defaultMessage:ar(function(e){return e+"$property must be a boolean value"})}},r)}var ai="isDate";function ii(r){return r instanceof Date&&!isNaN(r.getTime())}function la(r){return ir({name:ai,validator:{validate:function(e,t){return ii(e)},defaultMessage:ar(function(e){return e+"$property must be a Date instance"})}},r)}var si="isNumber";function oi(r,e){if(e===void 0&&(e={}),typeof r!="number")return!1;if(r===1/0||r===-1/0)return!!e.allowInfinity;if(Number.isNaN(r))return!!e.allowNaN;if(e.maxDecimalPlaces!==void 0){var t=0;if(r%1!==0&&(t=r.toString().split(".")[1].length),t>e.maxDecimalPlaces)return!1}return Number.isFinite(r)}function vn(r,e){return r===void 0&&(r={}),ir({name:si,constraints:[r],validator:{validate:function(t,n){return oi(t,n==null?void 0:n.constraints[0])},defaultMessage:ar(function(t){return t+"$property must be a number conforming to the specified constraints"})}},e)}var ta=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(c){o={error:c}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return i},ci="isEnum";function ui(r,e){var t=Object.keys(e).map(function(n){return e[n]});return t.includes(r)}function li(r){return Object.entries(r).filter(function(e){var t=ta(e,2),n=t[0];return t[1],isNaN(parseInt(n))}).map(function(e){var t=ta(e,2);t[0];var n=t[1];return n})}function fi(r,e){return ir({name:ci,constraints:[r,li(r)],validator:{validate:function(t,n){return ui(t,n==null?void 0:n.constraints[0])},defaultMessage:ar(function(t){return t+"$property must be one of the following values: $constraint2"})}},e)}var di="isString";function pi(r){return r instanceof String||typeof r=="string"}function rt(r){return ir({name:di,validator:{validate:function(e,t){return pi(e)},defaultMessage:ar(function(e){return e+"$property must be a string"})}},r)}function Zr(r,e,t){return typeof r=="string"?zr(qn).validateSync(r,e,t):zr(qn).validateSync(r,e)}var hi=Object.defineProperty,Pe=(r,e,t,n)=>{for(var a=void 0,i=r.length-1,o;i>=0;i--)(o=r[i])&&(a=o(e,t,a)||a);return a&&hi(e,t,a),a};class Tr{constructor(){G(this,"name");G(this,"key");G(this,"image")}}Pe([rt()],Tr.prototype,"name");Pe([rt()],Tr.prototype,"key");Pe([rt()],Tr.prototype,"image");var bn=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(bn||{});class Mt{constructor(){G(this,"text");G(this,"code");G(this,"symbol");G(this,"format");G(this,"amount")}}Pe([rt()],Mt.prototype,"text");Pe([rt()],Mt.prototype,"code");Pe([rt()],Mt.prototype,"symbol");Pe([rt()],Mt.prototype,"format");Pe([vn()],Mt.prototype,"amount");var fa=(r=>(r.USD="USD",r.KRW="KRW",r))(fa||{});class bt{constructor(){G(this,"planName");G(this,"currentCycleBillAmount");G(this,"nextPaymentDue");G(this,"cycleTerm");G(this,"isFreeTier");G(this,"isPerUser");G(this,"paidMemberCount");G(this,"usedMemberCount");G(this,"unitPrice")}}Pe([rt()],bt.prototype,"planName");Pe([yn(),Ar(()=>Mt)],bt.prototype,"currentCycleBillAmount");Pe([rt()],bt.prototype,"nextPaymentDue");Pe([mn(),fi(bn)],bt.prototype,"cycleTerm");Pe([gn()],bt.prototype,"isFreeTier");Pe([gn()],bt.prototype,"isPerUser");Pe([vn()],bt.prototype,"paidMemberCount");Pe([vn()],bt.prototype,"usedMemberCount");Pe([mn(),yn(),Ar(()=>Mt)],bt.prototype,"unitPrice");class Pt{constructor(){G(this,"uid");G(this,"issuedDate");G(this,"paidDate");G(this,"paymentMethod");G(this,"amount");G(this,"isSuccessfulPaid");G(this,"receiptUrl")}}Pe([rt()],Pt.prototype,"uid");Pe([la(),Ar(()=>Date)],Pt.prototype,"issuedDate");Pe([mn(),la(),Ar(()=>Date)],Pt.prototype,"paidDate");Pe([rt()],Pt.prototype,"paymentMethod");Pe([yn(),Ar(()=>Mt)],Pt.prototype,"amount");Pe([gn()],Pt.prototype,"isSuccessfulPaid");Pe([rt()],Pt.prototype,"receiptUrl");class sr{constructor(){G(this,"name");G(this,"email");G(this,"profileImageUrl");G(this,"role")}}Pe([rt()],sr.prototype,"name");Pe([ti()],sr.prototype,"email");Pe([rt()],sr.prototype,"profileImageUrl");Pe([rt()],sr.prototype,"role");class mi{constructor(){}async checkExtension(){return new Promise((e,t)=>{const n=setTimeout(()=>{t(pt.extensionNotInstalled())},5e3),a=i=>{Aa(i.data)&&(clearTimeout(n),window.removeEventListener("message",a),e(i.data))};window.addEventListener("message",a),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((t,n)=>{const a=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,o=setTimeout(()=>{n(pt.requestTimeout(i))},i),c=d=>{var p,S,w,h;if(((p=d.data)==null?void 0:p.type)==="8G_COLLECT_RESPONSE"&&d.data.requestId===a){clearTimeout(o),window.removeEventListener("message",c);const _=d.data,I=((S=_==null?void 0:_.result)==null?void 0:S.steps)??((h=(w=_==null?void 0:_.result)==null?void 0:w.result)==null?void 0:h.steps)??[];t({success:_.success,steps:I,error:_.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",c),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:a,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var o,c;const t=await this.collectWorkflow(e);if(!t.success)throw new pt("Failed to get workspaces","GET_WORKSPACES_FAILED");const n=(c=(o=t.steps[t.steps.length-1])==null?void 0:o.result)==null?void 0:c.data;if(!n||!Array.isArray(n))return{data:[],isSuccess:!1};const a=Fr(Tr,n),i=[];for(const d of a){const p=Zr(d);p.length===0?i.push(d):console.warn("Invalid workspace data:",d,p)}return{data:i,isSuccess:!0}}async getWorkspacePlanAndCycle(e){var o,c;const t=await this.collectWorkflow(e);if(!t.success)throw new pt("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const n=(c=(o=t.steps[t.steps.length-1])==null?void 0:o.result)==null?void 0:c.data;if(!n)return null;const a=Fr(bt,n),i=Zr(a);return i.length===0?a:(console.warn("Invalid workspace billing data:",a,i),null)}async getWorkspaceBillingHistories(e){var o,c;const t=await this.collectWorkflow(e);if(!t.success)throw new pt("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const n=(c=(o=t.steps[t.steps.length-1])==null?void 0:o.result)==null?void 0:c.data;if(!n||!Array.isArray(n))return[];const a=Fr(Pt,n),i=[];for(const d of a){const p=Zr(d);p.length===0?i.push(d):console.warn("Invalid workspace billing history data:",d,p)}return i}async getWorkspaceMembers(e){var o,c;const t=await this.collectWorkflow(e);if(!t.success)throw new pt("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const n=(c=(o=t.steps[t.steps.length-1])==null?void 0:o.result)==null?void 0:c.data;if(!n||!Array.isArray(n))return[];const a=Fr(sr,n),i=[];for(const d of a){const p=Zr(d);p.length===0?i.push(d):console.warn("Invalid workspace member data:",d,p)}return i}}var Ee;(function(r){r.assertEqual=a=>{};function e(a){}r.assertIs=e;function t(a){throw new Error}r.assertNever=t,r.arrayToEnum=a=>{const i={};for(const o of a)i[o]=o;return i},r.getValidEnumValues=a=>{const i=r.objectKeys(a).filter(c=>typeof a[a[c]]!="number"),o={};for(const c of i)o[c]=a[c];return r.objectValues(o)},r.objectValues=a=>r.objectKeys(a).map(function(i){return a[i]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},r.find=(a,i)=>{for(const o of a)if(i(o))return o},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(Ee||(Ee={}));var ln;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ln||(ln={}));const H=Ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ct=r=>{switch(typeof r){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(r)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(r)?H.array:r===null?H.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?H.promise:typeof Map<"u"&&r instanceof Map?H.map:typeof Set<"u"&&r instanceof Set?H.set:typeof Date<"u"&&r instanceof Date?H.date:H.object;default:return H.unknown}},L=Ee.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"]),yi=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class ut extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},n={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,d=0;for(;d<o.path.length;){const p=o.path[d];d===o.path.length-1?(c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(o))):c[p]=c[p]||{_errors:[]},c=c[p],d++}}};return a(this),n}static assert(e){if(!(e instanceof ut))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];t[i]=t[i]||[],t[i].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ut.create=r=>new ut(r);const tr=(r,e)=>{let t;switch(r.code){case L.invalid_type:r.received===H.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case L.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ee.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ee.joinValues(r.keys,", ")}`;break;case L.invalid_union:t="Invalid input";break;case L.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ee.joinValues(r.options)}`;break;case L.invalid_enum_value:t=`Invalid enum value. Expected ${Ee.joinValues(r.options)}, received '${r.received}'`;break;case L.invalid_arguments:t="Invalid function arguments";break;case L.invalid_return_type:t="Invalid function return type";break;case L.invalid_date:t="Invalid date";break;case L.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ee.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case L.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case L.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case L.custom:t="Invalid input";break;case L.invalid_intersection_types:t="Intersection results could not be merged";break;case L.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case L.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ee.assertNever(r)}return{message:t}};let da=tr;function gi(r){da=r}function qr(){return da}const Hr=r=>{const{data:e,path:t,errorMaps:n,issueData:a}=r,i=[...t,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let c="";const d=n.filter(p=>!!p).slice().reverse();for(const p of d)c=p(o,{data:e,defaultError:c}).message;return{...a,path:i,message:c}},vi=[];function W(r,e){const t=qr(),n=Hr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===tr?void 0:tr].filter(a=>!!a)});r.common.issues.push(n)}class Xe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const a of t){if(a.status==="aborted")return ce;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const a of t){const i=await a.key,o=await a.value;n.push({key:i,value:o})}return Xe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const a of t){const{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return ce;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}}const ce=Object.freeze({status:"aborted"}),Qt=r=>({status:"dirty",value:r}),tt=r=>({status:"valid",value:r}),fn=r=>r.status==="aborted",dn=r=>r.status==="dirty",Zt=r=>r.status==="valid",pr=r=>typeof Promise<"u"&&r instanceof Promise;var X;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(X||(X={}));class Et{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}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 ra=(r,e)=>{if(Zt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ut(r.common.issues);return this._error=t,this._error}}};function pe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:a}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,c)=>{const{message:d}=r;return o.code==="invalid_enum_value"?{message:d??c.defaultError}:typeof c.data>"u"?{message:d??n??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:d??t??c.defaultError}},description:a}}class ye{get description(){return this._def.description}_getType(e){return Ct(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Xe,ctx:{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(pr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ct(e)},a=this._parseSync({data:e,path:n.path,parent:n});return ra(n,a)}"~validate"(e){var n,a;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ct(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return Zt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(a=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>Zt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ct(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(pr(a)?a:Promise.resolve(a));return ra(n,i)}refine(e,t){const n=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,i)=>{const o=e(a),c=()=>i.addIssue({code:L.custom,...n(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof t=="function"?t(n,a):t),!1))}_refinement(e){return new vt({schema:this,typeName:le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return _t.create(this,this._def)}nullable(){return $t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gt.create(this)}promise(){return nr.create(this,this._def)}or(e){return gr.create([this,e],this._def)}and(e){return vr.create(this,e,this._def)}transform(e){return new vt({...pe(this._def),schema:this,typeName:le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new _r({...pe(this._def),innerType:this,defaultValue:t,typeName:le.ZodDefault})}brand(){return new wn({typeName:le.ZodBranded,type:this,...pe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Er({...pe(this._def),innerType:this,catchValue:t,typeName:le.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Or.create(this,e)}readonly(){return Sr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bi=/^c[^\s-]{8,}$/i,wi=/^[0-9a-z]+$/,ki=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xi=/^[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,_i=/^[a-z0-9_-]{21}$/i,Ei=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Si=/^[-+]?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)?)??$/,Ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ti="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let sn;const Oi=/^(?:(?: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])$/,Ci=/^(?:(?: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])$/,Di=/^(([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]))$/,Mi=/^(([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])$/,Pi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ni=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pa="((\\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])))",Ii=new RegExp(`^${pa}$`);function ha(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Fi(r){return new RegExp(`^${ha(r)}$`)}function ma(r){let e=`${pa}T${ha(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Li(r,e){return!!((e==="v4"||!e)&&Oi.test(r)||(e==="v6"||!e)&&Di.test(r))}function Ri(r,e){if(!Ei.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function ji(r,e){return!!((e==="v4"||!e)&&Ci.test(r)||(e==="v6"||!e)&&Mi.test(r))}class yt extends ye{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){const i=this._getOrReturnCtx(e);return W(i,{code:L.invalid_type,expected:H.string,received:i.parsedType}),ce}const n=new Xe;let a;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),W(a,{code:L.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),W(a,{code:L.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,c=e.data.length<i.value;(o||c)&&(a=this._getOrReturnCtx(e,a),o?W(a,{code:L.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&W(a,{code:L.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ai.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"email",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")sn||(sn=new RegExp(Ti,"u")),sn.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"emoji",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")xi.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"uuid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")_i.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"nanoid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")bi.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"cuid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")wi.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"cuid2",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")ki.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"ulid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),W(a,{validation:"url",code:L.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"regex",code:L.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?ma(i).test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Ii.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Fi(i).test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{code:L.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Si.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"duration",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Li(e.data,i.version)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"ip",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Ri(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"jwt",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?ji(e.data,i.version)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"cidr",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Pi.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"base64",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Ni.test(e.data)||(a=this._getOrReturnCtx(e,a),W(a,{validation:"base64url",code:L.invalid_string,message:i.message}),n.dirty()):Ee.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(a=>e.test(a),{validation:t,code:L.invalid_string,...X.errToObj(n)})}_addCheck(e){return new yt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...X.errToObj(e)})}url(e){return this._addCheck({kind:"url",...X.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...X.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...X.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...X.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...X.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...X.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...X.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...X.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...X.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...X.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...X.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...X.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,...X.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,...X.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...X.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...X.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...X.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...X.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...X.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...X.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...X.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...X.errToObj(t)})}nonempty(e){return this.min(1,X.errToObj(e))}trim(){return new yt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new yt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new yt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}yt.create=r=>new yt({checks:[],typeName:le.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...pe(r)});function $i(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=t>n?t:n,i=Number.parseInt(r.toFixed(a).replace(".","")),o=Number.parseInt(e.toFixed(a).replace(".",""));return i%o/10**a}class Lt extends ye{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)!==H.number){const i=this._getOrReturnCtx(e);return W(i,{code:L.invalid_type,expected:H.number,received:i.parsedType}),ce}let n;const a=new Xe;for(const i of this._def.checks)i.kind==="int"?Ee.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:L.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?$i(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:L.not_finite,message:i.message}),a.dirty()):Ee.assertNever(i);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,X.toString(t))}gt(e,t){return this.setLimit("min",e,!1,X.toString(t))}lte(e,t){return this.setLimit("max",e,!0,X.toString(t))}lt(e,t){return this.setLimit("max",e,!1,X.toString(t))}setLimit(e,t,n,a){return new Lt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:X.toString(a)}]})}_addCheck(e){return new Lt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:X.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:X.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:X.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:X.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:X.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ee.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Lt.create=r=>new Lt({checks:[],typeName:le.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...pe(r)});class Rt extends ye{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)!==H.bigint)return this._getInvalidInput(e);let n;const a=new Xe;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:L.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):Ee.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return W(t,{code:L.invalid_type,expected:H.bigint,received:t.parsedType}),ce}gte(e,t){return this.setLimit("min",e,!0,X.toString(t))}gt(e,t){return this.setLimit("min",e,!1,X.toString(t))}lte(e,t){return this.setLimit("max",e,!0,X.toString(t))}lt(e,t){return this.setLimit("max",e,!1,X.toString(t))}setLimit(e,t,n,a){return new Rt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:X.toString(a)}]})}_addCheck(e){return new Rt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:X.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Rt.create=r=>new Rt({checks:[],typeName:le.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...pe(r)});class hr extends ye{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.boolean,received:n.parsedType}),ce}return tt(e.data)}}hr.create=r=>new hr({typeName:le.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...pe(r)});class Wt extends ye{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){const i=this._getOrReturnCtx(e);return W(i,{code:L.invalid_type,expected:H.date,received:i.parsedType}),ce}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:L.invalid_date}),ce}const n=new Xe;let a;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),W(a,{code:L.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),W(a,{code:L.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Ee.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Wt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:X.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:X.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Wt.create=r=>new Wt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:le.ZodDate,...pe(r)});class Gr extends ye{_parse(e){if(this._getType(e)!==H.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.symbol,received:n.parsedType}),ce}return tt(e.data)}}Gr.create=r=>new Gr({typeName:le.ZodSymbol,...pe(r)});class mr extends ye{_parse(e){if(this._getType(e)!==H.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.undefined,received:n.parsedType}),ce}return tt(e.data)}}mr.create=r=>new mr({typeName:le.ZodUndefined,...pe(r)});class yr extends ye{_parse(e){if(this._getType(e)!==H.null){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.null,received:n.parsedType}),ce}return tt(e.data)}}yr.create=r=>new yr({typeName:le.ZodNull,...pe(r)});class rr extends ye{constructor(){super(...arguments),this._any=!0}_parse(e){return tt(e.data)}}rr.create=r=>new rr({typeName:le.ZodAny,...pe(r)});class Vt extends ye{constructor(){super(...arguments),this._unknown=!0}_parse(e){return tt(e.data)}}Vt.create=r=>new Vt({typeName:le.ZodUnknown,...pe(r)});class Dt extends ye{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:L.invalid_type,expected:H.never,received:t.parsedType}),ce}}Dt.create=r=>new Dt({typeName:le.ZodNever,...pe(r)});class Yr extends ye{_parse(e){if(this._getType(e)!==H.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.void,received:n.parsedType}),ce}return tt(e.data)}}Yr.create=r=>new Yr({typeName:le.ZodVoid,...pe(r)});class gt extends ye{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==H.array)return W(t,{code:L.invalid_type,expected:H.array,received:t.parsedType}),ce;if(a.exactLength!==null){const o=t.data.length>a.exactLength.value,c=t.data.length<a.exactLength.value;(o||c)&&(W(t,{code:o?L.too_big:L.too_small,minimum:c?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(W(t,{code:L.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(W(t,{code:L.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>a.type._parseAsync(new Et(t,o,t.path,c)))).then(o=>Xe.mergeArray(n,o));const i=[...t.data].map((o,c)=>a.type._parseSync(new Et(t,o,t.path,c)));return Xe.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new gt({...this._def,minLength:{value:e,message:X.toString(t)}})}max(e,t){return new gt({...this._def,maxLength:{value:e,message:X.toString(t)}})}length(e,t){return new gt({...this._def,exactLength:{value:e,message:X.toString(t)}})}nonempty(e){return this.min(1,e)}}gt.create=(r,e)=>new gt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:le.ZodArray,...pe(e)});function Xt(r){if(r instanceof Re){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_t.create(Xt(n))}return new Re({...r._def,shape:()=>e})}else return r instanceof gt?new gt({...r._def,type:Xt(r.element)}):r instanceof _t?_t.create(Xt(r.unwrap())):r instanceof $t?$t.create(Xt(r.unwrap())):r instanceof St?St.create(r.items.map(e=>Xt(e))):r}class Re extends ye{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Ee.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){const p=this._getOrReturnCtx(e);return W(p,{code:L.invalid_type,expected:H.object,received:p.parsedType}),ce}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Dt&&this._def.unknownKeys==="strip"))for(const p in a.data)o.includes(p)||c.push(p);const d=[];for(const p of o){const S=i[p],w=a.data[p];d.push({key:{status:"valid",value:p},value:S._parse(new Et(a,w,a.path,p)),alwaysSet:p in a.data})}if(this._def.catchall instanceof Dt){const p=this._def.unknownKeys;if(p==="passthrough")for(const S of c)d.push({key:{status:"valid",value:S},value:{status:"valid",value:a.data[S]}});else if(p==="strict")c.length>0&&(W(a,{code:L.unrecognized_keys,keys:c}),n.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const S of c){const w=a.data[S];d.push({key:{status:"valid",value:S},value:p._parse(new Et(a,w,a.path,S)),alwaysSet:S in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const p=[];for(const S of d){const w=await S.key,h=await S.value;p.push({key:w,value:h,alwaysSet:S.alwaysSet})}return p}).then(p=>Xe.mergeObjectSync(n,p)):Xe.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new Re({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,o;const a=((o=(i=this._def).errorMap)==null?void 0:o.call(i,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:X.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new Re({...this._def,unknownKeys:"strip"})}passthrough(){return new Re({...this._def,unknownKeys:"passthrough"})}extend(e){return new Re({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Re({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Re({...this._def,catchall:e})}pick(e){const t={};for(const n of Ee.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new Re({...this._def,shape:()=>t})}omit(e){const t={};for(const n of Ee.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new Re({...this._def,shape:()=>t})}deepPartial(){return Xt(this)}partial(e){const t={};for(const n of Ee.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?t[n]=a:t[n]=a.optional()}return new Re({...this._def,shape:()=>t})}required(e){const t={};for(const n of Ee.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _t;)i=i._def.innerType;t[n]=i}return new Re({...this._def,shape:()=>t})}keyof(){return ya(Ee.objectKeys(this.shape))}}Re.create=(r,e)=>new Re({shape:()=>r,unknownKeys:"strip",catchall:Dt.create(),typeName:le.ZodObject,...pe(e)});Re.strictCreate=(r,e)=>new Re({shape:()=>r,unknownKeys:"strict",catchall:Dt.create(),typeName:le.ZodObject,...pe(e)});Re.lazycreate=(r,e)=>new Re({shape:r,unknownKeys:"strip",catchall:Dt.create(),typeName:le.ZodObject,...pe(e)});class gr extends ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function a(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=i.map(c=>new ut(c.ctx.common.issues));return W(t,{code:L.invalid_union,unionErrors:o}),ce}if(t.common.async)return Promise.all(n.map(async i=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(a);{let i;const o=[];for(const d of n){const p={...t,common:{...t.common,issues:[]},parent:null},S=d._parseSync({data:t.data,path:t.path,parent:p});if(S.status==="valid")return S;S.status==="dirty"&&!i&&(i={result:S,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const c=o.map(d=>new ut(d));return W(t,{code:L.invalid_union,unionErrors:c}),ce}}get options(){return this._def.options}}gr.create=(r,e)=>new gr({options:r,typeName:le.ZodUnion,...pe(e)});const Ot=r=>r instanceof wr?Ot(r.schema):r instanceof vt?Ot(r.innerType()):r instanceof kr?[r.value]:r instanceof jt?r.options:r instanceof xr?Ee.objectValues(r.enum):r instanceof _r?Ot(r._def.innerType):r instanceof mr?[void 0]:r instanceof yr?[null]:r instanceof _t?[void 0,...Ot(r.unwrap())]:r instanceof $t?[null,...Ot(r.unwrap())]:r instanceof wn||r instanceof Sr?Ot(r.unwrap()):r instanceof Er?Ot(r._def.innerType):[];class rn extends ye{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return W(t,{code:L.invalid_type,expected:H.object,received:t.parsedType}),ce;const n=this.discriminator,a=t.data[n],i=this.optionsMap.get(a);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const a=new Map;for(const i of t){const o=Ot(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(a.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);a.set(c,i)}}return new rn({typeName:le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...pe(n)})}}function pn(r,e){const t=Ct(r),n=Ct(e);if(r===e)return{valid:!0,data:r};if(t===H.object&&n===H.object){const a=Ee.objectKeys(e),i=Ee.objectKeys(r).filter(c=>a.indexOf(c)!==-1),o={...r,...e};for(const c of i){const d=pn(r[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===H.array&&n===H.array){if(r.length!==e.length)return{valid:!1};const a=[];for(let i=0;i<r.length;i++){const o=r[i],c=e[i],d=pn(o,c);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return t===H.date&&n===H.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class vr extends ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=(i,o)=>{if(fn(i)||fn(o))return ce;const c=pn(i.value,o.value);return c.valid?((dn(i)||dn(o))&&t.dirty(),{status:t.value,value:c.data}):(W(n,{code:L.invalid_intersection_types}),ce)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}vr.create=(r,e,t)=>new vr({left:r,right:e,typeName:le.ZodIntersection,...pe(t)});class St extends ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return W(n,{code:L.invalid_type,expected:H.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return W(n,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new Et(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>Xe.mergeArray(t,o)):Xe.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new St({...this._def,rest:e})}}St.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new St({items:r,typeName:le.ZodTuple,rest:null,...pe(e)})};class br extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.object)return W(n,{code:L.invalid_type,expected:H.object,received:n.parsedType}),ce;const a=[],i=this._def.keyType,o=this._def.valueType;for(const c in n.data)a.push({key:i._parse(new Et(n,c,n.path,c)),value:o._parse(new Et(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?Xe.mergeObjectAsync(t,a):Xe.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ye?new br({keyType:e,valueType:t,typeName:le.ZodRecord,...pe(n)}):new br({keyType:yt.create(),valueType:e,typeName:le.ZodRecord,...pe(t)})}}class Jr extends ye{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.map)return W(n,{code:L.invalid_type,expected:H.map,received:n.parsedType}),ce;const a=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([c,d],p)=>({key:a._parse(new Et(n,c,n.path,[p,"key"])),value:i._parse(new Et(n,d,n.path,[p,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const p=await d.key,S=await d.value;if(p.status==="aborted"||S.status==="aborted")return ce;(p.status==="dirty"||S.status==="dirty")&&t.dirty(),c.set(p.value,S.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const p=d.key,S=d.value;if(p.status==="aborted"||S.status==="aborted")return ce;(p.status==="dirty"||S.status==="dirty")&&t.dirty(),c.set(p.value,S.value)}return{status:t.value,value:c}}}}Jr.create=(r,e,t)=>new Jr({valueType:e,keyType:r,typeName:le.ZodMap,...pe(t)});class zt extends ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return W(n,{code:L.invalid_type,expected:H.set,received:n.parsedType}),ce;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(W(n,{code:L.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(W(n,{code:L.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const i=this._def.valueType;function o(d){const p=new Set;for(const S of d){if(S.status==="aborted")return ce;S.status==="dirty"&&t.dirty(),p.add(S.value)}return{status:t.value,value:p}}const c=[...n.data.values()].map((d,p)=>i._parse(new Et(n,d,n.path,p)));return n.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new zt({...this._def,minSize:{value:e,message:X.toString(t)}})}max(e,t){return new zt({...this._def,maxSize:{value:e,message:X.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}zt.create=(r,e)=>new zt({valueType:r,minSize:null,maxSize:null,typeName:le.ZodSet,...pe(e)});class er extends ye{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return W(t,{code:L.invalid_type,expected:H.function,received:t.parsedType}),ce;function n(c,d){return Hr({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qr(),tr].filter(p=>!!p),issueData:{code:L.invalid_arguments,argumentsError:d}})}function a(c,d){return Hr({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,qr(),tr].filter(p=>!!p),issueData:{code:L.invalid_return_type,returnTypeError:d}})}const i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof nr){const c=this;return tt(async function(...d){const p=new ut([]),S=await c._def.args.parseAsync(d,i).catch(_=>{throw p.addIssue(n(d,_)),p}),w=await Reflect.apply(o,this,S);return await c._def.returns._def.type.parseAsync(w,i).catch(_=>{throw p.addIssue(a(w,_)),p})})}else{const c=this;return tt(function(...d){const p=c._def.args.safeParse(d,i);if(!p.success)throw new ut([n(d,p.error)]);const S=Reflect.apply(o,this,p.data),w=c._def.returns.safeParse(S,i);if(!w.success)throw new ut([a(S,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new er({...this._def,args:St.create(e).rest(Vt.create())})}returns(e){return new er({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new er({args:e||St.create([]).rest(Vt.create()),returns:t||Vt.create(),typeName:le.ZodFunction,...pe(n)})}}class wr extends ye{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}wr.create=(r,e)=>new wr({getter:r,typeName:le.ZodLazy,...pe(e)});class kr extends ye{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:L.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}}kr.create=(r,e)=>new kr({value:r,typeName:le.ZodLiteral,...pe(e)});function ya(r,e){return new jt({values:r,typeName:le.ZodEnum,...pe(e)})}class jt extends ye{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Ee.joinValues(n),received:t.parsedType,code:L.invalid_type}),ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:L.invalid_enum_value,options:n}),ce}return tt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return jt.create(e,{...this._def,...t})}exclude(e,t=this._def){return jt.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}jt.create=ya;class xr extends ye{_parse(e){const t=Ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){const a=Ee.objectValues(t);return W(n,{expected:Ee.joinValues(a),received:n.parsedType,code:L.invalid_type}),ce}if(this._cache||(this._cache=new Set(Ee.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=Ee.objectValues(t);return W(n,{received:n.data,code:L.invalid_enum_value,options:a}),ce}return tt(e.data)}get enum(){return this._def.values}}xr.create=(r,e)=>new xr({values:r,typeName:le.ZodNativeEnum,...pe(e)});class nr extends ye{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.promise&&t.common.async===!1)return W(t,{code:L.invalid_type,expected:H.promise,received:t.parsedType}),ce;const n=t.parsedType===H.promise?t.data:Promise.resolve(t.data);return tt(n.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}nr.create=(r,e)=>new nr({type:r,typeName:le.ZodPromise,...pe(e)});class vt extends ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{W(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const o=a.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return ce;const d=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return d.status==="aborted"?ce:d.status==="dirty"||t.value==="dirty"?Qt(d.value):d});{if(t.value==="aborted")return ce;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"||t.value==="dirty"?Qt(c.value):c}}if(a.type==="refinement"){const o=c=>{const d=a.refinement(c,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?ce:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?ce:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(a.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Zt(o))return ce;const c=a.transform(o.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Zt(o)?Promise.resolve(a.transform(o.value,i)).then(c=>({status:t.value,value:c})):ce);Ee.assertNever(a)}}vt.create=(r,e,t)=>new vt({schema:r,typeName:le.ZodEffects,effect:e,...pe(t)});vt.createWithPreprocess=(r,e,t)=>new vt({schema:e,effect:{type:"preprocess",transform:r},typeName:le.ZodEffects,...pe(t)});class _t extends ye{_parse(e){return this._getType(e)===H.undefined?tt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_t.create=(r,e)=>new _t({innerType:r,typeName:le.ZodOptional,...pe(e)});class $t extends ye{_parse(e){return this._getType(e)===H.null?tt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$t.create=(r,e)=>new $t({innerType:r,typeName:le.ZodNullable,...pe(e)});class _r extends ye{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...pe(e)});class Er extends ye{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pr(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Er.create=(r,e)=>new Er({innerType:r,typeName:le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...pe(e)});class Kr extends ye{_parse(e){if(this._getType(e)!==H.nan){const n=this._getOrReturnCtx(e);return W(n,{code:L.invalid_type,expected:H.nan,received:n.parsedType}),ce}return{status:"valid",value:e.data}}}Kr.create=r=>new Kr({typeName:le.ZodNaN,...pe(r)});const Bi=Symbol("zod_brand");class wn extends ye{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Or extends ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ce:i.status==="dirty"?(t.dirty(),Qt(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ce:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,t){return new Or({in:e,out:t,typeName:le.ZodPipeline})}}class Sr extends ye{_parse(e){const t=this._def.innerType._parse(e),n=a=>(Zt(a)&&(a.value=Object.freeze(a.value)),a);return pr(t)?t.then(a=>n(a)):n(t)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:le.ZodReadonly,...pe(e)});function na(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function ga(r,e={},t){return r?rr.create().superRefine((n,a)=>{const i=r(n);if(i instanceof Promise)return i.then(o=>{if(!o){const c=na(e,n),d=c.fatal??t??!0;a.addIssue({code:"custom",...c,fatal:d})}});if(!i){const o=na(e,n),c=o.fatal??t??!0;a.addIssue({code:"custom",...o,fatal:c})}}):rr.create()}const Ui={object:Re.lazycreate};var le;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(le||(le={}));const Vi=(r,e={message:`Input not instance of ${r.name}`})=>ga(t=>t instanceof r,e),Xr=yt.create,kn=Lt.create,Zi=Kr.create,Wi=Rt.create,Qr=hr.create,zi=Wt.create,qi=Gr.create,Hi=mr.create,Gi=yr.create,Yi=rr.create,Ji=Vt.create,Ki=Dt.create,Xi=Yr.create,Qi=gt.create,hn=Re.create,es=Re.strictCreate,ts=gr.create,rs=rn.create,ns=vr.create,as=St.create,is=br.create,ss=Jr.create,os=zt.create,cs=er.create,us=wr.create,ls=kr.create,va=jt.create,fs=xr.create,ds=nr.create,aa=vt.create,ps=_t.create,hs=$t.create,ms=vt.createWithPreprocess,ys=Or.create,gs=()=>Xr().optional(),vs=()=>kn().optional(),bs=()=>Qr().optional(),ws={string:(r=>yt.create({...r,coerce:!0})),number:(r=>Lt.create({...r,coerce:!0})),boolean:(r=>hr.create({...r,coerce:!0})),bigint:(r=>Rt.create({...r,coerce:!0})),date:(r=>Wt.create({...r,coerce:!0}))},ks=ce,N=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Bi,DIRTY:Qt,EMPTY_PATH:vi,INVALID:ce,NEVER:ks,OK:tt,ParseStatus:Xe,Schema:ye,ZodAny:rr,ZodArray:gt,ZodBigInt:Rt,ZodBoolean:hr,ZodBranded:wn,ZodCatch:Er,ZodDate:Wt,ZodDefault:_r,ZodDiscriminatedUnion:rn,ZodEffects:vt,ZodEnum:jt,ZodError:ut,get ZodFirstPartyTypeKind(){return le},ZodFunction:er,ZodIntersection:vr,ZodIssueCode:L,ZodLazy:wr,ZodLiteral:kr,ZodMap:Jr,ZodNaN:Kr,ZodNativeEnum:xr,ZodNever:Dt,ZodNull:yr,ZodNullable:$t,ZodNumber:Lt,ZodObject:Re,ZodOptional:_t,ZodParsedType:H,ZodPipeline:Or,ZodPromise:nr,ZodReadonly:Sr,ZodRecord:br,ZodSchema:ye,ZodSet:zt,ZodString:yt,ZodSymbol:Gr,ZodTransformer:vt,ZodTuple:St,ZodType:ye,ZodUndefined:mr,ZodUnion:gr,ZodUnknown:Vt,ZodVoid:Yr,addIssueToContext:W,any:Yi,array:Qi,bigint:Wi,boolean:Qr,coerce:ws,custom:ga,date:zi,datetimeRegex:ma,defaultErrorMap:tr,discriminatedUnion:rs,effect:aa,enum:va,function:cs,getErrorMap:qr,getParsedType:Ct,instanceof:Vi,intersection:ns,isAborted:fn,isAsync:pr,isDirty:dn,isValid:Zt,late:Ui,lazy:us,literal:ls,makeIssue:Hr,map:ss,nan:Zi,nativeEnum:fs,never:Ki,null:Gi,nullable:hs,number:kn,object:hn,get objectUtil(){return ln},oboolean:bs,onumber:vs,optional:ps,ostring:gs,pipeline:ys,preprocess:ms,promise:ds,quotelessJson:yi,record:is,set:os,setErrorMap:gi,strictObject:es,string:Xr,symbol:qi,transformer:aa,tuple:as,undefined:Hi,union:ts,unknown:Ji,get util(){return Ee},void:Xi},Symbol.toStringTag,{value:"Module"})),wt=hn({name:Xr(),selector:Xr(),findBy:va(["cssSelector","xpath"]),option:hn({waitForSelector:Qr().optional(),waitSelectorTimeout:kn().optional(),multiple:Qr().optional()})}),xs=N.object({type:N.literal("object"),shape:N.record(N.string(),N.any())}),_s=N.object({type:N.literal("array"),items:N.any()}),Es=N.discriminatedUnion("type",[xs,_s]),xn=N.object({name:N.literal("ai-parse-data"),sourceData:N.any().optional(),schemaDefinition:Es,prompt:N.string().optional(),model:N.string().optional(),apiKey:N.string().min(1,"OpenAI API key is required")});function Ss(r){return xn.parse(r)}async function As(r){try{const{sourceData:e,schemaDefinition:t,prompt:n,model:a="gpt-4o-mini",apiKey:i}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const o=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:n,model:a,apiKey:i}});if(o.$isError)throw new Error(o.message||"AI parsing failed");return{data:o.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function Ts(r){return{type:"object",shape:r}}function Os(r){return{type:"array",items:r}}const Cs={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e})};class nn{async waitForElement(e,t,n){return new Promise(a=>{const i=Date.now(),o=async()=>{const c=await this.find(e,t);if(c&&(!Array.isArray(c)||c.length>0)){a(c);return}if(Date.now()-i>=n){a(null);return}setTimeout(o,100)};o()})}}class Ds extends nn{async find(e,t=document){const{selector:n,option:a}=e,{multiple:i=!1}=a||{};try{const o=this.processCustomPseudoSelectors(n,t);return i?Array.from(t.querySelectorAll(o)):t.querySelector(o)}catch(o){return console.error("CSS Selector error:",o),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-contains="${o}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-equal="${o}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(n=>{var i;const a=((i=n.textContent)==null?void 0:i.trim())||"";if(a){n.setAttribute("data-contains",a);const c=Array.from(n.childNodes).filter(d=>d.nodeType===Node.TEXT_NODE).map(d=>{var p;return((p=d.textContent)==null?void 0:p.trim())||""}).join(" ").trim();(c&&c===a||n.children.length===0&&a)&&n.setAttribute("data-equal",a)}})}}class Ms extends nn{async find(e,t=document){const{selector:n,option:a}=e,{multiple:i=!1}=a||{};if(!n||n.trim()==="")return null;const o=n.split("|>").map(p=>p.trim());if(o.length!==2)return null;const c=o[0],d=o[1];if(!c||!d)return null;try{const p=t.querySelector(c);if(!p||!p.contentDocument)return null;const S=p.contentDocument;return i?Array.from(S.querySelectorAll(d)):S.querySelector(d)}catch(p){return console.error("Iframe Selector error:",p),null}}}class Ps extends nn{async find(e,t=document){const{selector:n,option:a}=e,{multiple:i=!1}=a||{};if(!n||n.trim()==="")return null;const o=n.split(">>").map(d=>d.trim());let c=t;try{for(let d=0;d<o.length;d++){const p=o[d],S=d===o.length-1;if(!p)return null;if(S&&i)return Array.from(c.querySelectorAll(p));const w=c.querySelector(p);if(!w)return null;if(S)return w;if(w.shadowRoot)c=w.shadowRoot;else return null}}catch(d){return console.error("Shadow DOM Selector error:",d),null}return null}}class Ns extends nn{async find(e,t=document){const{selector:n,option:a}=e,{multiple:i=!1}=a||{};try{const o=t.evaluate(n,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const c=[];for(let d=0;d<o.snapshotLength;d++){const p=o.snapshotItem(d);p&&p.nodeType===Node.ELEMENT_NODE&&c.push(p)}return Promise.resolve(c.length>0?c:null)}else{const c=o.singleNodeValue;return c&&c.nodeType===Node.ELEMENT_NODE?c:null}}catch(o){return console.error("XPath error:",o),null}}}class Is{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const n=e.tagName.toLowerCase(),a=e.parentElement;if(a){const i=Array.from(a.children),o=i.indexOf(e)+1;if(i.length>1)return`${n}:nth-child(${o})`}if(a){const i=this.generateParentSelector(a);if(i)return`${i} > ${n}:nth-child(${Array.from(a.children).indexOf(e)+1})`}return n}static generateParentSelector(e){const t=e.tagName.toLowerCase(),n=["data-testid","aria-label","title","alt","role"];for(const i of n){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const a=e.parentElement;if(a){const i=Array.from(a.children),o=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${o})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(n=>n.test(e))}}async function kt(r,e=document){const{selector:t,findBy:n="cssSelector",option:a}=r,{waitForSelector:i=!1,waitSelectorTimeout:o=5e3}=a||{},c=Fs(t,n);return i?c.waitForElement(r,e,o):c.find(r,e)}function Fs(r,e){return e==="xpath"?new Ns:r.includes(">>")?new Ps:r.includes("|>")?new Ms:new Ds}const _n=wt.extend({name:N.literal("get-text"),includeTags:N.boolean().optional(),useTextContent:N.boolean().optional(),regex:N.string().optional(),prefixText:N.string().optional(),suffixText:N.string().optional(),filterEmpty:N.boolean().optional(),scrollToCollect:N.boolean().optional(),scrollDistance:N.number().optional(),scrollWaitMs:N.number().optional(),maxScrollAttempts:N.number().optional()});function Ls(r){return _n.parse(r)}async function Rs(r){try{const{selector:e="",includeTags:t=!1,useTextContent:n=!1,regex:a,prefixText:i="",suffixText:o="",findBy:c="cssSelector",option:d,filterEmpty:p=!0,scrollToCollect:S=!1,scrollDistance:w=500,scrollWaitMs:h=300,maxScrollAttempts:_=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(S&&(d!=null&&d.multiple))return await js({selector:e,findBy:c,option:d,includeTags:t,useTextContent:n,regex:a,prefixText:i,suffixText:o,filterEmpty:p,scrollDistance:w,scrollWaitMs:h,maxScrollAttempts:_});const I=await kt({selector:e,findBy:c,option:d});if(!I)return{data:""};const Q=ba(t,n,a,i,o);if(Array.isArray(I)){const q=I.map(Q);return{data:p?q.filter($=>$.trim()!==""):q}}else return{data:Q(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function js(r){const{selector:e,findBy:t,option:n,includeTags:a,useTextContent:i,regex:o,prefixText:c,suffixText:d,filterEmpty:p,scrollDistance:S,scrollWaitMs:w,maxScrollAttempts:h}=r,_=ba(a,i,o,c,d),I=new Set;let Q=0,q=0;const ee=5;for(;Q<h;){const $=await kt({selector:e,findBy:t,option:n});if($&&Array.isArray($)){const D=I.size;if($.forEach(j=>{const F=_(j);(!p||F.trim()!=="")&&I.add(F)}),I.size===D){if(q++,q>=ee)break}else q=0}const C=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:S,behavior:"auto"}),await new Promise(D=>setTimeout(D,w)),(window.pageYOffset||document.documentElement.scrollTop)===C)break;Q++}return{data:Array.from(I)}}function ba(r,e,t,n="",a=""){return i=>{let o="";if(r?o=i.innerHTML:o=e?i.textContent||"":i.innerText||"",t){const c=new RegExp(t,"g"),d=o.match(c);o=d?d.join(" "):""}return o.trim()&&(o=n+o.trim()+a),o}}const En=wt.extend({name:N.literal("attribute-value"),attributeName:N.string()});function $s(r){return En.parse(r)}async function Bs(r){try{const{selector:e="",attributeName:t,findBy:n="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await kt({selector:e,findBy:n,option:a});return i?{data:Array.isArray(i)?i.map(c=>c.getAttribute(t)).filter(c=>c!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Sn=wt.extend({name:N.literal("get-value-form"),type:N.enum(["text-field","select","checkbox"]).optional()});function Us(r){return Sn.parse(r)}async function Vs(r){try{const{selector:e="",type:t="text-field",findBy:n="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const a=await kt({selector:e,findBy:n,option:r.option});if(!a)throw new Error("Form element not found");return{data:Zs(a,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function Zs(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const An=wt.extend({name:N.literal("set-value-form"),setValue:N.string(),type:N.enum(["text-field","select","checkbox"]).optional()});function Ws(r){return An.parse(r)}async function zs(r){try{const{selector:e="",setValue:t,type:n="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await kt({selector:e,findBy:a,option:r.option});if(!i)throw new Error("Form element not found");return qs(i,t,n),{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 qs(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const Tn=wt.extend({name:N.literal("clear-value-form"),type:N.enum(["text-field","select","checkbox"]).optional()});function Hs(r){return Tn.parse(r)}async function Gs(r){try{const{selector:e="",type:t="text-field",findBy:n="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const a=await kt({selector:e,findBy:n,option:r.option});if(!a)throw new Error("Form element not found");return Ys(a,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function Ys(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const On=wt.extend({name:N.literal("element-exists")});function Js(r){return On.parse(r)}async function Ks(r){try{const{selector:e="",findBy:t="cssSelector",option:n}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await kt({selector:e,findBy:t,option:n})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Cn=wt.extend({name:N.literal("event-click"),textFilter:N.object({text:N.union([N.string(),N.array(N.string())]),mode:N.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function Xs(r){return Cn.parse(r)}async function Qs(r){try{const{selector:e="",findBy:t="cssSelector",option:n,textFilter:a}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await kt({selector:e,findBy:t,option:n});if(!i)throw new Error("Element not found for clicking");let o;if(Array.isArray(i))if(a){const c=eo(i,a.text,a.mode);if(!c){const d=Array.isArray(a.text)?a.text.join(", "):a.text;throw new Error(`No element found with text filter: "${d}" (mode: ${a.mode})`)}o=c}else o=i[0];else o=i;return await ro(o),{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 eo(r,e,t){for(const n of r){const a=to(n),i=Array.isArray(e)?e:[e];for(const o of i){let c=!1;switch(t){case"exact":c=a===o;break;case"contains":c=a.includes(o);break;case"startsWith":c=a.startsWith(o);break;case"endsWith":c=a.endsWith(o);break;case"regex":try{c=new RegExp(o).test(a)}catch{console.warn("Invalid regex pattern:",o);continue}break}if(c)return n}}return null}function to(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const n=r.getAttribute("aria-label");return n?n.trim():""}async function ro(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(a=>setTimeout(a,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2;try{const a=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:n}});if(a&&!a.$isError)console.log("[EventClick] CDP click successful:",a);else throw new Error((a==null?void 0:a.message)||"CDP click failed")}catch(a){console.error("[EventClick] CDP click failed, falling back to native click:",a),r.click&&r.click()}await new Promise(a=>setTimeout(a,50))}const Dn=N.object({name:N.literal("keypress"),key:N.string(),code:N.string().optional(),keyCode:N.number().optional(),modifiers:N.array(N.enum(["Alt","Control","Meta","Shift"])).optional()});function no(r){return Dn.parse(r)}async function ao(r){try{const{key:e,code:t,keyCode:n,modifiers:a=[]}=r;return await io(e,t,n,a),{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 io(r,e,t,n=[]){try{const a=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||on(r),modifiers:n}});if(a&&!a.$isError)console.log("[Keypress] CDP keypress successful:",a);else throw new Error((a==null?void 0:a.message)||"CDP keypress failed")}catch(a){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",a);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||on(r),bubbles:!0,cancelable:!0,...ia(n)}),o=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||on(r),bubbles:!0,cancelable:!0,...ia(n)});document.dispatchEvent(i),await new Promise(c=>setTimeout(c,10)),document.dispatchEvent(o)}await new Promise(a=>setTimeout(a,50))}function on(r){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[r]||0}function ia(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Mn=N.object({name:N.literal("wait"),duration:N.number().min(0)});function so(r){return Mn.parse(r)}async function oo(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Pn=N.object({name:N.literal("wait-for-condition"),conditions:N.object({urlPattern:N.string().optional(),elementExists:N.object({selector:N.string(),findBy:N.enum(["cssSelector","xpath"])}).optional(),cookieExists:N.string().optional(),storageKey:N.object({type:N.enum(["localStorage","sessionStorage"]),key:N.string()}).optional(),userConfirmation:N.boolean().optional(),message:N.string().optional(),buttonText:N.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:N.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:N.number().min(100).optional(),timeoutMs:N.number().min(1e3).optional(),position:N.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function co(r){return Pn.parse(r)}async function uo(r){try{const{conditions:e,mode:t="auto-or-manual",pollingIntervalMs:n=1e3,timeoutMs:a=3e5,position:i="bottom-right"}=r;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",t,"Timeout:",a);const o=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),c=e.userConfirmation===!0;let d=null,p=null;(t==="manual"||t==="auto-or-manual")&&c&&(d=new Promise(w=>{p=w}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:p}})));const S=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(w){console.warn("[WaitForCondition] Invalid URL pattern:",w)}if(e.elementExists){const{selector:w,findBy:h}=e.elementExists;let _=null;if(h==="cssSelector"?_=document.querySelector(w):h==="xpath"&&(_=document.evaluate(w,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),_)return{success:!0,reason:"elementExists",message:`Element found: ${w}`}}if(e.cookieExists&&document.cookie.split(";").some(_=>{const[I]=_.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:w,key:h}=e.storageKey;if((w==="localStorage"?window.localStorage:window.sessionStorage).getItem(h)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${w}.${h}`}}return null};return new Promise(w=>{let h=null,_=!1;const I=()=>{h&&(clearInterval(h),h=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},Q=ee=>{_||(_=!0,I(),console.log("[WaitForCondition] Resolved with:",ee),w({data:ee}))},q=setTimeout(()=>{Q({success:!1,reason:"timeout",message:`Timeout after ${a}ms`})},a);(t==="auto"||t==="auto-or-manual")&&o&&(h=setInterval(async()=>{const ee=await S();ee&&(clearTimeout(q),Q(ee))},n)),(t==="manual"||t==="auto-or-manual")&&d&&d.then(()=>{clearTimeout(q),Q({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 Nn=N.object({name:N.literal("navigate"),url:N.string().url("Valid URL is required"),waitForLoad:N.boolean().optional(),timeout:N.number().min(0).optional()});function lo(r){return Nn.parse(r)}async function fo(r){try{const{url:e,waitForLoad:t=!0,timeout:n=3e4}=r;return console.log(`[Navigate] Navigating to: ${e}`),t?new Promise((a,i)=>{const o=setTimeout(()=>{i(new Error(`Navigation timeout after ${n}ms`))},n),c=()=>{clearTimeout(o),window.removeEventListener("load",c),console.log(`[Navigate] Page loaded: ${e}`),a({data:!0})};document.readyState==="complete"?(clearTimeout(o),console.log(`[Navigate] Page already loaded: ${e}`),a({data:!0})):window.addEventListener("load",c),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 In=wt.extend({name:N.literal("save-assets")});function po(r){return In.parse(r)}async function ho(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:n}=r,a=await kt({selector:e,findBy:t,option:n});if(!a||!Array.isArray(a))return{data:[]};const i=[];return a.forEach(o=>{let c="";(o instanceof HTMLImageElement||o instanceof HTMLAudioElement||o instanceof HTMLVideoElement||o instanceof HTMLSourceElement)&&(c=o.src),c&&!i.includes(c)&&i.push(c)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class mo{static generate(e){var a;const t=[];let n=e;for(;n&&n.nodeType===Node.ELEMENT_NODE;){let i=n.tagName.toLowerCase();const o=Array.from(((a=n.parentElement)==null?void 0:a.children)||[]).filter(d=>d.tagName===n.tagName);if(o.length>1){const d=o.indexOf(n)+1;i+=`[${d}]`}const c=this.getStableAttributes(n);c.length>0&&(i+=`[@${c.join(" and @")}]`),t.unshift(i),n=n.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],n=["data-testid","aria-label","title","alt","role"];for(const a of n){const i=e.getAttribute(a);i&&!this.isDynamicValue(i)&&t.push(`${a}="${i}"`)}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(n=>n.test(e))}}const Fn=wt.extend({name:N.literal("get-element-data"),includeText:N.boolean().optional(),includeTags:N.boolean().optional(),useTextContent:N.boolean().optional(),regex:N.string().optional(),prefixText:N.string().optional(),suffixText:N.string().optional(),attributes:N.array(N.string()).optional(),includeSelector:N.boolean().optional(),includeXPath:N.boolean().optional()});function yo(r){return Fn.parse(r)}async function go(r){try{const{selector:e="",includeText:t=!0,includeTags:n=!1,useTextContent:a=!1,regex:i,prefixText:o="",suffixText:c="",attributes:d=[],includeSelector:p=!1,includeXPath:S=!1,findBy:w="cssSelector",option:h}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&d.length===0)throw new Error("Either includeText must be true or attributes must be provided");const _=await kt({selector:e,findBy:w,option:h});if(!_)return{data:Array.isArray(_)?[]:{}};const I=vo(t,n,a,i,o,c,d,p,S);return Array.isArray(_)?{data:_.map(I)}:{data:I(_)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function vo(r,e,t,n,a="",i="",o=[],c=!1,d=!1){return p=>{const S={};if(r){let w="";if(e?w=p.innerHTML:w=t?p.textContent||"":p.innerText||"",n){const h=new RegExp(n,"g"),_=w.match(h);w=_?_.join(" "):""}w.trim()&&(w=a+w.trim()+i),S.text=w}return o.length>0&&(S.attributes={},o.forEach(w=>{let h=p.getAttribute(w);if(h===null){const _=p.querySelector(`[${w}]`);_&&(h=_.getAttribute(w))}S.attributes[w]=h})),c&&(S.selector=Is.generate(p)),d&&(S.xpath=mo.generate(p)),S}}const Ln=wt.extend({name:N.literal("scroll"),scrollType:N.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:N.number().optional(),behavior:N.enum(["auto","smooth"]).optional(),maxScrolls:N.number().optional(),waitAfterScroll:N.number().optional()});function bo(r){return Ln.parse(r)}async function wo(r){try{const{selector:e="",scrollType:t="toBottom",distance:n=500,behavior:a="smooth",maxScrolls:i=50,waitAfterScroll:o=300,findBy:c="cssSelector",option:d}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await ko(e,c,d,a);case"toBottom":return await xo(a,o);case"byDistance":return await _o(n,a);case"untilLoaded":return await Eo(i,n,a,o);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function ko(r,e,t,n){const a=await kt({selector:r,findBy:e,option:t});return a?((Array.isArray(a)?a[0]:a).scrollIntoView({behavior:n,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function xo(r,e){let t=document.body.scrollHeight,n=0;const a=50;for(;n<a;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(o=>setTimeout(o,e));const i=document.body.scrollHeight;if(i===t)break;t=i,n++}return{data:!0}}async function _o(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Eo(r,e,t,n){let a=0,i=document.body.scrollHeight;for(;a<r;){window.scrollBy({top:e,behavior:t}),await new Promise(p=>setTimeout(p,n));const o=document.body.scrollHeight,c=window.pageYOffset||document.documentElement.scrollTop,d=window.innerHeight;if(c+d>=o-10&&o===i)break;i=o,a++}return{data:!0}}const Rn=N.object({name:N.literal("fetch-api"),url:N.string(),method:N.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:N.record(N.string(),N.string()).optional(),body:N.record(N.string(),N.any()).optional(),timeout:N.number().min(0).optional(),parseJson:N.boolean().optional(),returnHeaders:N.boolean().optional()});function So(r){return Rn.parse(r)}async function Ao(r){try{console.log("[FetchApiBlock] Sending API request to background:",r.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:r.url,method:r.method||"GET",headers:r.headers||{},body:r.body,timeout:r.timeout||3e4,parseJson:r.parseJson??!0,returnHeaders:r.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}function Wr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var cn={exports:{}},sa;function To(){return sa||(sa=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(n,a,i){function o(p,S){if(!a[p]){if(!n[p]){var w=typeof Wr=="function"&&Wr;if(!S&&w)return w(p,!0);if(c)return c(p,!0);var h=new Error("Cannot find module '"+p+"'");throw h.code="MODULE_NOT_FOUND",h}var _=a[p]={exports:{}};n[p][0].call(_.exports,function(I){var Q=n[p][1][I];return o(Q||I)},_,_.exports,t,n,a,i)}return a[p].exports}for(var c=typeof Wr=="function"&&Wr,d=0;d<i.length;d++)o(i[d]);return o}return t})()({1:[function(t,n,a){const i=t("./utils"),o=(function(){const c=i.stringToArray,d=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],p=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],S=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],w=["Thousand","Million","Billion","Trillion"];function h(E,O){var A=function(Z,U,P){var V="";if(Z<=19)V=(U?" and ":"")+(P?p[Z]:d[Z]);else if(Z<100){const _e=Math.floor(Z/10),Se=Z%10;V=(U?" and ":"")+S[_e-2],Se>0?V+="-"+A(Se,!1,P):P&&(V=V.substring(0,V.length-1)+"ieth")}else if(Z<1e3){const _e=Math.floor(Z/100),Se=Z%100;V=(U?", ":"")+d[_e]+" Hundred",Se>0?V+=A(Se,!0,P):P&&(V+="th")}else{var ne=Math.floor(Math.log10(Z)/3);ne>w.length&&(ne=w.length);const _e=Math.pow(10,ne*3),Se=Math.floor(Z/_e),re=Z-Se*_e;V=(U?", ":"")+A(Se,!1,!1)+" "+w[ne-1],re>0?V+=A(re,!0,P):P&&(V+="th")}return V},R=A(E,!1,O);return R}const _={};d.forEach(function(E,O){_[E.toLowerCase()]=O}),p.forEach(function(E,O){_[E.toLowerCase()]=O}),S.forEach(function(E,O){const A=E.toLowerCase();_[A]=(O+2)*10,_[A.substring(0,E.length-1)+"ieth"]=_[A]}),_.hundredth=100,w.forEach(function(E,O){const A=E.toLowerCase(),R=Math.pow(10,(O+1)*3);_[A]=R,_[A+"th"]=R});function I(E){const A=E.split(/,\s|\sand\s|[\s\\-]/).map(U=>_[U]);let R=[0];return A.forEach(U=>{if(U<100){let P=R.pop();P>=1e3&&(R.push(P),P=0),R.push(P+U)}else R.push(R.pop()*U)}),R.reduce((U,P)=>U+P,0)}const Q=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],q={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ee(E){for(var O=0;O<Q.length;O++){const A=Q[O];if(E>=A[0])return A[1]+ee(E-A[0])}return""}function $(E){for(var O=0,A=1,R=E.length-1;R>=0;R--){const Z=E[R],U=q[Z];U<A?O-=U:(A=U,O+=U)}return O}function C(E,O){for(var A=[],R=O.charCodeAt(0);E>0;)A.unshift(String.fromCharCode((E-1)%26+R)),E=Math.floor((E-1)/26);return A.join("")}function M(E,O){for(var A=O.charCodeAt(0),R=0,Z=0;Z<E.length;Z++)R+=(E.charCodeAt(E.length-Z-1)-A+1)*Math.pow(26,Z);return R}function D(E,O){if(typeof E>"u")return;E=Math.floor(E);const A=ie(O);return F(E,A)}const x={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},j={UPPER:"upper",LOWER:"lower",TITLE:"title"};function F(E,O){let A;const R=E<0;switch(E=Math.abs(E),O.primary){case x.LETTERS:A=C(E,O.case===j.UPPER?"A":"a");break;case x.ROMAN:A=ee(E),O.case===j.UPPER&&(A=A.toUpperCase());break;case x.WORDS:A=h(E,O.ordinal),O.case===j.UPPER?A=A.toUpperCase():O.case===j.LOWER&&(A=A.toLowerCase());break;case x.DECIMAL:A=""+E;var Z=O.mandatoryDigits-A.length;if(Z>0){var U=new Array(Z+1).join("0");A=U+A}if(O.zeroCode!==48&&(A=c(A).map(_e=>String.fromCodePoint(_e.codePointAt(0)+O.zeroCode-48)).join("")),O.regular){const _e=Math.floor((A.length-1)/O.groupingSeparators.position);for(let Se=_e;Se>0;Se--){const re=A.length-Se*O.groupingSeparators.position;A=A.substr(0,re)+O.groupingSeparators.character+A.substr(re)}}else O.groupingSeparators.reverse().forEach(_e=>{const Se=A.length-_e.position;A=A.substr(0,Se)+_e.character+A.substr(Se)});if(O.ordinal){var P={1:"st",2:"nd",3:"rd"},V=A[A.length-1],ne=P[V];(!ne||A.length>1&&A[A.length-2]==="1")&&(ne="th"),A=A+ne}break;case x.SEQUENCE:throw{code:"D3130",value:O.token}}return R&&(A="-"+A),A}const fe=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function ie(E){const O={type:"integer",primary:x.DECIMAL,case:j.LOWER,ordinal:!1};let A,R;const Z=E.lastIndexOf(";");switch(Z===-1?A=E:(A=E.substring(0,Z),R=E.substring(Z+1),R[0]==="o"&&(O.ordinal=!0)),A){case"A":O.case=j.UPPER;case"a":O.primary=x.LETTERS;break;case"I":O.case=j.UPPER;case"i":O.primary=x.ROMAN;break;case"W":O.case=j.UPPER,O.primary=x.WORDS;break;case"Ww":O.case=j.TITLE,O.primary=x.WORDS;break;case"w":O.primary=x.WORDS;break;default:{let U=null,P=0,V=0,ne=[],_e=0;if(c(A).map(re=>re.codePointAt(0)).reverse().forEach(re=>{let oe=!1;for(let we=0;we<fe.length;we++){const K=fe[we];if(re>=K&&re<=K+9){if(oe=!0,P++,_e++,U===null)U=K;else if(K!==U)throw{code:"D3131"};break}}oe||(re===35?(_e++,V++):ne.push({position:_e,character:String.fromCodePoint(re)}))}),P>0){O.primary=x.DECIMAL,O.zeroCode=U,O.mandatoryDigits=P,O.optionalDigits=V;const oe=function(we){if(we.length===0)return 0;const K=we[0].character;for(let Ve=1;Ve<we.length;Ve++)if(we[Ve].character!==K)return 0;const We=we.map(Ve=>Ve.position),ft=function(Ve,Ye){return Ye===0?Ve:ft(Ye,Ve%Ye)},Ge=We.reduce(ft);for(let Ve=1;Ve<=We.length;Ve++)if(We.indexOf(Ve*Ge)===-1)return 0;return Ge}(ne);oe>0?(O.regular=!0,O.groupingSeparators={position:oe,character:ne[0].character}):(O.regular=!1,O.groupingSeparators=ne)}else O.primary=x.SEQUENCE,O.token=A}}return O}const be={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 xe(E){var O=[];const A={type:"datetime",parts:O},R=function(oe,we){if(we>oe){let K=E.substring(oe,we);K=K.split("]]").join("]"),O.push({type:"literal",value:K})}};for(var Z=0,U=0;U<E.length;){if(E.charAt(U)==="["){if(E.charAt(U+1)==="["){R(Z,U),O.push({type:"literal",value:"["}),U+=2,Z=U;continue}if(R(Z,U),Z=U,U=E.indexOf("]",Z),U===-1)throw{code:"D3135"};let oe=E.substring(Z+1,U);oe=oe.split(/\s+/).join("");var P={type:"marker",component:oe.charAt(0)},V=oe.lastIndexOf(","),ne;if(V!==-1){const we=oe.substring(V+1),K=we.indexOf("-");let We,ft;const Ge=function(Ye){if(!(typeof Ye>"u"||Ye==="*"))return parseInt(Ye)};K===-1?We=we:(We=we.substring(0,K),ft=we.substring(K+1));const Ve={min:Ge(We),max:Ge(ft)};P.width=Ve,ne=oe.substring(1,V)}else ne=oe.substring(1);if(ne.length===1)P.presentation1=ne;else if(ne.length>1){var _e=ne.charAt(ne.length-1);"atco".indexOf(_e)!==-1?(P.presentation2=_e,_e==="o"&&(P.ordinal=!0),P.presentation1=ne.substring(0,ne.length-1)):P.presentation1=ne}else P.presentation1=be[P.component];if(typeof P.presentation1>"u")throw{code:"D3132",value:P.component};if(P.presentation1[0]==="n")P.names=j.LOWER;else if(P.presentation1[0]==="N")P.presentation1[1]==="n"?P.names=j.TITLE:P.names=j.UPPER;else if("YMDdFWwXxHhmsf".indexOf(P.component)!==-1){var Se=P.presentation1;if(P.presentation2&&(Se+=";"+P.presentation2),P.integerFormat=ie(Se),P.width&&P.width.min!==void 0&&P.integerFormat.mandatoryDigits<P.width.min&&(P.integerFormat.mandatoryDigits=P.width.min),P.component==="Y")if(P.n=-1,P.width&&P.width.max!==void 0)P.n=P.width.max,P.integerFormat.mandatoryDigits=P.n;else{var re=P.integerFormat.mandatoryDigits+P.integerFormat.optionalDigits;re>=2&&(P.n=re)}const we=O[O.length-1];we&&we.integerFormat&&(we.integerFormat.parseWidth=we.integerFormat.mandatoryDigits)}(P.component==="Z"||P.component==="z")&&(P.integerFormat=ie(P.presentation1)),O.push(P),Z=U+1}U++}return R(Z,U),A}const he=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Oe=["January","February","March","April","May","June","July","August","September","October","November","December"],Ue=1e3*60*60*24,te=function(E){const O=Date.UTC(E.year,E.month);var A=new Date(O).getUTCDay();return A===0&&(A=7),A>4?O+(8-A)*Ue:O-(A-1)*Ue},se=function(E,O){return{year:E,month:O,nextMonth:function(){return O===11?se(E+1,0):se(E,O+1)},previousMonth:function(){return O===0?se(E-1,11):se(E,O-1)},nextYear:function(){return se(E+1,O)},previousYear:function(){return se(E-1,O)}}},st=function(E,O){return(O-E)/(Ue*7)+1},de=(E,O)=>{let A;switch(O){case"Y":A=E.getUTCFullYear();break;case"M":A=E.getUTCMonth()+1;break;case"D":A=E.getUTCDate();break;case"d":{const R=Date.UTC(E.getUTCFullYear(),E.getUTCMonth(),E.getUTCDate()),Z=Date.UTC(E.getUTCFullYear(),0);A=(R-Z)/Ue+1;break}case"F":A=E.getUTCDay(),A===0&&(A=7);break;case"W":{const R=se(E.getUTCFullYear(),0),Z=te(R),U=Date.UTC(R.year,E.getUTCMonth(),E.getUTCDate());let P=st(Z,U);if(P>52){const V=te(R.nextYear());U>=V&&(P=1)}else if(P<1){const V=te(R.previousYear());P=st(V,U)}A=Math.floor(P);break}case"w":{const R=se(E.getUTCFullYear(),E.getUTCMonth()),Z=te(R),U=Date.UTC(R.year,R.month,E.getUTCDate());let P=st(Z,U);if(P>4){const V=te(R.nextMonth());U>=V&&(P=1)}else if(P<1){const V=te(R.previousMonth());P=st(V,U)}A=Math.floor(P);break}case"X":{const R=se(E.getUTCFullYear(),0),Z=te(R),U=te(R.nextYear()),P=E.getTime();P<Z?A=R.year-1:P>=U?A=R.year+1:A=R.year;break}case"x":{const R=se(E.getUTCFullYear(),E.getUTCMonth()),Z=te(R),U=R.nextMonth(),P=te(U),V=E.getTime();V<Z?A=R.previousMonth().month+1:V>=P?A=U.month+1:A=R.month+1;break}case"H":A=E.getUTCHours();break;case"h":A=E.getUTCHours(),A=A%12,A===0&&(A=12);break;case"P":A=E.getUTCHours()>=12?"pm":"am";break;case"m":A=E.getUTCMinutes();break;case"s":A=E.getUTCSeconds();break;case"f":A=E.getUTCMilliseconds();break;case"Z":case"z":break;case"C":A="ISO";break;case"E":A="ISO";break}return A};let $e=null;function lt(E,O,A){var R=0,Z=0;if(typeof A<"u"){const Se=parseInt(A);R=Math.floor(Se/100),Z=Se%100}var U=function(Se,re){var oe=de(Se,re.component);if("YMDdFWwXxHhms".indexOf(re.component)!==-1)if(re.component==="Y"&&re.n!==-1&&(oe=oe%Math.pow(10,re.n)),re.names){if(re.component==="M"||re.component==="x")oe=Oe[oe-1];else if(re.component==="F")oe=he[oe];else throw{code:"D3133",value:re.component};re.names===j.UPPER?oe=oe.toUpperCase():re.names===j.LOWER&&(oe=oe.toLowerCase()),re.width&&oe.length>re.width.max&&(oe=oe.substring(0,re.width.max))}else oe=F(oe,re.integerFormat);else if(re.component==="f")oe=F(oe,re.integerFormat);else if(re.component==="Z"||re.component==="z"){const we=R*100+Z;if(re.integerFormat.regular)oe=F(we,re.integerFormat);else{const K=re.integerFormat.mandatoryDigits;if(K===1||K===2)oe=F(R,re.integerFormat),Z!==0&&(oe+=":"+D(Z,"00"));else if(K===3||K===4)oe=F(we,re.integerFormat);else throw{code:"D3134",value:K}}we>=0&&(oe="+"+oe),re.component==="z"&&(oe="GMT"+oe),we===0&&re.presentation2==="t"&&(oe="Z")}else re.component==="P"&&re.names===j.UPPER&&(oe=oe.toUpperCase());return oe};let P;typeof O>"u"?($e===null&&($e=xe("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),P=$e):P=xe(O);const V=(60*R+Z)*60*1e3,ne=new Date(E+V);let _e="";return P.parts.forEach(function(Se){Se.type==="literal"?_e+=Se.value:_e+=U(ne,Se)}),_e}function m(E){var O={};if(E.type==="datetime")O.type="datetime",O.parts=E.parts.map(function(A){var R={};if(A.type==="literal")R.regex=A.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(A.component==="Z"||A.component==="z"){let U;Array.isArray(A.integerFormat.groupingSeparators)||(U=A.integerFormat.groupingSeparators),R.regex="",A.component==="z"&&(R.regex="GMT"),R.regex+="[-+][0-9]+",U&&(R.regex+=U.character+"[0-9]+"),R.parse=function(P){A.component==="z"&&(P=P.substring(3));let V=0,ne=0;return U?(V=Number.parseInt(P.substring(0,P.indexOf(U.character))),ne=Number.parseInt(P.substring(P.indexOf(U.character)+1))):P.length-1<=2?V=Number.parseInt(P):(V=Number.parseInt(P.substring(0,3)),ne=Number.parseInt(P.substring(3))),V*60+ne}}else if(A.integerFormat)R=m(A.integerFormat);else{R.regex="[a-zA-Z]+";var Z={};if(A.component==="M"||A.component==="x")Oe.forEach(function(U,P){A.width&&A.width.max?Z[U.substring(0,A.width.max)]=P+1:Z[U]=P+1});else if(A.component==="F")he.forEach(function(U,P){P>0&&(A.width&&A.width.max?Z[U.substring(0,A.width.max)]=P:Z[U]=P)});else if(A.component==="P")Z={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:A.component};R.parse=function(U){return Z[U]}}return R.component=A.component,R});else{O.type="integer";const A=E.case===j.UPPER;switch(E.primary){case x.LETTERS:O.regex=A?"[A-Z]+":"[a-z]+",O.parse=function(R){return M(R,A?"A":"a")};break;case x.ROMAN:O.regex=A?"[MDCLXVI]+":"[mdclxvi]+",O.parse=function(R){return $(A?R:R.toUpperCase())};break;case x.WORDS:O.regex="(?:"+Object.keys(_).concat("and","[\\-, ]").join("|")+")+",O.parse=function(R){return I(R.toLowerCase())};break;case x.DECIMAL:O.regex="[0-9]",E.parseWidth?O.regex+=`{${E.parseWidth}}`:O.regex+="+",E.ordinal&&(O.regex+="(?:th|st|nd|rd)"),O.parse=function(R){let Z=R;return E.ordinal&&(Z=R.substring(0,R.length-2)),E.regular?Z=Z.split(",").join(""):E.groupingSeparators.forEach(U=>{Z=Z.split(U.character).join("")}),E.zeroCode!==48&&(Z=Z.split("").map(U=>String.fromCodePoint(U.codePointAt(0)-E.zeroCode+48)).join("")),parseInt(Z)};break;case x.SEQUENCE:throw{code:"D3130",value:E.token}}}return O}function v(E,O){if(typeof E>"u")return;const A=ie(O);return m(A).parse(E)}function Y(E,O){const A=xe(O),R=m(A),Z="^"+R.parts.map(ne=>"("+ne.regex+")").join("")+"$";var P=new RegExp(Z,"i").exec(E);if(P!==null){const K={};for(let De=1;De<P.length;De++){const l=R.parts[De-1];l.parse&&(K[l.component]=l.parse(P[De]))}if(Object.getOwnPropertyNames(K).length===0)return;let We=0;const ft=De=>{We<<=1,We+=De?1:0},Ge=De=>!(~De&We)&&!!(De&We);"YXMxWwdD".split("").forEach(De=>ft(K[De]));const Ye=!Ge(161)&&Ge(130),At=Ge(84),Nt=!At&&Ge(72);We=0,"PHhmsf".split("").forEach(De=>ft(K[De]));const It=!Ge(23)&&Ge(47),or=(Ye?"YD":At?"XxwF":Nt?"XWF":"YMD")+(It?"Phmsf":"Hmsf"),ht=this.environment.timestamp;let qt=!1,xt=!1;if(or.split("").forEach(De=>{if(typeof K[De]>"u")qt?(K[De]="MDd".indexOf(De)!==-1?1:0,xt=!0):K[De]=de(ht,De);else if(qt=!0,xt)throw{code:"D3136"}}),K.M>0?K.M-=1:K.M=0,Ye){const De=Date.UTC(K.Y,0),l=(K.d-1)*1e3*60*60*24,y=new Date(De+l);K.M=y.getUTCMonth(),K.D=y.getUTCDate()}if(At)throw{code:"D3136"};if(Nt)throw{code:"D3136"};It&&(K.H=K.h===12?0:K.h,K.P===1&&(K.H+=12));var V=Date.UTC(K.Y,K.M,K.D,K.H,K.m,K.s,K.f);return(K.Z||K.z)&&(V-=(K.Z||K.z)*60*1e3),V}}var ge=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 Ne(E,O){if(!(typeof E>"u"))if(typeof O>"u"){if(!ge.test(E))throw{stack:new Error().stack,code:"D3110",value:E};return Date.parse(E)}else return Y.call(this,E,O)}function Te(E,O,A){if(!(typeof E>"u"))return lt.call(this,E,O,A)}return{formatInteger:D,parseInteger:v,fromMillis:Te,toMillis:Ne}})();n.exports=o},{"./utils":6}],2:[function(t,n,a){(function(i){(function(){var o=t("./utils");const c=(()=>{var d=o.isNumeric,p=o.isArrayOfStrings,S=o.isArrayOfNumbers,w=o.createSequence,h=o.isSequence,_=o.isFunction,I=o.isLambda,Q=o.isPromise,q=o.getFunctionArity,ee=o.isDeepEqual,$=o.stringToArray;function C(s){if(!(typeof s>"u")){var u=0;return s.forEach(function(f){u+=f}),u}}function M(s){return typeof s>"u"?0:s.length}function D(s){if(!(typeof s>"u"||s.length===0))return Math.max.apply(Math,s)}function x(s){if(!(typeof s>"u"||s.length===0))return Math.min.apply(Math,s)}function j(s){if(!(typeof s>"u"||s.length===0)){var u=0;return s.forEach(function(f){u+=f}),u/s.length}}function F(s,u=!1){if(!(typeof s>"u")){var f;if(typeof s=="string")f=s;else if(_(s))f="";else{if(typeof s=="number"&&!isFinite(s))throw{code:"D3001",value:s,stack:new Error().stack};var k=u?2:0;Array.isArray(s)&&s.outerWrapper&&(s=s[0]),f=JSON.stringify(s,function(g,T){return typeof T<"u"&&T!==null&&T.toPrecision&&d(T)?Number(T.toPrecision(15)):T&&_(T)?"":T},k)}return f}}function fe(s,u,f){if(!(typeof s>"u")){var k=$(s),g=k.length;if(g+u<0&&(u=0),typeof f<"u"){if(f<=0)return"";var T=u>=0?u+f:g+u+f;return k.slice(u,T).join("")}return k.slice(u).join("")}}function ie(s,u){if(!(typeof s>"u")){var f=s.indexOf(u);return f>-1?s.substr(0,f):s}}function be(s,u){if(!(typeof s>"u")){var f=s.indexOf(u);return f>-1?s.substr(f+u.length):s}}function xe(s){if(!(typeof s>"u"))return s.toLowerCase()}function he(s){if(!(typeof s>"u"))return s.toUpperCase()}function Oe(s){if(!(typeof s>"u"))return $(s).length}function Ue(s){if(!(typeof s>"u")){var u=s.replace(/[ \t\n\r]+/gm," ");return u.charAt(0)===" "&&(u=u.substring(1)),u.charAt(u.length-1)===" "&&(u=u.substring(0,u.length-1)),u}}function te(s,u,f){if(!(typeof s>"u")){(typeof f>"u"||f.length===0)&&(f=" ");var k;u=Math.trunc(u);var g=Math.abs(u)-Oe(s);if(g>0){var T=new Array(g+1).join(f);f.length>1&&(T=fe(T,0,g)),u>0?k=s+T:k=T+s}else k=s;return k}}async function se(s,u){var f=s.apply(this,[u]);if(Q(f)&&(f=await f),f&&!(typeof f.start=="number"||f.end==="number"||Array.isArray(f.groups)||_(f.next)))throw{code:"T1010",stack:new Error().stack};return f}async function st(s,u){if(!(typeof s>"u")){var f;if(typeof u=="string")f=s.indexOf(u)!==-1;else{var k=await se(u,s);f=typeof k<"u"}return f}}async function de(s,u,f){if(!(typeof s>"u")){if(f<0)throw{stack:new Error().stack,value:f,code:"D3040",index:3};var k=w();if(typeof f>"u"||f>0){var g=0,T=await se(u,s);if(typeof T<"u")for(;typeof T<"u"&&(typeof f>"u"||g<f);)k.push({match:T.match,index:T.start,groups:T.groups}),T=await se(T.next),g++}return k}}async function $e(s,u,f,k){if(!(typeof s>"u")){var g=this;if(u==="")throw{code:"D3010",stack:new Error().stack,value:u,index:2};if(k<0)throw{code:"D3011",stack:new Error().stack,value:k,index:4};var T;typeof f=="string"?T=function(Ce){for(var ze="",Ae=0,je=f.indexOf("$",Ae);je!==-1&&Ae<f.length;){ze+=f.substring(Ae,je),Ae=je+1;var dt=f.charAt(Ae);if(dt==="$")ze+="$",Ae++;else if(dt==="0")ze+=Ce.match,Ae++;else{var qe;if(Ce.groups.length===0?qe=1:qe=Math.floor(Math.log(Ce.groups.length)*Math.LOG10E)+1,je=parseInt(f.substring(Ae,Ae+qe),10),qe>1&&je>Ce.groups.length&&(je=parseInt(f.substring(Ae,Ae+qe-1),10)),isNaN(je))ze+="$";else{if(Ce.groups.length>0){var Ht=Ce.groups[je-1];typeof Ht<"u"&&(ze+=Ht)}Ae+=je.toString().length}}je=f.indexOf("$",Ae)}return ze+=f.substring(Ae),ze}:T=f;var B="",J=0;if(typeof k>"u"||k>0){var ae=0;if(typeof u=="string"){for(var Me=s.indexOf(u,J);Me!==-1&&(typeof k>"u"||ae<k);)B+=s.substring(J,Me),B+=f,J=Me+u.length,ae++,Me=s.indexOf(u,J);B+=s.substring(J)}else{var ke=await se(u,s);if(typeof ke<"u"){for(;typeof ke<"u"&&(typeof k>"u"||ae<k);){B+=s.substring(J,ke.start);var Ie=T.apply(g,[ke]);if(Q(Ie)&&(Ie=await Ie),typeof Ie=="string")B+=Ie;else throw{code:"D3012",stack:new Error().stack,value:Ie};J=ke.start+ke.match.length,ae++,ke=await se(ke.next)}B+=s.substring(J)}else B=s}}else B=s;return B}}function lt(s){if(!(typeof s>"u")){var u=typeof window<"u"?window.btoa:function(f){return new i.Buffer.from(f,"binary").toString("base64")};return u(s)}}function m(s){if(!(typeof s>"u")){var u=typeof window<"u"?window.atob:function(f){return new i.Buffer.from(f,"base64").toString("binary")};return u(s)}}function v(s){if(!(typeof s>"u")){var u;try{u=encodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrlComponent"}}return u}}function Y(s){if(!(typeof s>"u")){var u;try{u=encodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrl"}}return u}}function ge(s){if(!(typeof s>"u")){var u;try{u=decodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrlComponent"}}return u}}function Ne(s){if(!(typeof s>"u")){var u;try{u=decodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrl"}}return u}}async function Te(s,u,f){if(!(typeof s>"u")){if(f<0)throw{code:"D3020",stack:new Error().stack,value:f,index:3};var k=[];if(typeof f>"u"||f>0)if(typeof u=="string")k=s.split(u,f);else{var g=0,T=await se(u,s);if(typeof T<"u"){for(var B=0;typeof T<"u"&&(typeof f>"u"||g<f);)k.push(s.substring(B,T.start)),B=T.end,T=await se(T.next),g++;(typeof f>"u"||g<f)&&k.push(s.substring(B))}else k.push(s)}return k}}function E(s,u){if(!(typeof s>"u"))return typeof u>"u"&&(u=""),s.join(u)}function O(s,u,f){if(!(typeof s>"u")){var k={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},g=k;typeof f<"u"&&Object.keys(f).forEach(function(ue){g[ue]=f[ue]});for(var T=[],B=g["zero-digit"].charCodeAt(0),J=B;J<B+10;J++)T.push(String.fromCharCode(J));var ae=T.concat([g["decimal-separator"],g["exponent-separator"],g["grouping-separator"],g.digit,g["pattern-separator"]]),Me=u.split(g["pattern-separator"]);if(Me.length>2)throw{code:"D3080",stack:new Error().stack};var ke=function(ue){var Le=(function(){for(var Ze,ct=0;ct<ue.length;ct++)if(Ze=ue.charAt(ct),ae.indexOf(Ze)!==-1&&Ze!==g["exponent-separator"])return ue.substring(0,ct)})(),Ke=(function(){for(var Ze,ct=ue.length-1;ct>=0;ct--)if(Ze=ue.charAt(ct),ae.indexOf(Ze)!==-1&&Ze!==g["exponent-separator"])return ue.substring(ct+1)})(),Fe=ue.substring(Le.length,ue.length-Ke.length),nt,Ft,at,Ut,ot=ue.indexOf(g["exponent-separator"],Le.length);ot===-1||ot>ue.length-Ke.length?(nt=Fe,Ft=void 0):(nt=Fe.substring(0,ot),Ft=Fe.substring(ot+1));var mt=nt.indexOf(g["decimal-separator"]);return mt===-1?(at=nt,Ut=Ke):(at=nt.substring(0,mt),Ut=nt.substring(mt+1)),{prefix:Le,suffix:Ke,activePart:Fe,mantissaPart:nt,exponentPart:Ft,integerPart:at,fractionalPart:Ut,subpicture:ue}},Ie=function(ue){var Le,Ke,Fe=ue.subpicture,nt=Fe.indexOf(g["decimal-separator"]);nt!==Fe.lastIndexOf(g["decimal-separator"])&&(Le="D3081"),Fe.indexOf(g.percent)!==Fe.lastIndexOf(g.percent)&&(Le="D3082"),Fe.indexOf(g["per-mille"])!==Fe.lastIndexOf(g["per-mille"])&&(Le="D3083"),Fe.indexOf(g.percent)!==-1&&Fe.indexOf(g["per-mille"])!==-1&&(Le="D3084");var Ft=!1;for(Ke=0;Ke<ue.mantissaPart.length;Ke++){var at=ue.mantissaPart.charAt(Ke);if(T.indexOf(at)!==-1||at===g.digit){Ft=!0;break}}Ft||(Le="D3085");var Ut=ue.activePart.split("").map(function(Ze){return ae.indexOf(Ze)===-1?"p":"a"}).join("");Ut.indexOf("p")!==-1&&(Le="D3086"),nt!==-1?(Fe.charAt(nt-1)===g["grouping-separator"]||Fe.charAt(nt+1)===g["grouping-separator"])&&(Le="D3087"):ue.integerPart.charAt(ue.integerPart.length-1)===g["grouping-separator"]&&(Le="D3088"),Fe.indexOf(g["grouping-separator"]+g["grouping-separator"])!==-1&&(Le="D3089");var ot=ue.integerPart.indexOf(g.digit);ot!==-1&&ue.integerPart.substring(0,ot).split("").filter(function(Ze){return T.indexOf(Ze)>-1}).length>0&&(Le="D3090"),ot=ue.fractionalPart.lastIndexOf(g.digit),ot!==-1&&ue.fractionalPart.substring(ot).split("").filter(function(Ze){return T.indexOf(Ze)>-1}).length>0&&(Le="D3091");var mt=typeof ue.exponentPart=="string";if(mt&&ue.exponentPart.length>0&&(Fe.indexOf(g.percent)!==-1||Fe.indexOf(g["per-mille"])!==-1)&&(Le="D3092"),mt&&(ue.exponentPart.length===0||ue.exponentPart.split("").filter(function(Ze){return T.indexOf(Ze)===-1}).length>0)&&(Le="D3093"),Le)throw{code:Le,stack:new Error().stack}},Ce=function(ue){var Le=function(He,Nr){for(var lr=[],Tt=He.indexOf(g["grouping-separator"]);Tt!==-1;){var Ir=(Nr?He.substring(0,Tt):He.substring(Tt)).split("").filter(function(Yt){return T.indexOf(Yt)!==-1||Yt===g.digit}).length;lr.push(Ir),Tt=ue.integerPart.indexOf(g["grouping-separator"],Tt+1)}return lr},Ke=Le(ue.integerPart),Fe=function(He){if(He.length===0)return 0;for(var Nr=function(Ir,Yt){return Yt===0?Ir:Nr(Yt,Ir%Yt)},lr=He.reduce(Nr),Tt=1;Tt<=He.length;Tt++)if(He.indexOf(Tt*lr)===-1)return 0;return lr},nt=Fe(Ke),Ft=Le(ue.fractionalPart,!0),at=ue.integerPart.split("").filter(function(He){return T.indexOf(He)!==-1}).length,Ut=at,ot=ue.fractionalPart.split(""),mt=ot.filter(function(He){return T.indexOf(He)!==-1}).length,Ze=ot.filter(function(He){return T.indexOf(He)!==-1||He===g.digit}).length,ct=typeof ue.exponentPart=="string";at===0&&Ze===0&&(ct?(mt=1,Ze=1):at=1),ct&&at===0&&ue.integerPart.indexOf(g.digit)!==-1&&(at=1),at===0&&mt===0&&(mt=1);var Un=0;return ct&&(Un=ue.exponentPart.split("").filter(function(He){return T.indexOf(He)!==-1}).length),{integerPartGroupingPositions:Ke,regularGrouping:nt,minimumIntegerPartSize:at,scalingFactor:Ut,prefix:ue.prefix,fractionalPartGroupingPositions:Ft,minimumFactionalPartSize:mt,maximumFactionalPartSize:Ze,minimumExponentSize:Un,suffix:ue.suffix,picture:ue.subpicture}},ze=Me.map(ke);ze.forEach(Ie);var Ae=ze.map(Ce),je=g["minus-sign"],dt=g["zero-digit"],qe=g["decimal-separator"],Ht=g["grouping-separator"];Ae.length===1&&(Ae.push(JSON.parse(JSON.stringify(Ae[0]))),Ae[1].prefix=je+Ae[1].prefix);var Be;s>=0?Be=Ae[0]:Be=Ae[1];var cr;Be.picture.indexOf(g.percent)!==-1?cr=s*100:Be.picture.indexOf(g["per-mille"])!==-1?cr=s*1e3:cr=s;var Bt,Gt;if(Be.minimumExponentSize===0)Bt=cr;else{var wa=Math.pow(10,Be.scalingFactor),ka=Math.pow(10,Be.scalingFactor-1);for(Bt=cr,Gt=0;Bt<ka;)Bt*=10,Gt-=1;for(;Bt>wa;)Bt/=10,Gt+=1}var xa=V(Bt,Be.maximumFactionalPartSize),$n=function(ue,Le){var Ke=Math.abs(ue).toFixed(Le);return dt!=="0"&&(Ke=Ke.split("").map(function(Fe){return Fe>="0"&&Fe<="9"?T[Fe.charCodeAt(0)-48]:Fe}).join("")),Ke},me=$n(xa,Be.maximumFactionalPartSize),Je=me.indexOf(".");for(Je===-1?me=me+qe:me=me.replace(".",qe);me.charAt(0)===dt;)me=me.substring(1);for(;me.charAt(me.length-1)===dt;)me=me.substring(0,me.length-1);Je=me.indexOf(qe);var ur=Be.minimumIntegerPartSize-Je,Bn=Be.minimumFactionalPartSize-(me.length-Je-1);if(me=(ur>0?new Array(ur+1).join(dt):"")+me,me=me+(Bn>0?new Array(Bn+1).join(dt):""),Je=me.indexOf(qe),Be.regularGrouping>0)for(var _a=Math.floor((Je-1)/Be.regularGrouping),Mr=1;Mr<=_a;Mr++)me=[me.slice(0,Je-Mr*Be.regularGrouping),Ht,me.slice(Je-Mr*Be.regularGrouping)].join("");else Be.integerPartGroupingPositions.forEach(function(ue){me=[me.slice(0,Je-ue),Ht,me.slice(Je-ue)].join(""),Je++});if(Je=me.indexOf(qe),Be.fractionalPartGroupingPositions.forEach(function(ue){me=[me.slice(0,ue+Je+1),Ht,me.slice(ue+Je+1)].join("")}),Je=me.indexOf(qe),(Be.picture.indexOf(qe)===-1||Je===me.length-1)&&(me=me.substring(0,me.length-1)),typeof Gt<"u"){var Pr=$n(Gt,0);ur=Be.minimumExponentSize-Pr.length,ur>0&&(Pr=new Array(ur+1).join(dt)+Pr),me=me+g["exponent-separator"]+(Gt<0?je:"")+Pr}return me=Be.prefix+me+Be.suffix,me}}function A(s,u){if(!(typeof s>"u")){if(s=V(s),typeof u>"u"?u=10:u=V(u),u<2||u>36)throw{code:"D3100",stack:new Error().stack,value:u};var f=s.toString(u);return f}}function R(s){var u;if(!(typeof s>"u")){if(typeof s=="number")u=s;else if(typeof s=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(s)&&!isNaN(parseFloat(s))&&isFinite(s))u=parseFloat(s);else if(typeof s=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(s))u=Number(s);else if(s===!0)u=1;else if(s===!1)u=0;else throw{code:"D3030",value:s,stack:new Error().stack,index:1};return u}}function Z(s){var u;if(!(typeof s>"u"))return u=Math.abs(s),u}function U(s){var u;if(!(typeof s>"u"))return u=Math.floor(s),u}function P(s){var u;if(!(typeof s>"u"))return u=Math.ceil(s),u}function V(s,u){var f;if(!(typeof s>"u")){if(u){var k=s.toString().split("e");s=+(k[0]+"e"+(k[1]?+k[1]+u:u))}f=Math.round(s);var g=f-s;return Math.abs(g)===.5&&Math.abs(f%2)===1&&(f=f-1),u&&(k=f.toString().split("e"),f=+(k[0]+"e"+(k[1]?+k[1]-u:-u))),Object.is(f,-0)&&(f=0),f}}function ne(s){var u;if(!(typeof s>"u")){if(s<0)throw{stack:new Error().stack,code:"D3060",index:1,value:s};return u=Math.sqrt(s),u}}function _e(s,u){var f;if(!(typeof s>"u")){if(f=Math.pow(s,u),!isFinite(f))throw{stack:new Error().stack,code:"D3061",index:1,value:s,exp:u};return f}}function Se(){return Math.random()}function re(s){if(!(typeof s>"u")){var u=!1;if(Array.isArray(s)){if(s.length===1)u=re(s[0]);else if(s.length>1){var f=s.filter(function(k){return re(k)});u=f.length>0}}else typeof s=="string"?s.length>0&&(u=!0):d(s)?s!==0&&(u=!0):s!==null&&typeof s=="object"&&!_(s)?Object.keys(s).length>0&&(u=!0):typeof s=="boolean"&&s===!0&&(u=!0);return u}}function oe(s){if(!(typeof s>"u"))return!re(s)}function we(s,u,f,k){var g=[u],T=q(s);return T>=2&&g.push(f),T>=3&&g.push(k),g}async function K(s,u){if(!(typeof s>"u")){for(var f=w(),k=0;k<s.length;k++){var g=we(u,s[k],k,s),T=await u.apply(this,g);typeof T<"u"&&f.push(T)}return f}}async function We(s,u){if(!(typeof s>"u")){for(var f=w(),k=0;k<s.length;k++){var g=s[k],T=we(u,g,k,s),B=await u.apply(this,T);re(B)&&f.push(g)}return f}}async function ft(s,u){if(!(typeof s>"u")){for(var f=!1,k,g=0;g<s.length;g++){var T=s[g],B=!0;if(typeof u<"u"){var J=we(u,T,g,s),ae=await u.apply(this,J);B=re(ae)}if(B)if(!f)k=T,f=!0;else throw{stack:new Error().stack,code:"D3138",index:g}}if(!f)throw{stack:new Error().stack,code:"D3139"};return k}}function Ge(){for(var s=[],u=Array.prototype.slice.call(arguments),f=Math.min.apply(Math,u.map(function(T){return Array.isArray(T)?T.length:0})),k=0;k<f;k++){var g=u.map(T=>T[k]);s.push(g)}return s}async function Ve(s,u,f){if(!(typeof s>"u")){var k,g=q(u);if(g<2)throw{stack:new Error().stack,code:"D3050",index:1};var T;for(typeof f>"u"&&s.length>0?(k=s[0],T=1):(k=f,T=0);T<s.length;){var B=[k,s[T]];g>=3&&B.push(T),g>=4&&B.push(s),k=await u.apply(this,B),T++}return k}}function Ye(s){var u=w();if(Array.isArray(s)){var f={};s.forEach(function(k){var g=Ye(k);g.forEach(function(T){f[T]=!0})}),u=Ye(f)}else s!==null&&typeof s=="object"&&!_(s)&&Object.keys(s).forEach(k=>u.push(k));return u}function At(s,u){var f;if(Array.isArray(s)){f=w();for(var k=0;k<s.length;k++){var g=At(s[k],u);typeof g<"u"&&(Array.isArray(g)?g.forEach(T=>f.push(T)):f.push(g))}}else s!==null&&typeof s=="object"&&!_(s)&&(f=s[u]);return f}function Nt(s,u){return typeof s>"u"?u:typeof u>"u"?s:(Array.isArray(s)||(s=w(s)),Array.isArray(u)||(u=[u]),s.concat(u))}function Cr(s){return!(typeof s>"u")}function It(s){var u=w();if(Array.isArray(s))s.forEach(function(g){u=Nt(u,It(g))});else if(s!==null&&typeof s=="object"&&!I(s))for(var f in s){var k={};k[f]=s[f],u.push(k)}else u=s;return u}function z(s){if(!(typeof s>"u")){var u={};return s.forEach(function(f){for(var k in f)u[k]=f[k]}),u}}function Dr(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var u=s.length,f=new Array(u),k=0;k<u;k++)f[u-k-1]=s[k];return f}}async function or(s,u){var f=w();for(var k in s){var g=we(u,s[k],k,s),T=await u.apply(this,g);typeof T<"u"&&f.push(T)}return f}function ht(s){throw{code:"D3137",stack:new Error().stack,message:s||"$error() function evaluated"}}function qt(s,u){if(!s)throw{code:"D3141",stack:new Error().stack,message:u||"$assert() statement failed"}}function xt(s){if(s!==void 0)return s===null?"null":d(s)?"number":typeof s=="string"?"string":typeof s=="boolean"?"boolean":Array.isArray(s)?"array":_(s)?"function":"object"}async function De(s,u){if(!(typeof s>"u")){if(s.length<=1)return s;var f;if(typeof u>"u"){if(!S(s)&&!p(s))throw{stack:new Error().stack,code:"D3070",index:1};f=async function(B,J){return B>J}}else f=u;var k=async function(B,J){var ae=async function(ke,Ie,Ce){Ie.length===0?Array.prototype.push.apply(ke,Ce):Ce.length===0?Array.prototype.push.apply(ke,Ie):await f(Ie[0],Ce[0])?(ke.push(Ce[0]),await ae(ke,Ie,Ce.slice(1))):(ke.push(Ie[0]),await ae(ke,Ie.slice(1),Ce))},Me=[];return await ae(Me,B,J),Me},g=async function(B){if(!Array.isArray(B)||B.length<=1)return B;var J=Math.floor(B.length/2),ae=B.slice(0,J),Me=B.slice(J);return ae=await g(ae),Me=await g(Me),await k(ae,Me)},T=await g(s);return T}}function l(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var u=new Array(s.length),f=0;f<s.length;f++){var k=Math.floor(Math.random()*(f+1));f!==k&&(u[f]=u[k]),u[k]=s[f]}return u}}function y(s){if(!(typeof s>"u")){if(!Array.isArray(s)||s.length<=1)return s;for(var u=h(s)?w():[],f=0;f<s.length;f++){for(var k=s[f],g=!1,T=0;T<u.length;T++)if(ee(k,u[T])){g=!0;break}g||u.push(k)}return u}}async function b(s,u){var f={};for(var k in s){var g=s[k],T=we(u,g,k,s),B=await u.apply(this,T);re(B)&&(f[k]=g)}return Object.keys(f).length===0&&(f=void 0),f}return{sum:C,count:M,max:D,min:x,average:j,string:F,substring:fe,substringBefore:ie,substringAfter:be,lowercase:xe,uppercase:he,length:Oe,trim:Ue,pad:te,match:de,contains:st,replace:$e,split:Te,join:E,formatNumber:O,formatBase:A,number:R,floor:U,ceil:P,round:V,abs:Z,sqrt:ne,power:_e,random:Se,boolean:re,not:oe,map:K,zip:Ge,filter:We,single:ft,foldLeft:Ve,sift:b,keys:Ye,lookup:At,append:Nt,exists:Cr,spread:It,merge:z,reverse:Dr,each:or,error:ht,assert:qt,type:xt,sort:De,shuffle:l,distinct:y,base64encode:lt,base64decode:m,encodeUrlComponent:v,encodeUrl:Y,decodeUrlComponent:ge,decodeUrl:Ne}})();n.exports=c}).call(this)}).call(this,typeof Hn<"u"?Hn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,n,a){var i=t("./datetime"),o=t("./functions"),c=t("./utils"),d=t("./parser"),p=t("./signature"),S=(function(){var w=c.isNumeric,h=c.isArrayOfStrings,_=c.isArrayOfNumbers,I=c.createSequence,Q=c.isSequence,q=c.isFunction,ee=c.isLambda,$=c.isIterable,C=c.isPromise,M=c.getFunctionArity,D=c.isDeepEqual,x=ht(null);async function j(l,y,b){var s,u=b.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(u&&await u(l,y,b),l.type){case"path":s=await F(l,y,b);break;case"binary":s=await Oe(l,y,b);break;case"unary":s=await Ue(l,y,b);break;case"name":s=te(l,y);break;case"string":case"number":case"value":s=se(l);break;case"wildcard":s=st(l,y);break;case"descendant":s=$e(l,y);break;case"parent":s=b.lookup(l.slot.label);break;case"condition":s=await U(l,y,b);break;case"block":s=await P(l,y,b);break;case"bind":s=await Z(l,y,b);break;case"regex":s=V(l);break;case"function":s=await we(l,y,b);break;case"variable":s=ne(l,y,b);break;case"lambda":s=ft(l,y,b);break;case"partial":s=await Ge(l,y,b);break;case"apply":s=await oe(l,y,b);break;case"transform":s=Se(l,y,b);break}if(Object.prototype.hasOwnProperty.call(l,"predicate"))for(var f=0;f<l.predicate.length;f++)s=await he(l.predicate[f].expr,s,b);l.type!=="path"&&Object.prototype.hasOwnProperty.call(l,"group")&&(s=await O(l.group,s,b));var k=b.lookup(Symbol.for("jsonata.__evaluate_exit"));return k&&await k(l,y,b,s),s&&Q(s)&&!s.tupleStream&&(l.keepArray&&(s.keepSingleton=!0),s.length===0?s=void 0:s.length===1&&(s=s.keepSingleton?s:s[0])),s}async function F(l,y,b){var s;Array.isArray(y)&&l.steps[0].type!=="variable"?s=y:s=I(y);for(var u,f=!1,k=void 0,g=0;g<l.steps.length;g++){var T=l.steps[g];if(T.tuple&&(f=!0),g===0&&T.consarray?u=await j(T,s,b):f?k=await xe(T,s,k,b):u=await ie(T,s,b,g===l.steps.length-1),!f&&(typeof u>"u"||u.length===0))break;typeof T.focus>"u"&&(s=u)}if(f)if(l.tuple)u=k;else for(u=I(),g=0;g<k.length;g++)u.push(k[g]["@"]);return l.keepSingletonArray&&(Array.isArray(u)&&u.cons&&!u.sequence&&(u=I(u)),u.keepSingleton=!0),l.hasOwnProperty("group")&&(u=await O(l.group,f?k:u,b)),u}function fe(l,y){var b=ht(l);for(const s in y)b.bind(s,y[s]);return b}async function ie(l,y,b,s){var u;if(l.type==="sort")return u=await _e(l,y,b),l.stages&&(u=await be(l.stages,u,b)),u;u=I();for(var f=0;f<y.length;f++){var k=await j(l,y[f],b);if(l.stages)for(var g=0;g<l.stages.length;g++)k=await he(l.stages[g].expr,k,b);typeof k<"u"&&u.push(k)}var T=I();return s&&u.length===1&&Array.isArray(u[0])&&!Q(u[0])?T=u[0]:u.forEach(function(B){!Array.isArray(B)||B.cons?T.push(B):B.forEach(J=>T.push(J))}),T}async function be(l,y,b){for(var s=y,u=0;u<l.length;u++){var f=l[u];switch(f.type){case"filter":s=await he(f.expr,s,b);break;case"index":for(var k=0;k<s.length;k++){var g=s[k];g[f.value]=k}break}}return s}async function xe(l,y,b,s){var u;if(l.type==="sort"){if(b)u=await _e(l,b,s);else{var f=await _e(l,y,s);u=I(),u.tupleStream=!0;for(var k=0;k<f.length;k++){var g={"@":f[k]};g[l.index]=k,u.push(g)}}return l.stages&&(u=await be(l.stages,u,s)),u}u=I(),u.tupleStream=!0;var T=s;b===void 0&&(b=y.map(Me=>({"@":Me})));for(var B=0;B<b.length;B++){T=fe(s,b[B]);var J=await j(l,b[B]["@"],T);if(typeof J<"u"){Array.isArray(J)||(J=[J]);for(var ae=0;ae<J.length;ae++)g={},Object.assign(g,b[B]),J.tupleStream?Object.assign(g,J[ae]):(l.focus?(g[l.focus]=J[ae],g["@"]=b[B]["@"]):g["@"]=J[ae],l.index&&(g[l.index]=ae),l.ancestor&&(g[l.ancestor.label]=b[B]["@"])),u.push(g)}}return l.stages&&(u=await be(l.stages,u,s)),u}async function he(l,y,b){var s=I();if(y&&y.tupleStream&&(s.tupleStream=!0),Array.isArray(y)||(y=I(y)),l.type==="number"){var u=Math.floor(l.value);u<0&&(u=y.length+u);var f=await y[u];typeof f<"u"&&(Array.isArray(f)?s=f:s.push(f))}else for(u=0;u<y.length;u++){var f=y[u],k=f,g=b;y.tupleStream&&(k=f["@"],g=fe(b,f));var T=await j(l,k,g);w(T)&&(T=[T]),_(T)?T.forEach(function(J){var ae=Math.floor(J);ae<0&&(ae=y.length+ae),ae===u&&s.push(f)}):o.boolean(T)&&s.push(f)}return s}async function Oe(l,y,b){var s,u=await j(l.lhs,y,b),f=l.value,k=async()=>await j(l.rhs,y,b);if(f==="and"||f==="or")try{return await Ne(u,k,f)}catch(T){throw T.position=l.position,T.token=f,T}var g=await k();try{switch(f){case"+":case"-":case"*":case"/":case"%":s=m(u,g,f);break;case"=":case"!=":s=v(u,g,f);break;case"<":case"<=":case">":case">=":s=Y(u,g,f);break;case"&":s=E(u,g);break;case"..":s=R(u,g);break;case"in":s=ge(u,g);break}}catch(T){throw T.position=l.position,T.token=f,T}return s}async function Ue(l,y,b){var s;switch(l.value){case"-":if(s=await j(l.expression,y,b),typeof s>"u")s=void 0;else if(w(s))s=-s;else throw{code:"D1002",stack:new Error().stack,position:l.position,token:l.value,value:s};break;case"[":s=[];let k=await Promise.all(l.expressions.map(async(g,T)=>(b.isParallelCall=T>0,[g,await j(g,y,b)])));for(let g of k){var[u,f]=g;typeof f<"u"&&(u.value==="["?s.push(f):s=o.append(s,f))}l.consarray&&Object.defineProperty(s,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":s=await O(l,y,b);break}return s}function te(l,y,b){return o.lookup(y,l.value)}function se(l){return l.value}function st(l,y){var b=I();return Array.isArray(y)&&y.outerWrapper&&y.length>0&&(y=y[0]),y!==null&&typeof y=="object"&&Object.keys(y).forEach(function(s){var u=y[s];Array.isArray(u)?(u=de(u),b=o.append(b,u)):b.push(u)}),b}function de(l,y){return typeof y>"u"&&(y=[]),Array.isArray(l)?l.forEach(function(b){de(b,y)}):y.push(l),y}function $e(l,y){var b,s=I();return typeof y<"u"&&(lt(y,s),s.length===1?b=s[0]:b=s),b}function lt(l,y){Array.isArray(l)||y.push(l),Array.isArray(l)?l.forEach(function(b){lt(b,y)}):l!==null&&typeof l=="object"&&Object.keys(l).forEach(function(b){lt(l[b],y)})}function m(l,y,b){var s;if(typeof l<"u"&&!w(l))throw{code:"T2001",stack:new Error().stack,value:l};if(typeof y<"u"&&!w(y))throw{code:"T2002",stack:new Error().stack,value:y};if(typeof l>"u"||typeof y>"u")return s;switch(b){case"+":s=l+y;break;case"-":s=l-y;break;case"*":s=l*y;break;case"/":s=l/y;break;case"%":s=l%y;break}return s}function v(l,y,b){var s,u=typeof l,f=typeof y;if(u==="undefined"||f==="undefined")return!1;switch(b){case"=":s=D(l,y);break;case"!=":s=!D(l,y);break}return s}function Y(l,y,b){var s,u=typeof l,f=typeof y,k=u==="undefined"||u==="string"||u==="number",g=f==="undefined"||f==="string"||f==="number";if(!k||!g)throw{code:"T2010",stack:new Error().stack,value:u==="string"||u==="number"?y:l};if(!(u==="undefined"||f==="undefined")){if(u!==f)throw{code:"T2009",stack:new Error().stack,value:l,value2:y};switch(b){case"<":s=l<y;break;case"<=":s=l<=y;break;case">":s=l>y;break;case">=":s=l>=y;break}return s}}function ge(l,y){var b=!1;if(typeof l>"u"||typeof y>"u")return!1;Array.isArray(y)||(y=[y]);for(var s=0;s<y.length;s++)if(y[s]===l){b=!0;break}return b}async function Ne(l,y,b){var s,u=Te(l);switch(b){case"and":s=u&&Te(await y());break;case"or":s=u||Te(await y());break}return s}function Te(l){var y=o.boolean(l);return typeof y>"u"?!1:y}function E(l,y){var b,s="",u="";return typeof l<"u"&&(s=o.string(l)),typeof y<"u"&&(u=o.string(y)),b=s.concat(u),b}async function O(l,y,b){var s={},u={},f=!!(y&&y.tupleStream);Array.isArray(y)||(y=I(y)),y.length===0&&y.push(void 0);for(var k=0;k<y.length;k++)for(var g=y[k],T=f?fe(b,g):b,B=0;B<l.lhs.length;B++){var J=l.lhs[B],ae=await j(J[0],f?g["@"]:g,T);if(typeof ae!="string"&&ae!==void 0)throw{code:"T1003",stack:new Error().stack,position:l.position,value:ae};if(ae!==void 0){var Me={data:g,exprIndex:B};if(u.hasOwnProperty(ae)){if(u[ae].exprIndex!==B)throw{code:"D1009",stack:new Error().stack,position:l.position,value:ae};u[ae].data=o.append(u[ae].data,g)}else u[ae]=Me}}let ke=await Promise.all(Object.keys(u).map(async(Ce,ze)=>{let Ae=u[Ce];var je=Ae.data,dt=b;if(f){var qe=A(Ae.data);je=qe["@"],delete qe["@"],dt=fe(b,qe)}return b.isParallelCall=ze>0,[Ce,await j(l.lhs[Ae.exprIndex][1],je,dt)]}));for(let Ce of ke){var[ae,Ie]=await Ce;typeof Ie<"u"&&(s[ae]=Ie)}return s}function A(l){if(!Array.isArray(l))return l;var y={};Object.assign(y,l[0]);for(var b=1;b<l.length;b++)for(const s in l[b])y[s]=o.append(y[s],l[b][s]);return y}function R(l,y){var b;if(typeof l<"u"&&!Number.isInteger(l))throw{code:"T2003",stack:new Error().stack,value:l};if(typeof y<"u"&&!Number.isInteger(y))throw{code:"T2004",stack:new Error().stack,value:y};if(typeof l>"u"||typeof y>"u"||l>y)return b;var s=y-l+1;if(s>1e7)throw{code:"D2014",stack:new Error().stack,value:s};b=new Array(s);for(var u=l,f=0;u<=y;u++,f++)b[f]=u;return b.sequence=!0,b}async function Z(l,y,b){var s=await j(l.rhs,y,b);return b.bind(l.lhs.value,s),s}async function U(l,y,b){var s,u=await j(l.condition,y,b);return o.boolean(u)?s=await j(l.then,y,b):typeof l.else<"u"&&(s=await j(l.else,y,b)),s}async function P(l,y,b){for(var s,u=ht(b),f=0;f<l.expressions.length;f++)s=await j(l.expressions[f],y,u);return s}function V(l){var y=new De.RegexEngine(l.value),b=function(s,u){var f;y.lastIndex=u||0;var k=y.exec(s);if(k!==null){if(f={match:k[0],start:k.index,end:k.index+k[0].length,groups:[]},k.length>1)for(var g=1;g<k.length;g++)f.groups.push(k[g]);f.next=function(){if(!(y.lastIndex>=s.length)){var T=b(s,y.lastIndex);if(T&&T.match==="")throw{code:"D1004",stack:new Error().stack,position:l.position,value:l.value.source};return T}}}return f};return b}function ne(l,y,b){var s;return l.value===""?s=y&&y.outerWrapper?y[0]:y:s=b.lookup(l.value),s}async function _e(l,y,b){var s,u=y,f=!!y.tupleStream,k=async function(T,B){for(var J=0,ae=0;J===0&&ae<l.terms.length;ae++){var Me=l.terms[ae],ke=T,Ie=b;f&&(ke=T["@"],Ie=fe(b,T));var Ce=await j(Me.expression,ke,Ie);ke=B,Ie=b,f&&(ke=B["@"],Ie=fe(b,B));var ze=await j(Me.expression,ke,Ie),Ae=typeof Ce,je=typeof ze;if(Ae==="undefined"){J=je==="undefined"?0:1;continue}if(je==="undefined"){J=-1;continue}if(!(Ae==="string"||Ae==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:l.position,value:Ae==="string"||Ae==="number"?ze:Ce};if(Ae!==je)throw{code:"T2007",stack:new Error().stack,position:l.position,value:Ce,value2:ze};Ce!==ze&&(Ce<ze?J=-1:J=1,Me.descending===!0&&(J=-J))}return J===1},g={environment:b,input:y};return s=await o.sort.apply(g,[u,k]),s}function Se(l,y,b){var s=async function(u){if(!(typeof u>"u")){var f=b.lookup("clone");if(!q(f))throw{code:"T2013",stack:new Error().stack,position:l.position};var k=await K(f,[u],null,b),g=await j(l.pattern,k,b);if(typeof g<"u"){Array.isArray(g)||(g=[g]);for(var T=0;T<g.length;T++){var B=g[T];if(B&&(B.isPrototypeOf(k)||B instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:l.position};var J=await j(l.update,B,b),ae=typeof J;if(ae!=="undefined"){if(ae!=="object"||J===null||Array.isArray(J))throw{code:"T2011",stack:new Error().stack,position:l.update.position,value:J};for(var Me in J)B[Me]=J[Me]}if(typeof l.delete<"u"){var ke=await j(l.delete,B,b);if(typeof ke<"u"){var Ie=ke;if(Array.isArray(ke)||(ke=[ke]),!h(ke))throw{code:"T2012",stack:new Error().stack,position:l.delete.position,value:Ie};for(var Ce=0;Ce<ke.length;Ce++)typeof B=="object"&&B!==null&&delete B[ke[Ce]]}}}}return k}};return z(s,"<(oa):o>")}var re=d("function($f, $g) { function($x){ $g($f($x)) } }");async function oe(l,y,b){var s,u=await j(l.lhs,y,b);if(l.rhs.type==="function")s=await we(l.rhs,y,b,{context:u});else{var f=await j(l.rhs,y,b);if(!q(f))throw{code:"T2006",stack:new Error().stack,position:l.position,value:f};if(q(u)){var k=await j(re,null,b);s=await K(k,[u,f],null,b)}else s=await K(f,[u],null,b)}return s}async function we(l,y,b,s){var u,f=await j(l.procedure,y,b);if(typeof f>"u"&&l.procedure.type==="path"&&b.lookup(l.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};var k=[];typeof s<"u"&&k.push(s.context);for(var g=0;g<l.arguments.length;g++){const B=await j(l.arguments[g],y,b);if(q(B)){const J=async function(...ae){return await K(B,ae,null,b)};J.arity=M(B),k.push(J)}else k.push(B)}var T=l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value;try{typeof f=="object"&&(f.token=T,f.position=l.position),u=await K(f,k,y,b)}catch(B){throw B.position||(B.position=l.position),B.token||(B.token=T),B}return u}async function K(l,y,b,s){var u;for(u=await We(l,y,b,s);ee(u)&&u.thunk===!0;){var f=await j(u.body.procedure,u.input,u.environment);u.body.procedure.type==="variable"&&(f.token=u.body.procedure.value),f.position=u.body.procedure.position;for(var k=[],g=0;g<u.body.arguments.length;g++)k.push(await j(u.body.arguments[g],u.input,u.environment));u=await We(f,k,b,s)}return u}async function We(l,y,b,s){var u;try{var f=y;if(l&&(f=Ve(l.signature,y,b)),ee(l))u=await Ye(l,f);else if(l&&l._jsonata_function===!0){var k={environment:s,input:b};u=l.implementation.apply(k,f),$(u)&&(u=u.next().value),C(u)&&(u=await u)}else if(typeof l=="function")u=l.apply(b,f),C(u)&&(u=await u);else throw{code:"T1006",stack:new Error().stack}}catch(g){throw l&&(typeof g.token>"u"&&typeof l.token<"u"&&(g.token=l.token),g.position=l.position||g.position),g}return u}function ft(l,y,b){var s={_jsonata_lambda:!0,input:y,environment:b,arguments:l.arguments,signature:l.signature,body:l.body};return l.thunk===!0&&(s.thunk=!0),s.apply=async function(u,f){return await K(s,f,y,u?u.environment:b)},s}async function Ge(l,y,b){for(var s,u=[],f=0;f<l.arguments.length;f++){var k=l.arguments[f];k.type==="operator"&&k.value==="?"?u.push(k):u.push(await j(k,y,b))}var g=await j(l.procedure,y,b);if(typeof g>"u"&&l.procedure.type==="path"&&b.lookup(l.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};if(ee(g))s=At(g,u);else if(g&&g._jsonata_function===!0)s=Nt(g.implementation,u);else if(typeof g=="function")s=Nt(g,u);else throw{code:"T1008",stack:new Error().stack,position:l.position,token:l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value};return s}function Ve(l,y,b){if(typeof l>"u")return y;var s=l.validate(y,b);return s}async function Ye(l,y){var b,s=ht(l.environment);return l.arguments.forEach(function(u,f){s.bind(u.value,y[f])}),typeof l.body=="function"?b=await Cr(l.body,s):b=await j(l.body,l.input,s),b}function At(l,y){var b=ht(l.environment),s=[];l.arguments.forEach(function(f,k){var g=y[k];g&&g.type==="operator"&&g.value==="?"?s.push(f):b.bind(f.value,g)});var u={_jsonata_lambda:!0,input:l.input,environment:b,arguments:s,body:l.body};return u}function Nt(l,y){var b=It(l);b=b.map(function(k){return"$"+k.trim()});var s="function("+b.join(", ")+"){ _ }",u=d(s);u.body=l;var f=At(u,y);return f}async function Cr(l,y){var b=It(l),s=b.map(function(k){return y.lookup(k.trim())}),u={environment:y},f=l.apply(u,s);return C(f)&&(f=await f),f}function It(l){var y=l.toString(),b=/\(([^)]*)\)/.exec(y)[1],s=b.split(",");return s}function z(l,y){var b={_jsonata_function:!0,implementation:l};return typeof y<"u"&&(b.signature=p(y)),b}async function Dr(l,y){if(!(typeof l>"u")){var b=this.input;typeof y<"u"&&(b=y,Array.isArray(b)&&!Q(b)&&(b=I(b),b.outerWrapper=!0));try{var s=d(l,!1)}catch(f){throw xt(f),{stack:new Error().stack,code:"D3120",value:f.message,error:f}}try{var u=await j(s,b,this.environment)}catch(f){throw xt(f),{stack:new Error().stack,code:"D3121",value:f.message,error:f}}return u}}function or(l){if(!(typeof l>"u"))return JSON.parse(o.string(l))}function ht(l){var y={};const b={bind:function(u,f){y[u]=f},lookup:function(u){var f;return y.hasOwnProperty(u)?f=y[u]:l&&(f=l.lookup(u)),f},timestamp:l?l.timestamp:null,async:l?l.async:!1,isParallelCall:l?l.isParallelCall:!1,global:l?l.global:{ancestry:[null]}};if(l){var s=l.lookup(Symbol.for("jsonata.__createFrame_push"));s&&s(l,b)}return b}x.bind("sum",z(o.sum,"<a<n>:n>")),x.bind("count",z(o.count,"<a:n>")),x.bind("max",z(o.max,"<a<n>:n>")),x.bind("min",z(o.min,"<a<n>:n>")),x.bind("average",z(o.average,"<a<n>:n>")),x.bind("string",z(o.string,"<x-b?:s>")),x.bind("substring",z(o.substring,"<s-nn?:s>")),x.bind("substringBefore",z(o.substringBefore,"<s-s:s>")),x.bind("substringAfter",z(o.substringAfter,"<s-s:s>")),x.bind("lowercase",z(o.lowercase,"<s-:s>")),x.bind("uppercase",z(o.uppercase,"<s-:s>")),x.bind("length",z(o.length,"<s-:n>")),x.bind("trim",z(o.trim,"<s-:s>")),x.bind("pad",z(o.pad,"<s-ns?:s>")),x.bind("match",z(o.match,"<s-f<s:o>n?:a<o>>")),x.bind("contains",z(o.contains,"<s-(sf):b>")),x.bind("replace",z(o.replace,"<s-(sf)(sf)n?:s>")),x.bind("split",z(o.split,"<s-(sf)n?:a<s>>")),x.bind("join",z(o.join,"<a<s>s?:s>")),x.bind("formatNumber",z(o.formatNumber,"<n-so?:s>")),x.bind("formatBase",z(o.formatBase,"<n-n?:s>")),x.bind("formatInteger",z(i.formatInteger,"<n-s:s>")),x.bind("parseInteger",z(i.parseInteger,"<s-s:n>")),x.bind("number",z(o.number,"<(nsb)-:n>")),x.bind("floor",z(o.floor,"<n-:n>")),x.bind("ceil",z(o.ceil,"<n-:n>")),x.bind("round",z(o.round,"<n-n?:n>")),x.bind("abs",z(o.abs,"<n-:n>")),x.bind("sqrt",z(o.sqrt,"<n-:n>")),x.bind("power",z(o.power,"<n-n:n>")),x.bind("random",z(o.random,"<:n>")),x.bind("boolean",z(o.boolean,"<x-:b>")),x.bind("not",z(o.not,"<x-:b>")),x.bind("map",z(o.map,"<af>")),x.bind("zip",z(o.zip,"<a+>")),x.bind("filter",z(o.filter,"<af>")),x.bind("single",z(o.single,"<af?>")),x.bind("reduce",z(o.foldLeft,"<afj?:j>")),x.bind("sift",z(o.sift,"<o-f?:o>")),x.bind("keys",z(o.keys,"<x-:a<s>>")),x.bind("lookup",z(o.lookup,"<x-s:x>")),x.bind("append",z(o.append,"<xx:a>")),x.bind("exists",z(o.exists,"<x:b>")),x.bind("spread",z(o.spread,"<x-:a<o>>")),x.bind("merge",z(o.merge,"<a<o>:o>")),x.bind("reverse",z(o.reverse,"<a:a>")),x.bind("each",z(o.each,"<o-f:a>")),x.bind("error",z(o.error,"<s?:x>")),x.bind("assert",z(o.assert,"<bs?:x>")),x.bind("type",z(o.type,"<x:s>")),x.bind("sort",z(o.sort,"<af?:a>")),x.bind("shuffle",z(o.shuffle,"<a:a>")),x.bind("distinct",z(o.distinct,"<x:x>")),x.bind("base64encode",z(o.base64encode,"<s-:s>")),x.bind("base64decode",z(o.base64decode,"<s-:s>")),x.bind("encodeUrlComponent",z(o.encodeUrlComponent,"<s-:s>")),x.bind("encodeUrl",z(o.encodeUrl,"<s-:s>")),x.bind("decodeUrlComponent",z(o.decodeUrlComponent,"<s-:s>")),x.bind("decodeUrl",z(o.decodeUrl,"<s-:s>")),x.bind("eval",z(Dr,"<sx?:x>")),x.bind("toMillis",z(i.toMillis,"<s-s?:n>")),x.bind("fromMillis",z(i.fromMillis,"<n-s?s?:s>")),x.bind("clone",z(or,"<(oa)-:o>"));var qt={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 xt(l){var y=qt[l.code];if(typeof y<"u"){var b=y.replace(/\{\{\{([^}]+)}}}/g,function(){return l[arguments[1]]});b=b.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(l[arguments[1]])}),l.message=b}}function De(l,y){var b,s;try{b=d(l,y&&y.recover),s=b.errors,delete b.errors}catch(k){throw xt(k),k}var u=ht(x),f=new Date;return u.bind("now",z(function(k,g){return i.fromMillis(f.getTime(),k,g)},"<s?s?:s>")),u.bind("millis",z(function(){return f.getTime()},"<:n>")),y&&y.RegexEngine?De.RegexEngine=y.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(k,g,T){if(typeof s<"u"){var B={code:"S0500",position:0};throw xt(B),B}if(typeof g<"u"){var J;J=ht(u);for(var ae in g)J.bind(ae,g[ae])}else J=u;J.bind("$",k),f=new Date,J.timestamp=f,Array.isArray(k)&&!Q(k)&&(k=I(k),k.outerWrapper=!0);var Me;try{return Me=await j(b,k,J),typeof T=="function"&&T(null,Me),Me}catch(ke){throw xt(ke),ke}},assign:function(k,g){u.bind(k,g)},registerFunction:function(k,g,T){var B=z(g,T);u.bind(k,B)},ast:function(){return b},errors:function(){return s}}}return De.parser=d,De})();n.exports=S},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,n,a){var i=t("./signature");const o=(()=>{var c={".":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},d={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
6
|
+
`,r:"\r",t:" "},p=function(w){var h=0,_=w.length,I=function(ee,$){var C={type:ee,value:$,position:h};return C},Q=function(){for(var ee=h,$=0,C,M,D=function(j){if(w.charAt(j)==="/"&&$===0){for(var F=0;w.charAt(j-(F+1))==="\\";)F++;if(F%2===0)return!0}return!1};h<_;){var x=w.charAt(h);if(D(h)){if(C=w.substring(ee,h),C==="")throw{code:"S0301",stack:new Error().stack,position:h};for(h++,x=w.charAt(h),ee=h;x==="i"||x==="m";)h++,x=w.charAt(h);return M=w.substring(ee,h)+"g",new RegExp(C,M)}(x==="("||x==="["||x==="{")&&w.charAt(h-1)!=="\\"&&$++,(x===")"||x==="]"||x==="}")&&w.charAt(h-1)!=="\\"&&$--,h++}throw{code:"S0302",stack:new Error().stack,position:h}},q=function(ee){if(h>=_)return null;for(var $=w.charAt(h);h<_&&`
|
|
7
|
+
\r\v`.indexOf($)>-1;)h++,$=w.charAt(h);if($==="/"&&w.charAt(h+1)==="*"){var C=h;for(h+=2,$=w.charAt(h);!($==="*"&&w.charAt(h+1)==="/");)if($=w.charAt(++h),h>=_)throw{code:"S0106",stack:new Error().stack,position:C};return h+=2,$=w.charAt(h),q(ee)}if(ee!==!0&&$==="/")return h++,I("regex",Q());if($==="."&&w.charAt(h+1)===".")return h+=2,I("operator","..");if($===":"&&w.charAt(h+1)==="=")return h+=2,I("operator",":=");if($==="!"&&w.charAt(h+1)==="=")return h+=2,I("operator","!=");if($===">"&&w.charAt(h+1)==="=")return h+=2,I("operator",">=");if($==="<"&&w.charAt(h+1)==="=")return h+=2,I("operator","<=");if($==="*"&&w.charAt(h+1)==="*")return h+=2,I("operator","**");if($==="~"&&w.charAt(h+1)===">")return h+=2,I("operator","~>");if($==="?"&&w.charAt(h+1)===":")return h+=2,I("operator","?:");if($==="?"&&w.charAt(h+1)==="?")return h+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(c,$))return h++,I("operator",$);if($==='"'||$==="'"){var M=$;h++;for(var D="";h<_;){if($=w.charAt(h),$==="\\")if(h++,$=w.charAt(h),Object.prototype.hasOwnProperty.call(d,$))D+=d[$];else if($==="u"){var x=w.substr(h+1,4);if(/^[0-9a-fA-F]+$/.test(x)){var j=parseInt(x,16);D+=String.fromCharCode(j),h+=4}else throw{code:"S0104",stack:new Error().stack,position:h}}else throw{code:"S0103",stack:new Error().stack,position:h,token:$};else{if($===M)return h++,I("string",D);D+=$}h++}throw{code:"S0101",stack:new Error().stack,position:h}}var F=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,fe=F.exec(w.substring(h));if(fe!==null){var ie=parseFloat(fe[0]);if(!isNaN(ie)&&isFinite(ie))return h+=fe[0].length,I("number",ie);throw{code:"S0102",stack:new Error().stack,position:h,token:fe[0]}}var be;if($==="`"){h++;var xe=w.indexOf("`",h);if(xe!==-1)return be=w.substring(h,xe),h=xe+1,I("name",be);throw h=_,{code:"S0105",stack:new Error().stack,position:h}}for(var he=h,Oe;;)if(Oe=w.charAt(he),he===_||`
|
|
8
|
+
\r\v`.indexOf(Oe)>-1||Object.prototype.hasOwnProperty.call(c,Oe)){if(w.charAt(h)==="$")return be=w.substring(h+1,he),h=he,I("variable",be);switch(be=w.substring(h,he),h=he,be){case"or":case"in":case"and":return I("operator",be);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return h===_&&be===""?null:I("name",be)}}else he++};return q},S=function(w,h){var _,I,Q={},q=[],ee=function(){var m=[];_.id!=="(end)"&&m.push({type:_.type,value:_.value,position:_.position});for(var v=I();v!==null;)m.push(v),v=I();return m},$={nud:function(){var m={code:"S0211",token:this.value,position:this.position};if(h)return m.remaining=ee(),m.type="error",q.push(m),m;throw m.stack=new Error().stack,m}},C=function(m,v){var Y=Q[m];return v=v||0,Y?v>=Y.lbp&&(Y.lbp=v):(Y=Object.create($),Y.id=Y.value=m,Y.lbp=v,Q[m]=Y),Y},M=function(m){if(h){m.remaining=ee(),q.push(m);var v=Q["(error)"];return _=Object.create(v),_.error=m,_.type="(error)",_}else throw m.stack=new Error().stack,m},D=function(m,v){if(m&&_.id!==m){var Y;_.id==="(end)"?Y="S0203":Y="S0202";var ge={code:Y,position:_.position,token:_.value,value:m};return M(ge)}var Ne=I(v);if(Ne===null)return _=Q["(end)"],_.position=w.length,_;var Te=Ne.value,E=Ne.type,O;switch(E){case"name":case"variable":O=Q["(name)"];break;case"operator":if(O=Q[Te],!O)return M({code:"S0204",stack:new Error().stack,position:Ne.position,token:Te});break;case"string":case"number":case"value":O=Q["(literal)"];break;case"regex":E="regex",O=Q["(regex)"];break;default:return M({code:"S0205",stack:new Error().stack,position:Ne.position,token:Te})}return _=Object.create(O),_.value=Te,_.type=E,_.position=Ne.position,_},x=function(m){var v,Y=_;for(D(null,!0),v=Y.nud();m<_.lbp;)Y=_,D(),v=Y.led(v);return v},j=function(m){var v=C(m,0);v.nud=function(){return this}},F=function(m,v,Y){var ge=v||c[m],Ne=C(m,ge);return Ne.led=Y||function(Te){return this.lhs=Te,this.rhs=x(ge),this.type="binary",this},Ne},fe=function(m,v,Y){var ge=C(m,v);return ge.led=Y,ge},ie=function(m,v){var Y=C(m);return Y.nud=v||function(){return this.expression=x(70),this.type="unary",this},Y};j("(end)"),j("(name)"),j("(literal)"),j("(regex)"),C(":"),C(";"),C(","),C(")"),C("]"),C("}"),C(".."),F("."),F("+"),F("-"),F("*"),F("/"),F("%"),F("="),F("<"),F(">"),F("!="),F("<="),F(">="),F("&"),F("and"),F("or"),F("in"),j("and"),j("or"),j("in"),ie("-"),F("~>"),F("??",c["??"],function(m){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[m]},this.then=m,this.else=x(0),this}),fe("(error)",10,function(m){return this.lhs=m,this.error=_.error,this.remaining=ee(),this.type="error",this}),ie("*",function(){return this.type="wildcard",this}),ie("**",function(){return this.type="descendant",this}),ie("%",function(){return this.type="parent",this}),F("(",c["("],function(m){if(this.procedure=m,this.type="function",this.arguments=[],_.id!==")")for(;_.type==="operator"&&_.id==="?"?(this.type="partial",this.arguments.push(_),D("?")):this.arguments.push(x(0)),_.id===",";)D(",");if(D(")",!0),m.type==="name"&&(m.value==="function"||m.value==="λ")){if(this.arguments.forEach(function(Te,E){if(Te.type!=="variable")return M({code:"S0208",stack:new Error().stack,position:Te.position,token:Te.value,value:E+1})}),this.type="lambda",_.id==="<"){for(var v=_.position,Y=1,ge="<";Y>0&&_.id!=="{"&&_.id!=="(end)";){var Ne=D();Ne.id===">"?Y--:Ne.id==="<"&&Y++,ge+=Ne.value}D(">");try{this.signature=i(ge)}catch(Te){return Te.position=v+Te.offset,M(Te)}}D("{"),this.body=x(0),D("}")}return this}),ie("(",function(){for(var m=[];_.id!==")"&&(m.push(x(0)),_.id===";");)D(";");return D(")",!0),this.type="block",this.expressions=m,this}),ie("[",function(){var m=[];if(_.id!=="]")for(;;){var v=x(0);if(_.id===".."){var Y={type:"binary",value:"..",position:_.position,lhs:v};D(".."),Y.rhs=x(0),v=Y}if(m.push(v),_.id!==",")break;D(",")}return D("]",!0),this.expressions=m,this.type="unary",this}),F("[",c["["],function(m){if(_.id==="]"){for(var v=m;v&&v.type==="binary"&&v.value==="[";)v=v.lhs;return v.keepArray=!0,D("]"),m}else return this.lhs=m,this.rhs=x(c["]"]),this.type="binary",D("]",!0),this}),F("^",c["^"],function(m){D("(");for(var v=[];;){var Y={descending:!1};if(_.id==="<"?D("<"):_.id===">"&&(Y.descending=!0,D(">")),Y.expression=x(0),v.push(Y),_.id!==",")break;D(",")}return D(")"),this.lhs=m,this.rhs=v,this.type="binary",this});var be=function(m){var v=[];if(_.id!=="}")for(;;){var Y=x(0);D(":");var ge=x(0);if(v.push([Y,ge]),_.id!==",")break;D(",")}return D("}",!0),typeof m>"u"?(this.lhs=v,this.type="unary"):(this.lhs=m,this.rhs=v,this.type="binary"),this};ie("{",be),F("{",c["{"],be),fe(":=",c[":="],function(m){return m.type!=="variable"?M({code:"S0212",stack:new Error().stack,position:m.position,token:m.value}):(this.lhs=m,this.rhs=x(c[":="]-1),this.type="binary",this)}),F("@",c["@"],function(m){return this.lhs=m,this.rhs=x(c["@"]),this.rhs.type!=="variable"?M({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),F("#",c["#"],function(m){return this.lhs=m,this.rhs=x(c["#"]),this.rhs.type!=="variable"?M({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),F("?",c["?"],function(m){return this.type="condition",this.condition=m,this.then=x(0),_.id===":"&&(D(":"),this.else=x(0)),this}),F("?:",c["?:"],function(m){return this.type="condition",this.condition=m,this.then=m,this.else=x(0),this}),ie("|",function(){return this.type="transform",this.pattern=x(0),D("|"),this.update=x(0),_.id===","&&(D(","),this.delete=x(0)),D("|"),this});var xe=function(m){var v;if(m.type==="function"&&!m.predicate){var Y={type:"lambda",thunk:!0,arguments:[],position:m.position};Y.body=m,v=Y}else if(m.type==="condition")m.then=xe(m.then),typeof m.else<"u"&&(m.else=xe(m.else)),v=m;else if(m.type==="block"){var ge=m.expressions.length;ge>0&&(m.expressions[ge-1]=xe(m.expressions[ge-1])),v=m}else v=m;return v},he=0,Oe=0,Ue=[],te=function(m,v){switch(m.type){case"name":case"wildcard":v.level--,v.level===0&&(typeof m.ancestor>"u"||(Ue[v.index].slot.label=m.ancestor.label),m.ancestor=v,m.tuple=!0);break;case"parent":v.level++;break;case"block":m.expressions.length>0&&(m.tuple=!0,v=te(m.expressions[m.expressions.length-1],v));break;case"path":m.tuple=!0;var Y=m.steps.length-1;for(v=te(m.steps[Y--],v);v.level>0&&Y>=0;)v=te(m.steps[Y--],v);break;default:throw{code:"S0217",token:m.type,position:m.position}}return v},se=function(m,v){if(typeof v.seekingParent<"u"||v.type==="parent"){var Y=typeof v.seekingParent<"u"?v.seekingParent:[];v.type==="parent"&&Y.push(v.slot),typeof m.seekingParent>"u"?m.seekingParent=Y:Array.prototype.push.apply(m.seekingParent,Y)}},st=function(m){var v=m.steps.length-1,Y=m.steps[v],ge=typeof Y.seekingParent<"u"?Y.seekingParent:[];Y.type==="parent"&&ge.push(Y.slot);for(var Ne=0;Ne<ge.length;Ne++){var Te=ge[Ne];for(v=m.steps.length-2;Te.level>0;){if(v<0){typeof m.seekingParent>"u"?m.seekingParent=[Te]:m.seekingParent.push(Te);break}for(var E=m.steps[v--];v>=0&&E.focus&&m.steps[v].focus;)E=m.steps[v--];Te=te(E,Te)}}},de=function(m){var v;switch(m.type){case"binary":switch(m.value){case".":var Y=de(m.lhs);Y.type==="path"?v=Y:v={type:"path",steps:[Y]},Y.type==="parent"&&(v.seekingParent=[Y.slot]);var ge=de(m.rhs);ge.type==="function"&&ge.procedure.type==="path"&&ge.procedure.steps.length===1&&ge.procedure.steps[0].type==="name"&&v.steps[v.steps.length-1].type==="function"&&(v.steps[v.steps.length-1].nextFunction=ge.procedure.steps[0].value),ge.type==="path"?Array.prototype.push.apply(v.steps,ge.steps):(typeof ge.predicate<"u"&&(ge.stages=ge.predicate,delete ge.predicate),v.steps.push(ge)),v.steps.filter(function(V){if(V.type==="number"||V.type==="value")throw{code:"S0213",stack:new Error().stack,position:V.position,value:V.value};return V.type==="string"}).forEach(function(V){V.type="name"}),v.steps.filter(function(V){return V.keepArray===!0}).length>0&&(v.keepSingletonArray=!0);var Ne=v.steps[0];Ne.type==="unary"&&Ne.value==="["&&(Ne.consarray=!0);var Te=v.steps[v.steps.length-1];Te.type==="unary"&&Te.value==="["&&(Te.consarray=!0),st(v);break;case"[":v=de(m.lhs);var E=v,O="predicate";if(v.type==="path"&&(E=v.steps[v.steps.length-1],O="stages"),typeof E.group<"u")throw{code:"S0209",stack:new Error().stack,position:m.position};typeof E[O]>"u"&&(E[O]=[]);var A=de(m.rhs);typeof A.seekingParent<"u"&&(A.seekingParent.forEach(V=>{V.level===1?te(E,V):V.level--}),se(E,A)),E[O].push({type:"filter",expr:A,position:m.position});break;case"{":if(v=de(m.lhs),typeof v.group<"u")throw{code:"S0210",stack:new Error().stack,position:m.position};v.group={lhs:m.rhs.map(function(V){return[de(V[0]),de(V[1])]}),position:m.position};break;case"^":v=de(m.lhs),v.type!=="path"&&(v={type:"path",steps:[v]});var R={type:"sort",position:m.position};R.terms=m.rhs.map(function(V){var ne=de(V.expression);return se(R,ne),{descending:V.descending,expression:ne}}),v.steps.push(R),st(v);break;case":=":v={type:"bind",value:m.value,position:m.position},v.lhs=de(m.lhs),v.rhs=de(m.rhs),se(v,v.rhs);break;case"@":if(v=de(m.lhs),E=v,v.type==="path"&&(E=v.steps[v.steps.length-1]),typeof E.stages<"u"||typeof E.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:m.position};if(E.type==="sort")throw{code:"S0216",stack:new Error().stack,position:m.position};m.keepArray&&(E.keepArray=!0),E.focus=m.rhs.value,E.tuple=!0;break;case"#":v=de(m.lhs),E=v,v.type==="path"?E=v.steps[v.steps.length-1]:(v={type:"path",steps:[v]},typeof E.predicate<"u"&&(E.stages=E.predicate,delete E.predicate)),typeof E.stages>"u"?E.index=m.rhs.value:E.stages.push({type:"index",value:m.rhs.value,position:m.position}),E.tuple=!0;break;case"~>":v={type:"apply",value:m.value,position:m.position},v.lhs=de(m.lhs),v.rhs=de(m.rhs),v.keepArray=v.lhs.keepArray||v.rhs.keepArray;break;default:v={type:m.type,value:m.value,position:m.position},v.lhs=de(m.lhs),v.rhs=de(m.rhs),se(v,v.lhs),se(v,v.rhs)}break;case"unary":v={type:m.type,value:m.value,position:m.position},m.value==="["?v.expressions=m.expressions.map(function(V){var ne=de(V);return se(v,ne),ne}):m.value==="{"?v.lhs=m.lhs.map(function(V){var ne=de(V[0]);se(v,ne);var _e=de(V[1]);return se(v,_e),[ne,_e]}):(v.expression=de(m.expression),m.value==="-"&&v.expression.type==="number"?(v=v.expression,v.value=-v.value):se(v,v.expression));break;case"function":case"partial":v={type:m.type,name:m.name,value:m.value,position:m.position},v.arguments=m.arguments.map(function(V){var ne=de(V);return se(v,ne),ne}),v.procedure=de(m.procedure);break;case"lambda":v={type:m.type,arguments:m.arguments,signature:m.signature,position:m.position};var Z=de(m.body);v.body=xe(Z);break;case"condition":v={type:m.type,position:m.position},v.condition=de(m.condition),se(v,v.condition),v.then=de(m.then),se(v,v.then),typeof m.else<"u"&&(v.else=de(m.else),se(v,v.else));break;case"transform":v={type:m.type,position:m.position},v.pattern=de(m.pattern),v.update=de(m.update),typeof m.delete<"u"&&(v.delete=de(m.delete));break;case"block":v={type:m.type,position:m.position},v.expressions=m.expressions.map(function(V){var ne=de(V);return se(v,ne),(ne.consarray||ne.type==="path"&&ne.steps[0].consarray)&&(v.consarray=!0),ne});break;case"name":v={type:"path",steps:[m]},m.keepArray&&(v.keepSingletonArray=!0);break;case"parent":v={type:"parent",slot:{label:"!"+he++,level:1,index:Oe++}},Ue.push(v);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":v=m;break;case"operator":if(m.value==="and"||m.value==="or"||m.value==="in")m.type="name",v=de(m);else if(m.value==="?")v=m;else throw{code:"S0201",stack:new Error().stack,position:m.position,token:m.value};break;case"error":v=m,m.lhs&&(v=de(m.lhs));break;default:var U="S0206";m.id==="(end)"&&(U="S0207");var P={code:U,position:m.position,token:m.value};if(h)return q.push(P),{type:"error",error:P};throw P.stack=new Error().stack,P}return m.keepArray&&(v.keepArray=!0),v};I=p(w),D();var $e=x(0);if(_.id!=="(end)"){var lt={code:"S0201",position:_.position,token:_.value};M(lt)}if($e=de($e),$e.type==="parent"||typeof $e.seekingParent<"u")throw{code:"S0217",token:$e.type,position:$e.position};return q.length>0&&($e.errors=q),$e};return S})();n.exports=o},{"./signature":5}],5:[function(t,n,a){var i=t("./utils");const o=(()=>{var c={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function d(p){for(var S=1,w=[],h={},_=h;S<p.length;){var I=p.charAt(S);if(I===":")break;var Q=function(){w.push(h),_=h,h={}},q=function(F,fe,ie,be){for(var xe=1,he=fe;he<F.length;)if(he++,I=F.charAt(he),I===be){if(xe--,xe===0)break}else I===ie&&xe++;return he};switch(I){case"s":case"n":case"b":case"l":case"o":h.regex="["+I+"m]",h.type=I,Q();break;case"a":h.regex="[asnblfom]",h.type=I,h.array=!0,Q();break;case"f":h.regex="f",h.type=I,Q();break;case"j":h.regex="[asnblom]",h.type=I,Q();break;case"x":h.regex="[asnblfom]",h.type=I,Q();break;case"-":_.context=!0,_.contextRegex=new RegExp(_.regex),_.regex+="?";break;case"?":case"+":_.regex+=I;break;case"(":var ee=q(p,S,"(",")"),$=p.substring(S+1,ee);if($.indexOf("<")===-1)h.regex="["+$+"m]";else throw{code:"S0402",stack:new Error().stack,value:$,offset:S};h.type="("+$+")",S=ee,Q();break;case"<":if(_.type==="a"||_.type==="f"){var C=q(p,S,"<",">");_.subtype=p.substring(S+1,C),S=C}else throw{code:"S0401",stack:new Error().stack,value:_.type,offset:S};break}S++}var M="^"+w.map(function(F){return"("+F.regex+")"}).join("")+"$",D=new RegExp(M),x=function(F){var fe;if(i.isFunction(F))fe="f";else{var ie=typeof F;switch(ie){case"string":fe="s";break;case"number":fe="n";break;case"boolean":fe="b";break;case"object":F===null?fe="l":Array.isArray(F)?fe="a":fe="o";break;case"undefined":default:fe="m"}}return fe},j=function(F,fe){for(var ie="^",be=0,xe=0;xe<w.length;xe++){ie+=w[xe].regex;var he=fe.match(ie);if(he===null)throw{code:"T0410",stack:new Error().stack,value:F[be],index:be+1};be=he[0].length}throw{code:"T0410",stack:new Error().stack,value:F[be],index:be+1}};return{definition:p,validate:function(F,fe){var ie="";F.forEach(function(Oe){ie+=x(Oe)});var be=D.exec(ie);if(be){var xe=[],he=0;return w.forEach(function(Oe,Ue){var te=F[he],se=be[Ue+1];if(se==="")if(Oe.context&&Oe.contextRegex){var st=x(fe);if(Oe.contextRegex.test(st))xe.push(fe);else throw{code:"T0411",stack:new Error().stack,value:fe,index:he+1}}else xe.push(te),he++;else se.split("").forEach(function(de){if(Oe.type==="a"){if(de==="m")te=void 0;else{te=F[he];var $e=!0;if(typeof Oe.subtype<"u"){if(de!=="a"&&se!==Oe.subtype)$e=!1;else if(de==="a"&&te.length>0){var lt=x(te[0]);if(lt!==Oe.subtype.charAt(0))$e=!1;else{var m=te.filter(function(v){return x(v)!==lt});$e=m.length===0}}}if(!$e)throw{code:"T0412",stack:new Error().stack,value:te,index:he+1,type:c[Oe.subtype]};de!=="a"&&(te=[te])}xe.push(te),he++}else xe.push(te),he++})}),xe}j(F,ie)}}}return d})();n.exports=o},{"./utils":6}],6:[function(t,n,a){const i=(()=>{function o(C){var M=!1;if(typeof C=="number"&&(M=!isNaN(C),M&&!isFinite(C)))throw{code:"D1001",value:C,stack:new Error().stack};return M}function c(C){var M=!1;return Array.isArray(C)&&(M=C.filter(function(D){return typeof D!="string"}).length===0),M}function d(C){var M=!1;return Array.isArray(C)&&(M=C.filter(function(D){return!o(D)}).length===0),M}function p(){var C=[];return C.sequence=!0,arguments.length===1&&C.push(arguments[0]),C}function S(C){return C.sequence===!0&&Array.isArray(C)}function w(C){return C&&(C._jsonata_function===!0||C._jsonata_lambda===!0)||typeof C=="function"}function h(C){var M=typeof C.arity=="number"?C.arity:typeof C.implementation=="function"?C.implementation.length:typeof C.length=="number"?C.length:C.arguments.length;return M}function _(C){return C&&C._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function Q(C){return typeof C=="object"&&C!==null&&I in C&&"next"in C&&typeof C.next=="function"}function q(C,M){if(C===M)return!0;if(typeof C=="object"&&typeof M=="object"&&C!==null&&M!==null){if(Array.isArray(C)&&Array.isArray(M)){if(C.length!==M.length)return!1;for(var D=0;D<C.length;D++)if(!q(C[D],M[D]))return!1;return!0}var x=Object.getOwnPropertyNames(C),j=Object.getOwnPropertyNames(M);if(x.length!==j.length)return!1;for(x=x.sort(),j=j.sort(),D=0;D<x.length;D++)if(x[D]!==j[D])return!1;for(D=0;D<x.length;D++){var F=x[D];if(!q(C[F],M[F]))return!1}return!0}return!1}function ee(C){return typeof C=="object"&&C!==null&&"then"in C&&typeof C.then=="function"}function $(C){var M=[];for(let D of C)M.push(D);return M}return{isNumeric:o,isArrayOfStrings:c,isArrayOfNumbers:d,createSequence:p,isSequence:S,isFunction:w,isLambda:_,isIterable:Q,getFunctionArity:h,isDeepEqual:q,stringToArray:$,isPromise:ee}})();n.exports=i},{}]},{},[3])(3)})})(cn)),cn.exports}var Oo=To();const Co=ca(Oo),jn=N.object({name:N.literal("data-extract"),code:N.string(),inputData:N.any().optional()});function Do(r){return jn.parse(r)}async function Mo(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Co(r.code).evaluate(r.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:t}}catch(e){return console.error("[DataExtractBlock] Data extraction error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in data extraction",data:void 0}}}const Po={"get-text":_n,"attribute-value":En,"get-value-form":Sn,"set-value-form":An,"clear-value-form":Tn,"element-exists":On,"event-click":Cn,keypress:Dn,wait:Mn,"wait-for-condition":Pn,navigate:Nn,"save-assets":In,"get-element-data":Fn,scroll:Ln,"ai-parse-data":xn,"fetch-api":Rn,"data-extract":jn};class No{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=Ls(e);return await Rs(t)}case"attribute-value":{const t=$s(e);return await Bs(t)}case"get-value-form":{const t=Us(e);return await Vs(t)}case"set-value-form":{const t=Ws(e);return await zs(t)}case"clear-value-form":{const t=Hs(e);return await Gs(t)}case"element-exists":{const t=Js(e);return await Ks(t)}case"event-click":{const t=Xs(e);return await Qs(t)}case"keypress":{const t=no(e);return await ao(t)}case"wait":{const t=so(e);return await oo(t)}case"wait-for-condition":{const t=co(e);return await uo(t)}case"navigate":{const t=lo(e);return await fo(t)}case"save-assets":{const t=po(e);return await ho(t)}case"get-element-data":{const t=yo(e);return await go(t)}case"scroll":{const t=bo(e);return await wo(t)}case"ai-parse-data":{const t=Ss(e);return await As(t)}case"fetch-api":{const t=So(e);return await Ao(t)}case"data-extract":{const t=Do(e);return await Mo(t)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(t){return{hasError:!0,message:t instanceof Error?t.message:"Unknown error in block execution",data:null}}}}class Io{constructor(){G(this,"expr");G(this,"json")}}class Fo{constructor(){G(this,"template");G(this,"valueFrom");G(this,"default")}}class Lo{constructor(){G(this,"id");G(this,"title");G(this,"when");G(this,"block");G(this,"repeat");G(this,"next");G(this,"onSuccess");G(this,"onFailure");G(this,"switch");G(this,"timeoutMs");G(this,"retry");G(this,"delayAfterMs")}}class Ro{constructor(){G(this,"version");G(this,"id");G(this,"title");G(this,"description");G(this,"start");G(this,"steps");G(this,"vars");G(this,"defaultDelayMs")}}class jo{constructor(){G(this,"stepId");G(this,"skipped");G(this,"success");G(this,"message");G(this,"result");G(this,"startedAt");G(this,"finishedAt");G(this,"attempts")}}class $o{constructor(){G(this,"success");G(this,"steps");G(this,"targetUrl");G(this,"timestamp");G(this,"error")}}exports.AiParseDataBlockSchema=xn;exports.AllBlockSchemas=Po;exports.BaseBlockSchema=wt;exports.BillingCycleTerm=bn;exports.Binding=Fo;exports.BlockHandler=No;exports.ClearValueFormsBlockSchema=Tn;exports.CollectWorkflowResult=$o;exports.Condition=Io;exports.Currency=fa;exports.CurrencyDto=Mt;exports.DataExtractBlockSchema=jn;exports.EightGClient=mi;exports.EightGError=pt;exports.ElementExistsBlockSchema=On;exports.EventClickBlockSchema=Cn;exports.FetchApiBlockSchema=Rn;exports.GetAttributeValueBlockSchema=En;exports.GetElementDataBlockSchema=Fn;exports.GetTextBlockSchema=_n;exports.GetValueFormsBlockSchema=Sn;exports.KeypressBlockSchema=Dn;exports.NavigateBlockSchema=Nn;exports.SaveAssetsBlockSchema=In;exports.Schema=Cs;exports.ScrollBlockSchema=Ln;exports.SetValueFormsBlockSchema=An;exports.WaitBlockSchema=Mn;exports.WaitForConditionBlockSchema=Pn;exports.Workflow=Ro;exports.WorkflowStep=Lo;exports.WorkflowStepRunResult=jo;exports.WorkspaceBillingDto=bt;exports.WorkspaceBillingHistoryDto=Pt;exports.WorkspaceItemDto=Tr;exports.WorkspaceMemberDto=sr;exports.createArraySchema=Os;exports.createSchema=Ts;
|