tjs-lang 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tjs-vm.js CHANGED
@@ -1,56 +1,55 @@
1
- import{s as $,validate as R1,filter as p1}from"tosijs-schema";var i0=Symbol.for("tjs.equals");function c0(Z,Q){if(Z!==null&&typeof Z==="object"&&typeof Z[i0]==="function")return Z[i0](Q);if(Q!==null&&typeof Q==="object"&&typeof Q[i0]==="function")return Q[i0](Z);if(Z!==null&&typeof Z==="object"&&typeof Z.Equals==="function")return Z.Equals(Q);if(Q!==null&&typeof Q==="object"&&typeof Q.Equals==="function")return Q.Equals(Z);if(Z===Q)return!0;if((Z===null||Z===void 0)&&(Q===null||Q===void 0))return!0;if(Z===null||Z===void 0||Q===null||Q===void 0)return!1;if(typeof Z!==typeof Q)return!1;if(typeof Z!=="object")return!1;if(Array.isArray(Z)&&Array.isArray(Q)){if(Z.length!==Q.length)return!1;return Z.every((X,K)=>c0(X,Q[K]))}if(Array.isArray(Z)!==Array.isArray(Q))return!1;let Y=Object.keys(Z),J=Object.keys(Q);if(Y.length!==J.length)return!1;return Y.every((X)=>c0(Z[X],Q[X]))}class s{$error=!0;message;op;cause;constructor(Z,Q,Y){this.message=Z,this.op=Q,this.cause=Y}toString(){return`AgentError[${this.op}]: ${this.message}`}toJSON(){return{$error:!0,message:this.message,op:this.op}}}function b9(Z){return Z instanceof s||Z&&Z.$error===!0}var P0=new Map,E9=3600000,v9=102400,U1="proc_";function O1(Z){return typeof Z==="string"&&Z.startsWith(U1)}function I1(Z){let Q=P0.get(Z);if(!Q)throw Error(`Procedure not found: ${Z}`);if(Date.now()>Q.expiresAt)throw P0.delete(Z),Error(`Procedure expired: ${Z}`);return Q.ast}function k9(){if(typeof crypto<"u"&&crypto.randomUUID)return U1+crypto.randomUUID();return U1+Math.random().toString(36).slice(2)+Date.now().toString(36)}var i1=new Set(["__proto__","constructor","prototype"]);function h1(Z){if(i1.has(Z))throw Error(`Security Error: Access to '${Z}' is forbidden`)}var g9=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","metadata.google.internal"]);function y9(Z){try{let Q=new URL(Z);if(Q.protocol!=="http:"&&Q.protocol!=="https:")return!0;let Y=Q.hostname.toLowerCase();if(g9.has(Y))return!0;if(Y.endsWith(".internal")||Y.endsWith(".local"))return!0;if(Y==="169.254.169.254")return!0;if(/^10\./.test(Y)||/^192\.168\./.test(Y)||/^172\.(1[6-9]|2\d|3[01])\./.test(Y))return!0;return!1}catch{return!0}}function f9(Z){if(/\([^)]*[+*][^)]*\)[+*]/.test(Z))return!0;if(/\(([^|)]+)\|\1\)[+*]/.test(Z))return!0;if(/\(\.\*\)\+/.test(Z))return!0;if(/\(\.\+\)\+/.test(Z))return!0;if(/\(\[.*\]\+\)\+/.test(Z))return!0;return!1}function L0(Z){return{...Z,state:Object.create(Z.state)}}function h9(Z,Q){let Y={},J=new Set([...Object.keys(Z),...Object.keys(Q)]);for(let X of J){let K=Z[X],H=Q[X];if(H!==K)Y[X]=H}return Y}function M(Z,Q){if(Z&&typeof Z==="object"&&Z.$kind==="arg")return Q.args[Z.path];if(Z&&typeof Z==="object"&&Z.$expr)return p(Z,Q);if(typeof Z==="string"){if(Z.startsWith("args.")&&!("args"in Q.state))return Q.args[Z.replace("args.","")];if(Z.includes(".")){let Y=Z.split(".");for(let X of Y)if(i1.has(X))throw Error(`Security Error: Access to '${X}' is forbidden`);let J=Q.state[Y[0]];if(J!==void 0){for(let X=1;X<Y.length;X++)J=J?.[Y[X]];return J}}if(Z in Q.state)return Q.state[Z];return Z}if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&Z.constructor===Object){let Y={};for(let J of Object.keys(Z))Y[J]=M(Z[J],Q);return Y}if(Array.isArray(Z))return Z.map((Y)=>M(Y,Q));return Z}function V0(Z,Q,Y){return new Proxy(Q,{get(J,X){if(X in J)return J[X];let K=Y?.[X];if(K)throw Error(`${Z}.${X} is not available. ${K}`);throw Error(`${Z}.${X} is not supported in AsyncJS. Check docs for available ${Z} methods.`)}})}function C0(Z){if(Z===null)return{type:"null"};if(Z===void 0)return{};if(typeof Z==="object"&&Z!==null&&"type"in Z&&typeof Z.type==="string")return Z;if(typeof Z==="object"&&Z!==null&&"schema"in Z&&typeof Z.schema==="object")return Z.schema;let Q=typeof Z;if(Q==="string")return{type:"string"};if(Q==="number")return Number.isInteger(Z)?{type:"integer"}:{type:"number"};if(Q==="boolean")return{type:"boolean"};if(Array.isArray(Z)){if(Z.length===0)return{type:"array"};return{type:"array",items:C0(Z[0])}}if(Q==="object"){let Y={},J=[];for(let[X,K]of Object.entries(Z))Y[X]=C0(K),J.push(X);return{type:"object",properties:Y,required:J}}return{}}var R0={Math:V0("Math",{PI:Math.PI,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,SQRT2:Math.SQRT2,SQRT1_2:Math.SQRT1_2,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc,sign:Math.sign,sqrt:Math.sqrt,cbrt:Math.cbrt,pow:Math.pow,exp:Math.exp,expm1:Math.expm1,log:Math.log,log2:Math.log2,log10:Math.log10,log1p:Math.log1p,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,asinh:Math.asinh,acosh:Math.acosh,atanh:Math.atanh,hypot:Math.hypot,min:Math.min,max:Math.max,clz32:Math.clz32,imul:Math.imul,fround:Math.fround,random:()=>{if(typeof crypto<"u"&&crypto.getRandomValues){let Z=new Uint32Array(1);return crypto.getRandomValues(Z),Z[0]/4294967296}return Math.random()}}),JSON:V0("JSON",{parse:(Z)=>JSON.parse(Z),stringify:(Z,Q,Y)=>JSON.stringify(Z,Q,Y)}),console:V0("console",{log:(...Z)=>{return},warn:(...Z)=>{return},error:(...Z)=>{return},info:(...Z)=>{return}},{table:"Use console.log with JSON.stringify for structured data.",dir:"Use console.log instead.",trace:"Stack traces are not available in AsyncJS."}),Array:V0("Array",{isArray:(Z)=>Array.isArray(Z),from:(Z,Q,Y)=>Array.from(Z,Q,Y),of:(...Z)=>Array.of(...Z)},{prototype:"Prototype access is not allowed."}),Object:V0("Object",{keys:(Z)=>Object.keys(Z),values:(Z)=>Object.values(Z),entries:(Z)=>Object.entries(Z),fromEntries:(Z)=>Object.fromEntries(Z),assign:(Z,...Q)=>Object.assign({},Z,...Q),hasOwn:(Z,Q)=>Object.hasOwn(Z,Q)},{prototype:"Prototype access is not allowed.",create:"Use object literals instead.",defineProperty:"Property descriptors are not supported.",getPrototypeOf:"Prototype access is not allowed.",setPrototypeOf:"Prototype modification is not allowed."}),String:V0("String",{fromCharCode:(...Z)=>String.fromCharCode(...Z),fromCodePoint:(...Z)=>String.fromCodePoint(...Z)}),Number:V0("Number",{isNaN:Number.isNaN,isFinite:Number.isFinite,isInteger:Number.isInteger,isSafeInteger:Number.isSafeInteger,parseFloat,parseInt,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,NaN:Number.NaN,EPSILON:Number.EPSILON}),parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,undefined:void 0,null:null,NaN:NaN,Infinity:1/0,filter:(Z,Q)=>{let Y=C0(Q),J=p1(Z,Y);if(J instanceof Error)throw J;return J},Schema:{...$,response:(Z,Q)=>{let Y=Q?.schema!=null?Q.schema:C0(Q);return{type:"json_schema",json_schema:{name:Z,strict:!0,schema:Y}}},fromExample:(Z)=>C0(Z),isValid:(Z,Q)=>{if(Q?.schema!=null)return R1(Z,Q);return R1(Z,C0(Q))}},Set:(Z=[])=>{let Q=[...new globalThis.Set(Z)];return{add(Y){if(!Q.includes(Y))Q.push(Y);return this},remove(Y){let J=Q.indexOf(Y);if(J!==-1)Q.splice(J,1);return this},clear(){return Q.length=0,this},has(Y){return Q.includes(Y)},get size(){return Q.length},toArray(){return[...Q]},union(Y){let J=Y?.toArray?.()??Y??[];return R0.Set([...Q,...J])},intersection(Y){let J=Y?.toArray?.()??Y??[];return R0.Set(Q.filter((X)=>J.includes(X)))},diff(Y){let J=Y?.toArray?.()??Y??[];return R0.Set(Q.filter((X)=>!J.includes(X)))},forEach(Y){Q.forEach(Y)},map(Y){return R0.Set(Q.map(Y))},filter(Y){return R0.Set(Q.filter(Y))},toJSON(){return[...Q]}}},Date:(()=>{let Z=(Y)=>({get value(){return Y.toISOString()},get timestamp(){return Y.getTime()},get year(){return Y.getFullYear()},get month(){return Y.getMonth()+1},get day(){return Y.getDate()},get hours(){return Y.getHours()},get minutes(){return Y.getMinutes()},get seconds(){return Y.getSeconds()},get dayOfWeek(){return Y.getDay()},add({years:J=0,months:X=0,days:K=0,hours:H=0,minutes:W=0,seconds:z=0,ms:_=0}={}){let q=new globalThis.Date(Y.getTime());if(J)q.setFullYear(q.getFullYear()+J);if(X)q.setMonth(q.getMonth()+X);if(K)q.setDate(q.getDate()+K);if(H)q.setHours(q.getHours()+H);if(W)q.setMinutes(q.getMinutes()+W);if(z)q.setSeconds(q.getSeconds()+z);if(_)q.setMilliseconds(q.getMilliseconds()+_);return Z(q)},diff(J,X="ms"){let K=typeof J==="object"&&J.timestamp?J.timestamp:new globalThis.Date(J).getTime(),H=Y.getTime()-K;switch(X){case"seconds":return H/1000;case"minutes":return H/60000;case"hours":return H/3600000;case"days":return H/86400000;default:return H}},format(J="ISO"){if(J==="ISO")return Y.toISOString();if(J==="date")return Y.toISOString().split("T")[0];if(J==="time")return Y.toISOString().split("T")[1].split(".")[0];return J.replace("YYYY",String(Y.getFullYear())).replace("MM",String(Y.getMonth()+1).padStart(2,"0")).replace("DD",String(Y.getDate()).padStart(2,"0")).replace("HH",String(Y.getHours()).padStart(2,"0")).replace("mm",String(Y.getMinutes()).padStart(2,"0")).replace("ss",String(Y.getSeconds()).padStart(2,"0"))},isBefore(J){let X=typeof J==="object"&&J.timestamp?J.timestamp:new globalThis.Date(J).getTime();return Y.getTime()<X},isAfter(J){let X=typeof J==="object"&&J.timestamp?J.timestamp:new globalThis.Date(J).getTime();return Y.getTime()>X},toString(){return Y.toISOString()},toJSON(){return Y.toISOString()}}),Q=(Y)=>{let J=Y!==void 0?new globalThis.Date(Y):new globalThis.Date;if(isNaN(J.getTime()))throw Error(`Invalid date: ${Y}`);return Z(J)};return Q.now=()=>globalThis.Date.now(),Q.parse=(Y)=>Z(new globalThis.Date(Y)),Q})()},n0={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."},x9=0.01,x1=0.0001,m1=0.001,m9=new Set(["concat","slice","map","filter","flatMap","flat","toReversed","toSorted","toSpliced","repeat","padStart","padEnd","split","join","replace","replaceAll","substring","substr","trim","trimStart","trimEnd","toLowerCase","toUpperCase","match","matchAll","parse","stringify"]);function p(Z,Q){if(Z===null||Z===void 0)return Z;if(typeof Z!=="object"||!("$expr"in Z))return Z;if(Q.fuel){if(Q.fuel.current-=x9,Q.fuel.current<=0)throw Error("Out of Fuel")}switch(Z.$expr){case"literal":return Z.value;case"ident":{if(Z.name in Q.state)return Q.state[Z.name];if(Z.name in Q.args)return Q.args[Z.name];if(Z.name in R0)return R0[Z.name];if(Z.name in n0)throw Error(n0[Z.name]);return}case"member":{let Y=p(Z.object,Q);if(Z.optional&&(Y===null||Y===void 0))return;let J=Z.property;return h1(J),Y?.[J]}case"binary":{let Y=p(Z.left,Q),J=p(Z.right,Q);switch(Z.op){case"+":{let X=Y+J;if(typeof X==="string"&&Q.fuel){if(Q.fuel.current-=X.length*x1,Q.fuel.current<=0){Q.error=new s("Out of Fuel","expr.concat");return}}return X}case"-":return Y-J;case"*":return Y*J;case"/":return Y/J;case"%":return Y%J;case"**":return Y**J;case">":return Y>J;case"<":return Y<J;case">=":return Y>=J;case"<=":return Y<=J;case"==":return c0(Y,J);case"!=":return!c0(Y,J);case"===":return Y===J;case"!==":return Y!==J;default:throw Error(`Unknown binary operator: ${Z.op}`)}}case"unary":{let Y=p(Z.argument,Q);switch(Z.op){case"!":return!Y;case"-":return-Y;case"+":return+Y;case"typeof":return typeof Y;default:throw Error(`Unknown unary operator: ${Z.op}`)}}case"logical":{let Y=p(Z.left,Q);if(Z.op==="&&")return Y?p(Z.right,Q):Y;else if(Z.op==="??")return Y??p(Z.right,Q);else return Y?Y:p(Z.right,Q)}case"conditional":return p(Z.test,Q)?p(Z.consequent,Q):p(Z.alternate,Q);case"array":return Z.elements.map((Y)=>p(Y,Q));case"object":{let Y={};for(let J of Z.properties)Y[J.key]=p(J.value,Q);return Y}case"call":{if(Z.callee==="Error"){let J=Z.arguments.map((K)=>p(K,Q)),X=typeof J[0]==="string"?J[0]:"Error";Q.error=new s(X,"Error");return}if(Z.callee in R0){let J=R0[Z.callee];if(typeof J==="function"){let X=Z.arguments.map((K)=>p(K,Q));return J(...X)}}if(!Q.resolver(Z.callee)){if(Z.callee in n0)throw Error(n0[Z.callee]);throw Error(`Unknown function: ${Z.callee}`)}throw Error(`Atom calls in expressions not yet supported: ${Z.callee}`)}case"methodCall":{let Y=p(Z.object,Q);if(Z.optional&&(Y===null||Y===void 0))return;let J=Z.method;if(h1(J),Y===null||Y===void 0)throw Error(`Cannot call method '${J}' on ${Y}`);let X=Y[J];if(typeof X!=="function")throw Error(`'${J}' is not a function`);let K=Z.arguments.map((W)=>p(W,Q)),H=X.apply(Y,K);if(Q.fuel&&m9.has(J)){let W=0;if(typeof H==="string")W=H.length*x1;else if(Array.isArray(H))W=H.length*m1;else if(typeof H==="object"&&H!==null)W=Object.keys(H).length*m1;if(Q.fuel.current-=W,Q.fuel.current<=0){Q.error=new s("Out of Fuel",`expr.${J}`);return}}return H}default:throw Error(`Unknown expression type: ${Z.$expr}`)}}function P(Z,Q,Y,J,X={}){let{docs:K="",timeoutMs:H=1000,cost:W=1}=typeof X==="string"?{docs:X}:X;return{op:Z,inputSchema:Q,outputSchema:Y,exec:async(_,q)=>{let{op:R,result:F,...U}=_;if(q.error)return;let O=q.trace?{...q.state}:null,L=q.fuel.current,B,N;try{let A=q.costOverrides?.[Z],I=A!==void 0?A:W,j=typeof I==="function"?I(U,q):I;if((q.fuel.current-=j)<=0){q.error=new s("Out of Fuel",Z);return}let C,w=async()=>J(_,q);if(B=H>0?await Promise.race([w(),new Promise((T,S)=>{C=setTimeout(()=>S(Error(`Atom '${Z}' timed out`)),H)})]).finally(()=>clearTimeout(C)):await w(),_.result){if(q.consts.has(_.result))throw Error(`Cannot reassign const variable '${_.result}'`);if(B!==void 0&&Y&&!R1(B,Y)){q.error=new s(`Output validation failed for '${Z}'`,Z);return}if(q.state[_.result]=B,_.resultConst)q.consts.add(_.result)}}catch(A){N=A.message||String(A),q.error=new s(N,Z,A)}finally{if(q.trace&&O){let A=h9(O,q.state);q.trace.push({op:Z,input:U,stateDiff:A,result:B,error:N,fuelBefore:L,fuelAfter:q.fuel.current,timestamp:new Date().toISOString()})}}},docs:K,timeoutMs:H,cost:W,create:(_)=>({op:Z,..._})}}var Q0=P("seq",$.object({steps:$.array($.any)}),void 0,async({steps:Z},Q)=>{for(let Y of Z){if(Q.output!==void 0)return;if(Q.error)return;let J=Q.resolver(Y.op);if(!J)throw Error(`Unknown Atom: ${Y.op}`);await J.exec(Y,Q)}},{docs:"Sequence",timeoutMs:0,cost:0.1}),u9=P("if",$.object({condition:$.any,then:$.array($.any),else:$.array($.any).optional}),void 0,async(Z,Q)=>{if(p(Z.condition,Q))await Q0.exec({op:"seq",steps:Z.then},Q);else if(Z.else)await Q0.exec({op:"seq",steps:Z.else},Q)},{docs:"If/Else",timeoutMs:0,cost:0.1}),d9=P("while",$.object({condition:$.any,body:$.array($.any)}),void 0,async(Z,Q)=>{while(p(Z.condition,Q)){if(Q.signal?.aborted)throw Error("Execution aborted");if((Q.fuel.current-=0.1)<=0)throw Error("Out of Fuel");if(await Q0.exec({op:"seq",steps:Z.body},Q),Q.output!==void 0)return}},{docs:"While Loop",timeoutMs:0,cost:0.1}),l9=P("return",void 0,$.any,async(Z,Q)=>{if(Q.error)return Q.output=Q.error,Q.error;if("value"in Z){let J=M(Z.value,Q);if(J!==void 0&&J!==null&&!b9(J)&&(typeof J!=="object"||Array.isArray(J))){let X=new s(`Agent must return an object, got ${Array.isArray(J)?"array":typeof J}`,"return");return Q.error=X,Q.output=X,X}return Q.output=J,J}let Y={};if(Z.schema?.properties){for(let J of Object.keys(Z.schema.properties))Y[J]=Q.state[J];if(Z.filter!==!1){let J=p1(Y,Z.schema);if(!(J instanceof Error))Y=J}}return Q.output=Y,Y},{docs:"Return",cost:0.1}),p9=P("try",$.object({try:$.array($.any),catch:$.array($.any).optional,catchParam:$.string.optional}),void 0,async(Z,Q)=>{if(await Q0.exec({op:"seq",steps:Z.try},Q),Q.error&&Z.catch){let Y=Z.catchParam||"error";Q.state[Y]=Q.error.message,Q.state.errorOp=Q.error.op,Q.error=void 0,await Q0.exec({op:"seq",steps:Z.catch},Q)}},{docs:"Try/Catch",timeoutMs:0,cost:0.1}),i9=P("Error",$.object({args:$.array($.any).optional}),void 0,async(Z,Q)=>{let Y=Z.args?.[0]??"Error";Q.error=new s(String(Y),"Error")},{docs:"Trigger error flow",cost:0.1}),n9=P("varSet",$.object({key:$.string,value:$.any}),void 0,async({key:Z,value:Q},Y)=>{if(Y.consts.has(Z))throw Error(`Cannot reassign const variable '${Z}'`);Y.state[Z]=M(Q,Y)},{docs:"Set Variable",cost:0.1}),c9=P("constSet",$.object({key:$.string,value:$.any}),void 0,async({key:Z,value:Q},Y)=>{if(Y.consts.has(Z))throw Error(`Cannot reassign const variable '${Z}'`);if(Z in Y.state)throw Error(`Cannot redeclare variable '${Z}' as const`);Y.state[Z]=M(Q,Y),Y.consts.add(Z)},{docs:"Set Const Variable (immutable)",cost:0.1}),o9=P("varGet",$.object({key:$.string}),$.any,async({key:Z},Q)=>{return M(Z,Q)},{docs:"Get Variable",cost:0.1}),a9=P("varsImport",$.object({keys:$.union([$.array($.string),$.record($.string)])}),void 0,async({keys:Z},Q)=>{if(Array.isArray(Z))for(let Y of Z)Q.state[Y]=M({$kind:"arg",path:Y},Q);else for(let[Y,J]of Object.entries(Z))Q.state[Y]=M({$kind:"arg",path:J},Q)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:0.2}),s9=P("varsLet",$.record($.any),void 0,async(Z,Q)=>{for(let Y of Object.keys(Z)){if(Y==="op"||Y==="result")continue;Q.state[Y]=M(Z[Y],Q)}},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:0.1}),r9=P("varsExport",$.object({keys:$.union([$.array($.string),$.record($.string)])}),$.record($.any),async({keys:Z},Q)=>{let Y={};if(Array.isArray(Z))for(let J of Z)Y[J]=M(J,Q);else for(let[J,X]of Object.entries(Z))Y[J]=M(X,Q);return Y},{docs:"Export variables from the current scope, with optional renaming.",cost:0.2}),t9=P("scope",$.object({steps:$.array($.any)}),void 0,async({steps:Z},Q)=>{let Y=L0(Q);if(await Q0.exec({op:"seq",steps:Z},Y),Y.output!==void 0)Q.output=Y.output},{docs:"Create new scope",timeoutMs:0,cost:0.1}),e9=P("map",$.object({items:$.array($.any),as:$.string,steps:$.array($.any)}),$.array($.any),async({items:Z,as:Q,steps:Y},J)=>{let X=[],K=M(Z,J);if(!Array.isArray(K))throw Error("map: items is not an array");for(let H of K){if(J.signal?.aborted)throw Error("Execution aborted");let W=L0(J);W.state[Q]=H,await Q0.exec({op:"seq",steps:Y},W),X.push(W.state.result??null)}return X},{docs:"Map Array",timeoutMs:0,cost:1}),ZZ=P("filter",$.object({items:$.array($.any),as:$.string,condition:$.any}),$.array($.any),async({items:Z,as:Q,condition:Y},J)=>{let X=[],K=M(Z,J);if(!Array.isArray(K))throw Error("filter: items is not an array");for(let H of K){if(J.signal?.aborted)throw Error("Execution aborted");let W=L0(J);if(W.state[Q]=H,p(Y,W))X.push(H)}return X},{docs:"Filter Array",timeoutMs:0,cost:1}),QZ=P("reduce",$.object({items:$.array($.any),as:$.string,accumulator:$.string,initial:$.any,steps:$.array($.any)}),$.any,async({items:Z,as:Q,accumulator:Y,initial:J,steps:X},K)=>{let H=M(Z,K),W=M(J,K);if(!Array.isArray(H))throw Error("reduce: items is not an array");let z=W;for(let _ of H){if(K.signal?.aborted)throw Error("Execution aborted");let q=L0(K);q.state[Q]=_,q.state[Y]=z,await Q0.exec({op:"seq",steps:X},q),z=q.state.result??z}return z},{docs:"Reduce Array",timeoutMs:0,cost:1}),YZ=P("find",$.object({items:$.array($.any),as:$.string,condition:$.any}),$.any,async({items:Z,as:Q,condition:Y},J)=>{let X=M(Z,J);if(!Array.isArray(X))throw Error("find: items is not an array");for(let K of X){if(J.signal?.aborted)throw Error("Execution aborted");let H=L0(J);if(H.state[Q]=K,p(Y,H))return K}return null},{docs:"Find in Array",timeoutMs:0,cost:1}),JZ=P("push",$.object({list:$.array($.any),item:$.any}),$.array($.any),async({list:Z,item:Q},Y)=>{let J=M(Z,Y),X=M(Q,Y);if(Array.isArray(J))J.push(X);return J},{docs:"Push to Array",cost:1}),XZ=P("len",$.object({list:$.any}),$.number,async({list:Z},Q)=>{let Y=M(Z,Q);return Array.isArray(Y)||typeof Y==="string"?Y.length:0},{docs:"Length",cost:1}),KZ=P("split",$.object({str:$.string,sep:$.string}),$.array($.string),async({str:Z,sep:Q},Y)=>M(Z,Y).split(M(Q,Y)),{docs:"Split String",cost:1}),HZ=P("join",$.object({list:$.array($.string),sep:$.string}),$.string,async({list:Z,sep:Q},Y)=>M(Z,Y).join(M(Q,Y)),{docs:"Join String",cost:1}),WZ=P("template",$.object({tmpl:$.string,vars:$.record($.any)}),$.string,async({tmpl:Z,vars:Q},Y)=>{return M(Z,Y).replace(/\{\{(\w+)\}\}/g,(X,K)=>String(M(Q[K],Y)??""))},{docs:"String Template",cost:1}),zZ=P("regexMatch",$.object({pattern:$.string,value:$.any}),$.boolean,async({pattern:Z,value:Q},Y)=>{if(f9(Z))throw Error(`Suspicious regex pattern rejected (potential ReDoS): ${Z}`);let J=M(Q,Y);return new RegExp(Z).test(J)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),GZ=P("pick",$.object({obj:$.record($.any),keys:$.array($.string)}),$.record($.any),async({obj:Z,keys:Q},Y)=>{let J=M(Z,Y),X=M(Q,Y),K={};if(J&&Array.isArray(X))X.forEach((H)=>K[H]=J[H]);return K},{docs:"Pick Keys",cost:1}),_Z=P("omit",$.object({obj:$.record($.any),keys:$.array($.string)}),$.record($.any),async({obj:Z,keys:Q},Y)=>{let J=M(Z,Y),X=new Set(M(Q,Y)),K={};if(J)Object.keys(J).forEach((H)=>{if(!X.has(H))K[H]=J[H]});return K},{docs:"Omit Keys",cost:1}),qZ=P("merge",$.object({a:$.record($.any),b:$.record($.any)}),$.record($.any),async({a:Z,b:Q},Y)=>({...M(Z,Y),...M(Q,Y)}),{docs:"Merge Objects",cost:1}),FZ=P("keys",$.object({obj:$.record($.any)}),$.array($.string),async({obj:Z},Q)=>Object.keys(M(Z,Q)??{}),{docs:"Object Keys",cost:1}),u1=10,d1="X-Agent-Depth";function $Z(Z,Q){try{let J=new URL(Z).hostname.toLowerCase();for(let X of Q){let K=X.toLowerCase();if(K.startsWith("*.")){let H=K.slice(1);if(J.endsWith(H)||J===K.slice(2))return!0}else if(J===K)return!0}return!1}catch{return!1}}var RZ=P("httpFetch",$.object({url:$.string,method:$.string.optional,headers:$.record($.string).optional,body:$.any.optional,responseType:$.string.optional}),$.any,async(Z,Q)=>{let Y=M(Z.url,Q),J=M(Z.method,Q),X=M(Z.headers,Q)||{},K=M(Z.body,Q),H=M(Z.responseType,Q),W=Q.context?.requestDepth??0;if(W>=u1)throw Error(`Agent request depth exceeded (max ${u1}). This prevents recursive agent loops.`);if(Q.capabilities.fetch)return Q.capabilities.fetch(Y,{method:J,headers:{...X,[d1]:String(W+1)},body:K,signal:Q.signal,responseType:H});let z=Q.context?.allowedFetchDomains;if(z){if(!$Z(Y,z))throw Error(`Fetch blocked: domain not in allowlist. Allowed: ${z.join(", ")}`)}else{if(y9(Y))throw Error("Blocked URL: private/internal addresses not allowed in default fetch");try{let q=new URL(Y).hostname.toLowerCase();if(q!=="localhost"&&q!=="127.0.0.1"&&q!=="[::1]")throw Error("Fetch blocked: no allowedFetchDomains configured. Set ctx.context.allowedFetchDomains or provide a custom fetch capability.")}catch(_){if(_.message.includes("allowedFetchDomains"))throw _;throw Error(`Invalid URL: ${Y}`)}}if(typeof globalThis.fetch==="function"){let _=await globalThis.fetch(Y,{method:J,headers:{...X,[d1]:String(W+1)},body:K?JSON.stringify(K):void 0,signal:Q.signal});if(H==="dataUrl"){let R=await _.arrayBuffer(),F=new Uint8Array(R),U="";for(let B=0;B<F.length;B++)U+=String.fromCharCode(F[B]);let O=btoa(U);return`data:${_.headers.get("content-type")||"application/octet-stream"};base64,${O}`}let q=_.headers.get("content-type");if(H==="json"||q&&q.includes("application/json"))return _.json();return _.text()}throw Error("Capability 'fetch' missing and no global fetch available")},{docs:"HTTP Fetch",timeoutMs:30000,cost:5}),UZ=P("storeGet",$.object({key:$.string}),$.any,async({key:Z},Q)=>{let Y=M(Z,Q);return Q.capabilities.store?.get(Y)},{docs:"Store Get",cost:5}),OZ=P("storeSet",$.object({key:$.string,value:$.any}),void 0,async({key:Z,value:Q},Y)=>{let J=M(Z,Y),X=M(Q,Y);return Y.capabilities.store?.set(J,X)},{docs:"Store Set",cost:5}),IZ=P("storeQuery",$.object({query:$.any}),$.array($.any),async({query:Z},Q)=>Q.capabilities.store?.query?.(M(Z,Q))??[],{docs:"Store Query",cost:5}),BZ=P("storeVectorSearch",$.object({collection:$.string.optional,vector:$.array($.number),k:$.number.optional}),$.array($.any),async({collection:Z,vector:Q,k:Y},J)=>J.capabilities.store?.vectorSearch?.(M(Z,J),M(Q,J),M(Y,J))??[],{docs:"Vector Search",cost:(Z,Q)=>5+(M(Z.k,Q)??5)}),MZ=P("llmPredict",$.object({prompt:$.string,options:$.any.optional}),$.string,async({prompt:Z,options:Q},Y)=>{if(!Y.capabilities.llm?.predict)throw Error("Capability 'llm.predict' missing");return Y.capabilities.llm.predict(M(Z,Y),M(Q,Y))},{docs:"LLM Predict",timeoutMs:120000,cost:100}),LZ=P("agentRun",$.object({agentId:$.any,input:$.any}),$.any,async({agentId:Z,input:Q},Y)=>{let J=M(Z,Y),X=M(Q,Y),K=X;if(X&&typeof X==="object"&&!Array.isArray(X)){K={};for(let W in X)K[W]=M(X[W],Y)}if(O1(J)){let W=I1(J),z={...Y,args:K,state:{},consts:new Set,output:void 0,error:void 0},_=Y.resolver("seq");if(!_)throw Error("seq atom not found");if(await _.exec(W,z),z.error)throw Error(z.error.message||"Sub-agent failed");return z.output}if(J&&typeof J==="object"&&"op"in J){let W={...Y,args:K,state:{},consts:new Set,output:void 0,error:void 0},z=Y.resolver("seq");if(!z)throw Error("seq atom not found");if(await z.exec(J,W),W.error)throw Error(W.error.message||"Sub-agent failed");return W.output}if(!Y.capabilities.agent?.run)throw Error("Capability 'agent.run' missing");let H=await Y.capabilities.agent.run(J,K);if(H&&typeof H==="object"&&"fuelUsed"in H&&typeof H.fuelUsed==="number"){if(H.error)throw Error(H.error.message||"Sub-agent failed");return H.result}return H},{docs:"Run Sub-Agent (accepts procedure token, AST, or agent ID)",cost:1}),NZ=P("transpileCode",$.object({code:$.string}),$.any,async({code:Z},Q)=>{if(!Q.capabilities.code?.transpile)throw Error("Capability 'code.transpile' missing. Enable code transpilation by providing the code capability.");let Y=M(Z,Q);try{return Q.capabilities.code.transpile(Y)}catch(J){throw Error(`Code transpilation failed: ${J.message}`)}},{docs:"Transpile AsyncJS code to AST",cost:1}),l1=10,jZ=P("runCode",$.object({code:$.string,args:$.record($.any).optional}),$.any,async({code:Z,args:Q},Y)=>{let J=Y.runCodeDepth??0;if(J>=l1)throw Error(`runCode recursion limit exceeded (max ${l1}). This prevents infinite loops from dynamically generated code calling runCode.`);if(!Y.capabilities.code?.transpile)throw Error("Capability 'code.transpile' missing. Enable dynamic code execution by providing the code capability.");let X=M(Z,Y),K=Q?M(Q,Y):{},H;try{H=Y.capabilities.code.transpile(X)}catch(z){throw Error(`Code transpilation failed: ${z.message}`)}if(H.op!=="seq")throw Error("Transpiled code must be a seq node");let W=L0(Y);if(W.args=K,W.output=void 0,W.runCodeDepth=J+1,await Q0.exec(H,W),W.error){Y.error=W.error;return}return W.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),wZ=P("jsonParse",$.object({str:$.string}),$.any,async({str:Z},Q)=>JSON.parse(M(Z,Q)),{docs:"Parse JSON",cost:1}),AZ=P("jsonStringify",$.object({value:$.any}),$.string,async({value:Z},Q)=>JSON.stringify(M(Z,Q)),{docs:"Stringify JSON",cost:1}),VZ=P("xmlParse",$.object({str:$.string}),$.any,async({str:Z},Q)=>{if(!Q.capabilities.xml?.parse)throw Error("Capability 'xml.parse' missing");return Q.capabilities.xml.parse(M(Z,Q))},{docs:"Parse XML",cost:1}),DZ=P("memoize",$.object({key:$.string.optional,steps:$.array($.any)}),$.any,async({key:Z,steps:Q},Y)=>{if(!Y.memo)Y.memo=new Map;let J=M(Z,Y)??await B1.exec({value:Q,algorithm:"SHA-256"},Y);if(Y.memo.has(J))return Y.memo.get(J);let X=L0(Y);await Q0.exec({op:"seq",steps:Q},X);let K=X.output??X.state.result;return Y.memo.set(J,K),K},{docs:"Memoize steps result in memory",cost:1}),TZ=P("cache",$.object({key:$.string.optional,steps:$.array($.any),ttlMs:$.number.optional}),$.any,async({key:Z,steps:Q,ttlMs:Y},J)=>{if(!J.capabilities.store)throw Error("Capability 'store' missing for caching");let K=`cache:${M(Z,J)??await B1.exec({value:Q,algorithm:"SHA-256"},J)}`,H=await J.capabilities.store.get(K);if(H)if(typeof H==="object"&&H._exp){if(Date.now()<H._exp)return H.val}else return H;let W=L0(J);await Q0.exec({op:"seq",steps:Q},W);let z=W.output??W.state.result,_=Date.now()+(Y??86400000);if((J.fuel.current-=5)<=0)throw Error("Out of Fuel");return await J.capabilities.store.set(K,{val:z,_exp:_}),z},{docs:"Cache steps result in store with TTL",cost:5}),CZ=P("random",$.object({min:$.number.optional,max:$.number.optional,format:$.string.optional,length:$.number.optional}),$.any,async({min:Z,max:Q,format:Y,length:J},X)=>{let K=M(Y,X)??"float",H=M(J,X)??10,W=M(Z,X)??0,z=M(Q,X)??1;if(K==="base36"){let U="";if(typeof crypto<"u"&&crypto.getRandomValues){let O=new Uint8Array(H);crypto.getRandomValues(O);for(let L=0;L<H;L++)U+="0123456789abcdefghijklmnopqrstuvwxyz"[O[L]%36]}else for(let O=0;O<H;O++)U+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(Math.floor(Math.random()*36));return U}let _;if(typeof crypto<"u"&&crypto.getRandomValues){let F=new Uint32Array(1);crypto.getRandomValues(F),_=F[0]/4294967296}else _=Math.random();let q=z-W,R=_*q+W;if(K==="integer")return Math.floor(R);return R},{docs:"Generate Random",cost:1}),PZ=P("uuid",void 0,$.string,async()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();if(typeof crypto<"u"&&crypto.getRandomValues){let Z=new Uint8Array(16);crypto.getRandomValues(Z),Z[6]=Z[6]&15|64,Z[8]=Z[8]&63|128;let Q=Array.from(Z,(Y)=>Y.toString(16).padStart(2,"0")).join("");return`${Q.slice(0,8)}-${Q.slice(8,12)}-${Q.slice(12,16)}-${Q.slice(16,20)}-${Q.slice(20)}`}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(Z)=>{let Q=Math.random()*16|0;return(Z==="x"?Q:Q&3|8).toString(16)})},{docs:"Generate UUID",cost:1}),B1=P("hash",$.object({value:$.any,algorithm:$.string.optional}),$.string,async({value:Z,algorithm:Q},Y)=>{let J=typeof Z==="string"?Z:JSON.stringify(M(Z,Y)),X=M(Q,Y)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let W=new TextEncoder().encode(J),z=await crypto.subtle.digest(X,W);return Array.from(new Uint8Array(z)).map((q)=>q.toString(16).padStart(2,"0")).join("")}let K=0;for(let H=0;H<J.length;H++){let W=J.charCodeAt(H);K=(K<<5)-K+W,K|=0}return String(K)},{docs:"Hash a value",cost:1}),SZ=P("consoleLog",$.object({message:$.any}),void 0,async({message:Z},Q)=>{let Y=M(Z,Q);if(Q.trace)Q.trace.push({op:"console.log",input:{message:Y},stateDiff:{},result:Y,fuelBefore:Q.fuel.current,fuelAfter:Q.fuel.current,timestamp:new Date().toISOString()})},{docs:"Log to trace",cost:0.1}),bZ=P("consoleWarn",$.object({message:$.any}),void 0,async({message:Z},Q)=>{let Y=M(Z,Q),J=typeof Y==="string"?Y:JSON.stringify(Y);if(!Q.warnings)Q.warnings=[];if(Q.warnings.push(J),Q.trace)Q.trace.push({op:"console.warn",input:{message:Y},stateDiff:{},result:Y,fuelBefore:Q.fuel.current,fuelAfter:Q.fuel.current,timestamp:new Date().toISOString()})},{docs:"Add warning",cost:0.1}),EZ=P("consoleError",$.object({message:$.any}),void 0,async({message:Z},Q)=>{let Y=M(Z,Q),J=typeof Y==="string"?Y:JSON.stringify(Y);Q.error=new s(J,"console.error")},{docs:"Emit error and stop",cost:0.1}),vZ=P("storeProcedure",$.object({ast:$.any,ttl:$.number.optional,maxSize:$.number.optional}),$.string,async({ast:Z,ttl:Q,maxSize:Y},J)=>{let X=M(Z,J),K=Q?M(Q,J):E9,H=Y?M(Y,J):v9;if(!X||typeof X!=="object"||!X.op)throw Error('Invalid AST: must be an object with an "op" property');let W=JSON.stringify(X);if(W.length>H)throw Error(`AST too large: ${W.length} bytes exceeds limit of ${H} bytes. Consider reducing AST size or using a shorter TTL.`);let z=k9(),_=Date.now();return P0.set(z,{ast:X,createdAt:_,expiresAt:_+K}),z},{docs:"Store an AST and return a token for later execution",cost:1}),kZ=P("releaseProcedure",$.object({token:$.string}),$.boolean,async({token:Z},Q)=>{let Y=M(Z,Q);return P0.delete(Y)},{docs:"Release a stored procedure by token",cost:0.1}),gZ=P("clearExpiredProcedures",void 0,$.number,async()=>{let Z=Date.now(),Q=0;for(let[Y,J]of P0)if(Z>J.expiresAt)P0.delete(Y),Q++;return Q},{docs:"Clear all expired procedures and return count",cost:0.5}),n1={seq:Q0,if:u9,while:d9,return:l9,try:p9,Error:i9,varSet:n9,constSet:c9,varGet:o9,varsImport:a9,varsLet:s9,varsExport:r9,scope:t9,map:e9,filter:ZZ,reduce:QZ,find:YZ,push:JZ,len:XZ,split:KZ,join:HZ,template:WZ,regexMatch:zZ,pick:GZ,omit:_Z,merge:qZ,keys:FZ,httpFetch:RZ,storeGet:UZ,storeSet:OZ,storeQuery:IZ,storeVectorSearch:BZ,llmPredict:MZ,agentRun:LZ,transpileCode:NZ,runCode:jZ,jsonParse:wZ,jsonStringify:AZ,xmlParse:VZ,memoize:DZ,cache:TZ,random:CZ,uuid:PZ,hash:B1,consoleLog:SZ,consoleWarn:bZ,consoleError:EZ,storeProcedure:vZ,releaseProcedure:kZ,clearExpiredProcedures:gZ};var yZ=new Set(["true","false","null","undefined","and","or","not"]);function fZ(Z,Q){let Y=Z.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),J=[],X=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,K;while((K=X.exec(Y))!==null)J.push(K[1]);let W=[...new Set(J)].filter((z)=>!yZ.has(z)&&!(z in Q)&&!new RegExp(`\\b${z}\\s*\\(`).test(Y));if(W.length>0)console.warn(`[Agent99 Builder] Condition "${Z}" references variables not in vars mapping: ${W.join(", ")}. Add them to vars or use AsyncJS syntax (ajs\`...\`) which handles this automatically.`)}function o0(Z,Q){fZ(Z,Q);let Y=hZ(Z),J=r1(Y,0,Q);if(J.pos<Y.length){let X=Y.slice(J.pos).join(" ");throw Error(`Unsupported condition syntax near '${X}' in: ${Z}
2
- Supported: comparisons, &&, ||, !, arithmetic, member access (a.b), literals`)}return J.node}function hZ(Z){let Q=[],Y=0;while(Y<Z.length){while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y>=Z.length)break;if(Z[Y]==='"'||Z[Y]==="'"){let J=Z[Y++],X="";while(Y<Z.length&&Z[Y]!==J)if(Z[Y]==="\\"&&Y+1<Z.length)Y++,X+=Z[Y++];else X+=Z[Y++];Y++,Q.push(JSON.stringify(X));continue}if(Z.slice(Y,Y+2).match(/^(&&|\|\||==|!=|>=|<=)$/)){Q.push(Z.slice(Y,Y+2)),Y+=2;continue}if("+-*/%><!().?:[]".includes(Z[Y])){Q.push(Z[Y]),Y++;continue}if(/\d/.test(Z[Y])){let J="";while(Y<Z.length&&/[\d.]/.test(Z[Y]))J+=Z[Y++];Q.push(J);continue}if(/[a-zA-Z_]/.test(Z[Y])){let J="";while(Y<Z.length&&/[a-zA-Z0-9_]/.test(Z[Y]))J+=Z[Y++];Q.push(J);continue}Y++}return Q}function r1(Z,Q,Y){return xZ(Z,Q,Y)}function xZ(Z,Q,Y){let{node:J,pos:X}=c1(Z,Q,Y);while(Z[X]==="||"){X++;let{node:K,pos:H}=c1(Z,X,Y);J={$expr:"logical",op:"||",left:J,right:K},X=H}return{node:J,pos:X}}function c1(Z,Q,Y){let{node:J,pos:X}=o1(Z,Q,Y);while(Z[X]==="&&"){X++;let{node:K,pos:H}=o1(Z,X,Y);J={$expr:"logical",op:"&&",left:J,right:K},X=H}return{node:J,pos:X}}function o1(Z,Q,Y){let{node:J,pos:X}=a1(Z,Q,Y),K=["==","!=",">","<",">=","<="];while(K.includes(Z[X])){let H=Z[X++],{node:W,pos:z}=a1(Z,X,Y);J={$expr:"binary",op:H,left:J,right:W},X=z}return{node:J,pos:X}}function a1(Z,Q,Y){let{node:J,pos:X}=s1(Z,Q,Y);while(Z[X]==="+"||Z[X]==="-"){let K=Z[X++],{node:H,pos:W}=s1(Z,X,Y);J={$expr:"binary",op:K,left:J,right:H},X=W}return{node:J,pos:X}}function s1(Z,Q,Y){let{node:J,pos:X}=M1(Z,Q,Y);while(Z[X]==="*"||Z[X]==="/"||Z[X]==="%"){let K=Z[X++],{node:H,pos:W}=M1(Z,X,Y);J={$expr:"binary",op:K,left:J,right:H},X=W}return{node:J,pos:X}}function M1(Z,Q,Y){if(Z[Q]==="!"||Z[Q]==="-"){let J=Z[Q++],{node:X,pos:K}=M1(Z,Q,Y);return{node:{$expr:"unary",op:J,argument:X},pos:K}}return mZ(Z,Q,Y)}function mZ(Z,Q,Y){let J=Z[Q];if(J==="("){let{node:X,pos:K}=r1(Z,Q+1,Y);return{node:X,pos:K+1}}if(J&&J.startsWith('"'))return{node:{$expr:"literal",value:JSON.parse(J)},pos:Q+1};if(J&&/^\d/.test(J))return{node:{$expr:"literal",value:parseFloat(J)},pos:Q+1};if(J==="true")return{node:{$expr:"literal",value:!0},pos:Q+1};if(J==="false")return{node:{$expr:"literal",value:!1},pos:Q+1};if(J==="null")return{node:{$expr:"literal",value:null},pos:Q+1};if(J&&/^[a-zA-Z_]/.test(J)){let X={$expr:"ident",name:J},K=Q+1;while(Z[K]==="."){K++;let H=Z[K++];X={$expr:"member",object:X,property:H}}return{node:X,pos:K}}return{node:{$expr:"literal",value:null},pos:Q+1}}class r{steps=[];atoms;proxy;constructor(Z){return this.atoms=Z,this.proxy=new Proxy(this,{get:(Q,Y,J)=>{if(Y in Q)return Q[Y];if(typeof Y==="string"&&Y in Q.atoms)return(X)=>{let K=Q.atoms[Y];return Q.add(K.create(X)),J};return}}),this.proxy}add(Z){return this.steps.push(Z),this.proxy}as(Z){if(this.steps.length===0)throw Error("No step to capture");let Q=this.steps[this.steps.length-1];return Q.result=Z,this.proxy}step(Z){return this.add(Z)}return(Z){let Q=this.atoms.return;if(!Q)throw Error("Atom 'return' not found");let Y=Z.schema??Z;return this.add(Q.create({schema:Y}))}toJSON(){return{op:"seq",steps:[...this.steps]}}varsImport(Z){return this.add(this.atoms.varsImport.create({keys:Z}))}varsExport(Z){return this.add(this.atoms.varsExport.create({keys:Z}))}if(Z,Q,Y,J){let X=new r(this.atoms);Y(X);let K;if(J){let z=new r(this.atoms);J(z),K=z.steps}let H=o0(Z,Q),W=this.atoms.if;return this.add(W.create({condition:H,then:X.steps,else:K}))}while(Z,Q,Y){let J=new r(this.atoms);Y(J);let X=o0(Z,Q),K=this.atoms.while;return this.add(K.create({condition:X,body:J.steps}))}scope(Z){let Q=new r(this.atoms);Z(Q);let Y=this.atoms.scope;return this.add(Y.create({steps:Q.steps}))}map(Z,Q,Y){let J=new r(this.atoms);Y(J);let X=this.atoms.map;return this.add(X.create({items:Z,as:Q,steps:J.steps}))}filter(Z,Q,Y,J={}){let X=o0(Y,J),K=this.atoms.filter;return this.add(K.create({items:Z,as:Q,condition:X}))}find(Z,Q,Y,J={}){let X=o0(Y,J),K=this.atoms.find;return this.add(K.create({items:Z,as:Q,condition:X}))}reduce(Z,Q,Y,J,X){let K=new r(this.atoms);X(K);let H=this.atoms.reduce;return this.add(H.create({items:Z,as:Q,accumulator:Y,initial:J,steps:K.steps}))}memoize(Z,Q){let Y=new r(this.atoms);Z(Y);let J=this.atoms.memoize;return this.add(J.create({key:Q,steps:Y.steps}))}cache(Z,Q,Y){let J=new r(this.atoms);Z(J);let X=this.atoms.cache;return this.add(X.create({key:Q,steps:J.steps,ttlMs:Y}))}try(Z){let Q=new r(this.atoms);Z.try(Q);let Y;if(Z.catch){let X=new r(this.atoms);Z.catch(X),Y=X.steps}let J=this.atoms.try;return this.add(J.create({try:Q.steps,catch:Y}))}}import{validate as Z7}from"tosijs-schema";var uZ=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],Y8=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],dZ="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",J8="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",L1={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},N1="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",lZ={5:N1,"5module":N1+" export import",6:N1+" const class extends export import super"},pZ=/^in(stanceof)?$/,iZ=new RegExp("["+J8+"]"),nZ=new RegExp("["+J8+dZ+"]");function j1(Z,Q){var Y=65536;for(var J=0;J<Q.length;J+=2){if(Y+=Q[J],Y>Z)return!1;if(Y+=Q[J+1],Y>=Z)return!0}return!1}function G0(Z,Q){if(Z<65)return Z===36;if(Z<91)return!0;if(Z<97)return Z===95;if(Z<123)return!0;if(Z<=65535)return Z>=170&&iZ.test(String.fromCharCode(Z));if(Q===!1)return!1;return j1(Z,Y8)}function j0(Z,Q){if(Z<48)return Z===36;if(Z<58)return!0;if(Z<65)return!1;if(Z<91)return!0;if(Z<97)return Z===95;if(Z<123)return!0;if(Z<=65535)return Z>=170&&nZ.test(String.fromCharCode(Z));if(Q===!1)return!1;return j1(Z,Y8)||j1(Z,uZ)}var f=function(Q,Y){if(Y===void 0)Y={};this.label=Q,this.keyword=Y.keyword,this.beforeExpr=!!Y.beforeExpr,this.startsExpr=!!Y.startsExpr,this.isLoop=!!Y.isLoop,this.isAssign=!!Y.isAssign,this.prefix=!!Y.prefix,this.postfix=!!Y.postfix,this.binop=Y.binop||null,this.updateContext=null};function Y0(Z,Q){return new f(Z,{beforeExpr:!0,binop:Q})}var J0={beforeExpr:!0},t={startsExpr:!0},T1={};function g(Z,Q){if(Q===void 0)Q={};return Q.keyword=Z,T1[Z]=new f(Z,Q)}var G={num:new f("num",t),regexp:new f("regexp",t),string:new f("string",t),name:new f("name",t),privateId:new f("privateId",t),eof:new f("eof"),bracketL:new f("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new f("]"),braceL:new f("{",{beforeExpr:!0,startsExpr:!0}),braceR:new f("}"),parenL:new f("(",{beforeExpr:!0,startsExpr:!0}),parenR:new f(")"),comma:new f(",",J0),semi:new f(";",J0),colon:new f(":",J0),dot:new f("."),question:new f("?",J0),questionDot:new f("?."),arrow:new f("=>",J0),template:new f("template"),invalidTemplate:new f("invalidTemplate"),ellipsis:new f("...",J0),backQuote:new f("`",t),dollarBraceL:new f("${",{beforeExpr:!0,startsExpr:!0}),eq:new f("=",{beforeExpr:!0,isAssign:!0}),assign:new f("_=",{beforeExpr:!0,isAssign:!0}),incDec:new f("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new f("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Y0("||",1),logicalAND:Y0("&&",2),bitwiseOR:Y0("|",3),bitwiseXOR:Y0("^",4),bitwiseAND:Y0("&",5),equality:Y0("==/!=/===/!==",6),relational:Y0("</>/<=/>=",7),bitShift:Y0("<</>>/>>>",8),plusMin:new f("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Y0("%",10),star:Y0("*",10),slash:Y0("/",10),starstar:new f("**",{beforeExpr:!0}),coalesce:Y0("??",1),_break:g("break"),_case:g("case",J0),_catch:g("catch"),_continue:g("continue"),_debugger:g("debugger"),_default:g("default",J0),_do:g("do",{isLoop:!0,beforeExpr:!0}),_else:g("else",J0),_finally:g("finally"),_for:g("for",{isLoop:!0}),_function:g("function",t),_if:g("if"),_return:g("return",J0),_switch:g("switch"),_throw:g("throw",J0),_try:g("try"),_var:g("var"),_const:g("const"),_while:g("while",{isLoop:!0}),_with:g("with"),_new:g("new",{beforeExpr:!0,startsExpr:!0}),_this:g("this",t),_super:g("super",t),_class:g("class",t),_extends:g("extends",J0),_export:g("export"),_import:g("import",t),_null:g("null",t),_true:g("true",t),_false:g("false",t),_in:g("in",{beforeExpr:!0,binop:7}),_instanceof:g("instanceof",{beforeExpr:!0,binop:7}),_typeof:g("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:g("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:g("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},e=/\r\n?|\n|\u2028|\u2029/,cZ=new RegExp(e.source,"g");function S0(Z){return Z===10||Z===13||Z===8232||Z===8233}function X8(Z,Q,Y){if(Y===void 0)Y=Z.length;for(var J=Q;J<Y;J++){var X=Z.charCodeAt(J);if(S0(X))return J<Y-1&&X===13&&Z.charCodeAt(J+1)===10?J+2:J+1}return-1}var K8=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,c=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,H8=Object.prototype,oZ=H8.hasOwnProperty,aZ=H8.toString,b0=Object.hasOwn||function(Z,Q){return oZ.call(Z,Q)},t1=Array.isArray||function(Z){return aZ.call(Z)==="[object Array]"},e1=Object.create(null);function N0(Z){return e1[Z]||(e1[Z]=new RegExp("^(?:"+Z.replace(/ /g,"|")+")$"))}function U0(Z){if(Z<=65535)return String.fromCharCode(Z);return Z-=65536,String.fromCharCode((Z>>10)+55296,(Z&1023)+56320)}var sZ=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,y0=function(Q,Y){this.line=Q,this.column=Y};y0.prototype.offset=function(Q){return new y0(this.line,this.column+Q)};var Z1=function(Q,Y,J){if(this.start=Y,this.end=J,Q.sourceFile!==null)this.source=Q.sourceFile};function W8(Z,Q){for(var Y=1,J=0;;){var X=X8(Z,J,Q);if(X<0)return new y0(Y,Q-J);++Y,J=X}}var w1={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Z8=!1;function rZ(Z){var Q={};for(var Y in w1)Q[Y]=Z&&b0(Z,Y)?Z[Y]:w1[Y];if(Q.ecmaVersion==="latest")Q.ecmaVersion=1e8;else if(Q.ecmaVersion==null){if(!Z8&&typeof console==="object"&&console.warn)Z8=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
3
- Defaulting to 2020, but this will stop working in the future.`);Q.ecmaVersion=11}else if(Q.ecmaVersion>=2015)Q.ecmaVersion-=2009;if(Q.allowReserved==null)Q.allowReserved=Q.ecmaVersion<5;if(!Z||Z.allowHashBang==null)Q.allowHashBang=Q.ecmaVersion>=14;if(t1(Q.onToken)){var J=Q.onToken;Q.onToken=function(X){return J.push(X)}}if(t1(Q.onComment))Q.onComment=tZ(Q,Q.onComment);return Q}function tZ(Z,Q){return function(Y,J,X,K,H,W){var z={type:Y?"Block":"Line",value:J,start:X,end:K};if(Z.locations)z.loc=new Z1(this,H,W);if(Z.ranges)z.range=[X,K];Q.push(z)}}var f0=1,E0=2,C1=4,z8=8,P1=16,G8=32,Q1=64,_8=128,D0=256,h0=512,Y1=f0|E0|D0;function S1(Z,Q){return E0|(Z?C1:0)|(Q?z8:0)}var s0=0,b1=1,I0=2,q8=3,F8=4,$8=5,i=function(Q,Y,J){this.options=Q=rZ(Q),this.sourceFile=Q.sourceFile,this.keywords=N0(lZ[Q.ecmaVersion>=6?6:Q.sourceType==="module"?"5module":5]);var X="";if(Q.allowReserved!==!0){if(X=L1[Q.ecmaVersion>=6?6:Q.ecmaVersion===5?5:3],Q.sourceType==="module")X+=" await"}this.reservedWords=N0(X);var K=(X?X+" ":"")+L1.strict;if(this.reservedWordsStrict=N0(K),this.reservedWordsStrictBind=N0(K+" "+L1.strictBind),this.input=String(Y),this.containsEsc=!1,J)this.pos=J,this.lineStart=this.input.lastIndexOf(`
4
- `,J-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(e).length;else this.pos=this.lineStart=0,this.curLine=1;if(this.type=G.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=Q.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&Q.allowHashBang&&this.input.slice(0,2)==="#!")this.skipLineComment(2);this.scopeStack=[],this.enterScope(f0),this.regexpState=null,this.privateNameStack=[]},_0={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};i.prototype.parse=function(){var Q=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(Q)};_0.inFunction.get=function(){return(this.currentVarScope().flags&E0)>0};_0.inGenerator.get=function(){return(this.currentVarScope().flags&z8)>0};_0.inAsync.get=function(){return(this.currentVarScope().flags&C1)>0};_0.canAwait.get=function(){for(var Z=this.scopeStack.length-1;Z>=0;Z--){var Q=this.scopeStack[Z],Y=Q.flags;if(Y&(D0|h0))return!1;if(Y&E0)return(Y&C1)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};_0.allowSuper.get=function(){var Z=this.currentThisScope(),Q=Z.flags;return(Q&Q1)>0||this.options.allowSuperOutsideMethod};_0.allowDirectSuper.get=function(){return(this.currentThisScope().flags&_8)>0};_0.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};_0.allowNewDotTarget.get=function(){for(var Z=this.scopeStack.length-1;Z>=0;Z--){var Q=this.scopeStack[Z],Y=Q.flags;if(Y&(D0|h0)||Y&E0&&!(Y&P1))return!0}return!1};_0.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&D0)>0};i.extend=function(){var Q=[],Y=arguments.length;while(Y--)Q[Y]=arguments[Y];var J=this;for(var X=0;X<Q.length;X++)J=Q[X](J);return J};i.parse=function(Q,Y){return new this(Y,Q).parse()};i.parseExpressionAt=function(Q,Y,J){var X=new this(J,Q,Y);return X.nextToken(),X.parseExpression()};i.tokenizer=function(Q,Y){return new this(Y,Q)};Object.defineProperties(i.prototype,_0);var a=i.prototype,eZ=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;a.strictDirective=function(Z){if(this.options.ecmaVersion<5)return!1;for(;;){c.lastIndex=Z,Z+=c.exec(this.input)[0].length;var Q=eZ.exec(this.input.slice(Z));if(!Q)return!1;if((Q[1]||Q[2])==="use strict"){c.lastIndex=Z+Q[0].length;var Y=c.exec(this.input),J=Y.index+Y[0].length,X=this.input.charAt(J);return X===";"||X==="}"||e.test(Y[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(X)||X==="!"&&this.input.charAt(J+1)==="=")}if(Z+=Q[0].length,c.lastIndex=Z,Z+=c.exec(this.input)[0].length,this.input[Z]===";")Z++}};a.eat=function(Z){if(this.type===Z)return this.next(),!0;else return!1};a.isContextual=function(Z){return this.type===G.name&&this.value===Z&&!this.containsEsc};a.eatContextual=function(Z){if(!this.isContextual(Z))return!1;return this.next(),!0};a.expectContextual=function(Z){if(!this.eatContextual(Z))this.unexpected()};a.canInsertSemicolon=function(){return this.type===G.eof||this.type===G.braceR||e.test(this.input.slice(this.lastTokEnd,this.start))};a.insertSemicolon=function(){if(this.canInsertSemicolon()){if(this.options.onInsertedSemicolon)this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc);return!0}};a.semicolon=function(){if(!this.eat(G.semi)&&!this.insertSemicolon())this.unexpected()};a.afterTrailingComma=function(Z,Q){if(this.type===Z){if(this.options.onTrailingComma)this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc);if(!Q)this.next();return!0}};a.expect=function(Z){this.eat(Z)||this.unexpected()};a.unexpected=function(Z){this.raise(Z!=null?Z:this.start,"Unexpected token")};var J1=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};a.checkPatternErrors=function(Z,Q){if(!Z)return;if(Z.trailingComma>-1)this.raiseRecoverable(Z.trailingComma,"Comma is not permitted after the rest element");var Y=Q?Z.parenthesizedAssign:Z.parenthesizedBind;if(Y>-1)this.raiseRecoverable(Y,Q?"Assigning to rvalue":"Parenthesized pattern")};a.checkExpressionErrors=function(Z,Q){if(!Z)return!1;var{shorthandAssign:Y,doubleProto:J}=Z;if(!Q)return Y>=0||J>=0;if(Y>=0)this.raise(Y,"Shorthand property assignments are valid only in destructuring patterns");if(J>=0)this.raiseRecoverable(J,"Redefinition of __proto__ property")};a.checkYieldAwaitInDefaultParams=function(){if(this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos))this.raise(this.yieldPos,"Yield expression cannot be a default value");if(this.awaitPos)this.raise(this.awaitPos,"Await expression cannot be a default value")};a.isSimpleAssignTarget=function(Z){if(Z.type==="ParenthesizedExpression")return this.isSimpleAssignTarget(Z.expression);return Z.type==="Identifier"||Z.type==="MemberExpression"};var D=i.prototype;D.parseTopLevel=function(Z){var Q=Object.create(null);if(!Z.body)Z.body=[];while(this.type!==G.eof){var Y=this.parseStatement(null,!0,Q);Z.body.push(Y)}if(this.inModule)for(var J=0,X=Object.keys(this.undefinedExports);J<X.length;J+=1){var K=X[J];this.raiseRecoverable(this.undefinedExports[K].start,"Export '"+K+"' is not defined")}return this.adaptDirectivePrologue(Z.body),this.next(),Z.sourceType=this.options.sourceType,this.finishNode(Z,"Program")};var E1={kind:"loop"},Z6={kind:"switch"};D.isLet=function(Z){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;c.lastIndex=this.pos;var Q=c.exec(this.input),Y=this.pos+Q[0].length,J=this.input.charCodeAt(Y);if(J===91||J===92)return!0;if(Z)return!1;if(J===123||J>55295&&J<56320)return!0;if(G0(J,!0)){var X=Y+1;while(j0(J=this.input.charCodeAt(X),!0))++X;if(J===92||J>55295&&J<56320)return!0;var K=this.input.slice(Y,X);if(!pZ.test(K))return!0}return!1};D.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;c.lastIndex=this.pos;var Z=c.exec(this.input),Q=this.pos+Z[0].length,Y;return!e.test(this.input.slice(this.pos,Q))&&this.input.slice(Q,Q+8)==="function"&&(Q+8===this.input.length||!(j0(Y=this.input.charCodeAt(Q+8))||Y>55295&&Y<56320))};D.isUsingKeyword=function(Z,Q){if(this.options.ecmaVersion<17||!this.isContextual(Z?"await":"using"))return!1;c.lastIndex=this.pos;var Y=c.exec(this.input),J=this.pos+Y[0].length;if(e.test(this.input.slice(this.pos,J)))return!1;if(Z){var X=J+5,K;if(this.input.slice(J,X)!=="using"||X===this.input.length||j0(K=this.input.charCodeAt(X))||K>55295&&K<56320)return!1;c.lastIndex=X;var H=c.exec(this.input);if(H&&e.test(this.input.slice(X,X+H[0].length)))return!1}if(Q){var W=J+2,z;if(this.input.slice(J,W)==="of"){if(W===this.input.length||!j0(z=this.input.charCodeAt(W))&&!(z>55295&&z<56320))return!1}}var _=this.input.charCodeAt(J);return G0(_,!0)||_===92};D.isAwaitUsing=function(Z){return this.isUsingKeyword(!0,Z)};D.isUsing=function(Z){return this.isUsingKeyword(!1,Z)};D.parseStatement=function(Z,Q,Y){var J=this.type,X=this.startNode(),K;if(this.isLet(Z))J=G._var,K="let";switch(J){case G._break:case G._continue:return this.parseBreakContinueStatement(X,J.keyword);case G._debugger:return this.parseDebuggerStatement(X);case G._do:return this.parseDoStatement(X);case G._for:return this.parseForStatement(X);case G._function:if(Z&&(this.strict||Z!=="if"&&Z!=="label")&&this.options.ecmaVersion>=6)this.unexpected();return this.parseFunctionStatement(X,!1,!Z);case G._class:if(Z)this.unexpected();return this.parseClass(X,!0);case G._if:return this.parseIfStatement(X);case G._return:return this.parseReturnStatement(X);case G._switch:return this.parseSwitchStatement(X);case G._throw:return this.parseThrowStatement(X);case G._try:return this.parseTryStatement(X);case G._const:case G._var:if(K=K||this.value,Z&&K!=="var")this.unexpected();return this.parseVarStatement(X,K);case G._while:return this.parseWhileStatement(X);case G._with:return this.parseWithStatement(X);case G.braceL:return this.parseBlock(!0,X);case G.semi:return this.parseEmptyStatement(X);case G._export:case G._import:if(this.options.ecmaVersion>10&&J===G._import){c.lastIndex=this.pos;var H=c.exec(this.input),W=this.pos+H[0].length,z=this.input.charCodeAt(W);if(z===40||z===46)return this.parseExpressionStatement(X,this.parseExpression())}if(!this.options.allowImportExportEverywhere){if(!Q)this.raise(this.start,"'import' and 'export' may only appear at the top level");if(!this.inModule)this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")}return J===G._import?this.parseImport(X):this.parseExport(X,Y);default:if(this.isAsyncFunction()){if(Z)this.unexpected();return this.next(),this.parseFunctionStatement(X,!0,!Z)}var _=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(_){if(Q&&this.options.sourceType==="script")this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`");if(_==="await using"){if(!this.canAwait)this.raise(this.start,"Await using cannot appear outside of async function");this.next()}return this.next(),this.parseVar(X,!1,_),this.semicolon(),this.finishNode(X,"VariableDeclaration")}var q=this.value,R=this.parseExpression();if(J===G.name&&R.type==="Identifier"&&this.eat(G.colon))return this.parseLabeledStatement(X,q,R,Z);else return this.parseExpressionStatement(X,R)}};D.parseBreakContinueStatement=function(Z,Q){var Y=Q==="break";if(this.next(),this.eat(G.semi)||this.insertSemicolon())Z.label=null;else if(this.type!==G.name)this.unexpected();else Z.label=this.parseIdent(),this.semicolon();var J=0;for(;J<this.labels.length;++J){var X=this.labels[J];if(Z.label==null||X.name===Z.label.name){if(X.kind!=null&&(Y||X.kind==="loop"))break;if(Z.label&&Y)break}}if(J===this.labels.length)this.raise(Z.start,"Unsyntactic "+Q);return this.finishNode(Z,Y?"BreakStatement":"ContinueStatement")};D.parseDebuggerStatement=function(Z){return this.next(),this.semicolon(),this.finishNode(Z,"DebuggerStatement")};D.parseDoStatement=function(Z){if(this.next(),this.labels.push(E1),Z.body=this.parseStatement("do"),this.labels.pop(),this.expect(G._while),Z.test=this.parseParenExpression(),this.options.ecmaVersion>=6)this.eat(G.semi);else this.semicolon();return this.finishNode(Z,"DoWhileStatement")};D.parseForStatement=function(Z){this.next();var Q=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(E1),this.enterScope(0),this.expect(G.parenL),this.type===G.semi){if(Q>-1)this.unexpected(Q);return this.parseFor(Z,null)}var Y=this.isLet();if(this.type===G._var||this.type===G._const||Y){var J=this.startNode(),X=Y?"let":this.value;return this.next(),this.parseVar(J,!0,X),this.finishNode(J,"VariableDeclaration"),this.parseForAfterInit(Z,J,Q)}var K=this.isContextual("let"),H=!1,W=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(W){var z=this.startNode();if(this.next(),W==="await using")this.next();return this.parseVar(z,!0,W),this.finishNode(z,"VariableDeclaration"),this.parseForAfterInit(Z,z,Q)}var _=this.containsEsc,q=new J1,R=this.start,F=Q>-1?this.parseExprSubscripts(q,"await"):this.parseExpression(!0,q);if(this.type===G._in||(H=this.options.ecmaVersion>=6&&this.isContextual("of"))){if(Q>-1){if(this.type===G._in)this.unexpected(Q);Z.await=!0}else if(H&&this.options.ecmaVersion>=8){if(F.start===R&&!_&&F.type==="Identifier"&&F.name==="async")this.unexpected();else if(this.options.ecmaVersion>=9)Z.await=!1}if(K&&H)this.raise(F.start,"The left-hand side of a for-of loop may not start with 'let'.");return this.toAssignable(F,!1,q),this.checkLValPattern(F),this.parseForIn(Z,F)}else this.checkExpressionErrors(q,!0);if(Q>-1)this.unexpected(Q);return this.parseFor(Z,F)};D.parseForAfterInit=function(Z,Q,Y){if((this.type===G._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&Q.declarations.length===1){if(this.options.ecmaVersion>=9)if(this.type===G._in){if(Y>-1)this.unexpected(Y)}else Z.await=Y>-1;return this.parseForIn(Z,Q)}if(Y>-1)this.unexpected(Y);return this.parseFor(Z,Q)};D.parseFunctionStatement=function(Z,Q,Y){return this.next(),this.parseFunction(Z,g0|(Y?0:A1),!1,Q)};D.parseIfStatement=function(Z){return this.next(),Z.test=this.parseParenExpression(),Z.consequent=this.parseStatement("if"),Z.alternate=this.eat(G._else)?this.parseStatement("if"):null,this.finishNode(Z,"IfStatement")};D.parseReturnStatement=function(Z){if(!this.inFunction&&!this.options.allowReturnOutsideFunction)this.raise(this.start,"'return' outside of function");if(this.next(),this.eat(G.semi)||this.insertSemicolon())Z.argument=null;else Z.argument=this.parseExpression(),this.semicolon();return this.finishNode(Z,"ReturnStatement")};D.parseSwitchStatement=function(Z){this.next(),Z.discriminant=this.parseParenExpression(),Z.cases=[],this.expect(G.braceL),this.labels.push(Z6),this.enterScope(0);var Q;for(var Y=!1;this.type!==G.braceR;)if(this.type===G._case||this.type===G._default){var J=this.type===G._case;if(Q)this.finishNode(Q,"SwitchCase");if(Z.cases.push(Q=this.startNode()),Q.consequent=[],this.next(),J)Q.test=this.parseExpression();else{if(Y)this.raiseRecoverable(this.lastTokStart,"Multiple default clauses");Y=!0,Q.test=null}this.expect(G.colon)}else{if(!Q)this.unexpected();Q.consequent.push(this.parseStatement(null))}if(this.exitScope(),Q)this.finishNode(Q,"SwitchCase");return this.next(),this.labels.pop(),this.finishNode(Z,"SwitchStatement")};D.parseThrowStatement=function(Z){if(this.next(),e.test(this.input.slice(this.lastTokEnd,this.start)))this.raise(this.lastTokEnd,"Illegal newline after throw");return Z.argument=this.parseExpression(),this.semicolon(),this.finishNode(Z,"ThrowStatement")};var Q6=[];D.parseCatchClauseParam=function(){var Z=this.parseBindingAtom(),Q=Z.type==="Identifier";return this.enterScope(Q?G8:0),this.checkLValPattern(Z,Q?F8:I0),this.expect(G.parenR),Z};D.parseTryStatement=function(Z){if(this.next(),Z.block=this.parseBlock(),Z.handler=null,this.type===G._catch){var Q=this.startNode();if(this.next(),this.eat(G.parenL))Q.param=this.parseCatchClauseParam();else{if(this.options.ecmaVersion<10)this.unexpected();Q.param=null,this.enterScope(0)}Q.body=this.parseBlock(!1),this.exitScope(),Z.handler=this.finishNode(Q,"CatchClause")}if(Z.finalizer=this.eat(G._finally)?this.parseBlock():null,!Z.handler&&!Z.finalizer)this.raise(Z.start,"Missing catch or finally clause");return this.finishNode(Z,"TryStatement")};D.parseVarStatement=function(Z,Q,Y){return this.next(),this.parseVar(Z,!1,Q,Y),this.semicolon(),this.finishNode(Z,"VariableDeclaration")};D.parseWhileStatement=function(Z){return this.next(),Z.test=this.parseParenExpression(),this.labels.push(E1),Z.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(Z,"WhileStatement")};D.parseWithStatement=function(Z){if(this.strict)this.raise(this.start,"'with' in strict mode");return this.next(),Z.object=this.parseParenExpression(),Z.body=this.parseStatement("with"),this.finishNode(Z,"WithStatement")};D.parseEmptyStatement=function(Z){return this.next(),this.finishNode(Z,"EmptyStatement")};D.parseLabeledStatement=function(Z,Q,Y,J){for(var X=0,K=this.labels;X<K.length;X+=1){var H=K[X];if(H.name===Q)this.raise(Y.start,"Label '"+Q+"' is already declared")}var W=this.type.isLoop?"loop":this.type===G._switch?"switch":null;for(var z=this.labels.length-1;z>=0;z--){var _=this.labels[z];if(_.statementStart===Z.start)_.statementStart=this.start,_.kind=W;else break}return this.labels.push({name:Q,kind:W,statementStart:this.start}),Z.body=this.parseStatement(J?J.indexOf("label")===-1?J+"label":J:"label"),this.labels.pop(),Z.label=Y,this.finishNode(Z,"LabeledStatement")};D.parseExpressionStatement=function(Z,Q){return Z.expression=Q,this.semicolon(),this.finishNode(Z,"ExpressionStatement")};D.parseBlock=function(Z,Q,Y){if(Z===void 0)Z=!0;if(Q===void 0)Q=this.startNode();if(Q.body=[],this.expect(G.braceL),Z)this.enterScope(0);while(this.type!==G.braceR){var J=this.parseStatement(null);Q.body.push(J)}if(Y)this.strict=!1;if(this.next(),Z)this.exitScope();return this.finishNode(Q,"BlockStatement")};D.parseFor=function(Z,Q){return Z.init=Q,this.expect(G.semi),Z.test=this.type===G.semi?null:this.parseExpression(),this.expect(G.semi),Z.update=this.type===G.parenR?null:this.parseExpression(),this.expect(G.parenR),Z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(Z,"ForStatement")};D.parseForIn=function(Z,Q){var Y=this.type===G._in;if(this.next(),Q.type==="VariableDeclaration"&&Q.declarations[0].init!=null&&(!Y||this.options.ecmaVersion<8||this.strict||Q.kind!=="var"||Q.declarations[0].id.type!=="Identifier"))this.raise(Q.start,(Y?"for-in":"for-of")+" loop variable declaration may not have an initializer");return Z.left=Q,Z.right=Y?this.parseExpression():this.parseMaybeAssign(),this.expect(G.parenR),Z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(Z,Y?"ForInStatement":"ForOfStatement")};D.parseVar=function(Z,Q,Y,J){Z.declarations=[],Z.kind=Y;for(;;){var X=this.startNode();if(this.parseVarId(X,Y),this.eat(G.eq))X.init=this.parseMaybeAssign(Q);else if(!J&&Y==="const"&&!(this.type===G._in||this.options.ecmaVersion>=6&&this.isContextual("of")))this.unexpected();else if(!J&&(Y==="using"||Y==="await using")&&this.options.ecmaVersion>=17&&this.type!==G._in&&!this.isContextual("of"))this.raise(this.lastTokEnd,"Missing initializer in "+Y+" declaration");else if(!J&&X.id.type!=="Identifier"&&!(Q&&(this.type===G._in||this.isContextual("of"))))this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value");else X.init=null;if(Z.declarations.push(this.finishNode(X,"VariableDeclarator")),!this.eat(G.comma))break}return Z};D.parseVarId=function(Z,Q){Z.id=Q==="using"||Q==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(Z.id,Q==="var"?b1:I0,!1)};var g0=1,A1=2,R8=4;D.parseFunction=function(Z,Q,Y,J,X){if(this.initFunction(Z),this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!J){if(this.type===G.star&&Q&A1)this.unexpected();Z.generator=this.eat(G.star)}if(this.options.ecmaVersion>=8)Z.async=!!J;if(Q&g0){if(Z.id=Q&R8&&this.type!==G.name?null:this.parseIdent(),Z.id&&!(Q&A1))this.checkLValSimple(Z.id,this.strict||Z.generator||Z.async?this.treatFunctionsAsVar?b1:I0:q8)}var K=this.yieldPos,H=this.awaitPos,W=this.awaitIdentPos;if(this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(S1(Z.async,Z.generator)),!(Q&g0))Z.id=this.type===G.name?this.parseIdent():null;return this.parseFunctionParams(Z),this.parseFunctionBody(Z,Y,!1,X),this.yieldPos=K,this.awaitPos=H,this.awaitIdentPos=W,this.finishNode(Z,Q&g0?"FunctionDeclaration":"FunctionExpression")};D.parseFunctionParams=function(Z){this.expect(G.parenL),Z.params=this.parseBindingList(G.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};D.parseClass=function(Z,Q){this.next();var Y=this.strict;this.strict=!0,this.parseClassId(Z,Q),this.parseClassSuper(Z);var J=this.enterClassBody(),X=this.startNode(),K=!1;X.body=[],this.expect(G.braceL);while(this.type!==G.braceR){var H=this.parseClassElement(Z.superClass!==null);if(H){if(X.body.push(H),H.type==="MethodDefinition"&&H.kind==="constructor"){if(K)this.raiseRecoverable(H.start,"Duplicate constructor in the same class");K=!0}else if(H.key&&H.key.type==="PrivateIdentifier"&&Y6(J,H))this.raiseRecoverable(H.key.start,"Identifier '#"+H.key.name+"' has already been declared")}}return this.strict=Y,this.next(),Z.body=this.finishNode(X,"ClassBody"),this.exitClassBody(),this.finishNode(Z,Q?"ClassDeclaration":"ClassExpression")};D.parseClassElement=function(Z){if(this.eat(G.semi))return null;var Q=this.options.ecmaVersion,Y=this.startNode(),J="",X=!1,K=!1,H="method",W=!1;if(this.eatContextual("static")){if(Q>=13&&this.eat(G.braceL))return this.parseClassStaticBlock(Y),Y;if(this.isClassElementNameStart()||this.type===G.star)W=!0;else J="static"}if(Y.static=W,!J&&Q>=8&&this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===G.star)&&!this.canInsertSemicolon())K=!0;else J="async";if(!J&&(Q>=9||!K)&&this.eat(G.star))X=!0;if(!J&&!K&&!X){var z=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())H=z;else J=z}if(J)Y.computed=!1,Y.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),Y.key.name=J,this.finishNode(Y.key,"Identifier");else this.parseClassElementName(Y);if(Q<13||this.type===G.parenL||H!=="method"||X||K){var _=!Y.static&&r0(Y,"constructor"),q=_&&Z;if(_&&H!=="method")this.raise(Y.key.start,"Constructor can't have get/set modifier");Y.kind=_?"constructor":H,this.parseClassMethod(Y,X,K,q)}else this.parseClassField(Y);return Y};D.isClassElementNameStart=function(){return this.type===G.name||this.type===G.privateId||this.type===G.num||this.type===G.string||this.type===G.bracketL||this.type.keyword};D.parseClassElementName=function(Z){if(this.type===G.privateId){if(this.value==="constructor")this.raise(this.start,"Classes can't have an element named '#constructor'");Z.computed=!1,Z.key=this.parsePrivateIdent()}else this.parsePropertyName(Z)};D.parseClassMethod=function(Z,Q,Y,J){var X=Z.key;if(Z.kind==="constructor"){if(Q)this.raise(X.start,"Constructor can't be a generator");if(Y)this.raise(X.start,"Constructor can't be an async method")}else if(Z.static&&r0(Z,"prototype"))this.raise(X.start,"Classes may not have a static property named prototype");var K=Z.value=this.parseMethod(Q,Y,J);if(Z.kind==="get"&&K.params.length!==0)this.raiseRecoverable(K.start,"getter should have no params");if(Z.kind==="set"&&K.params.length!==1)this.raiseRecoverable(K.start,"setter should have exactly one param");if(Z.kind==="set"&&K.params[0].type==="RestElement")this.raiseRecoverable(K.params[0].start,"Setter cannot use rest params");return this.finishNode(Z,"MethodDefinition")};D.parseClassField=function(Z){if(r0(Z,"constructor"))this.raise(Z.key.start,"Classes can't have a field named 'constructor'");else if(Z.static&&r0(Z,"prototype"))this.raise(Z.key.start,"Classes can't have a static field named 'prototype'");if(this.eat(G.eq))this.enterScope(h0|Q1),Z.value=this.parseMaybeAssign(),this.exitScope();else Z.value=null;return this.semicolon(),this.finishNode(Z,"PropertyDefinition")};D.parseClassStaticBlock=function(Z){Z.body=[];var Q=this.labels;this.labels=[],this.enterScope(D0|Q1);while(this.type!==G.braceR){var Y=this.parseStatement(null);Z.body.push(Y)}return this.next(),this.exitScope(),this.labels=Q,this.finishNode(Z,"StaticBlock")};D.parseClassId=function(Z,Q){if(this.type===G.name){if(Z.id=this.parseIdent(),Q)this.checkLValSimple(Z.id,I0,!1)}else{if(Q===!0)this.unexpected();Z.id=null}};D.parseClassSuper=function(Z){Z.superClass=this.eat(G._extends)?this.parseExprSubscripts(null,!1):null};D.enterClassBody=function(){var Z={declared:Object.create(null),used:[]};return this.privateNameStack.push(Z),Z.declared};D.exitClassBody=function(){var Z=this.privateNameStack.pop(),Q=Z.declared,Y=Z.used;if(!this.options.checkPrivateFields)return;var J=this.privateNameStack.length,X=J===0?null:this.privateNameStack[J-1];for(var K=0;K<Y.length;++K){var H=Y[K];if(!b0(Q,H.name))if(X)X.used.push(H);else this.raiseRecoverable(H.start,"Private field '#"+H.name+"' must be declared in an enclosing class")}};function Y6(Z,Q){var Y=Q.key.name,J=Z[Y],X="true";if(Q.type==="MethodDefinition"&&(Q.kind==="get"||Q.kind==="set"))X=(Q.static?"s":"i")+Q.kind;if(J==="iget"&&X==="iset"||J==="iset"&&X==="iget"||J==="sget"&&X==="sset"||J==="sset"&&X==="sget")return Z[Y]="true",!1;else if(!J)return Z[Y]=X,!1;else return!0}function r0(Z,Q){var{computed:Y,key:J}=Z;return!Y&&(J.type==="Identifier"&&J.name===Q||J.type==="Literal"&&J.value===Q)}D.parseExportAllDeclaration=function(Z,Q){if(this.options.ecmaVersion>=11)if(this.eatContextual("as"))Z.exported=this.parseModuleExportName(),this.checkExport(Q,Z.exported,this.lastTokStart);else Z.exported=null;if(this.expectContextual("from"),this.type!==G.string)this.unexpected();if(Z.source=this.parseExprAtom(),this.options.ecmaVersion>=16)Z.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(Z,"ExportAllDeclaration")};D.parseExport=function(Z,Q){if(this.next(),this.eat(G.star))return this.parseExportAllDeclaration(Z,Q);if(this.eat(G._default))return this.checkExport(Q,"default",this.lastTokStart),Z.declaration=this.parseExportDefaultDeclaration(),this.finishNode(Z,"ExportDefaultDeclaration");if(this.shouldParseExportStatement()){if(Z.declaration=this.parseExportDeclaration(Z),Z.declaration.type==="VariableDeclaration")this.checkVariableExport(Q,Z.declaration.declarations);else this.checkExport(Q,Z.declaration.id,Z.declaration.id.start);if(Z.specifiers=[],Z.source=null,this.options.ecmaVersion>=16)Z.attributes=[]}else{if(Z.declaration=null,Z.specifiers=this.parseExportSpecifiers(Q),this.eatContextual("from")){if(this.type!==G.string)this.unexpected();if(Z.source=this.parseExprAtom(),this.options.ecmaVersion>=16)Z.attributes=this.parseWithClause()}else{for(var Y=0,J=Z.specifiers;Y<J.length;Y+=1){var X=J[Y];if(this.checkUnreserved(X.local),this.checkLocalExport(X.local),X.local.type==="Literal")this.raise(X.local.start,"A string literal cannot be used as an exported binding without `from`.")}if(Z.source=null,this.options.ecmaVersion>=16)Z.attributes=[]}this.semicolon()}return this.finishNode(Z,"ExportNamedDeclaration")};D.parseExportDeclaration=function(Z){return this.parseStatement(null)};D.parseExportDefaultDeclaration=function(){var Z;if(this.type===G._function||(Z=this.isAsyncFunction())){var Q=this.startNode();if(this.next(),Z)this.next();return this.parseFunction(Q,g0|R8,!1,Z)}else if(this.type===G._class){var Y=this.startNode();return this.parseClass(Y,"nullableID")}else{var J=this.parseMaybeAssign();return this.semicolon(),J}};D.checkExport=function(Z,Q,Y){if(!Z)return;if(typeof Q!=="string")Q=Q.type==="Identifier"?Q.name:Q.value;if(b0(Z,Q))this.raiseRecoverable(Y,"Duplicate export '"+Q+"'");Z[Q]=!0};D.checkPatternExport=function(Z,Q){var Y=Q.type;if(Y==="Identifier")this.checkExport(Z,Q,Q.start);else if(Y==="ObjectPattern")for(var J=0,X=Q.properties;J<X.length;J+=1){var K=X[J];this.checkPatternExport(Z,K)}else if(Y==="ArrayPattern")for(var H=0,W=Q.elements;H<W.length;H+=1){var z=W[H];if(z)this.checkPatternExport(Z,z)}else if(Y==="Property")this.checkPatternExport(Z,Q.value);else if(Y==="AssignmentPattern")this.checkPatternExport(Z,Q.left);else if(Y==="RestElement")this.checkPatternExport(Z,Q.argument)};D.checkVariableExport=function(Z,Q){if(!Z)return;for(var Y=0,J=Q;Y<J.length;Y+=1){var X=J[Y];this.checkPatternExport(Z,X.id)}};D.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};D.parseExportSpecifier=function(Z){var Q=this.startNode();return Q.local=this.parseModuleExportName(),Q.exported=this.eatContextual("as")?this.parseModuleExportName():Q.local,this.checkExport(Z,Q.exported,Q.exported.start),this.finishNode(Q,"ExportSpecifier")};D.parseExportSpecifiers=function(Z){var Q=[],Y=!0;this.expect(G.braceL);while(!this.eat(G.braceR)){if(!Y){if(this.expect(G.comma),this.afterTrailingComma(G.braceR))break}else Y=!1;Q.push(this.parseExportSpecifier(Z))}return Q};D.parseImport=function(Z){if(this.next(),this.type===G.string)Z.specifiers=Q6,Z.source=this.parseExprAtom();else Z.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),Z.source=this.type===G.string?this.parseExprAtom():this.unexpected();if(this.options.ecmaVersion>=16)Z.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(Z,"ImportDeclaration")};D.parseImportSpecifier=function(){var Z=this.startNode();if(Z.imported=this.parseModuleExportName(),this.eatContextual("as"))Z.local=this.parseIdent();else this.checkUnreserved(Z.imported),Z.local=Z.imported;return this.checkLValSimple(Z.local,I0),this.finishNode(Z,"ImportSpecifier")};D.parseImportDefaultSpecifier=function(){var Z=this.startNode();return Z.local=this.parseIdent(),this.checkLValSimple(Z.local,I0),this.finishNode(Z,"ImportDefaultSpecifier")};D.parseImportNamespaceSpecifier=function(){var Z=this.startNode();return this.next(),this.expectContextual("as"),Z.local=this.parseIdent(),this.checkLValSimple(Z.local,I0),this.finishNode(Z,"ImportNamespaceSpecifier")};D.parseImportSpecifiers=function(){var Z=[],Q=!0;if(this.type===G.name){if(Z.push(this.parseImportDefaultSpecifier()),!this.eat(G.comma))return Z}if(this.type===G.star)return Z.push(this.parseImportNamespaceSpecifier()),Z;this.expect(G.braceL);while(!this.eat(G.braceR)){if(!Q){if(this.expect(G.comma),this.afterTrailingComma(G.braceR))break}else Q=!1;Z.push(this.parseImportSpecifier())}return Z};D.parseWithClause=function(){var Z=[];if(!this.eat(G._with))return Z;this.expect(G.braceL);var Q={},Y=!0;while(!this.eat(G.braceR)){if(!Y){if(this.expect(G.comma),this.afterTrailingComma(G.braceR))break}else Y=!1;var J=this.parseImportAttribute(),X=J.key.type==="Identifier"?J.key.name:J.key.value;if(b0(Q,X))this.raiseRecoverable(J.key.start,"Duplicate attribute key '"+X+"'");Q[X]=!0,Z.push(J)}return Z};D.parseImportAttribute=function(){var Z=this.startNode();if(Z.key=this.type===G.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(G.colon),this.type!==G.string)this.unexpected();return Z.value=this.parseExprAtom(),this.finishNode(Z,"ImportAttribute")};D.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===G.string){var Z=this.parseLiteral(this.value);if(sZ.test(Z.value))this.raise(Z.start,"An export name cannot include a lone surrogate.");return Z}return this.parseIdent(!0)};D.adaptDirectivePrologue=function(Z){for(var Q=0;Q<Z.length&&this.isDirectiveCandidate(Z[Q]);++Q)Z[Q].directive=Z[Q].expression.raw.slice(1,-1)};D.isDirectiveCandidate=function(Z){return this.options.ecmaVersion>=5&&Z.type==="ExpressionStatement"&&Z.expression.type==="Literal"&&typeof Z.expression.value==="string"&&(this.input[Z.start]==='"'||this.input[Z.start]==="'")};var K0=i.prototype;K0.toAssignable=function(Z,Q,Y){if(this.options.ecmaVersion>=6&&Z)switch(Z.type){case"Identifier":if(this.inAsync&&Z.name==="await")this.raise(Z.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":if(Z.type="ObjectPattern",Y)this.checkPatternErrors(Y,!0);for(var J=0,X=Z.properties;J<X.length;J+=1){var K=X[J];if(this.toAssignable(K,Q),K.type==="RestElement"&&(K.argument.type==="ArrayPattern"||K.argument.type==="ObjectPattern"))this.raise(K.argument.start,"Unexpected token")}break;case"Property":if(Z.kind!=="init")this.raise(Z.key.start,"Object pattern can't contain getter or setter");this.toAssignable(Z.value,Q);break;case"ArrayExpression":if(Z.type="ArrayPattern",Y)this.checkPatternErrors(Y,!0);this.toAssignableList(Z.elements,Q);break;case"SpreadElement":if(Z.type="RestElement",this.toAssignable(Z.argument,Q),Z.argument.type==="AssignmentPattern")this.raise(Z.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":if(Z.operator!=="=")this.raise(Z.left.end,"Only '=' operator can be used for specifying default value.");Z.type="AssignmentPattern",delete Z.operator,this.toAssignable(Z.left,Q);break;case"ParenthesizedExpression":this.toAssignable(Z.expression,Q,Y);break;case"ChainExpression":this.raiseRecoverable(Z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!Q)break;default:this.raise(Z.start,"Assigning to rvalue")}else if(Y)this.checkPatternErrors(Y,!0);return Z};K0.toAssignableList=function(Z,Q){var Y=Z.length;for(var J=0;J<Y;J++){var X=Z[J];if(X)this.toAssignable(X,Q)}if(Y){var K=Z[Y-1];if(this.options.ecmaVersion===6&&Q&&K&&K.type==="RestElement"&&K.argument.type!=="Identifier")this.unexpected(K.argument.start)}return Z};K0.parseSpread=function(Z){var Q=this.startNode();return this.next(),Q.argument=this.parseMaybeAssign(!1,Z),this.finishNode(Q,"SpreadElement")};K0.parseRestBinding=function(){var Z=this.startNode();if(this.next(),this.options.ecmaVersion===6&&this.type!==G.name)this.unexpected();return Z.argument=this.parseBindingAtom(),this.finishNode(Z,"RestElement")};K0.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case G.bracketL:var Z=this.startNode();return this.next(),Z.elements=this.parseBindingList(G.bracketR,!0,!0),this.finishNode(Z,"ArrayPattern");case G.braceL:return this.parseObj(!0)}return this.parseIdent()};K0.parseBindingList=function(Z,Q,Y,J){var X=[],K=!0;while(!this.eat(Z)){if(K)K=!1;else this.expect(G.comma);if(Q&&this.type===G.comma)X.push(null);else if(Y&&this.afterTrailingComma(Z))break;else if(this.type===G.ellipsis){var H=this.parseRestBinding();if(this.parseBindingListItem(H),X.push(H),this.type===G.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");this.expect(Z);break}else X.push(this.parseAssignableListItem(J))}return X};K0.parseAssignableListItem=function(Z){var Q=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(Q),Q};K0.parseBindingListItem=function(Z){return Z};K0.parseMaybeDefault=function(Z,Q,Y){if(Y=Y||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(G.eq))return Y;var J=this.startNodeAt(Z,Q);return J.left=Y,J.right=this.parseMaybeAssign(),this.finishNode(J,"AssignmentPattern")};K0.checkLValSimple=function(Z,Q,Y){if(Q===void 0)Q=s0;var J=Q!==s0;switch(Z.type){case"Identifier":if(this.strict&&this.reservedWordsStrictBind.test(Z.name))this.raiseRecoverable(Z.start,(J?"Binding ":"Assigning to ")+Z.name+" in strict mode");if(J){if(Q===I0&&Z.name==="let")this.raiseRecoverable(Z.start,"let is disallowed as a lexically bound name");if(Y){if(b0(Y,Z.name))this.raiseRecoverable(Z.start,"Argument name clash");Y[Z.name]=!0}if(Q!==$8)this.declareName(Z.name,Q,Z.start)}break;case"ChainExpression":this.raiseRecoverable(Z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(J)this.raiseRecoverable(Z.start,"Binding member expression");break;case"ParenthesizedExpression":if(J)this.raiseRecoverable(Z.start,"Binding parenthesized expression");return this.checkLValSimple(Z.expression,Q,Y);default:this.raise(Z.start,(J?"Binding":"Assigning to")+" rvalue")}};K0.checkLValPattern=function(Z,Q,Y){if(Q===void 0)Q=s0;switch(Z.type){case"ObjectPattern":for(var J=0,X=Z.properties;J<X.length;J+=1){var K=X[J];this.checkLValInnerPattern(K,Q,Y)}break;case"ArrayPattern":for(var H=0,W=Z.elements;H<W.length;H+=1){var z=W[H];if(z)this.checkLValInnerPattern(z,Q,Y)}break;default:this.checkLValSimple(Z,Q,Y)}};K0.checkLValInnerPattern=function(Z,Q,Y){if(Q===void 0)Q=s0;switch(Z.type){case"Property":this.checkLValInnerPattern(Z.value,Q,Y);break;case"AssignmentPattern":this.checkLValPattern(Z.left,Q,Y);break;case"RestElement":this.checkLValPattern(Z.argument,Q,Y);break;default:this.checkLValPattern(Z,Q,Y)}};var W0=function(Q,Y,J,X,K){this.token=Q,this.isExpr=!!Y,this.preserveSpace=!!J,this.override=X,this.generator=!!K},u={b_stat:new W0("{",!1),b_expr:new W0("{",!0),b_tmpl:new W0("${",!1),p_stat:new W0("(",!1),p_expr:new W0("(",!0),q_tmpl:new W0("`",!0,!0,function(Z){return Z.tryReadTemplateToken()}),f_stat:new W0("function",!1),f_expr:new W0("function",!0),f_expr_gen:new W0("function",!0,!1,null,!0),f_gen:new W0("function",!1,!1,null,!0)},v0=i.prototype;v0.initialContext=function(){return[u.b_stat]};v0.curContext=function(){return this.context[this.context.length-1]};v0.braceIsBlock=function(Z){var Q=this.curContext();if(Q===u.f_expr||Q===u.f_stat)return!0;if(Z===G.colon&&(Q===u.b_stat||Q===u.b_expr))return!Q.isExpr;if(Z===G._return||Z===G.name&&this.exprAllowed)return e.test(this.input.slice(this.lastTokEnd,this.start));if(Z===G._else||Z===G.semi||Z===G.eof||Z===G.parenR||Z===G.arrow)return!0;if(Z===G.braceL)return Q===u.b_stat;if(Z===G._var||Z===G._const||Z===G.name)return!1;return!this.exprAllowed};v0.inGeneratorContext=function(){for(var Z=this.context.length-1;Z>=1;Z--){var Q=this.context[Z];if(Q.token==="function")return Q.generator}return!1};v0.updateContext=function(Z){var Q,Y=this.type;if(Y.keyword&&Z===G.dot)this.exprAllowed=!1;else if(Q=Y.updateContext)Q.call(this,Z);else this.exprAllowed=Y.beforeExpr};v0.overrideContext=function(Z){if(this.curContext()!==Z)this.context[this.context.length-1]=Z};G.parenR.updateContext=G.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var Z=this.context.pop();if(Z===u.b_stat&&this.curContext().token==="function")Z=this.context.pop();this.exprAllowed=!Z.isExpr};G.braceL.updateContext=function(Z){this.context.push(this.braceIsBlock(Z)?u.b_stat:u.b_expr),this.exprAllowed=!0};G.dollarBraceL.updateContext=function(){this.context.push(u.b_tmpl),this.exprAllowed=!0};G.parenL.updateContext=function(Z){var Q=Z===G._if||Z===G._for||Z===G._with||Z===G._while;this.context.push(Q?u.p_stat:u.p_expr),this.exprAllowed=!0};G.incDec.updateContext=function(){};G._function.updateContext=G._class.updateContext=function(Z){if(Z.beforeExpr&&Z!==G._else&&!(Z===G.semi&&this.curContext()!==u.p_stat)&&!(Z===G._return&&e.test(this.input.slice(this.lastTokEnd,this.start)))&&!((Z===G.colon||Z===G.braceL)&&this.curContext()===u.b_stat))this.context.push(u.f_expr);else this.context.push(u.f_stat);this.exprAllowed=!1};G.colon.updateContext=function(){if(this.curContext().token==="function")this.context.pop();this.exprAllowed=!0};G.backQuote.updateContext=function(){if(this.curContext()===u.q_tmpl)this.context.pop();else this.context.push(u.q_tmpl);this.exprAllowed=!1};G.star.updateContext=function(Z){if(Z===G._function){var Q=this.context.length-1;if(this.context[Q]===u.f_expr)this.context[Q]=u.f_expr_gen;else this.context[Q]=u.f_gen}this.exprAllowed=!0};G.name.updateContext=function(Z){var Q=!1;if(this.options.ecmaVersion>=6&&Z!==G.dot){if(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())Q=!0}this.exprAllowed=Q};var E=i.prototype;E.checkPropClash=function(Z,Q,Y){if(this.options.ecmaVersion>=9&&Z.type==="SpreadElement")return;if(this.options.ecmaVersion>=6&&(Z.computed||Z.method||Z.shorthand))return;var J=Z.key,X;switch(J.type){case"Identifier":X=J.name;break;case"Literal":X=String(J.value);break;default:return}var K=Z.kind;if(this.options.ecmaVersion>=6){if(X==="__proto__"&&K==="init"){if(Q.proto)if(Y){if(Y.doubleProto<0)Y.doubleProto=J.start}else this.raiseRecoverable(J.start,"Redefinition of __proto__ property");Q.proto=!0}return}X="$"+X;var H=Q[X];if(H){var W;if(K==="init")W=this.strict&&H.init||H.get||H.set;else W=H.init||H[K];if(W)this.raiseRecoverable(J.start,"Redefinition of property")}else H=Q[X]={init:!1,get:!1,set:!1};H[K]=!0};E.parseExpression=function(Z,Q){var Y=this.start,J=this.startLoc,X=this.parseMaybeAssign(Z,Q);if(this.type===G.comma){var K=this.startNodeAt(Y,J);K.expressions=[X];while(this.eat(G.comma))K.expressions.push(this.parseMaybeAssign(Z,Q));return this.finishNode(K,"SequenceExpression")}return X};E.parseMaybeAssign=function(Z,Q,Y){if(this.isContextual("yield"))if(this.inGenerator)return this.parseYield(Z);else this.exprAllowed=!1;var J=!1,X=-1,K=-1,H=-1;if(Q)X=Q.parenthesizedAssign,K=Q.trailingComma,H=Q.doubleProto,Q.parenthesizedAssign=Q.trailingComma=-1;else Q=new J1,J=!0;var W=this.start,z=this.startLoc;if(this.type===G.parenL||this.type===G.name)this.potentialArrowAt=this.start,this.potentialArrowInForAwait=Z==="await";var _=this.parseMaybeConditional(Z,Q);if(Y)_=Y.call(this,_,W,z);if(this.type.isAssign){var q=this.startNodeAt(W,z);if(q.operator=this.value,this.type===G.eq)_=this.toAssignable(_,!1,Q);if(!J)Q.parenthesizedAssign=Q.trailingComma=Q.doubleProto=-1;if(Q.shorthandAssign>=_.start)Q.shorthandAssign=-1;if(this.type===G.eq)this.checkLValPattern(_);else this.checkLValSimple(_);if(q.left=_,this.next(),q.right=this.parseMaybeAssign(Z),H>-1)Q.doubleProto=H;return this.finishNode(q,"AssignmentExpression")}else if(J)this.checkExpressionErrors(Q,!0);if(X>-1)Q.parenthesizedAssign=X;if(K>-1)Q.trailingComma=K;return _};E.parseMaybeConditional=function(Z,Q){var Y=this.start,J=this.startLoc,X=this.parseExprOps(Z,Q);if(this.checkExpressionErrors(Q))return X;if(this.eat(G.question)){var K=this.startNodeAt(Y,J);return K.test=X,K.consequent=this.parseMaybeAssign(),this.expect(G.colon),K.alternate=this.parseMaybeAssign(Z),this.finishNode(K,"ConditionalExpression")}return X};E.parseExprOps=function(Z,Q){var Y=this.start,J=this.startLoc,X=this.parseMaybeUnary(Q,!1,!1,Z);if(this.checkExpressionErrors(Q))return X;return X.start===Y&&X.type==="ArrowFunctionExpression"?X:this.parseExprOp(X,Y,J,-1,Z)};E.parseExprOp=function(Z,Q,Y,J,X){var K=this.type.binop;if(K!=null&&(!X||this.type!==G._in)){if(K>J){var H=this.type===G.logicalOR||this.type===G.logicalAND,W=this.type===G.coalesce;if(W)K=G.logicalAND.binop;var z=this.value;this.next();var _=this.start,q=this.startLoc,R=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,X),_,q,K,X),F=this.buildBinary(Q,Y,Z,R,z,H||W);if(H&&this.type===G.coalesce||W&&(this.type===G.logicalOR||this.type===G.logicalAND))this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");return this.parseExprOp(F,Q,Y,J,X)}}return Z};E.buildBinary=function(Z,Q,Y,J,X,K){if(J.type==="PrivateIdentifier")this.raise(J.start,"Private identifier can only be left side of binary expression");var H=this.startNodeAt(Z,Q);return H.left=Y,H.operator=X,H.right=J,this.finishNode(H,K?"LogicalExpression":"BinaryExpression")};E.parseMaybeUnary=function(Z,Q,Y,J){var X=this.start,K=this.startLoc,H;if(this.isContextual("await")&&this.canAwait)H=this.parseAwait(J),Q=!0;else if(this.type.prefix){var W=this.startNode(),z=this.type===G.incDec;if(W.operator=this.value,W.prefix=!0,this.next(),W.argument=this.parseMaybeUnary(null,!0,z,J),this.checkExpressionErrors(Z,!0),z)this.checkLValSimple(W.argument);else if(this.strict&&W.operator==="delete"&&U8(W.argument))this.raiseRecoverable(W.start,"Deleting local variable in strict mode");else if(W.operator==="delete"&&V1(W.argument))this.raiseRecoverable(W.start,"Private fields can not be deleted");else Q=!0;H=this.finishNode(W,z?"UpdateExpression":"UnaryExpression")}else if(!Q&&this.type===G.privateId){if((J||this.privateNameStack.length===0)&&this.options.checkPrivateFields)this.unexpected();if(H=this.parsePrivateIdent(),this.type!==G._in)this.unexpected()}else{if(H=this.parseExprSubscripts(Z,J),this.checkExpressionErrors(Z))return H;while(this.type.postfix&&!this.canInsertSemicolon()){var _=this.startNodeAt(X,K);_.operator=this.value,_.prefix=!1,_.argument=H,this.checkLValSimple(H),this.next(),H=this.finishNode(_,"UpdateExpression")}}if(!Y&&this.eat(G.starstar))if(Q)this.unexpected(this.lastTokStart);else return this.buildBinary(X,K,H,this.parseMaybeUnary(null,!1,!1,J),"**",!1);else return H};function U8(Z){return Z.type==="Identifier"||Z.type==="ParenthesizedExpression"&&U8(Z.expression)}function V1(Z){return Z.type==="MemberExpression"&&Z.property.type==="PrivateIdentifier"||Z.type==="ChainExpression"&&V1(Z.expression)||Z.type==="ParenthesizedExpression"&&V1(Z.expression)}E.parseExprSubscripts=function(Z,Q){var Y=this.start,J=this.startLoc,X=this.parseExprAtom(Z,Q);if(X.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return X;var K=this.parseSubscripts(X,Y,J,!1,Q);if(Z&&K.type==="MemberExpression"){if(Z.parenthesizedAssign>=K.start)Z.parenthesizedAssign=-1;if(Z.parenthesizedBind>=K.start)Z.parenthesizedBind=-1;if(Z.trailingComma>=K.start)Z.trailingComma=-1}return K};E.parseSubscripts=function(Z,Q,Y,J,X){var K=this.options.ecmaVersion>=8&&Z.type==="Identifier"&&Z.name==="async"&&this.lastTokEnd===Z.end&&!this.canInsertSemicolon()&&Z.end-Z.start===5&&this.potentialArrowAt===Z.start,H=!1;while(!0){var W=this.parseSubscript(Z,Q,Y,J,K,H,X);if(W.optional)H=!0;if(W===Z||W.type==="ArrowFunctionExpression"){if(H){var z=this.startNodeAt(Q,Y);z.expression=W,W=this.finishNode(z,"ChainExpression")}return W}Z=W}};E.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(G.arrow)};E.parseSubscriptAsyncArrow=function(Z,Q,Y,J){return this.parseArrowExpression(this.startNodeAt(Z,Q),Y,!0,J)};E.parseSubscript=function(Z,Q,Y,J,X,K,H){var W=this.options.ecmaVersion>=11,z=W&&this.eat(G.questionDot);if(J&&z)this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var _=this.eat(G.bracketL);if(_||z&&this.type!==G.parenL&&this.type!==G.backQuote||this.eat(G.dot)){var q=this.startNodeAt(Q,Y);if(q.object=Z,_)q.property=this.parseExpression(),this.expect(G.bracketR);else if(this.type===G.privateId&&Z.type!=="Super")q.property=this.parsePrivateIdent();else q.property=this.parseIdent(this.options.allowReserved!=="never");if(q.computed=!!_,W)q.optional=z;Z=this.finishNode(q,"MemberExpression")}else if(!J&&this.eat(G.parenL)){var R=new J1,F=this.yieldPos,U=this.awaitPos,O=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var L=this.parseExprList(G.parenR,this.options.ecmaVersion>=8,!1,R);if(X&&!z&&this.shouldParseAsyncArrow()){if(this.checkPatternErrors(R,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0)this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function");return this.yieldPos=F,this.awaitPos=U,this.awaitIdentPos=O,this.parseSubscriptAsyncArrow(Q,Y,L,H)}this.checkExpressionErrors(R,!0),this.yieldPos=F||this.yieldPos,this.awaitPos=U||this.awaitPos,this.awaitIdentPos=O||this.awaitIdentPos;var B=this.startNodeAt(Q,Y);if(B.callee=Z,B.arguments=L,W)B.optional=z;Z=this.finishNode(B,"CallExpression")}else if(this.type===G.backQuote){if(z||K)this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var N=this.startNodeAt(Q,Y);N.tag=Z,N.quasi=this.parseTemplate({isTagged:!0}),Z=this.finishNode(N,"TaggedTemplateExpression")}return Z};E.parseExprAtom=function(Z,Q,Y){if(this.type===G.slash)this.readRegexp();var J,X=this.potentialArrowAt===this.start;switch(this.type){case G._super:if(!this.allowSuper)this.raise(this.start,"'super' keyword outside a method");if(J=this.startNode(),this.next(),this.type===G.parenL&&!this.allowDirectSuper)this.raise(J.start,"super() call outside constructor of a subclass");if(this.type!==G.dot&&this.type!==G.bracketL&&this.type!==G.parenL)this.unexpected();return this.finishNode(J,"Super");case G._this:return J=this.startNode(),this.next(),this.finishNode(J,"ThisExpression");case G.name:var K=this.start,H=this.startLoc,W=this.containsEsc,z=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!W&&z.name==="async"&&!this.canInsertSemicolon()&&this.eat(G._function))return this.overrideContext(u.f_expr),this.parseFunction(this.startNodeAt(K,H),0,!1,!0,Q);if(X&&!this.canInsertSemicolon()){if(this.eat(G.arrow))return this.parseArrowExpression(this.startNodeAt(K,H),[z],!1,Q);if(this.options.ecmaVersion>=8&&z.name==="async"&&this.type===G.name&&!W&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc)){if(z=this.parseIdent(!1),this.canInsertSemicolon()||!this.eat(G.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAt(K,H),[z],!0,Q)}}return z;case G.regexp:var _=this.value;return J=this.parseLiteral(_.value),J.regex={pattern:_.pattern,flags:_.flags},J;case G.num:case G.string:return this.parseLiteral(this.value);case G._null:case G._true:case G._false:return J=this.startNode(),J.value=this.type===G._null?null:this.type===G._true,J.raw=this.type.keyword,this.next(),this.finishNode(J,"Literal");case G.parenL:var q=this.start,R=this.parseParenAndDistinguishExpression(X,Q);if(Z){if(Z.parenthesizedAssign<0&&!this.isSimpleAssignTarget(R))Z.parenthesizedAssign=q;if(Z.parenthesizedBind<0)Z.parenthesizedBind=q}return R;case G.bracketL:return J=this.startNode(),this.next(),J.elements=this.parseExprList(G.bracketR,!0,!0,Z),this.finishNode(J,"ArrayExpression");case G.braceL:return this.overrideContext(u.b_expr),this.parseObj(!1,Z);case G._function:return J=this.startNode(),this.next(),this.parseFunction(J,0);case G._class:return this.parseClass(this.startNode(),!1);case G._new:return this.parseNew();case G.backQuote:return this.parseTemplate();case G._import:if(this.options.ecmaVersion>=11)return this.parseExprImport(Y);else return this.unexpected();default:return this.parseExprAtomDefault()}};E.parseExprAtomDefault=function(){this.unexpected()};E.parseExprImport=function(Z){var Q=this.startNode();if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword import");if(this.next(),this.type===G.parenL&&!Z)return this.parseDynamicImport(Q);else if(this.type===G.dot){var Y=this.startNodeAt(Q.start,Q.loc&&Q.loc.start);return Y.name="import",Q.meta=this.finishNode(Y,"Identifier"),this.parseImportMeta(Q)}else this.unexpected()};E.parseDynamicImport=function(Z){if(this.next(),Z.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)if(!this.eat(G.parenR))if(this.expect(G.comma),!this.afterTrailingComma(G.parenR)){if(Z.options=this.parseMaybeAssign(),!this.eat(G.parenR)){if(this.expect(G.comma),!this.afterTrailingComma(G.parenR))this.unexpected()}}else Z.options=null;else Z.options=null;else if(!this.eat(G.parenR)){var Q=this.start;if(this.eat(G.comma)&&this.eat(G.parenR))this.raiseRecoverable(Q,"Trailing comma is not allowed in import()");else this.unexpected(Q)}return this.finishNode(Z,"ImportExpression")};E.parseImportMeta=function(Z){this.next();var Q=this.containsEsc;if(Z.property=this.parseIdent(!0),Z.property.name!=="meta")this.raiseRecoverable(Z.property.start,"The only valid meta property for import is 'import.meta'");if(Q)this.raiseRecoverable(Z.start,"'import.meta' must not contain escaped characters");if(this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere)this.raiseRecoverable(Z.start,"Cannot use 'import.meta' outside a module");return this.finishNode(Z,"MetaProperty")};E.parseLiteral=function(Z){var Q=this.startNode();if(Q.value=Z,Q.raw=this.input.slice(this.start,this.end),Q.raw.charCodeAt(Q.raw.length-1)===110)Q.bigint=Q.value!=null?Q.value.toString():Q.raw.slice(0,-1).replace(/_/g,"");return this.next(),this.finishNode(Q,"Literal")};E.parseParenExpression=function(){this.expect(G.parenL);var Z=this.parseExpression();return this.expect(G.parenR),Z};E.shouldParseArrow=function(Z){return!this.canInsertSemicolon()};E.parseParenAndDistinguishExpression=function(Z,Q){var Y=this.start,J=this.startLoc,X,K=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var H=this.start,W=this.startLoc,z=[],_=!0,q=!1,R=new J1,F=this.yieldPos,U=this.awaitPos,O;this.yieldPos=0,this.awaitPos=0;while(this.type!==G.parenR)if(_?_=!1:this.expect(G.comma),K&&this.afterTrailingComma(G.parenR,!0)){q=!0;break}else if(this.type===G.ellipsis){if(O=this.start,z.push(this.parseParenItem(this.parseRestBinding())),this.type===G.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else z.push(this.parseMaybeAssign(!1,R,this.parseParenItem));var L=this.lastTokEnd,B=this.lastTokEndLoc;if(this.expect(G.parenR),Z&&this.shouldParseArrow(z)&&this.eat(G.arrow))return this.checkPatternErrors(R,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=F,this.awaitPos=U,this.parseParenArrowList(Y,J,z,Q);if(!z.length||q)this.unexpected(this.lastTokStart);if(O)this.unexpected(O);if(this.checkExpressionErrors(R,!0),this.yieldPos=F||this.yieldPos,this.awaitPos=U||this.awaitPos,z.length>1)X=this.startNodeAt(H,W),X.expressions=z,this.finishNodeAt(X,"SequenceExpression",L,B);else X=z[0]}else X=this.parseParenExpression();if(this.options.preserveParens){var N=this.startNodeAt(Y,J);return N.expression=X,this.finishNode(N,"ParenthesizedExpression")}else return X};E.parseParenItem=function(Z){return Z};E.parseParenArrowList=function(Z,Q,Y,J){return this.parseArrowExpression(this.startNodeAt(Z,Q),Y,!1,J)};var J6=[];E.parseNew=function(){if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword new");var Z=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===G.dot){var Q=this.startNodeAt(Z.start,Z.loc&&Z.loc.start);Q.name="new",Z.meta=this.finishNode(Q,"Identifier"),this.next();var Y=this.containsEsc;if(Z.property=this.parseIdent(!0),Z.property.name!=="target")this.raiseRecoverable(Z.property.start,"The only valid meta property for new is 'new.target'");if(Y)this.raiseRecoverable(Z.start,"'new.target' must not contain escaped characters");if(!this.allowNewDotTarget)this.raiseRecoverable(Z.start,"'new.target' can only be used in functions and class static block");return this.finishNode(Z,"MetaProperty")}var J=this.start,X=this.startLoc;if(Z.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),J,X,!0,!1),this.eat(G.parenL))Z.arguments=this.parseExprList(G.parenR,this.options.ecmaVersion>=8,!1);else Z.arguments=J6;return this.finishNode(Z,"NewExpression")};E.parseTemplateElement=function(Z){var Q=Z.isTagged,Y=this.startNode();if(this.type===G.invalidTemplate){if(!Q)this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal");Y.value={raw:this.value.replace(/\r\n?/g,`
5
- `),cooked:null}}else Y.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
6
- `),cooked:this.value};return this.next(),Y.tail=this.type===G.backQuote,this.finishNode(Y,"TemplateElement")};E.parseTemplate=function(Z){if(Z===void 0)Z={};var Q=Z.isTagged;if(Q===void 0)Q=!1;var Y=this.startNode();this.next(),Y.expressions=[];var J=this.parseTemplateElement({isTagged:Q});Y.quasis=[J];while(!J.tail){if(this.type===G.eof)this.raise(this.pos,"Unterminated template literal");this.expect(G.dollarBraceL),Y.expressions.push(this.parseExpression()),this.expect(G.braceR),Y.quasis.push(J=this.parseTemplateElement({isTagged:Q}))}return this.next(),this.finishNode(Y,"TemplateLiteral")};E.isAsyncProp=function(Z){return!Z.computed&&Z.key.type==="Identifier"&&Z.key.name==="async"&&(this.type===G.name||this.type===G.num||this.type===G.string||this.type===G.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===G.star)&&!e.test(this.input.slice(this.lastTokEnd,this.start))};E.parseObj=function(Z,Q){var Y=this.startNode(),J=!0,X={};Y.properties=[],this.next();while(!this.eat(G.braceR)){if(!J){if(this.expect(G.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(G.braceR))break}else J=!1;var K=this.parseProperty(Z,Q);if(!Z)this.checkPropClash(K,X,Q);Y.properties.push(K)}return this.finishNode(Y,Z?"ObjectPattern":"ObjectExpression")};E.parseProperty=function(Z,Q){var Y=this.startNode(),J,X,K,H;if(this.options.ecmaVersion>=9&&this.eat(G.ellipsis)){if(Z){if(Y.argument=this.parseIdent(!1),this.type===G.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");return this.finishNode(Y,"RestElement")}if(Y.argument=this.parseMaybeAssign(!1,Q),this.type===G.comma&&Q&&Q.trailingComma<0)Q.trailingComma=this.start;return this.finishNode(Y,"SpreadElement")}if(this.options.ecmaVersion>=6){if(Y.method=!1,Y.shorthand=!1,Z||Q)K=this.start,H=this.startLoc;if(!Z)J=this.eat(G.star)}var W=this.containsEsc;if(this.parsePropertyName(Y),!Z&&!W&&this.options.ecmaVersion>=8&&!J&&this.isAsyncProp(Y))X=!0,J=this.options.ecmaVersion>=9&&this.eat(G.star),this.parsePropertyName(Y);else X=!1;return this.parsePropertyValue(Y,Z,J,X,K,H,Q,W),this.finishNode(Y,"Property")};E.parseGetterSetter=function(Z){var Q=Z.key.name;this.parsePropertyName(Z),Z.value=this.parseMethod(!1),Z.kind=Q;var Y=Z.kind==="get"?0:1;if(Z.value.params.length!==Y){var J=Z.value.start;if(Z.kind==="get")this.raiseRecoverable(J,"getter should have no params");else this.raiseRecoverable(J,"setter should have exactly one param")}else if(Z.kind==="set"&&Z.value.params[0].type==="RestElement")this.raiseRecoverable(Z.value.params[0].start,"Setter cannot use rest params")};E.parsePropertyValue=function(Z,Q,Y,J,X,K,H,W){if((Y||J)&&this.type===G.colon)this.unexpected();if(this.eat(G.colon))Z.value=Q?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,H),Z.kind="init";else if(this.options.ecmaVersion>=6&&this.type===G.parenL){if(Q)this.unexpected();Z.method=!0,Z.value=this.parseMethod(Y,J),Z.kind="init"}else if(!Q&&!W&&this.options.ecmaVersion>=5&&!Z.computed&&Z.key.type==="Identifier"&&(Z.key.name==="get"||Z.key.name==="set")&&(this.type!==G.comma&&this.type!==G.braceR&&this.type!==G.eq)){if(Y||J)this.unexpected();this.parseGetterSetter(Z)}else if(this.options.ecmaVersion>=6&&!Z.computed&&Z.key.type==="Identifier"){if(Y||J)this.unexpected();if(this.checkUnreserved(Z.key),Z.key.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=X;if(Q)Z.value=this.parseMaybeDefault(X,K,this.copyNode(Z.key));else if(this.type===G.eq&&H){if(H.shorthandAssign<0)H.shorthandAssign=this.start;Z.value=this.parseMaybeDefault(X,K,this.copyNode(Z.key))}else Z.value=this.copyNode(Z.key);Z.kind="init",Z.shorthand=!0}else this.unexpected()};E.parsePropertyName=function(Z){if(this.options.ecmaVersion>=6)if(this.eat(G.bracketL))return Z.computed=!0,Z.key=this.parseMaybeAssign(),this.expect(G.bracketR),Z.key;else Z.computed=!1;return Z.key=this.type===G.num||this.type===G.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};E.initFunction=function(Z){if(Z.id=null,this.options.ecmaVersion>=6)Z.generator=Z.expression=!1;if(this.options.ecmaVersion>=8)Z.async=!1};E.parseMethod=function(Z,Q,Y){var J=this.startNode(),X=this.yieldPos,K=this.awaitPos,H=this.awaitIdentPos;if(this.initFunction(J),this.options.ecmaVersion>=6)J.generator=Z;if(this.options.ecmaVersion>=8)J.async=!!Q;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(S1(Q,J.generator)|Q1|(Y?_8:0)),this.expect(G.parenL),J.params=this.parseBindingList(G.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(J,!1,!0,!1),this.yieldPos=X,this.awaitPos=K,this.awaitIdentPos=H,this.finishNode(J,"FunctionExpression")};E.parseArrowExpression=function(Z,Q,Y,J){var X=this.yieldPos,K=this.awaitPos,H=this.awaitIdentPos;if(this.enterScope(S1(Y,!1)|P1),this.initFunction(Z),this.options.ecmaVersion>=8)Z.async=!!Y;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,Z.params=this.toAssignableList(Q,!0),this.parseFunctionBody(Z,!0,!1,J),this.yieldPos=X,this.awaitPos=K,this.awaitIdentPos=H,this.finishNode(Z,"ArrowFunctionExpression")};E.parseFunctionBody=function(Z,Q,Y,J){var X=Q&&this.type!==G.braceL,K=this.strict,H=!1;if(X)Z.body=this.parseMaybeAssign(J),Z.expression=!0,this.checkParams(Z,!1);else{var W=this.options.ecmaVersion>=7&&!this.isSimpleParamList(Z.params);if(!K||W){if(H=this.strictDirective(this.end),H&&W)this.raiseRecoverable(Z.start,"Illegal 'use strict' directive in function with non-simple parameter list")}var z=this.labels;if(this.labels=[],H)this.strict=!0;if(this.checkParams(Z,!K&&!H&&!Q&&!Y&&this.isSimpleParamList(Z.params)),this.strict&&Z.id)this.checkLValSimple(Z.id,$8);Z.body=this.parseBlock(!1,void 0,H&&!K),Z.expression=!1,this.adaptDirectivePrologue(Z.body.body),this.labels=z}this.exitScope()};E.isSimpleParamList=function(Z){for(var Q=0,Y=Z;Q<Y.length;Q+=1){var J=Y[Q];if(J.type!=="Identifier")return!1}return!0};E.checkParams=function(Z,Q){var Y=Object.create(null);for(var J=0,X=Z.params;J<X.length;J+=1){var K=X[J];this.checkLValInnerPattern(K,b1,Q?null:Y)}};E.parseExprList=function(Z,Q,Y,J){var X=[],K=!0;while(!this.eat(Z)){if(!K){if(this.expect(G.comma),Q&&this.afterTrailingComma(Z))break}else K=!1;var H=void 0;if(Y&&this.type===G.comma)H=null;else if(this.type===G.ellipsis){if(H=this.parseSpread(J),J&&this.type===G.comma&&J.trailingComma<0)J.trailingComma=this.start}else H=this.parseMaybeAssign(!1,J);X.push(H)}return X};E.checkUnreserved=function(Z){var{start:Q,end:Y,name:J}=Z;if(this.inGenerator&&J==="yield")this.raiseRecoverable(Q,"Cannot use 'yield' as identifier inside a generator");if(this.inAsync&&J==="await")this.raiseRecoverable(Q,"Cannot use 'await' as identifier inside an async function");if(!(this.currentThisScope().flags&Y1)&&J==="arguments")this.raiseRecoverable(Q,"Cannot use 'arguments' in class field initializer");if(this.inClassStaticBlock&&(J==="arguments"||J==="await"))this.raise(Q,"Cannot use "+J+" in class static initialization block");if(this.keywords.test(J))this.raise(Q,"Unexpected keyword '"+J+"'");if(this.options.ecmaVersion<6&&this.input.slice(Q,Y).indexOf("\\")!==-1)return;var X=this.strict?this.reservedWordsStrict:this.reservedWords;if(X.test(J)){if(!this.inAsync&&J==="await")this.raiseRecoverable(Q,"Cannot use keyword 'await' outside an async function");this.raiseRecoverable(Q,"The keyword '"+J+"' is reserved")}};E.parseIdent=function(Z){var Q=this.parseIdentNode();if(this.next(!!Z),this.finishNode(Q,"Identifier"),!Z){if(this.checkUnreserved(Q),Q.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=Q.start}return Q};E.parseIdentNode=function(){var Z=this.startNode();if(this.type===G.name)Z.name=this.value;else if(this.type.keyword){if(Z.name=this.type.keyword,(Z.name==="class"||Z.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46))this.context.pop();this.type=G.name}else this.unexpected();return Z};E.parsePrivateIdent=function(){var Z=this.startNode();if(this.type===G.privateId)Z.name=this.value;else this.unexpected();if(this.next(),this.finishNode(Z,"PrivateIdentifier"),this.options.checkPrivateFields)if(this.privateNameStack.length===0)this.raise(Z.start,"Private field '#"+Z.name+"' must be declared in an enclosing class");else this.privateNameStack[this.privateNameStack.length-1].used.push(Z);return Z};E.parseYield=function(Z){if(!this.yieldPos)this.yieldPos=this.start;var Q=this.startNode();if(this.next(),this.type===G.semi||this.canInsertSemicolon()||this.type!==G.star&&!this.type.startsExpr)Q.delegate=!1,Q.argument=null;else Q.delegate=this.eat(G.star),Q.argument=this.parseMaybeAssign(Z);return this.finishNode(Q,"YieldExpression")};E.parseAwait=function(Z){if(!this.awaitPos)this.awaitPos=this.start;var Q=this.startNode();return this.next(),Q.argument=this.parseMaybeUnary(null,!0,!1,Z),this.finishNode(Q,"AwaitExpression")};var t0=i.prototype;t0.raise=function(Z,Q){var Y=W8(this.input,Z);if(Q+=" ("+Y.line+":"+Y.column+")",this.sourceFile)Q+=" in "+this.sourceFile;var J=SyntaxError(Q);throw J.pos=Z,J.loc=Y,J.raisedAt=this.pos,J};t0.raiseRecoverable=t0.raise;t0.curPosition=function(){if(this.options.locations)return new y0(this.curLine,this.pos-this.lineStart)};var w0=i.prototype,X6=function(Q){this.flags=Q,this.var=[],this.lexical=[],this.functions=[]};w0.enterScope=function(Z){this.scopeStack.push(new X6(Z))};w0.exitScope=function(){this.scopeStack.pop()};w0.treatFunctionsAsVarInScope=function(Z){return Z.flags&E0||!this.inModule&&Z.flags&f0};w0.declareName=function(Z,Q,Y){var J=!1;if(Q===I0){var X=this.currentScope();if(J=X.lexical.indexOf(Z)>-1||X.functions.indexOf(Z)>-1||X.var.indexOf(Z)>-1,X.lexical.push(Z),this.inModule&&X.flags&f0)delete this.undefinedExports[Z]}else if(Q===F8){var K=this.currentScope();K.lexical.push(Z)}else if(Q===q8){var H=this.currentScope();if(this.treatFunctionsAsVar)J=H.lexical.indexOf(Z)>-1;else J=H.lexical.indexOf(Z)>-1||H.var.indexOf(Z)>-1;H.functions.push(Z)}else for(var W=this.scopeStack.length-1;W>=0;--W){var z=this.scopeStack[W];if(z.lexical.indexOf(Z)>-1&&!(z.flags&G8&&z.lexical[0]===Z)||!this.treatFunctionsAsVarInScope(z)&&z.functions.indexOf(Z)>-1){J=!0;break}if(z.var.push(Z),this.inModule&&z.flags&f0)delete this.undefinedExports[Z];if(z.flags&Y1)break}if(J)this.raiseRecoverable(Y,"Identifier '"+Z+"' has already been declared")};w0.checkLocalExport=function(Z){if(this.scopeStack[0].lexical.indexOf(Z.name)===-1&&this.scopeStack[0].var.indexOf(Z.name)===-1)this.undefinedExports[Z.name]=Z};w0.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};w0.currentVarScope=function(){for(var Z=this.scopeStack.length-1;;Z--){var Q=this.scopeStack[Z];if(Q.flags&(Y1|h0|D0))return Q}};w0.currentThisScope=function(){for(var Z=this.scopeStack.length-1;;Z--){var Q=this.scopeStack[Z];if(Q.flags&(Y1|h0|D0)&&!(Q.flags&P1))return Q}};var X1=function(Q,Y,J){if(this.type="",this.start=Y,this.end=0,Q.options.locations)this.loc=new Z1(Q,J);if(Q.options.directSourceFile)this.sourceFile=Q.options.directSourceFile;if(Q.options.ranges)this.range=[Y,0]},x0=i.prototype;x0.startNode=function(){return new X1(this,this.start,this.startLoc)};x0.startNodeAt=function(Z,Q){return new X1(this,Z,Q)};function O8(Z,Q,Y,J){if(Z.type=Q,Z.end=Y,this.options.locations)Z.loc.end=J;if(this.options.ranges)Z.range[1]=Y;return Z}x0.finishNode=function(Z,Q){return O8.call(this,Z,Q,this.lastTokEnd,this.lastTokEndLoc)};x0.finishNodeAt=function(Z,Q,Y,J){return O8.call(this,Z,Q,Y,J)};x0.copyNode=function(Z){var Q=new X1(this,Z.start,this.startLoc);for(var Y in Z)Q[Y]=Z[Y];return Q};var K6="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",I8="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",B8=I8+" Extended_Pictographic",M8=B8,L8=M8+" EBase EComp EMod EPres ExtPict",N8=L8,H6=N8,W6={9:I8,10:B8,11:M8,12:L8,13:N8,14:H6},z6="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",G6={9:"",10:"",11:"",12:"",13:"",14:z6},Q8="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",j8="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",w8=j8+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",A8=w8+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",V8=A8+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",D8=V8+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",_6=D8+" "+K6,q6={9:j8,10:w8,11:A8,12:V8,13:D8,14:_6},T8={};function F6(Z){var Q=T8[Z]={binary:N0(W6[Z]+" "+Q8),binaryOfStrings:N0(G6[Z]),nonBinary:{General_Category:N0(Q8),Script:N0(q6[Z])}};Q.nonBinary.Script_Extensions=Q.nonBinary.Script,Q.nonBinary.gc=Q.nonBinary.General_Category,Q.nonBinary.sc=Q.nonBinary.Script,Q.nonBinary.scx=Q.nonBinary.Script_Extensions}for(k0=0,a0=[9,10,11,12,13,14];k0<a0.length;k0+=1)D1=a0[k0],F6(D1);var D1,k0,a0,V=i.prototype,e0=function(Q,Y){this.parent=Q,this.base=Y||this};e0.prototype.separatedFrom=function(Q){for(var Y=this;Y;Y=Y.parent)for(var J=Q;J;J=J.parent)if(Y.base===J.base&&Y!==J)return!0;return!1};e0.prototype.sibling=function(){return new e0(this.parent,this.base)};var q0=function(Q){this.parser=Q,this.validFlags="gim"+(Q.options.ecmaVersion>=6?"uy":"")+(Q.options.ecmaVersion>=9?"s":"")+(Q.options.ecmaVersion>=13?"d":"")+(Q.options.ecmaVersion>=15?"v":""),this.unicodeProperties=T8[Q.options.ecmaVersion>=14?14:Q.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};q0.prototype.reset=function(Q,Y,J){var X=J.indexOf("v")!==-1,K=J.indexOf("u")!==-1;if(this.start=Q|0,this.source=Y+"",this.flags=J,X&&this.parser.options.ecmaVersion>=15)this.switchU=!0,this.switchV=!0,this.switchN=!0;else this.switchU=K&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=K&&this.parser.options.ecmaVersion>=9};q0.prototype.raise=function(Q){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+Q)};q0.prototype.at=function(Q,Y){if(Y===void 0)Y=!1;var J=this.source,X=J.length;if(Q>=X)return-1;var K=J.charCodeAt(Q);if(!(Y||this.switchU)||K<=55295||K>=57344||Q+1>=X)return K;var H=J.charCodeAt(Q+1);return H>=56320&&H<=57343?(K<<10)+H-56613888:K};q0.prototype.nextIndex=function(Q,Y){if(Y===void 0)Y=!1;var J=this.source,X=J.length;if(Q>=X)return X;var K=J.charCodeAt(Q),H;if(!(Y||this.switchU)||K<=55295||K>=57344||Q+1>=X||(H=J.charCodeAt(Q+1))<56320||H>57343)return Q+1;return Q+2};q0.prototype.current=function(Q){if(Q===void 0)Q=!1;return this.at(this.pos,Q)};q0.prototype.lookahead=function(Q){if(Q===void 0)Q=!1;return this.at(this.nextIndex(this.pos,Q),Q)};q0.prototype.advance=function(Q){if(Q===void 0)Q=!1;this.pos=this.nextIndex(this.pos,Q)};q0.prototype.eat=function(Q,Y){if(Y===void 0)Y=!1;if(this.current(Y)===Q)return this.advance(Y),!0;return!1};q0.prototype.eatChars=function(Q,Y){if(Y===void 0)Y=!1;var J=this.pos;for(var X=0,K=Q;X<K.length;X+=1){var H=K[X],W=this.at(J,Y);if(W===-1||W!==H)return!1;J=this.nextIndex(J,Y)}return this.pos=J,!0};V.validateRegExpFlags=function(Z){var{validFlags:Q,flags:Y}=Z,J=!1,X=!1;for(var K=0;K<Y.length;K++){var H=Y.charAt(K);if(Q.indexOf(H)===-1)this.raise(Z.start,"Invalid regular expression flag");if(Y.indexOf(H,K+1)>-1)this.raise(Z.start,"Duplicate regular expression flag");if(H==="u")J=!0;if(H==="v")X=!0}if(this.options.ecmaVersion>=15&&J&&X)this.raise(Z.start,"Invalid regular expression flag")};function $6(Z){for(var Q in Z)return!0;return!1}V.validateRegExpPattern=function(Z){if(this.regexp_pattern(Z),!Z.switchN&&this.options.ecmaVersion>=9&&$6(Z.groupNames))Z.switchN=!0,this.regexp_pattern(Z)};V.regexp_pattern=function(Z){if(Z.pos=0,Z.lastIntValue=0,Z.lastStringValue="",Z.lastAssertionIsQuantifiable=!1,Z.numCapturingParens=0,Z.maxBackReference=0,Z.groupNames=Object.create(null),Z.backReferenceNames.length=0,Z.branchID=null,this.regexp_disjunction(Z),Z.pos!==Z.source.length){if(Z.eat(41))Z.raise("Unmatched ')'");if(Z.eat(93)||Z.eat(125))Z.raise("Lone quantifier brackets")}if(Z.maxBackReference>Z.numCapturingParens)Z.raise("Invalid escape");for(var Q=0,Y=Z.backReferenceNames;Q<Y.length;Q+=1){var J=Y[Q];if(!Z.groupNames[J])Z.raise("Invalid named capture referenced")}};V.regexp_disjunction=function(Z){var Q=this.options.ecmaVersion>=16;if(Q)Z.branchID=new e0(Z.branchID,null);this.regexp_alternative(Z);while(Z.eat(124)){if(Q)Z.branchID=Z.branchID.sibling();this.regexp_alternative(Z)}if(Q)Z.branchID=Z.branchID.parent;if(this.regexp_eatQuantifier(Z,!0))Z.raise("Nothing to repeat");if(Z.eat(123))Z.raise("Lone quantifier brackets")};V.regexp_alternative=function(Z){while(Z.pos<Z.source.length&&this.regexp_eatTerm(Z));};V.regexp_eatTerm=function(Z){if(this.regexp_eatAssertion(Z)){if(Z.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(Z)){if(Z.switchU)Z.raise("Invalid quantifier")}return!0}if(Z.switchU?this.regexp_eatAtom(Z):this.regexp_eatExtendedAtom(Z))return this.regexp_eatQuantifier(Z),!0;return!1};V.regexp_eatAssertion=function(Z){var Q=Z.pos;if(Z.lastAssertionIsQuantifiable=!1,Z.eat(94)||Z.eat(36))return!0;if(Z.eat(92)){if(Z.eat(66)||Z.eat(98))return!0;Z.pos=Q}if(Z.eat(40)&&Z.eat(63)){var Y=!1;if(this.options.ecmaVersion>=9)Y=Z.eat(60);if(Z.eat(61)||Z.eat(33)){if(this.regexp_disjunction(Z),!Z.eat(41))Z.raise("Unterminated group");return Z.lastAssertionIsQuantifiable=!Y,!0}}return Z.pos=Q,!1};V.regexp_eatQuantifier=function(Z,Q){if(Q===void 0)Q=!1;if(this.regexp_eatQuantifierPrefix(Z,Q))return Z.eat(63),!0;return!1};V.regexp_eatQuantifierPrefix=function(Z,Q){return Z.eat(42)||Z.eat(43)||Z.eat(63)||this.regexp_eatBracedQuantifier(Z,Q)};V.regexp_eatBracedQuantifier=function(Z,Q){var Y=Z.pos;if(Z.eat(123)){var J=0,X=-1;if(this.regexp_eatDecimalDigits(Z)){if(J=Z.lastIntValue,Z.eat(44)&&this.regexp_eatDecimalDigits(Z))X=Z.lastIntValue;if(Z.eat(125)){if(X!==-1&&X<J&&!Q)Z.raise("numbers out of order in {} quantifier");return!0}}if(Z.switchU&&!Q)Z.raise("Incomplete quantifier");Z.pos=Y}return!1};V.regexp_eatAtom=function(Z){return this.regexp_eatPatternCharacters(Z)||Z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(Z)||this.regexp_eatCharacterClass(Z)||this.regexp_eatUncapturingGroup(Z)||this.regexp_eatCapturingGroup(Z)};V.regexp_eatReverseSolidusAtomEscape=function(Z){var Q=Z.pos;if(Z.eat(92)){if(this.regexp_eatAtomEscape(Z))return!0;Z.pos=Q}return!1};V.regexp_eatUncapturingGroup=function(Z){var Q=Z.pos;if(Z.eat(40)){if(Z.eat(63)){if(this.options.ecmaVersion>=16){var Y=this.regexp_eatModifiers(Z),J=Z.eat(45);if(Y||J){for(var X=0;X<Y.length;X++){var K=Y.charAt(X);if(Y.indexOf(K,X+1)>-1)Z.raise("Duplicate regular expression modifiers")}if(J){var H=this.regexp_eatModifiers(Z);if(!Y&&!H&&Z.current()===58)Z.raise("Invalid regular expression modifiers");for(var W=0;W<H.length;W++){var z=H.charAt(W);if(H.indexOf(z,W+1)>-1||Y.indexOf(z)>-1)Z.raise("Duplicate regular expression modifiers")}}}}if(Z.eat(58)){if(this.regexp_disjunction(Z),Z.eat(41))return!0;Z.raise("Unterminated group")}}Z.pos=Q}return!1};V.regexp_eatCapturingGroup=function(Z){if(Z.eat(40)){if(this.options.ecmaVersion>=9)this.regexp_groupSpecifier(Z);else if(Z.current()===63)Z.raise("Invalid group");if(this.regexp_disjunction(Z),Z.eat(41))return Z.numCapturingParens+=1,!0;Z.raise("Unterminated group")}return!1};V.regexp_eatModifiers=function(Z){var Q="",Y=0;while((Y=Z.current())!==-1&&R6(Y))Q+=U0(Y),Z.advance();return Q};function R6(Z){return Z===105||Z===109||Z===115}V.regexp_eatExtendedAtom=function(Z){return Z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(Z)||this.regexp_eatCharacterClass(Z)||this.regexp_eatUncapturingGroup(Z)||this.regexp_eatCapturingGroup(Z)||this.regexp_eatInvalidBracedQuantifier(Z)||this.regexp_eatExtendedPatternCharacter(Z)};V.regexp_eatInvalidBracedQuantifier=function(Z){if(this.regexp_eatBracedQuantifier(Z,!0))Z.raise("Nothing to repeat");return!1};V.regexp_eatSyntaxCharacter=function(Z){var Q=Z.current();if(C8(Q))return Z.lastIntValue=Q,Z.advance(),!0;return!1};function C8(Z){return Z===36||Z>=40&&Z<=43||Z===46||Z===63||Z>=91&&Z<=94||Z>=123&&Z<=125}V.regexp_eatPatternCharacters=function(Z){var Q=Z.pos,Y=0;while((Y=Z.current())!==-1&&!C8(Y))Z.advance();return Z.pos!==Q};V.regexp_eatExtendedPatternCharacter=function(Z){var Q=Z.current();if(Q!==-1&&Q!==36&&!(Q>=40&&Q<=43)&&Q!==46&&Q!==63&&Q!==91&&Q!==94&&Q!==124)return Z.advance(),!0;return!1};V.regexp_groupSpecifier=function(Z){if(Z.eat(63)){if(!this.regexp_eatGroupName(Z))Z.raise("Invalid group");var Q=this.options.ecmaVersion>=16,Y=Z.groupNames[Z.lastStringValue];if(Y)if(Q)for(var J=0,X=Y;J<X.length;J+=1){var K=X[J];if(!K.separatedFrom(Z.branchID))Z.raise("Duplicate capture group name")}else Z.raise("Duplicate capture group name");if(Q)(Y||(Z.groupNames[Z.lastStringValue]=[])).push(Z.branchID);else Z.groupNames[Z.lastStringValue]=!0}};V.regexp_eatGroupName=function(Z){if(Z.lastStringValue="",Z.eat(60)){if(this.regexp_eatRegExpIdentifierName(Z)&&Z.eat(62))return!0;Z.raise("Invalid capture group name")}return!1};V.regexp_eatRegExpIdentifierName=function(Z){if(Z.lastStringValue="",this.regexp_eatRegExpIdentifierStart(Z)){Z.lastStringValue+=U0(Z.lastIntValue);while(this.regexp_eatRegExpIdentifierPart(Z))Z.lastStringValue+=U0(Z.lastIntValue);return!0}return!1};V.regexp_eatRegExpIdentifierStart=function(Z){var Q=Z.pos,Y=this.options.ecmaVersion>=11,J=Z.current(Y);if(Z.advance(Y),J===92&&this.regexp_eatRegExpUnicodeEscapeSequence(Z,Y))J=Z.lastIntValue;if(U6(J))return Z.lastIntValue=J,!0;return Z.pos=Q,!1};function U6(Z){return G0(Z,!0)||Z===36||Z===95}V.regexp_eatRegExpIdentifierPart=function(Z){var Q=Z.pos,Y=this.options.ecmaVersion>=11,J=Z.current(Y);if(Z.advance(Y),J===92&&this.regexp_eatRegExpUnicodeEscapeSequence(Z,Y))J=Z.lastIntValue;if(O6(J))return Z.lastIntValue=J,!0;return Z.pos=Q,!1};function O6(Z){return j0(Z,!0)||Z===36||Z===95||Z===8204||Z===8205}V.regexp_eatAtomEscape=function(Z){if(this.regexp_eatBackReference(Z)||this.regexp_eatCharacterClassEscape(Z)||this.regexp_eatCharacterEscape(Z)||Z.switchN&&this.regexp_eatKGroupName(Z))return!0;if(Z.switchU){if(Z.current()===99)Z.raise("Invalid unicode escape");Z.raise("Invalid escape")}return!1};V.regexp_eatBackReference=function(Z){var Q=Z.pos;if(this.regexp_eatDecimalEscape(Z)){var Y=Z.lastIntValue;if(Z.switchU){if(Y>Z.maxBackReference)Z.maxBackReference=Y;return!0}if(Y<=Z.numCapturingParens)return!0;Z.pos=Q}return!1};V.regexp_eatKGroupName=function(Z){if(Z.eat(107)){if(this.regexp_eatGroupName(Z))return Z.backReferenceNames.push(Z.lastStringValue),!0;Z.raise("Invalid named reference")}return!1};V.regexp_eatCharacterEscape=function(Z){return this.regexp_eatControlEscape(Z)||this.regexp_eatCControlLetter(Z)||this.regexp_eatZero(Z)||this.regexp_eatHexEscapeSequence(Z)||this.regexp_eatRegExpUnicodeEscapeSequence(Z,!1)||!Z.switchU&&this.regexp_eatLegacyOctalEscapeSequence(Z)||this.regexp_eatIdentityEscape(Z)};V.regexp_eatCControlLetter=function(Z){var Q=Z.pos;if(Z.eat(99)){if(this.regexp_eatControlLetter(Z))return!0;Z.pos=Q}return!1};V.regexp_eatZero=function(Z){if(Z.current()===48&&!K1(Z.lookahead()))return Z.lastIntValue=0,Z.advance(),!0;return!1};V.regexp_eatControlEscape=function(Z){var Q=Z.current();if(Q===116)return Z.lastIntValue=9,Z.advance(),!0;if(Q===110)return Z.lastIntValue=10,Z.advance(),!0;if(Q===118)return Z.lastIntValue=11,Z.advance(),!0;if(Q===102)return Z.lastIntValue=12,Z.advance(),!0;if(Q===114)return Z.lastIntValue=13,Z.advance(),!0;return!1};V.regexp_eatControlLetter=function(Z){var Q=Z.current();if(P8(Q))return Z.lastIntValue=Q%32,Z.advance(),!0;return!1};function P8(Z){return Z>=65&&Z<=90||Z>=97&&Z<=122}V.regexp_eatRegExpUnicodeEscapeSequence=function(Z,Q){if(Q===void 0)Q=!1;var Y=Z.pos,J=Q||Z.switchU;if(Z.eat(117)){if(this.regexp_eatFixedHexDigits(Z,4)){var X=Z.lastIntValue;if(J&&X>=55296&&X<=56319){var K=Z.pos;if(Z.eat(92)&&Z.eat(117)&&this.regexp_eatFixedHexDigits(Z,4)){var H=Z.lastIntValue;if(H>=56320&&H<=57343)return Z.lastIntValue=(X-55296)*1024+(H-56320)+65536,!0}Z.pos=K,Z.lastIntValue=X}return!0}if(J&&Z.eat(123)&&this.regexp_eatHexDigits(Z)&&Z.eat(125)&&I6(Z.lastIntValue))return!0;if(J)Z.raise("Invalid unicode escape");Z.pos=Y}return!1};function I6(Z){return Z>=0&&Z<=1114111}V.regexp_eatIdentityEscape=function(Z){if(Z.switchU){if(this.regexp_eatSyntaxCharacter(Z))return!0;if(Z.eat(47))return Z.lastIntValue=47,!0;return!1}var Q=Z.current();if(Q!==99&&(!Z.switchN||Q!==107))return Z.lastIntValue=Q,Z.advance(),!0;return!1};V.regexp_eatDecimalEscape=function(Z){Z.lastIntValue=0;var Q=Z.current();if(Q>=49&&Q<=57){do Z.lastIntValue=10*Z.lastIntValue+(Q-48),Z.advance();while((Q=Z.current())>=48&&Q<=57);return!0}return!1};var S8=0,O0=1,X0=2;V.regexp_eatCharacterClassEscape=function(Z){var Q=Z.current();if(B6(Q))return Z.lastIntValue=-1,Z.advance(),O0;var Y=!1;if(Z.switchU&&this.options.ecmaVersion>=9&&((Y=Q===80)||Q===112)){Z.lastIntValue=-1,Z.advance();var J;if(Z.eat(123)&&(J=this.regexp_eatUnicodePropertyValueExpression(Z))&&Z.eat(125)){if(Y&&J===X0)Z.raise("Invalid property name");return J}Z.raise("Invalid property name")}return S8};function B6(Z){return Z===100||Z===68||Z===115||Z===83||Z===119||Z===87}V.regexp_eatUnicodePropertyValueExpression=function(Z){var Q=Z.pos;if(this.regexp_eatUnicodePropertyName(Z)&&Z.eat(61)){var Y=Z.lastStringValue;if(this.regexp_eatUnicodePropertyValue(Z)){var J=Z.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(Z,Y,J),O0}}if(Z.pos=Q,this.regexp_eatLoneUnicodePropertyNameOrValue(Z)){var X=Z.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(Z,X)}return S8};V.regexp_validateUnicodePropertyNameAndValue=function(Z,Q,Y){if(!b0(Z.unicodeProperties.nonBinary,Q))Z.raise("Invalid property name");if(!Z.unicodeProperties.nonBinary[Q].test(Y))Z.raise("Invalid property value")};V.regexp_validateUnicodePropertyNameOrValue=function(Z,Q){if(Z.unicodeProperties.binary.test(Q))return O0;if(Z.switchV&&Z.unicodeProperties.binaryOfStrings.test(Q))return X0;Z.raise("Invalid property name")};V.regexp_eatUnicodePropertyName=function(Z){var Q=0;Z.lastStringValue="";while(b8(Q=Z.current()))Z.lastStringValue+=U0(Q),Z.advance();return Z.lastStringValue!==""};function b8(Z){return P8(Z)||Z===95}V.regexp_eatUnicodePropertyValue=function(Z){var Q=0;Z.lastStringValue="";while(M6(Q=Z.current()))Z.lastStringValue+=U0(Q),Z.advance();return Z.lastStringValue!==""};function M6(Z){return b8(Z)||K1(Z)}V.regexp_eatLoneUnicodePropertyNameOrValue=function(Z){return this.regexp_eatUnicodePropertyValue(Z)};V.regexp_eatCharacterClass=function(Z){if(Z.eat(91)){var Q=Z.eat(94),Y=this.regexp_classContents(Z);if(!Z.eat(93))Z.raise("Unterminated character class");if(Q&&Y===X0)Z.raise("Negated character class may contain strings");return!0}return!1};V.regexp_classContents=function(Z){if(Z.current()===93)return O0;if(Z.switchV)return this.regexp_classSetExpression(Z);return this.regexp_nonEmptyClassRanges(Z),O0};V.regexp_nonEmptyClassRanges=function(Z){while(this.regexp_eatClassAtom(Z)){var Q=Z.lastIntValue;if(Z.eat(45)&&this.regexp_eatClassAtom(Z)){var Y=Z.lastIntValue;if(Z.switchU&&(Q===-1||Y===-1))Z.raise("Invalid character class");if(Q!==-1&&Y!==-1&&Q>Y)Z.raise("Range out of order in character class")}}};V.regexp_eatClassAtom=function(Z){var Q=Z.pos;if(Z.eat(92)){if(this.regexp_eatClassEscape(Z))return!0;if(Z.switchU){var Y=Z.current();if(Y===99||k8(Y))Z.raise("Invalid class escape");Z.raise("Invalid escape")}Z.pos=Q}var J=Z.current();if(J!==93)return Z.lastIntValue=J,Z.advance(),!0;return!1};V.regexp_eatClassEscape=function(Z){var Q=Z.pos;if(Z.eat(98))return Z.lastIntValue=8,!0;if(Z.switchU&&Z.eat(45))return Z.lastIntValue=45,!0;if(!Z.switchU&&Z.eat(99)){if(this.regexp_eatClassControlLetter(Z))return!0;Z.pos=Q}return this.regexp_eatCharacterClassEscape(Z)||this.regexp_eatCharacterEscape(Z)};V.regexp_classSetExpression=function(Z){var Q=O0,Y;if(this.regexp_eatClassSetRange(Z));else if(Y=this.regexp_eatClassSetOperand(Z)){if(Y===X0)Q=X0;var J=Z.pos;while(Z.eatChars([38,38])){if(Z.current()!==38&&(Y=this.regexp_eatClassSetOperand(Z))){if(Y!==X0)Q=O0;continue}Z.raise("Invalid character in character class")}if(J!==Z.pos)return Q;while(Z.eatChars([45,45])){if(this.regexp_eatClassSetOperand(Z))continue;Z.raise("Invalid character in character class")}if(J!==Z.pos)return Q}else Z.raise("Invalid character in character class");for(;;){if(this.regexp_eatClassSetRange(Z))continue;if(Y=this.regexp_eatClassSetOperand(Z),!Y)return Q;if(Y===X0)Q=X0}};V.regexp_eatClassSetRange=function(Z){var Q=Z.pos;if(this.regexp_eatClassSetCharacter(Z)){var Y=Z.lastIntValue;if(Z.eat(45)&&this.regexp_eatClassSetCharacter(Z)){var J=Z.lastIntValue;if(Y!==-1&&J!==-1&&Y>J)Z.raise("Range out of order in character class");return!0}Z.pos=Q}return!1};V.regexp_eatClassSetOperand=function(Z){if(this.regexp_eatClassSetCharacter(Z))return O0;return this.regexp_eatClassStringDisjunction(Z)||this.regexp_eatNestedClass(Z)};V.regexp_eatNestedClass=function(Z){var Q=Z.pos;if(Z.eat(91)){var Y=Z.eat(94),J=this.regexp_classContents(Z);if(Z.eat(93)){if(Y&&J===X0)Z.raise("Negated character class may contain strings");return J}Z.pos=Q}if(Z.eat(92)){var X=this.regexp_eatCharacterClassEscape(Z);if(X)return X;Z.pos=Q}return null};V.regexp_eatClassStringDisjunction=function(Z){var Q=Z.pos;if(Z.eatChars([92,113])){if(Z.eat(123)){var Y=this.regexp_classStringDisjunctionContents(Z);if(Z.eat(125))return Y}else Z.raise("Invalid escape");Z.pos=Q}return null};V.regexp_classStringDisjunctionContents=function(Z){var Q=this.regexp_classString(Z);while(Z.eat(124))if(this.regexp_classString(Z)===X0)Q=X0;return Q};V.regexp_classString=function(Z){var Q=0;while(this.regexp_eatClassSetCharacter(Z))Q++;return Q===1?O0:X0};V.regexp_eatClassSetCharacter=function(Z){var Q=Z.pos;if(Z.eat(92)){if(this.regexp_eatCharacterEscape(Z)||this.regexp_eatClassSetReservedPunctuator(Z))return!0;if(Z.eat(98))return Z.lastIntValue=8,!0;return Z.pos=Q,!1}var Y=Z.current();if(Y<0||Y===Z.lookahead()&&L6(Y))return!1;if(N6(Y))return!1;return Z.advance(),Z.lastIntValue=Y,!0};function L6(Z){return Z===33||Z>=35&&Z<=38||Z>=42&&Z<=44||Z===46||Z>=58&&Z<=64||Z===94||Z===96||Z===126}function N6(Z){return Z===40||Z===41||Z===45||Z===47||Z>=91&&Z<=93||Z>=123&&Z<=125}V.regexp_eatClassSetReservedPunctuator=function(Z){var Q=Z.current();if(j6(Q))return Z.lastIntValue=Q,Z.advance(),!0;return!1};function j6(Z){return Z===33||Z===35||Z===37||Z===38||Z===44||Z===45||Z>=58&&Z<=62||Z===64||Z===96||Z===126}V.regexp_eatClassControlLetter=function(Z){var Q=Z.current();if(K1(Q)||Q===95)return Z.lastIntValue=Q%32,Z.advance(),!0;return!1};V.regexp_eatHexEscapeSequence=function(Z){var Q=Z.pos;if(Z.eat(120)){if(this.regexp_eatFixedHexDigits(Z,2))return!0;if(Z.switchU)Z.raise("Invalid escape");Z.pos=Q}return!1};V.regexp_eatDecimalDigits=function(Z){var Q=Z.pos,Y=0;Z.lastIntValue=0;while(K1(Y=Z.current()))Z.lastIntValue=10*Z.lastIntValue+(Y-48),Z.advance();return Z.pos!==Q};function K1(Z){return Z>=48&&Z<=57}V.regexp_eatHexDigits=function(Z){var Q=Z.pos,Y=0;Z.lastIntValue=0;while(E8(Y=Z.current()))Z.lastIntValue=16*Z.lastIntValue+v8(Y),Z.advance();return Z.pos!==Q};function E8(Z){return Z>=48&&Z<=57||Z>=65&&Z<=70||Z>=97&&Z<=102}function v8(Z){if(Z>=65&&Z<=70)return 10+(Z-65);if(Z>=97&&Z<=102)return 10+(Z-97);return Z-48}V.regexp_eatLegacyOctalEscapeSequence=function(Z){if(this.regexp_eatOctalDigit(Z)){var Q=Z.lastIntValue;if(this.regexp_eatOctalDigit(Z)){var Y=Z.lastIntValue;if(Q<=3&&this.regexp_eatOctalDigit(Z))Z.lastIntValue=Q*64+Y*8+Z.lastIntValue;else Z.lastIntValue=Q*8+Y}else Z.lastIntValue=Q;return!0}return!1};V.regexp_eatOctalDigit=function(Z){var Q=Z.current();if(k8(Q))return Z.lastIntValue=Q-48,Z.advance(),!0;return Z.lastIntValue=0,!1};function k8(Z){return Z>=48&&Z<=55}V.regexp_eatFixedHexDigits=function(Z,Q){var Y=Z.pos;Z.lastIntValue=0;for(var J=0;J<Q;++J){var X=Z.current();if(!E8(X))return Z.pos=Y,!1;Z.lastIntValue=16*Z.lastIntValue+v8(X),Z.advance()}return!0};var v1=function(Q){if(this.type=Q.type,this.value=Q.value,this.start=Q.start,this.end=Q.end,Q.options.locations)this.loc=new Z1(Q,Q.startLoc,Q.endLoc);if(Q.options.ranges)this.range=[Q.start,Q.end]},k=i.prototype;k.next=function(Z){if(!Z&&this.type.keyword&&this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword);if(this.options.onToken)this.options.onToken(new v1(this));this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};k.getToken=function(){return this.next(),new v1(this)};if(typeof Symbol<"u")k[Symbol.iterator]=function(){var Z=this;return{next:function(){var Q=Z.getToken();return{done:Q.type===G.eof,value:Q}}}};k.nextToken=function(){var Z=this.curContext();if(!Z||!Z.preserveSpace)this.skipSpace();if(this.start=this.pos,this.options.locations)this.startLoc=this.curPosition();if(this.pos>=this.input.length)return this.finishToken(G.eof);if(Z.override)return Z.override(this);else this.readToken(this.fullCharCodeAtPos())};k.readToken=function(Z){if(G0(Z,this.options.ecmaVersion>=6)||Z===92)return this.readWord();return this.getTokenFromCode(Z)};k.fullCharCodeAtPos=function(){var Z=this.input.charCodeAt(this.pos);if(Z<=55295||Z>=56320)return Z;var Q=this.input.charCodeAt(this.pos+1);return Q<=56319||Q>=57344?Z:(Z<<10)+Q-56613888};k.skipBlockComment=function(){var Z=this.options.onComment&&this.curPosition(),Q=this.pos,Y=this.input.indexOf("*/",this.pos+=2);if(Y===-1)this.raise(this.pos-2,"Unterminated comment");if(this.pos=Y+2,this.options.locations)for(var J=void 0,X=Q;(J=X8(this.input,X,this.pos))>-1;)++this.curLine,X=this.lineStart=J;if(this.options.onComment)this.options.onComment(!0,this.input.slice(Q+2,Y),Q,this.pos,Z,this.curPosition())};k.skipLineComment=function(Z){var Q=this.pos,Y=this.options.onComment&&this.curPosition(),J=this.input.charCodeAt(this.pos+=Z);while(this.pos<this.input.length&&!S0(J))J=this.input.charCodeAt(++this.pos);if(this.options.onComment)this.options.onComment(!1,this.input.slice(Q+Z,this.pos),Q,this.pos,Y,this.curPosition())};k.skipSpace=function(){Z:while(this.pos<this.input.length){var Z=this.input.charCodeAt(this.pos);switch(Z){case 32:case 160:++this.pos;break;case 13:if(this.input.charCodeAt(this.pos+1)===10)++this.pos;case 10:case 8232:case 8233:if(++this.pos,this.options.locations)++this.curLine,this.lineStart=this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break Z}break;default:if(Z>8&&Z<14||Z>=5760&&K8.test(String.fromCharCode(Z)))++this.pos;else break Z}}};k.finishToken=function(Z,Q){if(this.end=this.pos,this.options.locations)this.endLoc=this.curPosition();var Y=this.type;this.type=Z,this.value=Q,this.updateContext(Y)};k.readToken_dot=function(){var Z=this.input.charCodeAt(this.pos+1);if(Z>=48&&Z<=57)return this.readNumber(!0);var Q=this.input.charCodeAt(this.pos+2);if(this.options.ecmaVersion>=6&&Z===46&&Q===46)return this.pos+=3,this.finishToken(G.ellipsis);else return++this.pos,this.finishToken(G.dot)};k.readToken_slash=function(){var Z=this.input.charCodeAt(this.pos+1);if(this.exprAllowed)return++this.pos,this.readRegexp();if(Z===61)return this.finishOp(G.assign,2);return this.finishOp(G.slash,1)};k.readToken_mult_modulo_exp=function(Z){var Q=this.input.charCodeAt(this.pos+1),Y=1,J=Z===42?G.star:G.modulo;if(this.options.ecmaVersion>=7&&Z===42&&Q===42)++Y,J=G.starstar,Q=this.input.charCodeAt(this.pos+2);if(Q===61)return this.finishOp(G.assign,Y+1);return this.finishOp(J,Y)};k.readToken_pipe_amp=function(Z){var Q=this.input.charCodeAt(this.pos+1);if(Q===Z){if(this.options.ecmaVersion>=12){var Y=this.input.charCodeAt(this.pos+2);if(Y===61)return this.finishOp(G.assign,3)}return this.finishOp(Z===124?G.logicalOR:G.logicalAND,2)}if(Q===61)return this.finishOp(G.assign,2);return this.finishOp(Z===124?G.bitwiseOR:G.bitwiseAND,1)};k.readToken_caret=function(){var Z=this.input.charCodeAt(this.pos+1);if(Z===61)return this.finishOp(G.assign,2);return this.finishOp(G.bitwiseXOR,1)};k.readToken_plus_min=function(Z){var Q=this.input.charCodeAt(this.pos+1);if(Q===Z){if(Q===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||e.test(this.input.slice(this.lastTokEnd,this.pos))))return this.skipLineComment(3),this.skipSpace(),this.nextToken();return this.finishOp(G.incDec,2)}if(Q===61)return this.finishOp(G.assign,2);return this.finishOp(G.plusMin,1)};k.readToken_lt_gt=function(Z){var Q=this.input.charCodeAt(this.pos+1),Y=1;if(Q===Z){if(Y=Z===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+Y)===61)return this.finishOp(G.assign,Y+1);return this.finishOp(G.bitShift,Y)}if(Q===33&&Z===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45)return this.skipLineComment(4),this.skipSpace(),this.nextToken();if(Q===61)Y=2;return this.finishOp(G.relational,Y)};k.readToken_eq_excl=function(Z){var Q=this.input.charCodeAt(this.pos+1);if(Q===61)return this.finishOp(G.equality,this.input.charCodeAt(this.pos+2)===61?3:2);if(Z===61&&Q===62&&this.options.ecmaVersion>=6)return this.pos+=2,this.finishToken(G.arrow);return this.finishOp(Z===61?G.eq:G.prefix,1)};k.readToken_question=function(){var Z=this.options.ecmaVersion;if(Z>=11){var Q=this.input.charCodeAt(this.pos+1);if(Q===46){var Y=this.input.charCodeAt(this.pos+2);if(Y<48||Y>57)return this.finishOp(G.questionDot,2)}if(Q===63){if(Z>=12){var J=this.input.charCodeAt(this.pos+2);if(J===61)return this.finishOp(G.assign,3)}return this.finishOp(G.coalesce,2)}}return this.finishOp(G.question,1)};k.readToken_numberSign=function(){var Z=this.options.ecmaVersion,Q=35;if(Z>=13){if(++this.pos,Q=this.fullCharCodeAtPos(),G0(Q,!0)||Q===92)return this.finishToken(G.privateId,this.readWord1())}this.raise(this.pos,"Unexpected character '"+U0(Q)+"'")};k.getTokenFromCode=function(Z){switch(Z){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(G.parenL);case 41:return++this.pos,this.finishToken(G.parenR);case 59:return++this.pos,this.finishToken(G.semi);case 44:return++this.pos,this.finishToken(G.comma);case 91:return++this.pos,this.finishToken(G.bracketL);case 93:return++this.pos,this.finishToken(G.bracketR);case 123:return++this.pos,this.finishToken(G.braceL);case 125:return++this.pos,this.finishToken(G.braceR);case 58:return++this.pos,this.finishToken(G.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(G.backQuote);case 48:var Q=this.input.charCodeAt(this.pos+1);if(Q===120||Q===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(Q===111||Q===79)return this.readRadixNumber(8);if(Q===98||Q===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(Z);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(Z);case 124:case 38:return this.readToken_pipe_amp(Z);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(Z);case 60:case 62:return this.readToken_lt_gt(Z);case 61:case 33:return this.readToken_eq_excl(Z);case 63:return this.readToken_question();case 126:return this.finishOp(G.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+U0(Z)+"'")};k.finishOp=function(Z,Q){var Y=this.input.slice(this.pos,this.pos+Q);return this.pos+=Q,this.finishToken(Z,Y)};k.readRegexp=function(){var Z,Q,Y=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(Y,"Unterminated regular expression");var J=this.input.charAt(this.pos);if(e.test(J))this.raise(Y,"Unterminated regular expression");if(!Z){if(J==="[")Q=!0;else if(J==="]"&&Q)Q=!1;else if(J==="/"&&!Q)break;Z=J==="\\"}else Z=!1;++this.pos}var X=this.input.slice(Y,this.pos);++this.pos;var K=this.pos,H=this.readWord1();if(this.containsEsc)this.unexpected(K);var W=this.regexpState||(this.regexpState=new q0(this));W.reset(Y,X,H),this.validateRegExpFlags(W),this.validateRegExpPattern(W);var z=null;try{z=new RegExp(X,H)}catch(_){}return this.finishToken(G.regexp,{pattern:X,flags:H,value:z})};k.readInt=function(Z,Q,Y){var J=this.options.ecmaVersion>=12&&Q===void 0,X=Y&&this.input.charCodeAt(this.pos)===48,K=this.pos,H=0,W=0;for(var z=0,_=Q==null?1/0:Q;z<_;++z,++this.pos){var q=this.input.charCodeAt(this.pos),R=void 0;if(J&&q===95){if(X)this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals");if(W===95)this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore");if(z===0)this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits");W=q;continue}if(q>=97)R=q-97+10;else if(q>=65)R=q-65+10;else if(q>=48&&q<=57)R=q-48;else R=1/0;if(R>=Z)break;W=q,H=H*Z+R}if(J&&W===95)this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits");if(this.pos===K||Q!=null&&this.pos-K!==Q)return null;return H};function w6(Z,Q){if(Q)return parseInt(Z,8);return parseFloat(Z.replace(/_/g,""))}function g8(Z){if(typeof BigInt!=="function")return null;return BigInt(Z.replace(/_/g,""))}k.readRadixNumber=function(Z){var Q=this.pos;this.pos+=2;var Y=this.readInt(Z);if(Y==null)this.raise(this.start+2,"Expected number in radix "+Z);if(this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110)Y=g8(this.input.slice(Q,this.pos)),++this.pos;else if(G0(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(G.num,Y)};k.readNumber=function(Z){var Q=this.pos;if(!Z&&this.readInt(10,void 0,!0)===null)this.raise(Q,"Invalid number");var Y=this.pos-Q>=2&&this.input.charCodeAt(Q)===48;if(Y&&this.strict)this.raise(Q,"Invalid number");var J=this.input.charCodeAt(this.pos);if(!Y&&!Z&&this.options.ecmaVersion>=11&&J===110){var X=g8(this.input.slice(Q,this.pos));if(++this.pos,G0(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(G.num,X)}if(Y&&/[89]/.test(this.input.slice(Q,this.pos)))Y=!1;if(J===46&&!Y)++this.pos,this.readInt(10),J=this.input.charCodeAt(this.pos);if((J===69||J===101)&&!Y){if(J=this.input.charCodeAt(++this.pos),J===43||J===45)++this.pos;if(this.readInt(10)===null)this.raise(Q,"Invalid number")}if(G0(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");var K=w6(this.input.slice(Q,this.pos),Y);return this.finishToken(G.num,K)};k.readCodePoint=function(){var Z=this.input.charCodeAt(this.pos),Q;if(Z===123){if(this.options.ecmaVersion<6)this.unexpected();var Y=++this.pos;if(Q=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,Q>1114111)this.invalidStringToken(Y,"Code point out of bounds")}else Q=this.readHexChar(4);return Q};k.readString=function(Z){var Q="",Y=++this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated string constant");var J=this.input.charCodeAt(this.pos);if(J===Z)break;if(J===92)Q+=this.input.slice(Y,this.pos),Q+=this.readEscapedChar(!1),Y=this.pos;else if(J===8232||J===8233){if(this.options.ecmaVersion<10)this.raise(this.start,"Unterminated string constant");if(++this.pos,this.options.locations)this.curLine++,this.lineStart=this.pos}else{if(S0(J))this.raise(this.start,"Unterminated string constant");++this.pos}}return Q+=this.input.slice(Y,this.pos++),this.finishToken(G.string,Q)};var y8={};k.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(Z){if(Z===y8)this.readInvalidTemplateToken();else throw Z}this.inTemplateElement=!1};k.invalidStringToken=function(Z,Q){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw y8;else this.raise(Z,Q)};k.readTmplToken=function(){var Z="",Q=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated template");var Y=this.input.charCodeAt(this.pos);if(Y===96||Y===36&&this.input.charCodeAt(this.pos+1)===123){if(this.pos===this.start&&(this.type===G.template||this.type===G.invalidTemplate))if(Y===36)return this.pos+=2,this.finishToken(G.dollarBraceL);else return++this.pos,this.finishToken(G.backQuote);return Z+=this.input.slice(Q,this.pos),this.finishToken(G.template,Z)}if(Y===92)Z+=this.input.slice(Q,this.pos),Z+=this.readEscapedChar(!0),Q=this.pos;else if(S0(Y)){switch(Z+=this.input.slice(Q,this.pos),++this.pos,Y){case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:Z+=`
7
- `;break;default:Z+=String.fromCharCode(Y);break}if(this.options.locations)++this.curLine,this.lineStart=this.pos;Q=this.pos}else++this.pos}};k.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(G.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":if(this.input[this.pos+1]===`
8
- `)++this.pos;case`
9
- `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};k.readEscapedChar=function(Z){var Q=this.input.charCodeAt(++this.pos);switch(++this.pos,Q){case 110:return`
10
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return U0(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:if(this.options.locations)this.lineStart=this.pos,++this.curLine;return"";case 56:case 57:if(this.strict)this.invalidStringToken(this.pos-1,"Invalid escape sequence");if(Z){var Y=this.pos-1;this.invalidStringToken(Y,"Invalid escape sequence in template string")}default:if(Q>=48&&Q<=55){var J=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],X=parseInt(J,8);if(X>255)J=J.slice(0,-1),X=parseInt(J,8);if(this.pos+=J.length-1,Q=this.input.charCodeAt(this.pos),(J!=="0"||Q===56||Q===57)&&(this.strict||Z))this.invalidStringToken(this.pos-1-J.length,Z?"Octal literal in template string":"Octal literal in strict mode");return String.fromCharCode(X)}if(S0(Q)){if(this.options.locations)this.lineStart=this.pos,++this.curLine;return""}return String.fromCharCode(Q)}};k.readHexChar=function(Z){var Q=this.pos,Y=this.readInt(16,Z);if(Y===null)this.invalidStringToken(Q,"Bad character escape sequence");return Y};k.readWord1=function(){this.containsEsc=!1;var Z="",Q=!0,Y=this.pos,J=this.options.ecmaVersion>=6;while(this.pos<this.input.length){var X=this.fullCharCodeAtPos();if(j0(X,J))this.pos+=X<=65535?1:2;else if(X===92){this.containsEsc=!0,Z+=this.input.slice(Y,this.pos);var K=this.pos;if(this.input.charCodeAt(++this.pos)!==117)this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX");++this.pos;var H=this.readCodePoint();if(!(Q?G0:j0)(H,J))this.invalidStringToken(K,"Invalid Unicode escape");Z+=U0(H),Y=this.pos}else break;Q=!1}return Z+this.input.slice(Y,this.pos)};k.readWord=function(){var Z=this.readWord1(),Q=G.name;if(this.keywords.test(Z))Q=T1[Z];return this.finishToken(Q,Z)};var A6="8.15.0";i.acorn={Parser:i,version:A6,defaultOptions:w1,Position:y0,SourceLocation:Z1,getLineInfo:W8,Node:X1,TokenType:f,tokTypes:G,keywordTypes:T1,TokContext:W0,tokContexts:u,isIdentifierChar:j0,isIdentifierStart:G0,Token:v1,isNewLine:S0,lineBreak:e,lineBreakG:cZ,nonASCIIwhitespace:K8};function f8(Z,Q){return i.parse(Z,Q)}function h8(Z,Q,Y){return i.parseExpressionAt(Z,Q,Y)}class d extends Error{line;column;source;filename;constructor(Z,Q,Y,J){let X=`${J||"<source>"}:${Q.line}:${Q.column}`;super(`${Z} at ${X}`);this.name="TranspileError",this.line=Q.line,this.column=Q.column,this.source=Y,this.filename=J}}class Z0 extends d{constructor(Z,Q,Y,J){super(Z,Q,Y,J);this.name="SyntaxError"}formatWithContext(Z=2){if(!this.source)return this.message;let Q=this.source.split(`
11
- `),Y=this.line-1,J=Math.max(0,Y-Z),X=Math.min(Q.length-1,Y+Z),K=[],H=String(X+1).length;for(let W=J;W<=X;W++){let z=String(W+1).padStart(H),_=W===Y?">":" ";if(K.push(`${_} ${z} | ${Q[W]}`),W===Y){let q=" ".repeat(H+4+this.column);K.push(`${q}^ ${this.message.split(" at ")[0]}`)}}return K.join(`
12
- `)}}function H0(Z){return{depth:Z.depth+1,locals:new Map,parent:Z,parameters:Z.parameters,atoms:Z.atoms,warnings:Z.warnings,source:Z.source,filename:Z.filename,options:Z.options}}function l(Z){if(Z.loc)return{line:Z.loc.start.line,column:Z.loc.start.column};return{line:1,column:0}}function G1(Z,Q){let Y="",J=0,X,K,H="normal",W=[],z=[{type:"top-level",braceDepth:0}],_=0,q=()=>z[z.length-1]?.type||"top-level",R=()=>{let F=z[z.length-1];return F?.type==="class-body"&&_===F.braceDepth+1};while(J<Z.length){let F=Z[J],U=Z[J+1];switch(H){case"single-string":if(Y+=F,F==="\\"&&J+1<Z.length){Y+=U,J+=2;continue}if(F==="'")H="normal";J++;continue;case"double-string":if(Y+=F,F==="\\"&&J+1<Z.length){Y+=U,J+=2;continue}if(F==='"')H="normal";J++;continue;case"template-string":if(Y+=F,F==="\\"&&J+1<Z.length){Y+=U,J+=2;continue}if(F==="$"&&U==="{"){Y+=U,J+=2,W.push(1),H="normal";continue}if(F==="`")H="normal";J++;continue;case"line-comment":if(Y+=F,F===`
13
- `)H="normal";J++;continue;case"block-comment":if(Y+=F,F==="*"&&U==="/"){Y+=U,J+=2,H="normal";continue}J++;continue;case"regex":if(Y+=F,F==="\\"&&J+1<Z.length){Y+=U,J+=2;continue}if(F==="["){J++;while(J<Z.length&&Z[J]!=="]")if(Y+=Z[J],Z[J]==="\\"&&J+1<Z.length)Y+=Z[J+1],J+=2;else J++;if(J<Z.length)Y+=Z[J],J++;continue}if(F==="/"){J++;while(J<Z.length&&/[gimsuy]/.test(Z[J]))Y+=Z[J],J++;H="normal";continue}J++;continue;case"normal":if(W.length>0){if(F==="{")W[W.length-1]++;else if(F==="}"){if(W[W.length-1]--,W[W.length-1]===0){W.pop(),Y+=F,J++,H="template-string";continue}}}if(F==="'"){Y+=F,J++,H="single-string";continue}if(F==='"'){Y+=F,J++,H="double-string";continue}if(F==="`"){Y+=F,J++,H="template-string";continue}if(F==="/"&&U==="/"){Y+=F+U,J+=2,H="line-comment";continue}if(F==="/"&&U==="*"){Y+=F+U,J+=2,H="block-comment";continue}if(F==="/"){let I=Y.trimEnd();if(!I[I.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(I)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(I)){Y+=F,J++,H="regex";continue}}break}if(F==="{"){_++,Y+=F,J++;continue}if(F==="}"){_--;let I=z[z.length-1];if(I&&_===I.braceDepth)z.pop();Y+=F,J++;continue}let O=Z.slice(J).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(O){let I=O[0].slice(0,-1);Y+=I,J+=I.length,z.push({type:"class-body",braceDepth:_});continue}let L=Z.slice(J).match(/^function\s+(\w+)\s*\(/);if(L){let I=L[1],j=L[0].length,C=Z[J+j],w=null,T=J+j;if(C==="?"||C==="!")if(w=C,T++,w==="!")Q.unsafeFunctions.add(I);else Q.safeFunctions.add(I);Y+=`function ${I}(`,J=T;let S=H1(Z,J,"(",")");if(!S){Y+=Z[J],J++;continue}let{content:b,endPos:y}=S;J=y;let h=g1(b,Q,!0);Y+=h+")";let x=J;while(x<Z.length&&/\s/.test(Z[x]))x++;if(Z[x]===":"){let o=Z.slice(x,x+2),B0;if(o===":?"||o===":!")x+=2,B0=o===":?"?"safe":"unsafe";else x+=1;while(x<Z.length&&/\s/.test(Z[x]))x++;let A0=k1(Z,x);if(A0){if(X===void 0){if(X=A0.type,B0)K=B0}J=A0.endPos}}continue}let B=Z.slice(J).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),N=(()=>{for(let I=Y.length-1;I>=0;I--)if(!/\s/.test(Y[I]))return Y[I];return`
14
- `})(),A=N!=="="&&N!==","&&N!=="("&&N!=="["&&N!==">";if(B&&R()&&!A){let I=B[1].length;Y+=Z.slice(J,J+I),J+=I;continue}if(B&&R()&&A){let I=B[1],j=B[0].length,C=J+j;Y+=I+"(",J=C;let w=H1(Z,J,"(",")");if(!w){Y+=Z[J],J++;continue}let{content:T,endPos:S}=w;J=S;let b=g1(T,Q,!0);Y+=b+")";let y=J;while(y<Z.length&&/\s/.test(Z[y]))y++;if(Z[y]===":"){let h=Z.slice(y,y+2);if(h===":?"||h===":!")y+=2;else y++;while(y<Z.length&&/\s/.test(Z[y]))y++;let x=k1(Z,y);if(x)J=x.endPos}continue}if(Z[J]==="("){let I=H1(Z,J+1,"(",")");if(!I){Y+=Z[J],J++;continue}let{content:j,endPos:C}=I,w=C;while(w<Z.length&&/\s/.test(Z[w]))w++;let T;if(Z[w]===":"){let S=Z.slice(w,w+2);if(S===":?"||S===":!")w+=2;else w++;while(w<Z.length&&/\s/.test(Z[w]))w++;let b=k1(Z,w);if(b){T=b.type,w=b.endPos;while(w<Z.length&&/\s/.test(Z[w]))w++}}if(Z.slice(w,w+2)==="=>"){let S=null,b=j,y=j.trimStart();if(y.startsWith("?")&&(y.length===1||/\s/.test(y[1])))S="?",b=y.slice(1);else if(y.startsWith("!")&&(y.length===1||/\s/.test(y[1])))S="!",b=y.slice(1);let h=g1(b,Q,!1);Y+=`(${S==="?"?"/* safe */ ":S==="!"?"/* unsafe */ ":""}${h})`,J=C;while(J<w&&/\s/.test(Z[J]))Y+=Z[J],J++;if(T)J=w}else{let S=G1(j,Q);Y+=`(${S.source})`,J=C}continue}Y+=Z[J],J++}return{source:Y,returnType:X,returnSafety:K}}function H1(Z,Q,Y,J){let X=1,K=Q,H=!1,W="";while(K<Z.length&&X>0){let z=Z[K];if(!H&&(z==="'"||z==='"'||z==="`"))H=!0,W=z;else if(H&&z===W&&Z[K-1]!=="\\")H=!1;else if(!H){if(z===Y)X++;else if(z===J)X--}K++}if(X!==0)return null;return{content:Z.slice(Q,K-1),endPos:K}}function u8(Z,Q){let Y=Q;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y>=Z.length)return null;let J=Y,X=Z[Y];if(X==="{"||X==="["){let H=X==="{"?"}":"]",W=H1(Z,Y+1,X,H);if(!W)return null;return{value:Z.slice(J,W.endPos),endPos:W.endPos}}if(X==="'"||X==='"'||X==="`"){Y++;while(Y<Z.length){if(Z[Y]===X&&Z[Y-1]!=="\\")return Y++,{value:Z.slice(J,Y),endPos:Y};Y++}return null}if(/[-+\d]/.test(X)){while(Y<Z.length&&/[\d.eE+-]/.test(Z[Y]))Y++;return{value:Z.slice(J,Y),endPos:Y}}let K=Z.slice(Y).match(/^(true|false|null|undefined)\b/);if(K)return{value:K[1],endPos:Y+K[1].length};return null}function m0(Z){return Z.replace(/(?<!\|)\|(?!\|)/g," || ")}function k1(Z,Q){let Y=Q,J=0,X=!1,K="",H=!1,W=(z)=>({type:m0(Z.slice(Q,z).trim()),endPos:z});while(Y<Z.length){let z=Z[Y];if(!X&&(z==="'"||z==='"'||z==="`")){X=!0,K=z,H=!0,Y++;continue}if(X){if(z===K&&Z[Y-1]!=="\\"){if(X=!1,Y++,J===0){let _=Y;while(_<Z.length&&/\s/.test(Z[_]))_++;if(Z[_]==="{"){if(!Z.slice(_+1).match(/^\s*(\w+)\s*:/))return W(Y)}if(Z[_]!=="|"&&Z[_]!=="&")return W(Y)}continue}Y++;continue}if(z==="{"||z==="["||z==="("){J++,H=!0,Y++;continue}if(z==="}"||z==="]"||z===")"){if(J--,J===0){Y++;let _=Y;while(_<Z.length&&/\s/.test(Z[_]))_++;if(Z[_]==="|"||Z[_]==="&")continue;return W(Y)}Y++;continue}if(J===0&&z==="{"){if(H)return W(Y);if(Z.slice(Y+1).match(/^\s*(\w+)\s*:/)){J++,H=!0,Y++;continue}return W(Y)}if(J===0&&(z==="|"||z==="&")){if(Y++,Y<Z.length&&Z[Y]==="|")Y++;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;continue}if(J===0&&(/\d/.test(z)||z==="-"&&/\d/.test(Z[Y+1]))){let _=Y;if(Z[_]==="-")_++;while(_<Z.length&&/\d/.test(Z[_]))_++;if(_<Z.length&&Z[_]==="."&&/\d/.test(Z[_+1])){_++;while(_<Z.length&&/\d/.test(Z[_]))_++}if(_<Z.length&&(Z[_]==="e"||Z[_]==="E")){if(_++,_<Z.length&&(Z[_]==="+"||Z[_]==="-"))_++;while(_<Z.length&&/\d/.test(Z[_]))_++}H=!0,Y=_;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y<Z.length&&Z[Y]==="{")return{type:m0(Z.slice(Q,_).trim()),endPos:_};if(Z[Y]!=="|"&&Z[Y]!=="&")return{type:m0(Z.slice(Q,_).trim()),endPos:_};continue}if(J===0&&/[a-zA-Z_]/.test(z)){let _=Y;while(_<Z.length&&/\w/.test(Z[_]))_++;H=!0,Y=_;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y<Z.length&&Z[Y]==="("){J++,Y++;continue}if(Y<Z.length&&Z[Y]==="{"){if(!Z.slice(Y+1).match(/^\s*(\w+)\s*:/)){let R=_;while(R>Q&&/\s/.test(Z[R-1]))R--;return{type:m0(Z.slice(Q,R).trim()),endPos:_}}}if(Z[Y]!=="|"&&Z[Y]!=="&")return{type:m0(Z.slice(Q,_).trim()),endPos:_};continue}Y++}if(H)return W(Y);return null}function _1(Z){let Q=[],Y="",J=0,X=!1,K=!1,H=0;while(H<Z.length){let W=Z[H],z=Z[H+1];if(!K&&W==="/"&&z==="/"){X=!0,Y+="//",H+=2;continue}if(!X&&W==="/"&&z==="*"){K=!0,Y+="/*",H+=2;continue}if(X&&W===`
15
- `){X=!1,Y+=W,H++;continue}if(K&&W==="*"&&z==="/"){K=!1,Y+="*/",H+=2;continue}if(X||K){Y+=W,H++;continue}if(W==="("||W==="{"||W==="[")J++,Y+=W;else if(W===")"||W==="}"||W==="]")J--,Y+=W;else if(W===","&&J===0)Q.push(Y),Y="";else Y+=W;H++}if(Y.trim())Q.push(Y);return Q}function g1(Z,Q,Y){let J=G1(Z,{originalSource:Z,requiredParams:Q.requiredParams,unsafeFunctions:Q.unsafeFunctions,safeFunctions:Q.safeFunctions}).source,X=_1(J),K=!1,H=new Set,W=(_)=>{if(Y&&/^\w+$/.test(_)){if(H.has(_))throw Error(`Duplicate parameter name '${_}'`);H.add(_)}};return X.map((_)=>{let q=_.trim();if(!q)return _;if(Y&&q.startsWith("{")&&q.endsWith("}")){let U=q.slice(1,-1);return`{ ${x8(U,Q)} }`}if(Y&&q.startsWith("[")&&q.endsWith("]")){let U=q.slice(1,-1);return`[ ${x8(U,Q)} ]`}if(q.startsWith("...")){let U=m8(q);if(U!==-1)return q.slice(0,U).trim();return _}let R=q.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(R){let[,U,O]=R;return W(U),K=!0,`${U} = ${O}`}if(!D6(q)){let U=q.match(/^(\w+)\s*=/);if(U)W(U[1]);return K=!0,_}let F=m8(q);if(F!==-1){let U=q.slice(0,F).trim(),O=q.slice(F+1).trim();if(W(U),K&&Y&&/^\w+$/.test(U));if(Y&&/^\w+$/.test(U))Q.requiredParams.add(U);return`${U} = ${O}`}return _}).join(",")}function x8(Z,Q){return _1(Z).map((X)=>{let K=X.trim();if(!K)return X;let H=K.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(H){let[,_,q]=H;Q.requiredParams.add(_);let R=W1(q);return`${_} = ${R}`}let W=K.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(W){let[,_,q]=W;Q.requiredParams.add(_);let R=z1(q);return`${_} = ${R}`}let z=K.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(z){let[,_,q]=z;return Q.requiredParams.add(_),`${_} = ${q}`}return X}).join(", ")}function W1(Z){let Q=Z.slice(1,-1).trim();return`{ ${_1(Q).map((X)=>{let K=X.trim();if(!K)return X;let H=K.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(H){let[,R,F]=H;return`${R}: ${W1(F)}`}let W=K.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(W){let[,R,F]=W;return`${R}: ${W1(F)}`}let z=K.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(z){let[,R,F]=z;return`${R}: ${z1(F)}`}let _=K.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(_){let[,R,F]=_;return`${R}: ${z1(F)}`}let q=K.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(q){let[,R,F]=q;return`${R}: ${F}`}return X}).join(", ")} }`}function z1(Z){let Q=Z.slice(1,-1).trim();return`[ ${_1(Q).map((X)=>{let K=X.trim();if(!K)return X;if(K.startsWith("{")&&K.endsWith("}"))return W1(K);if(K.startsWith("[")&&K.endsWith("]"))return z1(K);return X}).join(", ")} ]`}function D6(Z){let Q=0,Y=!1,J=!1,X=!1,K="";for(let H=0;H<Z.length;H++){let W=Z[H];if(!X&&(W==="'"||W==='"'||W==="`")){X=!0,K=W;continue}if(X){if(W===K&&Z[H-1]!=="\\")X=!1;continue}if(W==="("||W==="{"||W==="[")Q++;else if(W===")"||W==="}"||W==="]")Q--;else if(Q===0){if(W===":")Y=!0;if(W==="="&&Z[H+1]!==">")J=!0}}return Y&&!J}function m8(Z){let Q=0,Y=!1,J="";for(let X=0;X<Z.length;X++){let K=Z[X];if(!Y&&(K==="'"||K==='"'||K==="`")){Y=!0,J=K;continue}if(Y){if(K===J&&Z[X-1]!=="\\")Y=!1;continue}if(K==="("||K==="{"||K==="[")Q++;else if(K===")"||K==="}"||K==="]")Q--;else if(Q===0&&K===":")return X}return-1}function T6(Z,Q){let Y=Z.match(Q);if(!Y)return null;let J=Y.index+Y[0].length-1,X=1,K=J+1;while(K<Z.length&&X>0){if(Z[K]==="{")X++;else if(Z[K]==="}")X--;K++}if(X!==0)return null;let H=Z.slice(J,K),W=[Y[0].slice(0,-1)+H,H];return W.index=Y.index,W}function n8(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\btry\s*\{/);if(J){let K=Y+J[0].length-1+1,H=1,W=K;while(W<Z.length&&H>0){let _=Z[W];if(_==="{")H++;else if(_==="}")H--;W++}if(H!==0){Q+=Z[Y],Y++;continue}if(Z.slice(W).match(/^\s*(catch|finally)\b/))Q+=Z.slice(Y,W),Y=W;else{let _=Z.slice(K,W-1);Q+=`try {${_}} catch (__try_err) { return new (__tjs?.MonadicError ?? Error)(__try_err?.message || String(__try_err), 'try', undefined, undefined, __tjs?.getStack?.()) }`,Y=W}}else Q+=Z[Y],Y++}return Q}function c8(Z){let Q=[],Y="",J=0,X=0;while(J<Z.length){let K=Z.slice(J).match(/^\bwasm\s*\{/);if(K){let H=J,W=J+K[0].length,z=1,_=W;while(_<Z.length&&z>0){let w=Z[_];if(w==="{")z++;else if(w==="}")z--;_++}if(z!==0){Y+=Z[J],J++;continue}let q=Z.slice(W,_-1),R,F=_,U=Z.slice(_).match(/^\s*fallback\s*\{/);if(U){let w=_+U[0].length;z=1;let T=w;while(T<Z.length&&z>0){let S=Z[T];if(S==="{")z++;else if(S==="}")z--;T++}if(z===0)R=Z.slice(w,T-1),F=T}let L=P6(q).map((w)=>{let T=S6(Z,H,w);return T?`${w}: ${T}`:w}),B={id:`__tjs_wasm_${X}`,body:q,fallback:R,captures:L,start:H,end:F};Q.push(B);let N=R??q,A=L.map((w)=>w.split(":")[0].trim()),I=A.length>0?A.join(", "):"",j=A.length>0?`globalThis.${B.id}(${I})`:`globalThis.${B.id}()`,C=`(globalThis.${B.id} ? ${j} : (() => {${N}})())`;Y+=C,J=F,X++}else Y+=Z[J],J++}return{source:Y,blocks:Q}}function C6(Z){return Z.startsWith("f32x4_")||Z.startsWith("v128_")}function P6(Z){let Q=Z.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),Y=new Set,J=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,X;while((X=J.exec(Q))!==null)Y.add(X[1]);let K=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,H=new Set;while((X=K.exec(Q))!==null)H.add(X[1]);for(let F of Y){if(!H.has(F))continue;let U=new RegExp(`(?<!\\.)\\b${F}\\b`,"g"),O=new RegExp(`\\.${F}\\b`,"g"),L=Q.match(U)?.length||0,B=Q.match(O)?.length||0;if(L<=B)H.delete(F)}let W=new Set,z=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;while((X=z.exec(Q))!==null)W.add(X[1]);let _=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;while((X=_.exec(Q))!==null)W.add(X[1]);let q=new Set(["if","else","for","while","do","switch","case","break","continue","return","function","let","const","var","new","this","true","false","null","undefined","typeof","instanceof","in","of","try","catch","finally","throw","async","await","class","extends","super","import","export","default","from","as","static","get","set","yield","console","Math","Array","Object","String","Number","Boolean","Date","JSON","Promise","Map","Set","WeakMap","WeakSet","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","ArrayBuffer","DataView","Error","TypeError","RangeError","length","push","pop","shift","unshift","slice","splice","map","filter","reduce","forEach","find","findIndex","indexOf","includes","globalThis","window","document","Infinity","NaN","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","eval","wasmBuffer"]),R=[];for(let F of H)if(!W.has(F)&&!q.has(F)&&!C6(F))R.push(F);return R.sort()}function S6(Z,Q,Y){let J=Z.slice(0,Q),X=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,K=J.match(X);if(!K){let H=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,W=J.match(H);if(!W)return;return d8(W[1],Y)}return d8(K[1],Y)}function d8(Z,Q){let Y=Z.split(",").map((J)=>J.trim());for(let J of Y){let X=J.match(new RegExp(`^${Q}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(X)return X[1];let K=J.match(new RegExp(`^${Q}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(K)return K[1]}return}function o8(Z){let Y=new RegExp(`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")\\s+IsNot\\s+([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,"g");Z=Z.replace(Y,"IsNot($1, $2)");let J=new RegExp(`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")\\s+Is\\s+([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,"g");return Z=Z.replace(J,"Is($1, $2)"),Z}function a8(Z){let Q=/^[\s]*[([/+\-`]/,Y=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,J=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,X=Z.split(`
16
- `),K=[],H=!1;for(let W=0;W<X.length;W++){let z=X[W],_=W>0?X[W-1]:"";if(H){if(K.push(z),z.includes("*/"))H=!1;continue}let q=z.indexOf("/*"),R=z.indexOf("*/");if(q!==-1&&(R===-1||R<q)){H=!0,K.push(z);continue}if(W>0&&Q.test(z)){let F=_.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!Y.test(F)&&!J.test(F)){let U=z.match(/^(\s*)/),O=U?U[1]:"",L=z.slice(O.length);K.push(O+";"+L);continue}}K.push(z)}return K.join(`
17
- `)}function s8(Z){Z=Z.replace(/\btypeof\s+([a-zA-Z_$][\w$.]*(?:\?\.[\w$]+)*)/g,"TypeOf($1)");let Q=[],Y=0,J="normal",X=[];while(Y<Z.length){let H=Z[Y],W=Z[Y+1];switch(J){case"single-string":if(H==="\\"&&Y+1<Z.length){Y+=2;continue}if(H==="'")J="normal";Y++;continue;case"double-string":if(H==="\\"&&Y+1<Z.length){Y+=2;continue}if(H==='"')J="normal";Y++;continue;case"template-string":if(H==="\\"&&Y+1<Z.length){Y+=2;continue}if(H==="$"&&W==="{"){Y+=2,X.push(1),J="normal";continue}if(H==="`")J="normal";Y++;continue;case"line-comment":if(H===`
18
- `)J="normal";Y++;continue;case"block-comment":if(H==="*"&&W==="/"){Y+=2,J="normal";continue}Y++;continue;case"regex":if(H==="\\"&&Y+1<Z.length){Y+=2;continue}if(H==="["){Y++;while(Y<Z.length&&Z[Y]!=="]")if(Z[Y]==="\\"&&Y+1<Z.length)Y+=2;else Y++;if(Y<Z.length)Y++;continue}if(H==="/"){Y++;while(Y<Z.length&&/[gimsuy]/.test(Z[Y]))Y++;J="normal";continue}Y++;continue;case"normal":if(X.length>0){if(H==="{")X[X.length-1]++;else if(H==="}"){if(X[X.length-1]--,X[X.length-1]===0){X.pop(),Y++,J="template-string";continue}}}if(H==="'"){Y++,J="single-string";continue}if(H==='"'){Y++,J="double-string";continue}if(H==="`"){Y++,J="template-string";continue}if(H==="/"&&W==="/"){Y+=2,J="line-comment";continue}if(H==="/"&&W==="*"){Y+=2,J="block-comment";continue}if(H==="/"){let z=Y-1;while(z>=0&&/\s/.test(Z[z]))z--;let _=z>=0?Z[z]:"";if(!_||/[=(!,;:{[&|?+\-*%<>~^]/.test(_)||z>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(Z.slice(Math.max(0,z-10),z+1))){Y++,J="regex";continue}}if(H==="="&&W==="="&&Z[Y+2]!=="="&&Z[Y-1]!=="!"){Q.push({pos:Y,op:"=="}),Y+=2;continue}if(H==="!"&&W==="="&&Z[Y+2]!=="="){Q.push({pos:Y,op:"!="}),Y+=2;continue}break}Y++}if(Q.length===0)return Z;let K=Z;for(let H=Q.length-1;H>=0;H--){let{pos:W,op:z}=Q[H],_=z==="=="?"Eq":"NotEq",q=b6(K,W),R=E6(K,W+2),F=K.slice(q,W).trim(),U=K.slice(W+2,R).trim();if(F&&U){let O=K.slice(0,q),L=K.slice(R),N=/[a-zA-Z0-9_$]$/.test(O)?" ":"";K=`${O}${N}${_}(${F}, ${U})${L}`}}return K}function b6(Z,Q){let Y=Q-1;while(Y>=0&&/\s/.test(Z[Y]))Y--;if(Y<0)return 0;let J=0,X=!1,K="";while(Y>=0){let H=Z[Y],W=Y>0?Z[Y-1]:"";if(X){if(H===K&&W!=="\\")X=!1;Y--;continue}if((H==='"'||H==="'"||H==="`")&&W!=="\\"){X=!0,K=H,Y--;continue}if(H===")"||H==="]"||H==="}"){J++,Y--;continue}if(H==="("||H==="["){if(J>0){J--,Y--;continue}return Y+1}if(H==="{"){if(J>0){J--,Y--;continue}return Y+1}if(J>0){Y--;continue}if(H===";")return Y+1;if(/[a-z]/.test(H)){let z=Y+1,_=Y;while(_>0&&/[a-z]/i.test(Z[_-1]))_--;let q=Z.slice(_,z),R=_>0?Z[_-1]:"";if(!/[a-zA-Z0-9_$]/.test(R)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(q))return z;if(q==="new")return _}}if(H===">"&&W==="=")return Y+1;if(H==="="&&W!=="="&&W!=="!"&&W!=="<"&&W!==">")return Y+1;if(H==="&"&&W==="&")return Y+1;if(H==="|"&&W==="|")return Y+1;if(H==="?"||H===":")return Y+1;if(H===",")return Y+1;Y--}return 0}function E6(Z,Q){let Y=Q;while(Y<Z.length&&/\s/.test(Z[Y]))Y++;if(Y>=Z.length)return Z.length;let J=0,X=!1,K="";while(Y<Z.length){let H=Z[Y],W=Y+1<Z.length?Z[Y+1]:"";if(X){if(H===K&&Z[Y-1]!=="\\")X=!1;Y++;continue}if((H==='"'||H==="'"||H==="`")&&Z[Y-1]!=="\\"){X=!0,K=H,Y++;continue}if(H==="("||H==="["||H==="{"){J++,Y++;continue}if(H===")"||H==="]"||H==="}"){if(J>0){J--,Y++;continue}return Y}if(J>0){Y++;continue}if(H===";")return Y;if(H==="&"&&W==="&")return Y;if(H==="|"&&W==="|")return Y;if(H==="?")return Y;if(H===":")return Y;if(H===",")return Y;if((H==="="||H==="!")&&W==="="&&Z[Y+2]!=="=")return Y;Y++}return Z.length}function r8(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(J){let X=J[1],K=Y+J[0].length,H=X,W=!1,z=Z.slice(K).match(/^(['"`])([^]*?)\1\s*/);if(z){let F=K+z[0].length,U=Z[F],O=U===void 0||F>=Z.length||U!=="="&&U!=="{";if(U==="="||U==="{")H=z[2],W=!0,K=F;else if(O){let L=z[0].trim(),B=z[0].slice(L.length);Q+=`const ${X} = Type('${X}', ${L})${B}`,Y=F;continue}}let _,q=K,R=Z.slice(K).match(/^=\s*/);if(R){K+=R[0].length;let F=Z.slice(K).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(F){_=F[0],K+=F[0].length,q=K;let U=Z.slice(K).match(/^\s*/);if(U)K+=U[0].length}}if(Z[K]==="{"){let F=K+1,U=1,O=F;while(O<Z.length&&U>0){let C=Z[O];if(C==="{")U++;else if(C==="}")U--;O++}if(U!==0){Q+=Z[Y],Y++;continue}let L=Z.slice(F,O-1).trim(),B=O,N=L.match(/description\s*:\s*(['"`])([^]*?)\1/);if(N&&!W)H=N[2];let A,I=L.match(/example\s*:\s*/);if(I){let C=I.index+I[0].length,w=u8(L,C);if(w)A=w.value.trim()}let j=L.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(j&&A){let C=j[1].trim(),w=j[2].trim(),T=_?`, ${_}`:"";Q+=`const ${X} = Type('${H}', (${C}) => { if (!globalThis.__tjs?.validate(${C}, globalThis.__tjs?.infer(${A}))) return false; ${w} }, ${A}${T})`}else if(j){let C=j[1].trim(),w=j[2].trim(),T=_?`, undefined, ${_}`:"";Q+=`const ${X} = Type('${H}', (${C}) => { ${w} }${T})`}else if(A){let C=_?`, ${_}`:"";Q+=`const ${X} = Type('${H}', undefined, ${A}${C})`}else if(_)Q+=`const ${X} = Type('${H}', ${_})`;else Q+=`const ${X} = Type('${H}')`;Y=B;continue}else if(_){Q+=`const ${X} = Type('${H}', ${_})`,Y=q;continue}else if(!z){let F=Z.slice(K).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(F){let U=F[0];Q+=`const ${X} = Type('${X}', ${U})`,Y=K+F[0].length;continue}}}Q+=Z[Y],Y++}return Q}function t8(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(J){let X=J[1],K=J[2],H=Y+J[0].length;if(Z[H]==="{"){let W=1,z=H+1;while(z<Z.length&&W>0){if(Z[z]==="{")W++;else if(Z[z]==="}")W--;z++}if(W===0){let _=Z.slice(H+1,z-1).trim(),q=T6(_,/params\s*:\s*\{/),R=_.match(/returns\s*:\s*(.+?)(?:\n|$)/),F=_.match(/returnContract\s*:\s*['"](\w+)['"]/),U=_.match(/description\s*:\s*(['"])([^]*?)\1/),O=[];if(q)O.push(`params: ${q[1]}`);if(R)O.push(`returns: ${R[1].trim()}`);if(F)O.push(`returnContract: '${F[1]}'`);let L=U?U[2]:X;if(K){let B=K.split(",").map((A)=>{let I=A.trim().split("=").map((j)=>j.trim());if(I.length===2){let j=I[1]==="any"||I[1]==="undefined"?"null":I[1];return`['${I[0]}', ${j}]`}return`'${I[0]}'`}),N=K.split(",").map((A)=>A.trim().split("=")[0].trim());Q+=`const ${X} = FunctionPredicate('${L}', [${B.join(", ")}], (${N.join(", ")}) => ({ ${O.join(", ")} }))`}else Q+=`const ${X} = FunctionPredicate('${L}', { ${O.join(", ")} })`;Y=z;continue}}if(Z[H]==="("){let W=1,z=H+1;while(z<Z.length&&W>0){if(Z[z]==="(")W++;else if(Z[z]===")")W--;z++}if(W===0){let _=Z.slice(H+1,z-1).trim(),q=_.indexOf(",");if(q!==-1){let R=_.slice(0,q).trim(),F=_.slice(q+1).trim();Q+=`const ${X} = FunctionPredicate(${F}, ${R})`}else Q+=`const ${X} = FunctionPredicate('${X}', ${_})`;Y=z;continue}}}Q+=Z[Y],Y++}return Q}function e8(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(J){let X=J[1],K=J[2],W=Y+J[0].length-1+1,z=1,_=W;while(_<Z.length&&z>0){let A=Z[_];if(A==="{")z++;else if(A==="}")z--;_++}if(z!==0){Q+=Z[Y],Y++;continue}let q=Z.slice(W,_-1).trim(),R=_,F=K.split(",").map((A)=>{let I=A.trim().split("=").map((j)=>j.trim());if(I.length===2){let j=I[1]==="any"||I[1]==="undefined"?"null":I[1];return`['${I[0]}', ${j}]`}return`'${I[0]}'`}),U=q,O=U.search(/\bdeclaration\s*\{/);if(O!==-1){let A=U.indexOf("{",O),I=1,j=A+1;while(j<U.length&&I>0){if(U[j]==="{")I++;else if(U[j]==="}")I--;j++}U=U.slice(0,O)+U.slice(j)}let L=U.match(/description\s*:\s*(['"`])([^]*?)\1/),B=U.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),N=L?L[2]:X;if(B){let A=B[1].trim().split(",").map((T)=>T.trim()),I=B[2].trim(),j=A[0]||"x",C=A.slice(1),w=C.map((T)=>`check${T}`);C.forEach((T,S)=>{I=I.replace(new RegExp(`\\b${T}\\s*\\(`,"g"),`${w[S]}(`)}),Q+=`const ${X} = Generic([${F.join(", ")}], (${j}, ${w.join(", ")}) => { ${I} }, '${N}')`}else Q+=`const ${X} = Generic([${F.join(", ")}], () => true, '${N}')`;Y=R;continue}Q+=Z[Y],Y++}return Q}function Z9(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(J){let X=J[1],K=J[3],H=Y+J[0].length;if(Z[H]==="{"){let W=H+1,z=1,_=W;while(_<Z.length&&z>0){let U=Z[_];if(U==="{")z++;else if(U==="}")z--;_++}if(z!==0){Q+=Z[Y],Y++;continue}let q=Z.slice(W,_-1).trim(),R=_,F=l8(q);Q+=`const ${X} = Union('${K}', [${F.join(", ")}])`,Y=R;continue}else{let W=Z.indexOf(`
19
- `,H);if(W===-1)W=Z.length;let z=Z.slice(H,W).trim();if(z){let _=l8(z);Q+=`const ${X} = Union('${K}', [${_.join(", ")}])`,Y=W;continue}}}Q+=Z[Y],Y++}return Q}function l8(Z){let Q=[],Y=Z.split("|").map((J)=>J.trim());for(let J of Y){if(!J)continue;Q.push(J)}return Q}function Q9(Z){let Q="",Y=0;while(Y<Z.length){let J=Z.slice(Y).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(J){let X=J[1],K=J[3],W=Y+J[0].length-1+1,z=1,_=W;while(_<Z.length&&z>0){let O=Z[_];if(O==="{")z++;else if(O==="}")z--;_++}if(z!==0){Q+=Z[Y],Y++;continue}let q=Z.slice(W,_-1).trim(),R=_,U=v6(q).map(([O,L])=>`${O}: ${L}`).join(", ");Q+=`const ${X} = Enum('${K}', { ${U} })`,Y=R;continue}Q+=Z[Y],Y++}return Q}function v6(Z){let Q=[],Y=0,J=Z.split(/[\n,]/).map((X)=>X.trim()).filter((X)=>X&&!X.startsWith("//"));for(let X of J){let K=X.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(K){let H=K[1],W=K[2]?.trim();if(W!==void 0){Q.push([H,W]);let z=Number(W);if(!isNaN(z))Y=z+1}else Q.push([H,String(Y)]),Y++}}return Q}function Y9(Z){let Q=new Map,Y="",J=0;while(J<Z.length){let X=Z.slice(J),K=X.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!K){if(J===0||Z[J-1]===`
20
- `||Z[J-1]===";"||Z[J-1]==="}"){let I=X.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}Y+=Z[J],J++;continue}let H=K[1],W=K[2],z=J+K[0].length-1,_=d0(Z,z),q=Z.slice(z+1,_-1).trim(),R=[],F=0,U=Z.slice(z+1,_-1);while(F<U.length){let I=U.slice(F).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!I){F++;continue}let j=I[1],C=!!I[2],w=I[3],T=F+I[0].length-1,S=1,b=T+1;while(b<U.length&&S>0){if(U[b]==="(")S++;if(U[b]===")")S--;b++}let y=U.slice(T+1,b-1),h=b;while(h<U.length&&/\s/.test(U[h]))h++;if(U[h]==="="&&U[h+1]===">"){let M0=u0(Z,z+1+F);throw new Z0(`Arrow functions are not allowed in extend blocks (method '${w}' in extend ${W}). Use regular function syntax instead, as extension methods need 'this' binding.`,M0)}if(U[h]!=="{"){F++;continue}let x=d0(U,h),o=U.slice(F,x).trim(),B0=y.split(",").map((M0)=>M0.trim()).filter((M0)=>M0.length>0).map((M0)=>{let $1=M0.match(/^(\w+)\s*:\s*(.+)$/);if($1)return`${$1[1]} = ${$1[2]}`;return M0}).join(", "),A0=C?"async ":"",S9=U.slice(h+1,x-1);R.push({name:w,isAsync:C,fullText:`${w}: ${A0}function(${B0}) {${S9}}`}),F=x}let O=!Q.has(W);if(O)Q.set(W,new Set);let L=Q.get(W);for(let A of R)L.add(A.name);let B=R.map((A)=>` ${A.fullText}`).join(`,
21
- `),N;if(O)N=`${H}const __ext_${W} = {
22
- ${B}
23
- ${H}}
24
- `;else N=`${H}Object.assign(__ext_${W}, {
25
- ${B}
26
- ${H}})
27
- `;for(let A of R)N+=`${H}if (__tjs?.registerExtension) { __tjs.registerExtension('${W}', '${A.name}', __ext_${W}.${A.name}) }
28
- `;Y+=N,J=_}if(J<=Z.length&&Y.length<Z.length);return{source:Y,extensions:Q}}function J9(Z,Q){if(Q.size===0)return Z;let Y=new Map;for(let[X,K]of Q)for(let H of K){if(!Y.has(H))Y.set(H,[]);Y.get(H).push(X)}let J=Z;for(let[X,K]of Y){if(!K.includes("String"))continue;let H=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${X})\\((\\))?`,"g");J=J.replace(H,(_,q,R,F)=>{return F?`__ext_String.${R}.call(${q})`:`__ext_String.${R}.call(${q}, `});let W=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${X})\\((\\))?`,"g");J=J.replace(W,(_,q,R,F)=>{return F?`__ext_String.${R}.call(${q})`:`__ext_String.${R}.call(${q}, `});let z=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+X+"\\((\\))?","g");J=J.replace(z,(_,q,R)=>{return R?`__ext_String.${X}.call(${q})`:`__ext_String.${X}.call(${q}, `})}for(let[X,K]of Y){if(!K.includes("Array"))continue;let H=`].${X}(`,W=0,z;while((z=J.indexOf(H,W))!==-1){let _=1,q=z-1,R=!1;while(q>=0&&_>0){let F=J[q];if(R){if(F===R&&(q===0||J[q-1]!=="\\"))R=!1}else{if(F==="]")_++;if(F==="[")_--;if(F==="'"||F==='"'||F==="`")R=F}q--}if(_===0){let F=J.slice(q+1,z+1),U=J.slice(0,q+1),O=J.slice(z+H.length);if(O[0]===")")J=`${U}__ext_Array.${X}.call(${F})${O.slice(1)}`;else J=`${U}__ext_Array.${X}.call(${F}, ${O}`}W=z+1}}for(let[X,K]of Y){if(!K.includes("Number"))continue;let H=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${X})\\((\\))?`,"g");J=J.replace(H,(W,z,_,q)=>{return q?`__ext_Number.${_}.call(${z})`:`__ext_Number.${_}.call(${z}, `})}return J}function u0(Z,Q){let Y=1,J=0;for(let X=0;X<Q&&X<Z.length;X++)if(Z[X]===`
29
- `)Y++,J=0;else J++;return{line:Y,column:J}}function X9(Z,Q){let Y=Q.trim();if(/^['"`]/.test(Y))return`typeof ${Z} === 'string'`;if(Y==="true"||Y==="false")return`typeof ${Z} === 'boolean'`;if(Y==="null")return`${Z} === null`;if(Y==="undefined")return`${Z} === undefined`;if(Y.startsWith("["))return`Array.isArray(${Z})`;if(Y.startsWith("{"))return`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}))`;if(/^\+\d+/.test(Y))return`(typeof ${Z} === 'number' && Number.isInteger(${Z}) && ${Z} >= 0)`;if(/^-?\d+\.\d+/.test(Y))return`typeof ${Z} === 'number'`;if(/^-?\d+$/.test(Y))return`(typeof ${Z} === 'number' && Number.isInteger(${Z}))`;return"true"}function q1(Z){let Q=Z.trim();if(/^['"`]/.test(Q))return"string";if(Q==="true"||Q==="false")return"boolean";if(Q==="null")return"null";if(Q==="undefined")return"undefined";if(Q.startsWith("["))return"array";if(Q.startsWith("{"))return"object";if(/^\+\d+/.test(Q))return"non-negative-integer";if(/^-?\d+\.\d+/.test(Q))return"number";if(/^-?\d+$/.test(Q))return"integer";return"any"}function y1(Z,Q){let Y=[],J=0,X="",K=!1;for(let W=0;W<Z.length;W++){let z=Z[W];if(!K&&(z==="'"||z==='"'||z==="`")){K=z,X+=z;continue}if(K){if(X+=z,z==="\\"){if(W++,W<Z.length)X+=Z[W];continue}if(z===K)K=!1;continue}if(z==="("||z==="["||z==="{"){J++,X+=z;continue}if(z===")"||z==="]"||z==="}"){J--,X+=z;continue}if(z===","&&J===0){let _=p8(X.trim(),Q);if(_)Y.push(_);X="";continue}X+=z}let H=X.trim();if(H){let W=p8(H,Q);if(W)Y.push(W)}return Y}function p8(Z,Q){let Y=Z.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(Y.startsWith("..."))return null;let J=Y.indexOf("=");if(J===-1)return{name:Y.trim(),defaultValue:"",required:!0};let X=Y.slice(0,J).trim(),K=Y.slice(J+1).trim();return{name:X,defaultValue:K,required:Q.has(X)}}function d0(Z,Q){let Y=1,J=Q+1,X=!1,K=!1,H=!1;while(J<Z.length&&Y>0){let W=Z[J],z=J+1<Z.length?Z[J+1]:"";if(K){if(W===`
30
- `)K=!1;J++;continue}if(H){if(W==="*"&&z==="/"){H=!1,J+=2;continue}J++;continue}if(X){if(W==="\\"){J+=2;continue}if(W===X)X=!1;J++;continue}if(W==="/"&&z==="/"){K=!0,J+=2;continue}if(W==="/"&&z==="*"){H=!0,J+=2;continue}if(W==="'"||W==='"'||W==="`"){X=W,J++;continue}if(W==="{")Y++;if(W==="}")Y--;J++}return J}function K9(Z,Q){let Y=new Set,J=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,X=new Map,K,H=[];while((K=J.exec(Z))!==null){let R=!!K[1],F=!!K[2],U=K[3],O=K.index,L=O,N=K[0].indexOf("function");if(N>=0)L=O+N;H.push({name:U,fullMatchStart:O,funcKeywordStart:L,exported:R,isAsync:F})}for(let R of H)if(!X.has(R.name))X.set(R.name,[]);let W=new Map;for(let R of H)W.set(R.name,(W.get(R.name)||0)+1);let z=new Set;for(let[R,F]of W)if(F>1)z.add(R);if(z.size===0)return{source:Z,polymorphicNames:Y};for(let R of H){if(!z.has(R.name))continue;let F=Z.indexOf("(",R.funcKeywordStart);if(F===-1)continue;let U=1,O=F+1;while(O<Z.length&&U>0){if(Z[O]==="(")U++;if(Z[O]===")")U--;O++}let L=O-1,B=Z.slice(F+1,L),N=O;while(N<Z.length&&Z[N]!=="{")N++;if(N>=Z.length)continue;let A=d0(Z,N),I=R.fullMatchStart;while(I>0&&Z[I-1]===" ")I--;let j=X.get(R.name),C=y1(B,Q);if(B.includes("...")){let T=u0(Z,R.funcKeywordStart);throw new Z0(`Rest parameters are not supported in polymorphic function '${R.name}'. Use separate function names instead.`,T)}j.push({index:j.length+1,start:I,end:A,text:Z.slice(I,A),exported:R.exported,isAsync:R.isAsync,params:C})}for(let[R,F]of X){if(F.length<2)continue;let U=F.filter((O)=>O.isAsync).length;if(U>0&&U<F.length){let O=u0(Z,F[0].start);throw new Z0(`Polymorphic function '${R}': all variants must be either sync or async, not mixed.`,O)}for(let O=0;O<F.length;O++)for(let L=O+1;L<F.length;L++){let B=F[O],N=F[L];if(B.params.length!==N.params.length)continue;let A=!0;for(let I=0;I<B.params.length;I++){let j=B.params[I].defaultValue?q1(B.params[I].defaultValue):"any",C=N.params[I].defaultValue?q1(N.params[I].defaultValue):"any";if(j!==C){A=!1;break}}if(A){let I=u0(Z,N.start);throw new Z0(`Polymorphic function '${R}': variants ${O+1} and ${L+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,I)}}}let _=[];for(let[R,F]of X){if(F.length<2)continue;for(let U of F)_.push({name:R,variant:U})}_.sort((R,F)=>F.variant.start-R.variant.start);let q=Z;for(let{name:R,variant:F}of _){let U=F.isAsync?"async ":"",O=F.text.replace(new RegExp(`(?:export\\s+)?${U?U.replace(/\s+$/,"\\s+"):""}function\\s+${R}\\s*\\(`),`${U}function ${R}$$${F.index}(`);q=q.slice(0,F.start)+O+q.slice(F.end)}for(let[R,F]of X){if(F.length<2)continue;Y.add(R);let U=F[0].isAsync,O=F.some((j)=>j.exported),L=U?"async ":"",B=O?"export ":"",N=[...F].sort((j,C)=>{if(j.params.length!==C.params.length)return 0;let w=0,T=0;for(let S of j.params){let b=S.defaultValue?q1(S.defaultValue):"any";if(b==="non-negative-integer")w+=3;else if(b==="integer")w+=2;else if(b!=="any")w+=1}for(let S of C.params){let b=S.defaultValue?q1(S.defaultValue):"any";if(b==="non-negative-integer")T+=3;else if(b==="integer")T+=2;else if(b!=="any")T+=1}return T-w}),A=[];for(let j of N){let C=[`__args.length === ${j.params.length}`],w=[];for(let T=0;T<j.params.length;T++){let S=j.params[T];if(w.push(`__args[${T}]`),S.defaultValue){let b=X9(`__args[${T}]`,S.defaultValue);if(b!=="true")C.push(b)}}A.push(` if (${C.join(" && ")}) return ${R}$${j.index}(${w.join(", ")})`)}let I=`
31
- ${B}${L}function ${R}(...__args) {
32
- ${A.join(`
1
+ import{s as h,validate as ht,filter as qt}from"tosijs-schema";var We=Symbol.for("tjs.equals");function Ge(e,t){if(e!==null&&typeof e=="object"&&typeof e[We]=="function")return e[We](t);if(t!==null&&typeof t=="object"&&typeof t[We]=="function")return t[We](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if(e===t||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,i)=>Ge(s,t[i]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>Ge(e[s],t[s]))}var K=class{$error=!0;message;op;cause;constructor(t,n,r){this.message=t,this.op=n,this.cause=r}toString(){return`AgentError[${this.op}]: ${this.message}`}toJSON(){return{$error:!0,message:this.message,op:this.op}}};function Mr(e){return e instanceof K||e&&e.$error===!0}var Te=new Map,$r=3600*1e3,Br=100*1024,dt="proc_";function mt(e){return typeof e=="string"&&e.startsWith(dt)}function gt(e){let t=Te.get(e);if(!t)throw new Error(`Procedure not found: ${e}`);if(Date.now()>t.expiresAt)throw Te.delete(e),new Error(`Procedure expired: ${e}`);return t.ast}function jr(){return typeof crypto<"u"&&crypto.randomUUID?dt+crypto.randomUUID():dt+Math.random().toString(36).slice(2)+Date.now().toString(36)}var Wt=new Set(["__proto__","constructor","prototype"]);function Ot(e){if(Wt.has(e))throw new Error(`Security Error: Access to '${e}' is forbidden`)}var Or=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","metadata.google.internal"]);function Vr(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return!0;let n=t.hostname.toLowerCase();return!!(Or.has(n)||n.endsWith(".internal")||n.endsWith(".local")||n==="169.254.169.254"||/^10\./.test(n)||/^192\.168\./.test(n)||/^172\.(1[6-9]|2\d|3[01])\./.test(n))}catch{return!0}}function Lr(e){return!!(/\([^)]*[+*][^)]*\)[+*]/.test(e)||/\(([^|)]+)\|\1\)[+*]/.test(e)||/\(\.\*\)\+/.test(e)||/\(\.\+\)\+/.test(e)||/\(\[.*\]\+\)\+/.test(e))}function xe(e){return{...e,state:Object.create(e.state)}}function Dr(e,t){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r){let i=e[s],a=t[s];a!==i&&(n[s]=a)}return n}function x(e,t){if(e&&typeof e=="object"&&e.$kind==="arg")return t.args[e.path];if(e&&typeof e=="object"&&e.$expr)return W(e,t);if(typeof e=="string"){if(e.startsWith("args.")&&!("args"in t.state))return t.args[e.replace("args.","")];if(e.includes(".")){let n=e.split(".");for(let s of n)if(Wt.has(s))throw new Error(`Security Error: Access to '${s}' is forbidden`);let r=t.state[n[0]];if(r!==void 0){for(let s=1;s<n.length;s++)r=r?.[n[s]];return r}}return e in t.state?t.state[e]:e}if(e&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object){let n={};for(let r of Object.keys(e))n[r]=x(e[r],t);return n}return Array.isArray(e)?e.map(n=>x(n,t)):e}function Ce(e,t,n){return new Proxy(t,{get(r,s){if(s in r)return r[s];let i=n?.[s];throw i?new Error(`${e}.${s} is not available. ${i}`):new Error(`${e}.${s} is not supported in AsyncJS. Check docs for available ${e} methods.`)}})}function _e(e){if(e===null)return{type:"null"};if(e===void 0)return{};if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e;if(typeof e=="object"&&e!==null&&"schema"in e&&typeof e.schema=="object")return e.schema;let t=typeof e;if(t==="string")return{type:"string"};if(t==="number")return Number.isInteger(e)?{type:"integer"}:{type:"number"};if(t==="boolean")return{type:"boolean"};if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:_e(e[0])};if(t==="object"){let n={},r=[];for(let[s,i]of Object.entries(e))n[s]=_e(i),r.push(s);return{type:"object",properties:n,required:r}}return{}}var he={Math:Ce("Math",{PI:Math.PI,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,SQRT2:Math.SQRT2,SQRT1_2:Math.SQRT1_2,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc,sign:Math.sign,sqrt:Math.sqrt,cbrt:Math.cbrt,pow:Math.pow,exp:Math.exp,expm1:Math.expm1,log:Math.log,log2:Math.log2,log10:Math.log10,log1p:Math.log1p,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,asinh:Math.asinh,acosh:Math.acosh,atanh:Math.atanh,hypot:Math.hypot,min:Math.min,max:Math.max,clz32:Math.clz32,imul:Math.imul,fround:Math.fround,random:()=>{if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]/4294967296}return Math.random()}}),JSON:Ce("JSON",{parse:e=>JSON.parse(e),stringify:(e,t,n)=>JSON.stringify(e,t,n)}),console:Ce("console",{log:(...e)=>{},warn:(...e)=>{},error:(...e)=>{},info:(...e)=>{}},{table:"Use console.log with JSON.stringify for structured data.",dir:"Use console.log instead.",trace:"Stack traces are not available in AsyncJS."}),Array:Ce("Array",{isArray:e=>Array.isArray(e),from:(e,t,n)=>Array.from(e,t,n),of:(...e)=>Array.of(...e)},{prototype:"Prototype access is not allowed."}),Object:Ce("Object",{keys:e=>Object.keys(e),values:e=>Object.values(e),entries:e=>Object.entries(e),fromEntries:e=>Object.fromEntries(e),assign:(e,...t)=>Object.assign({},e,...t),hasOwn:(e,t)=>Object.hasOwn(e,t)},{prototype:"Prototype access is not allowed.",create:"Use object literals instead.",defineProperty:"Property descriptors are not supported.",getPrototypeOf:"Prototype access is not allowed.",setPrototypeOf:"Prototype modification is not allowed."}),String:Ce("String",{fromCharCode:(...e)=>String.fromCharCode(...e),fromCodePoint:(...e)=>String.fromCodePoint(...e)}),Number:Ce("Number",{isNaN:Number.isNaN,isFinite:Number.isFinite,isInteger:Number.isInteger,isSafeInteger:Number.isSafeInteger,parseFloat,parseInt,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,NaN:Number.NaN,EPSILON:Number.EPSILON}),parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,undefined:void 0,null:null,NaN:NaN,Infinity:1/0,filter:(e,t)=>{let n=_e(t),r=qt(e,n);if(r instanceof Error)throw r;return r},Schema:{...h,response:(e,t)=>{let n=t?.schema!=null?t.schema:_e(t);return{type:"json_schema",json_schema:{name:e,strict:!0,schema:n}}},fromExample:e=>_e(e),isValid:(e,t)=>t?.schema!=null?ht(e,t):ht(e,_e(t))},Set:(e=[])=>{let t=[...new globalThis.Set(e)];return{add(n){return t.includes(n)||t.push(n),this},remove(n){let r=t.indexOf(n);return r!==-1&&t.splice(r,1),this},clear(){return t.length=0,this},has(n){return t.includes(n)},get size(){return t.length},toArray(){return[...t]},union(n){let r=n?.toArray?.()??n??[];return he.Set([...t,...r])},intersection(n){let r=n?.toArray?.()??n??[];return he.Set(t.filter(s=>r.includes(s)))},diff(n){let r=n?.toArray?.()??n??[];return he.Set(t.filter(s=>!r.includes(s)))},forEach(n){t.forEach(n)},map(n){return he.Set(t.map(n))},filter(n){return he.Set(t.filter(n))},toJSON(){return[...t]}}},Date:(()=>{let e=n=>({get value(){return n.toISOString()},get timestamp(){return n.getTime()},get year(){return n.getFullYear()},get month(){return n.getMonth()+1},get day(){return n.getDate()},get hours(){return n.getHours()},get minutes(){return n.getMinutes()},get seconds(){return n.getSeconds()},get dayOfWeek(){return n.getDay()},add({years:r=0,months:s=0,days:i=0,hours:a=0,minutes:o=0,seconds:u=0,ms:l=0}={}){let p=new globalThis.Date(n.getTime());return r&&p.setFullYear(p.getFullYear()+r),s&&p.setMonth(p.getMonth()+s),i&&p.setDate(p.getDate()+i),a&&p.setHours(p.getHours()+a),o&&p.setMinutes(p.getMinutes()+o),u&&p.setSeconds(p.getSeconds()+u),l&&p.setMilliseconds(p.getMilliseconds()+l),e(p)},diff(r,s="ms"){let i=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime(),a=n.getTime()-i;switch(s){case"seconds":return a/1e3;case"minutes":return a/6e4;case"hours":return a/36e5;case"days":return a/864e5;default:return a}},format(r="ISO"){return r==="ISO"?n.toISOString():r==="date"?n.toISOString().split("T")[0]:r==="time"?n.toISOString().split("T")[1].split(".")[0]:r.replace("YYYY",String(n.getFullYear())).replace("MM",String(n.getMonth()+1).padStart(2,"0")).replace("DD",String(n.getDate()).padStart(2,"0")).replace("HH",String(n.getHours()).padStart(2,"0")).replace("mm",String(n.getMinutes()).padStart(2,"0")).replace("ss",String(n.getSeconds()).padStart(2,"0"))},isBefore(r){let s=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime();return n.getTime()<s},isAfter(r){let s=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime();return n.getTime()>s},toString(){return n.toISOString()},toJSON(){return n.toISOString()}}),t=n=>{let r=n!==void 0?new globalThis.Date(n):new globalThis.Date;if(isNaN(r.getTime()))throw new Error(`Invalid date: ${n}`);return e(r)};return t.now=()=>globalThis.Date.now(),t.parse=n=>e(new globalThis.Date(n)),t})()},ze={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."},Fr=.01,Vt=1e-4,Lt=.001,Ur=new Set(["concat","slice","map","filter","flatMap","flat","toReversed","toSorted","toSpliced","repeat","padStart","padEnd","split","join","replace","replaceAll","substring","substr","trim","trimStart","trimEnd","toLowerCase","toUpperCase","match","matchAll","parse","stringify"]);function W(e,t){if(e==null||typeof e!="object"||!("$expr"in e))return e;if(t.fuel&&(t.fuel.current-=Fr,t.fuel.current<=0))throw new Error("Out of Fuel");switch(e.$expr){case"literal":return e.value;case"ident":{if(e.name in t.state)return t.state[e.name];if(e.name in t.args)return t.args[e.name];if(e.name in he)return he[e.name];if(e.name in ze)throw new Error(ze[e.name]);return}case"member":{let n=W(e.object,t);if(e.optional&&n==null)return;let r=e.property;return Ot(r),n?.[r]}case"binary":{let n=W(e.left,t),r=W(e.right,t);switch(e.op){case"+":{let s=n+r;if(typeof s=="string"&&t.fuel&&(t.fuel.current-=s.length*Vt,t.fuel.current<=0)){t.error=new K("Out of Fuel","expr.concat");return}return s}case"-":return n-r;case"*":return n*r;case"/":return n/r;case"%":return n%r;case"**":return n**r;case">":return n>r;case"<":return n<r;case">=":return n>=r;case"<=":return n<=r;case"==":return Ge(n,r);case"!=":return!Ge(n,r);case"===":return n===r;case"!==":return n!==r;default:throw new Error(`Unknown binary operator: ${e.op}`)}}case"unary":{let n=W(e.argument,t);switch(e.op){case"!":return!n;case"-":return-n;case"+":return+n;case"typeof":return typeof n;default:throw new Error(`Unknown unary operator: ${e.op}`)}}case"logical":{let n=W(e.left,t);return e.op==="&&"?n&&W(e.right,t):e.op==="??"?n??W(e.right,t):n||W(e.right,t)}case"conditional":{let n=W(e.test,t);return W(n?e.consequent:e.alternate,t)}case"array":return e.elements.map(n=>W(n,t));case"object":{let n={};for(let r of e.properties)n[r.key]=W(r.value,t);return n}case"call":{if(e.callee==="Error"){let r=e.arguments.map(i=>W(i,t)),s=typeof r[0]=="string"?r[0]:"Error";t.error=new K(s,"Error");return}if(e.callee in he){let r=he[e.callee];if(typeof r=="function"){let s=e.arguments.map(i=>W(i,t));return r(...s)}}throw t.resolver(e.callee)?new Error(`Atom calls in expressions not yet supported: ${e.callee}`):e.callee in ze?new Error(ze[e.callee]):new Error(`Unknown function: ${e.callee}`)}case"methodCall":{let n=W(e.object,t);if(e.optional&&n==null)return;let r=e.method;if(Ot(r),n==null)throw new Error(`Cannot call method '${r}' on ${n}`);let s=n[r];if(typeof s!="function")throw new Error(`'${r}' is not a function`);let i=e.arguments.map(o=>W(o,t)),a=s.apply(n,i);if(t.fuel&&Ur.has(r)){let o=0;if(typeof a=="string"?o=a.length*Vt:Array.isArray(a)?o=a.length*Lt:typeof a=="object"&&a!==null&&(o=Object.keys(a).length*Lt),t.fuel.current-=o,t.fuel.current<=0){t.error=new K("Out of Fuel",`expr.${r}`);return}}return a}default:throw new Error(`Unknown expression type: ${e.$expr}`)}}function I(e,t,n,r,s={}){let{docs:i="",timeoutMs:a=1e3,cost:o=1}=typeof s=="string"?{docs:s}:s;return{op:e,inputSchema:t,outputSchema:n,exec:async(l,p)=>{let{op:d,result:f,...m}=l;if(p.error)return;let g=p.trace?{...p.state}:null,v=p.fuel.current,b,w;try{let C=p.costOverrides?.[e],y=C!==void 0?C:o,S=typeof y=="function"?y(m,p):y;if((p.fuel.current-=S)<=0){p.error=new K("Out of Fuel",e);return}let T,E=async()=>r(l,p);if(b=a>0?await Promise.race([E(),new Promise((_,P)=>{T=setTimeout(()=>P(new Error(`Atom '${e}' timed out`)),a)})]).finally(()=>clearTimeout(T)):await E(),l.result){if(p.consts.has(l.result))throw new Error(`Cannot reassign const variable '${l.result}'`);if(b!==void 0&&n&&!ht(b,n)){p.error=new K(`Output validation failed for '${e}'`,e);return}p.state[l.result]=b,l.resultConst&&p.consts.add(l.result)}}catch(C){w=C.message||String(C),p.error=new K(w,e,C)}finally{if(p.trace&&g){let C=Dr(g,p.state);p.trace.push({op:e,input:m,stateDiff:C,result:b,error:w,fuelBefore:v,fuelAfter:p.fuel.current,timestamp:new Date().toISOString()})}}},docs:i,timeoutMs:a,cost:o,create:l=>({op:e,...l})}}var ee=I("seq",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{for(let n of e){if(t.output!==void 0||t.error)return;let r=t.resolver(n.op);if(!r)throw new Error(`Unknown Atom: ${n.op}`);await r.exec(n,t)}},{docs:"Sequence",timeoutMs:0,cost:.1}),qr=I("if",h.object({condition:h.any,then:h.array(h.any),else:h.array(h.any).optional}),void 0,async(e,t)=>{W(e.condition,t)?await ee.exec({op:"seq",steps:e.then},t):e.else&&await ee.exec({op:"seq",steps:e.else},t)},{docs:"If/Else",timeoutMs:0,cost:.1}),Wr=I("while",h.object({condition:h.any,body:h.array(h.any)}),void 0,async(e,t)=>{for(;W(e.condition,t);){if(t.signal?.aborted)throw new Error("Execution aborted");if((t.fuel.current-=.1)<=0)throw new Error("Out of Fuel");if(await ee.exec({op:"seq",steps:e.body},t),t.output!==void 0)return}},{docs:"While Loop",timeoutMs:0,cost:.1}),zr=I("return",void 0,h.any,async(e,t)=>{if(t.error)return t.output=t.error,t.error;if("value"in e){let r=x(e.value,t);if(r!=null&&!Mr(r)&&(typeof r!="object"||Array.isArray(r))){let s=new K(`Agent must return an object, got ${Array.isArray(r)?"array":typeof r}`,"return");return t.error=s,t.output=s,s}return t.output=r,r}let n={};if(e.schema?.properties){for(let r of Object.keys(e.schema.properties))n[r]=t.state[r];if(e.filter!==!1){let r=qt(n,e.schema);r instanceof Error||(n=r)}}return t.output=n,n},{docs:"Return",cost:.1}),Gr=I("try",h.object({try:h.array(h.any),catch:h.array(h.any).optional,catchParam:h.string.optional}),void 0,async(e,t)=>{if(await ee.exec({op:"seq",steps:e.try},t),t.error&&e.catch){let n=e.catchParam||"error";t.state[n]=t.error.message,t.state.errorOp=t.error.op,t.error=void 0,await ee.exec({op:"seq",steps:e.catch},t)}},{docs:"Try/Catch",timeoutMs:0,cost:.1}),Hr=I("Error",h.object({args:h.array(h.any).optional}),void 0,async(e,t)=>{let n=e.args?.[0]??"Error";t.error=new K(String(n),"Error")},{docs:"Trigger error flow",cost:.1}),Jr=I("varSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{if(n.consts.has(e))throw new Error(`Cannot reassign const variable '${e}'`);n.state[e]=x(t,n)},{docs:"Set Variable",cost:.1}),Kr=I("constSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{if(n.consts.has(e))throw new Error(`Cannot reassign const variable '${e}'`);if(e in n.state)throw new Error(`Cannot redeclare variable '${e}' as const`);n.state[e]=x(t,n),n.consts.add(e)},{docs:"Set Const Variable (immutable)",cost:.1}),Zr=I("varGet",h.object({key:h.string}),h.any,async({key:e},t)=>x(e,t),{docs:"Get Variable",cost:.1}),Qr=I("varsImport",h.object({keys:h.union([h.array(h.string),h.record(h.string)])}),void 0,async({keys:e},t)=>{if(Array.isArray(e))for(let n of e)t.state[n]=x({$kind:"arg",path:n},t);else for(let[n,r]of Object.entries(e))t.state[n]=x({$kind:"arg",path:r},t)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:.2}),Yr=I("varsLet",h.record(h.any),void 0,async(e,t)=>{for(let n of Object.keys(e))n==="op"||n==="result"||(t.state[n]=x(e[n],t))},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:.1}),Xr=I("varsExport",h.object({keys:h.union([h.array(h.string),h.record(h.string)])}),h.record(h.any),async({keys:e},t)=>{let n={};if(Array.isArray(e))for(let r of e)n[r]=x(r,t);else for(let[r,s]of Object.entries(e))n[r]=x(s,t);return n},{docs:"Export variables from the current scope, with optional renaming.",cost:.2}),es=I("scope",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{let n=xe(t);await ee.exec({op:"seq",steps:e},n),n.output!==void 0&&(t.output=n.output)},{docs:"Create new scope",timeoutMs:0,cost:.1}),ts=I("map",h.object({items:h.array(h.any),as:h.string,steps:h.array(h.any)}),h.array(h.any),async({items:e,as:t,steps:n},r)=>{let s=[],i=x(e,r);if(!Array.isArray(i))throw new Error("map: items is not an array");for(let a of i){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=a,await ee.exec({op:"seq",steps:n},o),s.push(o.state.result??null)}return s},{docs:"Map Array",timeoutMs:0,cost:1}),ns=I("filter",h.object({items:h.array(h.any),as:h.string,condition:h.any}),h.array(h.any),async({items:e,as:t,condition:n},r)=>{let s=[],i=x(e,r);if(!Array.isArray(i))throw new Error("filter: items is not an array");for(let a of i){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=a,W(n,o)&&s.push(a)}return s},{docs:"Filter Array",timeoutMs:0,cost:1}),rs=I("reduce",h.object({items:h.array(h.any),as:h.string,accumulator:h.string,initial:h.any,steps:h.array(h.any)}),h.any,async({items:e,as:t,accumulator:n,initial:r,steps:s},i)=>{let a=x(e,i),o=x(r,i);if(!Array.isArray(a))throw new Error("reduce: items is not an array");let u=o;for(let l of a){if(i.signal?.aborted)throw new Error("Execution aborted");let p=xe(i);p.state[t]=l,p.state[n]=u,await ee.exec({op:"seq",steps:s},p),u=p.state.result??u}return u},{docs:"Reduce Array",timeoutMs:0,cost:1}),ss=I("find",h.object({items:h.array(h.any),as:h.string,condition:h.any}),h.any,async({items:e,as:t,condition:n},r)=>{let s=x(e,r);if(!Array.isArray(s))throw new Error("find: items is not an array");for(let i of s){if(r.signal?.aborted)throw new Error("Execution aborted");let a=xe(r);if(a.state[t]=i,W(n,a))return i}return null},{docs:"Find in Array",timeoutMs:0,cost:1}),is=I("push",h.object({list:h.array(h.any),item:h.any}),h.array(h.any),async({list:e,item:t},n)=>{let r=x(e,n),s=x(t,n);return Array.isArray(r)&&r.push(s),r},{docs:"Push to Array",cost:1}),as=I("len",h.object({list:h.any}),h.number,async({list:e},t)=>{let n=x(e,t);return Array.isArray(n)||typeof n=="string"?n.length:0},{docs:"Length",cost:1}),os=I("split",h.object({str:h.string,sep:h.string}),h.array(h.string),async({str:e,sep:t},n)=>x(e,n).split(x(t,n)),{docs:"Split String",cost:1}),us=I("join",h.object({list:h.array(h.string),sep:h.string}),h.string,async({list:e,sep:t},n)=>x(e,n).join(x(t,n)),{docs:"Join String",cost:1}),ls=I("template",h.object({tmpl:h.string,vars:h.record(h.any)}),h.string,async({tmpl:e,vars:t},n)=>x(e,n).replace(/\{\{(\w+)\}\}/g,(s,i)=>String(x(t[i],n)??"")),{docs:"String Template",cost:1}),cs=I("regexMatch",h.object({pattern:h.string,value:h.any}),h.boolean,async({pattern:e,value:t},n)=>{if(Lr(e))throw new Error(`Suspicious regex pattern rejected (potential ReDoS): ${e}`);let r=x(t,n);return new RegExp(e).test(r)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),ps=I("pick",h.object({obj:h.record(h.any),keys:h.array(h.string)}),h.record(h.any),async({obj:e,keys:t},n)=>{let r=x(e,n),s=x(t,n),i={};return r&&Array.isArray(s)&&s.forEach(a=>i[a]=r[a]),i},{docs:"Pick Keys",cost:1}),fs=I("omit",h.object({obj:h.record(h.any),keys:h.array(h.string)}),h.record(h.any),async({obj:e,keys:t},n)=>{let r=x(e,n),s=new Set(x(t,n)),i={};return r&&Object.keys(r).forEach(a=>{s.has(a)||(i[a]=r[a])}),i},{docs:"Omit Keys",cost:1}),hs=I("merge",h.object({a:h.record(h.any),b:h.record(h.any)}),h.record(h.any),async({a:e,b:t},n)=>({...x(e,n),...x(t,n)}),{docs:"Merge Objects",cost:1}),ds=I("keys",h.object({obj:h.record(h.any)}),h.array(h.string),async({obj:e},t)=>Object.keys(x(e,t)??{}),{docs:"Object Keys",cost:1}),Dt=10,Ft="X-Agent-Depth";function ms(e,t){try{let r=new URL(e).hostname.toLowerCase();for(let s of t){let i=s.toLowerCase();if(i.startsWith("*.")){let a=i.slice(1);if(r.endsWith(a)||r===i.slice(2))return!0}else if(r===i)return!0}return!1}catch{return!1}}var gs=I("httpFetch",h.object({url:h.string,method:h.string.optional,headers:h.record(h.string).optional,body:h.any.optional,responseType:h.string.optional}),h.any,async(e,t)=>{let n=x(e.url,t),r=x(e.method,t),s=x(e.headers,t)||{},i=x(e.body,t),a=x(e.responseType,t),o=t.context?.requestDepth??0;if(o>=Dt)throw new Error(`Agent request depth exceeded (max ${Dt}). This prevents recursive agent loops.`);if(t.capabilities.fetch)return t.capabilities.fetch(n,{method:r,headers:{...s,[Ft]:String(o+1)},body:i,signal:t.signal,responseType:a});let u=t.context?.allowedFetchDomains;if(u){if(!ms(n,u))throw new Error(`Fetch blocked: domain not in allowlist. Allowed: ${u.join(", ")}`)}else{if(Vr(n))throw new Error("Blocked URL: private/internal addresses not allowed in default fetch");try{let p=new URL(n).hostname.toLowerCase();if(p!=="localhost"&&p!=="127.0.0.1"&&p!=="[::1]")throw new Error("Fetch blocked: no allowedFetchDomains configured. Set ctx.context.allowedFetchDomains or provide a custom fetch capability.")}catch(l){throw l.message.includes("allowedFetchDomains")?l:new Error(`Invalid URL: ${n}`)}}if(typeof globalThis.fetch=="function"){let l=await globalThis.fetch(n,{method:r,headers:{...s,[Ft]:String(o+1)},body:i?JSON.stringify(i):void 0,signal:t.signal});if(a==="dataUrl"){let d=await l.arrayBuffer(),f=new Uint8Array(d),m="";for(let b=0;b<f.length;b++)m+=String.fromCharCode(f[b]);let g=btoa(m);return`data:${l.headers.get("content-type")||"application/octet-stream"};base64,${g}`}let p=l.headers.get("content-type");return a==="json"||p&&p.includes("application/json")?l.json():l.text()}throw new Error("Capability 'fetch' missing and no global fetch available")},{docs:"HTTP Fetch",timeoutMs:3e4,cost:5}),ys=I("storeGet",h.object({key:h.string}),h.any,async({key:e},t)=>{let n=x(e,t);return t.capabilities.store?.get(n)},{docs:"Store Get",cost:5}),bs=I("storeSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{let r=x(e,n),s=x(t,n);return n.capabilities.store?.set(r,s)},{docs:"Store Set",cost:5}),xs=I("storeQuery",h.object({query:h.any}),h.array(h.any),async({query:e},t)=>t.capabilities.store?.query?.(x(e,t))??[],{docs:"Store Query",cost:5}),vs=I("storeVectorSearch",h.object({collection:h.string.optional,vector:h.array(h.number),k:h.number.optional}),h.array(h.any),async({collection:e,vector:t,k:n},r)=>r.capabilities.store?.vectorSearch?.(x(e,r),x(t,r),x(n,r))??[],{docs:"Vector Search",cost:(e,t)=>5+(x(e.k,t)??5)}),ws=I("llmPredict",h.object({prompt:h.string,options:h.any.optional}),h.string,async({prompt:e,options:t},n)=>{if(!n.capabilities.llm?.predict)throw new Error("Capability 'llm.predict' missing");return n.capabilities.llm.predict(x(e,n),x(t,n))},{docs:"LLM Predict",timeoutMs:12e4,cost:100}),Ss=I("agentRun",h.object({agentId:h.any,input:h.any}),h.any,async({agentId:e,input:t},n)=>{let r=x(e,n),s=x(t,n),i=s;if(s&&typeof s=="object"&&!Array.isArray(s)){i={};for(let o in s)i[o]=x(s[o],n)}if(mt(r)){let o=gt(r),u={...n,args:i,state:{},consts:new Set,output:void 0,error:void 0},l=n.resolver("seq");if(!l)throw new Error("seq atom not found");if(await l.exec(o,u),u.error)throw new Error(u.error.message||"Sub-agent failed");return u.output}if(r&&typeof r=="object"&&"op"in r){let o={...n,args:i,state:{},consts:new Set,output:void 0,error:void 0},u=n.resolver("seq");if(!u)throw new Error("seq atom not found");if(await u.exec(r,o),o.error)throw new Error(o.error.message||"Sub-agent failed");return o.output}if(!n.capabilities.agent?.run)throw new Error("Capability 'agent.run' missing");let a=await n.capabilities.agent.run(r,i);if(a&&typeof a=="object"&&"fuelUsed"in a&&typeof a.fuelUsed=="number"){if(a.error)throw new Error(a.error.message||"Sub-agent failed");return a.result}return a},{docs:"Run Sub-Agent (accepts procedure token, AST, or agent ID)",cost:1}),Es=I("transpileCode",h.object({code:h.string}),h.any,async({code:e},t)=>{if(!t.capabilities.code?.transpile)throw new Error("Capability 'code.transpile' missing. Enable code transpilation by providing the code capability.");let n=x(e,t);try{return t.capabilities.code.transpile(n)}catch(r){throw new Error(`Code transpilation failed: ${r.message}`)}},{docs:"Transpile AsyncJS code to AST",cost:1}),Ut=10,Cs=I("runCode",h.object({code:h.string,args:h.record(h.any).optional}),h.any,async({code:e,args:t},n)=>{let r=n.runCodeDepth??0;if(r>=Ut)throw new Error(`runCode recursion limit exceeded (max ${Ut}). This prevents infinite loops from dynamically generated code calling runCode.`);if(!n.capabilities.code?.transpile)throw new Error("Capability 'code.transpile' missing. Enable dynamic code execution by providing the code capability.");let s=x(e,n),i=t?x(t,n):{},a;try{a=n.capabilities.code.transpile(s)}catch(u){throw new Error(`Code transpilation failed: ${u.message}`)}if(a.op!=="seq")throw new Error("Transpiled code must be a seq node");let o=xe(n);if(o.args=i,o.output=void 0,o.runCodeDepth=r+1,await ee.exec(a,o),o.error){n.error=o.error;return}return o.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),ks=I("jsonParse",h.object({str:h.string}),h.any,async({str:e},t)=>JSON.parse(x(e,t)),{docs:"Parse JSON",cost:1}),As=I("jsonStringify",h.object({value:h.any}),h.string,async({value:e},t)=>JSON.stringify(x(e,t)),{docs:"Stringify JSON",cost:1}),_s=I("xmlParse",h.object({str:h.string}),h.any,async({str:e},t)=>{if(!t.capabilities.xml?.parse)throw new Error("Capability 'xml.parse' missing");return t.capabilities.xml.parse(x(e,t))},{docs:"Parse XML",cost:1}),Ts=I("memoize",h.object({key:h.string.optional,steps:h.array(h.any)}),h.any,async({key:e,steps:t},n)=>{n.memo||(n.memo=new Map);let r=x(e,n)??await yt.exec({value:t,algorithm:"SHA-256"},n);if(n.memo.has(r))return n.memo.get(r);let s=xe(n);await ee.exec({op:"seq",steps:t},s);let i=s.output??s.state.result;return n.memo.set(r,i),i},{docs:"Memoize steps result in memory",cost:1}),Is=I("cache",h.object({key:h.string.optional,steps:h.array(h.any),ttlMs:h.number.optional}),h.any,async({key:e,steps:t,ttlMs:n},r)=>{if(!r.capabilities.store)throw new Error("Capability 'store' missing for caching");let i=`cache:${x(e,r)??await yt.exec({value:t,algorithm:"SHA-256"},r)}`,a=await r.capabilities.store.get(i);if(a)if(typeof a=="object"&&a._exp){if(Date.now()<a._exp)return a.val}else return a;let o=xe(r);await ee.exec({op:"seq",steps:t},o);let u=o.output??o.state.result,l=Date.now()+(n??24*3600*1e3);if((r.fuel.current-=5)<=0)throw new Error("Out of Fuel");return await r.capabilities.store.set(i,{val:u,_exp:l}),u},{docs:"Cache steps result in store with TTL",cost:5}),Ps=I("random",h.object({min:h.number.optional,max:h.number.optional,format:h.string.optional,length:h.number.optional}),h.any,async({min:e,max:t,format:n,length:r},s)=>{let i=x(n,s)??"float",a=x(r,s)??10,o=x(e,s)??0,u=x(t,s)??1;if(i==="base36"){let f="0123456789abcdefghijklmnopqrstuvwxyz",m="";if(typeof crypto<"u"&&crypto.getRandomValues){let g=new Uint8Array(a);crypto.getRandomValues(g);for(let v=0;v<a;v++)m+=f[g[v]%36]}else for(let g=0;g<a;g++)m+=f.charAt(Math.floor(Math.random()*36));return m}let l;if(typeof crypto<"u"&&crypto.getRandomValues){let f=new Uint32Array(1);crypto.getRandomValues(f),l=f[0]/4294967296}else l=Math.random();let p=u-o,d=l*p+o;return i==="integer"?Math.floor(d):d},{docs:"Generate Random",cost:1}),Ns=I("uuid",void 0,h.string,async()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})},{docs:"Generate UUID",cost:1}),yt=I("hash",h.object({value:h.any,algorithm:h.string.optional}),h.string,async({value:e,algorithm:t},n)=>{let r=typeof e=="string"?e:JSON.stringify(x(e,n)),s=x(t,n)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let o=new TextEncoder().encode(r),u=await crypto.subtle.digest(s,o);return Array.from(new Uint8Array(u)).map(p=>p.toString(16).padStart(2,"0")).join("")}let i=0;for(let a=0;a<r.length;a++){let o=r.charCodeAt(a);i=(i<<5)-i+o,i|=0}return String(i)},{docs:"Hash a value",cost:1}),Rs=I("consoleLog",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t);t.trace&&t.trace.push({op:"console.log",input:{message:n},stateDiff:{},result:n,fuelBefore:t.fuel.current,fuelAfter:t.fuel.current,timestamp:new Date().toISOString()})},{docs:"Log to trace",cost:.1}),Ms=I("consoleWarn",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.warnings||(t.warnings=[]),t.warnings.push(r),t.trace&&t.trace.push({op:"console.warn",input:{message:n},stateDiff:{},result:n,fuelBefore:t.fuel.current,fuelAfter:t.fuel.current,timestamp:new Date().toISOString()})},{docs:"Add warning",cost:.1}),$s=I("consoleError",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.error=new K(r,"console.error")},{docs:"Emit error and stop",cost:.1}),Bs=I("storeProcedure",h.object({ast:h.any,ttl:h.number.optional,maxSize:h.number.optional}),h.string,async({ast:e,ttl:t,maxSize:n},r)=>{let s=x(e,r),i=t?x(t,r):$r,a=n?x(n,r):Br;if(!s||typeof s!="object"||!s.op)throw new Error('Invalid AST: must be an object with an "op" property');let o=JSON.stringify(s);if(o.length>a)throw new Error(`AST too large: ${o.length} bytes exceeds limit of ${a} bytes. Consider reducing AST size or using a shorter TTL.`);let u=jr(),l=Date.now();return Te.set(u,{ast:s,createdAt:l,expiresAt:l+i}),u},{docs:"Store an AST and return a token for later execution",cost:1}),js=I("releaseProcedure",h.object({token:h.string}),h.boolean,async({token:e},t)=>{let n=x(e,t);return Te.delete(n)},{docs:"Release a stored procedure by token",cost:.1}),Os=I("clearExpiredProcedures",void 0,h.number,async()=>{let e=Date.now(),t=0;for(let[n,r]of Te)e>r.expiresAt&&(Te.delete(n),t++);return t},{docs:"Clear all expired procedures and return count",cost:.5}),zt={seq:ee,if:qr,while:Wr,return:zr,try:Gr,Error:Hr,varSet:Jr,constSet:Kr,varGet:Zr,varsImport:Qr,varsLet:Yr,varsExport:Xr,scope:es,map:ts,filter:ns,reduce:rs,find:ss,push:is,len:as,split:os,join:us,template:ls,regexMatch:cs,pick:ps,omit:fs,merge:hs,keys:ds,httpFetch:gs,storeGet:ys,storeSet:bs,storeQuery:xs,storeVectorSearch:vs,llmPredict:ws,agentRun:Ss,transpileCode:Es,runCode:Cs,jsonParse:ks,jsonStringify:As,xmlParse:_s,memoize:Ts,cache:Is,random:Ps,uuid:Ns,hash:yt,consoleLog:Rs,consoleWarn:Ms,consoleError:$s,storeProcedure:Bs,releaseProcedure:js,clearExpiredProcedures:Os};var Vs=new Set(["true","false","null","undefined","and","or","not"]);function Ls(e,t){let n=e.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),r=[],s=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,i;for(;(i=s.exec(n))!==null;)r.push(i[1]);let o=[...new Set(r)].filter(u=>!Vs.has(u)&&!(u in t)&&!new RegExp(`\\b${u}\\s*\\(`).test(n));o.length>0&&console.warn(`[Agent99 Builder] Condition "${e}" references variables not in vars mapping: ${o.join(", ")}. Add them to vars or use AsyncJS syntax (ajs\`...\`) which handles this automatically.`)}function He(e,t){Ls(e,t);let n=Ds(e),r=Zt(n,0,t);if(r.pos<n.length){let s=n.slice(r.pos).join(" ");throw new Error(`Unsupported condition syntax near '${s}' in: ${e}
2
+ Supported: comparisons, &&, ||, !, arithmetic, member access (a.b), literals`)}return r.node}function Ds(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]==='"'||e[n]==="'"){let r=e[n++],s="";for(;n<e.length&&e[n]!==r;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n++];n++,t.push(JSON.stringify(s));continue}if(e.slice(n,n+2).match(/^(&&|\|\||==|!=|>=|<=)$/)){t.push(e.slice(n,n+2)),n+=2;continue}if("+-*/%><!().?:[]".includes(e[n])){t.push(e[n]),n++;continue}if(/\d/.test(e[n])){let r="";for(;n<e.length&&/[\d.]/.test(e[n]);)r+=e[n++];t.push(r);continue}if(/[a-zA-Z_]/.test(e[n])){let r="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)r+=e[n++];t.push(r);continue}n++}return t}function Zt(e,t,n){return Fs(e,t,n)}function Fs(e,t,n){let{node:r,pos:s}=Gt(e,t,n);for(;e[s]==="||";){s++;let{node:i,pos:a}=Gt(e,s,n);r={$expr:"logical",op:"||",left:r,right:i},s=a}return{node:r,pos:s}}function Gt(e,t,n){let{node:r,pos:s}=Ht(e,t,n);for(;e[s]==="&&";){s++;let{node:i,pos:a}=Ht(e,s,n);r={$expr:"logical",op:"&&",left:r,right:i},s=a}return{node:r,pos:s}}function Ht(e,t,n){let{node:r,pos:s}=Jt(e,t,n),i=["==","!=",">","<",">=","<="];for(;i.includes(e[s]);){let a=e[s++],{node:o,pos:u}=Jt(e,s,n);r={$expr:"binary",op:a,left:r,right:o},s=u}return{node:r,pos:s}}function Jt(e,t,n){let{node:r,pos:s}=Kt(e,t,n);for(;e[s]==="+"||e[s]==="-";){let i=e[s++],{node:a,pos:o}=Kt(e,s,n);r={$expr:"binary",op:i,left:r,right:a},s=o}return{node:r,pos:s}}function Kt(e,t,n){let{node:r,pos:s}=bt(e,t,n);for(;e[s]==="*"||e[s]==="/"||e[s]==="%";){let i=e[s++],{node:a,pos:o}=bt(e,s,n);r={$expr:"binary",op:i,left:r,right:a},s=o}return{node:r,pos:s}}function bt(e,t,n){if(e[t]==="!"||e[t]==="-"){let r=e[t++],{node:s,pos:i}=bt(e,t,n);return{node:{$expr:"unary",op:r,argument:s},pos:i}}return Us(e,t,n)}function Us(e,t,n){let r=e[t];if(r==="("){let{node:s,pos:i}=Zt(e,t+1,n);return{node:s,pos:i+1}}if(r&&r.startsWith('"'))return{node:{$expr:"literal",value:JSON.parse(r)},pos:t+1};if(r&&/^\d/.test(r))return{node:{$expr:"literal",value:parseFloat(r)},pos:t+1};if(r==="true")return{node:{$expr:"literal",value:!0},pos:t+1};if(r==="false")return{node:{$expr:"literal",value:!1},pos:t+1};if(r==="null")return{node:{$expr:"literal",value:null},pos:t+1};if(r&&/^[a-zA-Z_]/.test(r)){let s={$expr:"ident",name:r},i=t+1;for(;e[i]===".";){i++;let a=e[i++];s={$expr:"member",object:s,property:a}}return{node:s,pos:i}}return{node:{$expr:"literal",value:null},pos:t+1}}var Me=class e{steps=[];atoms;proxy;constructor(t){return this.atoms=t,this.proxy=new Proxy(this,{get:(n,r,s)=>{if(r in n)return n[r];if(typeof r=="string"&&r in n.atoms)return i=>{let a=n.atoms[r];return n.add(a.create(i)),s}}}),this.proxy}add(t){return this.steps.push(t),this.proxy}as(t){if(this.steps.length===0)throw new Error("No step to capture");let n=this.steps[this.steps.length-1];return n.result=t,this.proxy}step(t){return this.add(t)}return(t){let n=this.atoms.return;if(!n)throw new Error("Atom 'return' not found");let r=t.schema??t;return this.add(n.create({schema:r}))}toJSON(){return{op:"seq",steps:[...this.steps]}}varsImport(t){return this.add(this.atoms.varsImport.create({keys:t}))}varsExport(t){return this.add(this.atoms.varsExport.create({keys:t}))}if(t,n,r,s){let i=new e(this.atoms);r(i);let a;if(s){let l=new e(this.atoms);s(l),a=l.steps}let o=He(t,n),u=this.atoms.if;return this.add(u.create({condition:o,then:i.steps,else:a}))}while(t,n,r){let s=new e(this.atoms);r(s);let i=He(t,n),a=this.atoms.while;return this.add(a.create({condition:i,body:s.steps}))}scope(t){let n=new e(this.atoms);t(n);let r=this.atoms.scope;return this.add(r.create({steps:n.steps}))}map(t,n,r){let s=new e(this.atoms);r(s);let i=this.atoms.map;return this.add(i.create({items:t,as:n,steps:s.steps}))}filter(t,n,r,s={}){let i=He(r,s),a=this.atoms.filter;return this.add(a.create({items:t,as:n,condition:i}))}find(t,n,r,s={}){let i=He(r,s),a=this.atoms.find;return this.add(a.create({items:t,as:n,condition:i}))}reduce(t,n,r,s,i){let a=new e(this.atoms);i(a);let o=this.atoms.reduce;return this.add(o.create({items:t,as:n,accumulator:r,initial:s,steps:a.steps}))}memoize(t,n){let r=new e(this.atoms);t(r);let s=this.atoms.memoize;return this.add(s.create({key:n,steps:r.steps}))}cache(t,n,r){let s=new e(this.atoms);t(s);let i=this.atoms.cache;return this.add(i.create({key:n,steps:s.steps,ttlMs:r}))}try(t){let n=new e(this.atoms);t.try(n);let r;if(t.catch){let i=new e(this.atoms);t.catch(i),r=i.steps}let s=this.atoms.try;return this.add(s.create({try:n.steps,catch:r}))}};import{validate as na}from"tosijs-schema";var qs=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],nn=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Ws="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",rn="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",xt={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},vt="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",zs={5:vt,"5module":vt+" export import",6:vt+" const class extends export import super"},Gs=/^in(stanceof)?$/,Hs=new RegExp("["+rn+"]"),Js=new RegExp("["+rn+Ws+"]");function St(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function ue(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Hs.test(String.fromCharCode(e)):t===!1?!1:St(e,nn)}function we(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Js.test(String.fromCharCode(e)):t===!1?!1:St(e,nn)||St(e,qs)}var O=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function te(e,t){return new O(e,{beforeExpr:!0,binop:t})}var ne={beforeExpr:!0},Y={startsExpr:!0},At={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,At[e]=new O(e,t)}var c={num:new O("num",Y),regexp:new O("regexp",Y),string:new O("string",Y),name:new O("name",Y),privateId:new O("privateId",Y),eof:new O("eof"),bracketL:new O("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new O("]"),braceL:new O("{",{beforeExpr:!0,startsExpr:!0}),braceR:new O("}"),parenL:new O("(",{beforeExpr:!0,startsExpr:!0}),parenR:new O(")"),comma:new O(",",ne),semi:new O(";",ne),colon:new O(":",ne),dot:new O("."),question:new O("?",ne),questionDot:new O("?."),arrow:new O("=>",ne),template:new O("template"),invalidTemplate:new O("invalidTemplate"),ellipsis:new O("...",ne),backQuote:new O("`",Y),dollarBraceL:new O("${",{beforeExpr:!0,startsExpr:!0}),eq:new O("=",{beforeExpr:!0,isAssign:!0}),assign:new O("_=",{beforeExpr:!0,isAssign:!0}),incDec:new O("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new O("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:te("||",1),logicalAND:te("&&",2),bitwiseOR:te("|",3),bitwiseXOR:te("^",4),bitwiseAND:te("&",5),equality:te("==/!=/===/!==",6),relational:te("</>/<=/>=",7),bitShift:te("<</>>/>>>",8),plusMin:new O("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:te("%",10),star:te("*",10),slash:te("/",10),starstar:new O("**",{beforeExpr:!0}),coalesce:te("??",1),_break:B("break"),_case:B("case",ne),_catch:B("catch"),_continue:B("continue"),_debugger:B("debugger"),_default:B("default",ne),_do:B("do",{isLoop:!0,beforeExpr:!0}),_else:B("else",ne),_finally:B("finally"),_for:B("for",{isLoop:!0}),_function:B("function",Y),_if:B("if"),_return:B("return",ne),_switch:B("switch"),_throw:B("throw",ne),_try:B("try"),_var:B("var"),_const:B("const"),_while:B("while",{isLoop:!0}),_with:B("with"),_new:B("new",{beforeExpr:!0,startsExpr:!0}),_this:B("this",Y),_super:B("super",Y),_class:B("class",Y),_extends:B("extends",ne),_export:B("export"),_import:B("import",Y),_null:B("null",Y),_true:B("true",Y),_false:B("false",Y),_in:B("in",{beforeExpr:!0,binop:7}),_instanceof:B("instanceof",{beforeExpr:!0,binop:7}),_typeof:B("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},X=/\r\n?|\n|\u2028|\u2029/,Ks=new RegExp(X.source,"g");function Ie(e){return e===10||e===13||e===8232||e===8233}function sn(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(Ie(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var an=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,H=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,on=Object.prototype,Zs=on.hasOwnProperty,Qs=on.toString,Pe=Object.hasOwn||(function(e,t){return Zs.call(e,t)}),Qt=Array.isArray||(function(e){return Qs.call(e)==="[object Array]"}),Yt=Object.create(null);function ve(e){return Yt[e]||(Yt[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function de(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Ys=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Be=function(t,n){this.line=t,this.column=n};Be.prototype.offset=function(t){return new Be(this.line,this.column+t)};var Xe=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function un(e,t){for(var n=1,r=0;;){var s=sn(e,r,t);if(s<0)return new Be(n,t-r);++n,r=s}}var Et={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Xt=!1;function Xs(e){var t={};for(var n in Et)t[n]=e&&Pe(e,n)?e[n]:Et[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Xt&&typeof console=="object"&&console.warn&&(Xt=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
3
+ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Qt(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return Qt(t.onComment)&&(t.onComment=ei(t,t.onComment)),t}function ei(e,t){return function(n,r,s,i,a,o){var u={type:n?"Block":"Line",value:r,start:s,end:i};e.locations&&(u.loc=new Xe(this,a,o)),e.ranges&&(u.range=[s,i]),t.push(u)}}var je=1,Ne=2,_t=4,ln=8,Tt=16,cn=32,et=64,pn=128,ke=256,Oe=512,tt=je|Ne|ke;function It(e,t){return Ne|(e?_t:0)|(t?ln:0)}var Ke=0,Pt=1,ge=2,fn=3,hn=4,dn=5,z=function(t,n,r){this.options=t=Xs(t),this.sourceFile=t.sourceFile,this.keywords=ve(zs[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=xt[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=ve(s);var i=(s?s+" ":"")+xt.strict;this.reservedWordsStrict=ve(i),this.reservedWordsStrictBind=ve(i+" "+xt.strictBind),this.input=String(n),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
4
+ `,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(X).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=c.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(je),this.regexpState=null,this.privateNameStack=[]},le={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};z.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};le.inFunction.get=function(){return(this.currentVarScope().flags&Ne)>0};le.inGenerator.get=function(){return(this.currentVarScope().flags&ln)>0};le.inAsync.get=function(){return(this.currentVarScope().flags&_t)>0};le.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Oe))return!1;if(n&Ne)return(n&_t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};le.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&et)>0||this.options.allowSuperOutsideMethod};le.allowDirectSuper.get=function(){return(this.currentThisScope().flags&pn)>0};le.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};le.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Oe)||n&Ne&&!(n&Tt))return!0}return!1};le.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ke)>0};z.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};z.parse=function(t,n){return new this(n,t).parse()};z.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};z.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(z.prototype,le);var Z=z.prototype,ti=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){H.lastIndex=e,e+=H.exec(this.input)[0].length;var t=ti.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){H.lastIndex=e+t[0].length;var n=H.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||X.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,H.lastIndex=e,e+=H.exec(this.input)[0].length,this.input[e]===";"&&e++}};Z.eat=function(e){return this.type===e?(this.next(),!0):!1};Z.isContextual=function(e){return this.type===c.name&&this.value===e&&!this.containsEsc};Z.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};Z.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};Z.canInsertSemicolon=function(){return this.type===c.eof||this.type===c.braceR||X.test(this.input.slice(this.lastTokEnd,this.start))};Z.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};Z.semicolon=function(){!this.eat(c.semi)&&!this.insertSemicolon()&&this.unexpected()};Z.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};Z.expect=function(e){this.eat(e)||this.unexpected()};Z.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var nt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Z.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};Z.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};Z.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};Z.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var A=z.prototype;A.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==c.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var i=s[r];this.raiseRecoverable(this.undefinedExports[i].start,"Export '"+i+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Nt={kind:"loop"},ni={kind:"switch"};A.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;H.lastIndex=this.pos;var t=H.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(ue(r,!0)){for(var s=n+1;we(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var i=this.input.slice(n,s);if(!Gs.test(i))return!0}return!1};A.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;H.lastIndex=this.pos;var e=H.exec(this.input),t=this.pos+e[0].length,n;return!X.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(we(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};A.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;H.lastIndex=this.pos;var n=H.exec(this.input),r=this.pos+n[0].length;if(X.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,i;if(this.input.slice(r,s)!=="using"||s===this.input.length||we(i=this.input.charCodeAt(s))||i>55295&&i<56320)return!1;H.lastIndex=s;var a=H.exec(this.input);if(a&&X.test(this.input.slice(s,s+a[0].length)))return!1}if(t){var o=r+2,u;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!we(u=this.input.charCodeAt(o))&&!(u>55295&&u<56320)))return!1}var l=this.input.charCodeAt(r);return ue(l,!0)||l===92};A.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};A.isUsing=function(e){return this.isUsingKeyword(!1,e)};A.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),i;switch(this.isLet(e)&&(r=c._var,i="let"),r){case c._break:case c._continue:return this.parseBreakContinueStatement(s,r.keyword);case c._debugger:return this.parseDebuggerStatement(s);case c._do:return this.parseDoStatement(s);case c._for:return this.parseForStatement(s);case c._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case c._class:return e&&this.unexpected(),this.parseClass(s,!0);case c._if:return this.parseIfStatement(s);case c._return:return this.parseReturnStatement(s);case c._switch:return this.parseSwitchStatement(s);case c._throw:return this.parseThrowStatement(s);case c._try:return this.parseTryStatement(s);case c._const:case c._var:return i=i||this.value,e&&i!=="var"&&this.unexpected(),this.parseVarStatement(s,i);case c._while:return this.parseWhileStatement(s);case c._with:return this.parseWithStatement(s);case c.braceL:return this.parseBlock(!0,s);case c.semi:return this.parseEmptyStatement(s);case c._export:case c._import:if(this.options.ecmaVersion>10&&r===c._import){H.lastIndex=this.pos;var a=H.exec(this.input),o=this.pos+a[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===c._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,l),this.semicolon(),this.finishNode(s,"VariableDeclaration");var p=this.value,d=this.parseExpression();return r===c.name&&d.type==="Identifier"&&this.eat(c.colon)?this.parseLabeledStatement(s,p,d,e):this.parseExpressionStatement(s,d)}};A.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(c.semi)||this.insertSemicolon()?e.label=null:this.type!==c.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(n||s.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};A.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};A.parseDoStatement=function(e){return this.next(),this.labels.push(Nt),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(c._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(c.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};A.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Nt),this.enterScope(0),this.expect(c.parenL),this.type===c.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===c._var||this.type===c._const||n){var r=this.startNode(),s=n?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var i=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var u=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(u,!0,o),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var l=this.containsEsc,p=new nt,d=this.start,f=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===c._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===c._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),i&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,p),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))};A.parseForAfterInit=function(e,t,n){return(this.type===c._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===c._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))};A.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,$e|(n?0:Ct),!1,t)};A.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(c._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};A.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(c.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};A.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(ni),this.enterScope(0);for(var t,n=!1;this.type!==c.braceR;)if(this.type===c._case||this.type===c._default){var r=this.type===c._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(c.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};A.parseThrowStatement=function(e){return this.next(),X.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var ri=[];A.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?cn:0),this.checkLValPattern(e,t?hn:ge),this.expect(c.parenR),e};A.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===c._catch){var t=this.startNode();this.next(),this.eat(c.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(c._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};A.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};A.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Nt),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};A.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};A.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};A.parseLabeledStatement=function(e,t,n,r){for(var s=0,i=this.labels;s<i.length;s+=1){var a=i[s];a.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===c._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var l=this.labels[u];if(l.statementStart===e.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")};A.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};A.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(c.braceL),e&&this.enterScope(0);this.type!==c.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};A.parseFor=function(e,t){return e.init=t,this.expect(c.semi),e.test=this.type===c.semi?null:this.parseExpression(),this.expect(c.semi),e.update=this.type===c.parenR?null:this.parseExpression(),this.expect(c.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};A.parseForIn=function(e,t){var n=this.type===c._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(c.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")};A.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var s=this.startNode();if(this.parseVarId(s,n),this.eat(c.eq)?s.init=this.parseMaybeAssign(t):!r&&n==="const"&&!(this.type===c._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==c._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!r&&s.id.type!=="Identifier"&&!(t&&(this.type===c._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(c.comma))break}return e};A.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Pt:ge,!1)};var $e=1,Ct=2,mn=4;A.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===c.star&&t&Ct&&this.unexpected(),e.generator=this.eat(c.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&$e&&(e.id=t&mn&&this.type!==c.name?null:this.parseIdent(),e.id&&!(t&Ct)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Pt:ge:fn));var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(It(e.async,e.generator)),t&$e||(e.id=this.type===c.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&$e?"FunctionDeclaration":"FunctionExpression")};A.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};A.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),i=!1;for(s.body=[],this.expect(c.braceL);this.type!==c.braceR;){var a=this.parseClassElement(e.superClass!==null);a&&(s.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(i&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),i=!0):a.key&&a.key.type==="PrivateIdentifier"&&si(r,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};A.parseClassElement=function(e){if(this.eat(c.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,i=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(c.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===c.star?o=!0:r="static"}if(n.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===c.star)&&!this.canInsertSemicolon()?i=!0:r="async"),!r&&(t>=9||!i)&&this.eat(c.star)&&(s=!0),!r&&!i&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=u:r=u)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===c.parenL||a!=="method"||s||i){var l=!n.static&&Ze(n,"constructor"),p=l&&e;l&&a!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=l?"constructor":a,this.parseClassMethod(n,s,i,p)}else this.parseClassField(n);return n};A.isClassElementNameStart=function(){return this.type===c.name||this.type===c.privateId||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword};A.parseClassElementName=function(e){this.type===c.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};A.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Ze(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var i=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&i.params.length!==0&&this.raiseRecoverable(i.start,"getter should have no params"),e.kind==="set"&&i.params.length!==1&&this.raiseRecoverable(i.start,"setter should have exactly one param"),e.kind==="set"&&i.params[0].type==="RestElement"&&this.raiseRecoverable(i.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};A.parseClassField=function(e){return Ze(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Ze(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(c.eq)?(this.enterScope(Oe|et),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};A.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ke|et);this.type!==c.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};A.parseClassId=function(e,t){this.type===c.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,ge,!1)):(t===!0&&this.unexpected(),e.id=null)};A.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};A.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};A.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],i=0;i<n.length;++i){var a=n[i];Pe(t,a.name)||(s?s.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function si(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Ze(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}A.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==c.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};A.parseExport=function(e,t){if(this.next(),this.eat(c.star))return this.parseExportAllDeclaration(e,t);if(this.eat(c._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==c.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var s=r[n];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};A.parseExportDeclaration=function(e){return this.parseStatement(null)};A.parseExportDefaultDeclaration=function(){var e;if(this.type===c._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,$e|mn,!1,e)}else if(this.type===c._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};A.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Pe(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};A.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var i=s[r];this.checkPatternExport(e,i)}else if(n==="ArrayPattern")for(var a=0,o=t.elements;a<o.length;a+=1){var u=o[a];u&&this.checkPatternExport(e,u)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};A.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var s=r[n];this.checkPatternExport(e,s.id)}};A.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};A.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};A.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(c.braceL);!this.eat(c.braceR);){if(n)n=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;t.push(this.parseExportSpecifier(e))}return t};A.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=ri,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===c.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};A.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportSpecifier")};A.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportDefaultSpecifier")};A.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportNamespaceSpecifier")};A.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===c.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(c.comma)))return e;if(this.type===c.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(c.braceL);!this.eat(c.braceR);){if(t)t=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;e.push(this.parseImportSpecifier())}return e};A.parseWithClause=function(){var e=[];if(!this.eat(c._with))return e;this.expect(c.braceL);for(var t={},n=!0;!this.eat(c.braceR);){if(n)n=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;Pe(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};A.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(c.colon),this.type!==c.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};A.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return Ys.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};A.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};A.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var se=z.prototype;se.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var i=s[r];this.toAssignable(i,t),i.type==="RestElement"&&(i.argument.type==="ArrayPattern"||i.argument.type==="ObjectPattern")&&this.raise(i.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e};se.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var i=e[n-1];this.options.ecmaVersion===6&&t&&i&&i.type==="RestElement"&&i.argument.type!=="Identifier"&&this.unexpected(i.argument.start)}return e};se.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};se.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==c.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};se.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case c.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(c.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case c.braceL:return this.parseObj(!0)}return this.parseIdent()};se.parseBindingList=function(e,t,n,r){for(var s=[],i=!0;!this.eat(e);)if(i?i=!1:this.expect(c.comma),t&&this.type===c.comma)s.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===c.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),s.push(a),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};se.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};se.parseBindingListItem=function(e){return e};se.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(c.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};se.checkLValSimple=function(e,t,n){t===void 0&&(t=Ke);var r=t!==Ke;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===ge&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(Pe(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==dn&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};se.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ke),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var i=s[r];this.checkLValInnerPattern(i,t,n)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var u=o[a];u&&this.checkLValInnerPattern(u,t,n)}break;default:this.checkLValSimple(e,t,n)}};se.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ke),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ae=function(t,n,r,s,i){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!i},U={b_stat:new ae("{",!1),b_expr:new ae("{",!0),b_tmpl:new ae("${",!1),p_stat:new ae("(",!1),p_expr:new ae("(",!0),q_tmpl:new ae("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ae("function",!1),f_expr:new ae("function",!0),f_expr_gen:new ae("function",!0,!1,null,!0),f_gen:new ae("function",!1,!1,null,!0)},Re=z.prototype;Re.initialContext=function(){return[U.b_stat]};Re.curContext=function(){return this.context[this.context.length-1]};Re.braceIsBlock=function(e){var t=this.curContext();return t===U.f_expr||t===U.f_stat?!0:e===c.colon&&(t===U.b_stat||t===U.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?X.test(this.input.slice(this.lastTokEnd,this.start)):e===c._else||e===c.semi||e===c.eof||e===c.parenR||e===c.arrow?!0:e===c.braceL?t===U.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Re.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};Re.updateContext=function(e){var t,n=this.type;n.keyword&&e===c.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};Re.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};c.parenR.updateContext=c.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===U.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};c.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?U.b_stat:U.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(U.b_tmpl),this.exprAllowed=!0};c.parenL.updateContext=function(e){var t=e===c._if||e===c._for||e===c._with||e===c._while;this.context.push(t?U.p_stat:U.p_expr),this.exprAllowed=!0};c.incDec.updateContext=function(){};c._function.updateContext=c._class.updateContext=function(e){e.beforeExpr&&e!==c._else&&!(e===c.semi&&this.curContext()!==U.p_stat)&&!(e===c._return&&X.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===U.b_stat)?this.context.push(U.f_expr):this.context.push(U.f_stat),this.exprAllowed=!1};c.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};c.backQuote.updateContext=function(){this.curContext()===U.q_tmpl?this.context.pop():this.context.push(U.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===U.f_expr?this.context[t]=U.f_expr_gen:this.context[t]=U.f_gen}this.exprAllowed=!0};c.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==c.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var R=z.prototype;R.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var i=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&i==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var a=t[s];if(a){var o;i==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[i],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=t[s]={init:!1,get:!1,set:!1};a[i]=!0}};R.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===c.comma){var i=this.startNodeAt(n,r);for(i.expressions=[s];this.eat(c.comma);)i.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(i,"SequenceExpression")}return s};R.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,i=-1,a=-1;t?(s=t.parenthesizedAssign,i=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new nt,r=!0);var o=this.start,u=this.startLoc;(this.type===c.parenL||this.type===c.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,o,u)),this.type.isAssign){var p=this.startNodeAt(o,u);return p.operator=this.value,this.type===c.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===c.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),i>-1&&(t.trailingComma=i),l};R.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(c.question)){var i=this.startNodeAt(n,r);return i.test=s,i.consequent=this.parseMaybeAssign(),this.expect(c.colon),i.alternate=this.parseMaybeAssign(e),this.finishNode(i,"ConditionalExpression")}return s};R.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};R.parseExprOp=function(e,t,n,r,s){var i=this.type.binop;if(i!=null&&(!s||this.type!==c._in)&&i>r){var a=this.type===c.logicalOR||this.type===c.logicalAND,o=this.type===c.coalesce;o&&(i=c.logicalAND.binop);var u=this.value;this.next();var l=this.start,p=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),l,p,i,s),f=this.buildBinary(t,n,e,d,u,a||o);return(a&&this.type===c.coalesce||o&&(this.type===c.logicalOR||this.type===c.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,t,n,r,s)}return e};R.buildBinary=function(e,t,n,r,s,i){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=n,a.operator=s,a.right=r,this.finishNode(a,i?"LogicalExpression":"BinaryExpression")};R.parseMaybeUnary=function(e,t,n,r){var s=this.start,i=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===c.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&gn(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&kt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,a=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===c.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==c._in&&this.unexpected();else{if(a=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(s,i);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!n&&this.eat(c.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,i,a,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return a};function gn(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&gn(e.expression)}function kt(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&kt(e.expression)||e.type==="ParenthesizedExpression"&&kt(e.expression)}R.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var i=this.parseSubscripts(s,n,r,!1,t);return e&&i.type==="MemberExpression"&&(e.parenthesizedAssign>=i.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=i.start&&(e.parenthesizedBind=-1),e.trailingComma>=i.start&&(e.trailingComma=-1)),i};R.parseSubscripts=function(e,t,n,r,s){for(var i=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,n,r,i,a,s);if(o.optional&&(a=!0),o===e||o.type==="ArrowFunctionExpression"){if(a){var u=this.startNodeAt(t,n);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}e=o}};R.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};R.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};R.parseSubscript=function(e,t,n,r,s,i,a){var o=this.options.ecmaVersion>=11,u=o&&this.eat(c.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(c.bracketL);if(l||u&&this.type!==c.parenL&&this.type!==c.backQuote||this.eat(c.dot)){var p=this.startNodeAt(t,n);p.object=e,l?(p.property=this.parseExpression(),this.expect(c.bracketR)):this.type===c.privateId&&e.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!l,o&&(p.optional=u),e=this.finishNode(p,"MemberExpression")}else if(!r&&this.eat(c.parenL)){var d=new nt,f=this.yieldPos,m=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var v=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,d);if(s&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=m,this.awaitIdentPos=g,this.parseSubscriptAsyncArrow(t,n,v,a);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var b=this.startNodeAt(t,n);b.callee=e,b.arguments=v,o&&(b.optional=u),e=this.finishNode(b,"CallExpression")}else if(this.type===c.backQuote){(u||i)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var w=this.startNodeAt(t,n);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};R.parseExprAtom=function(e,t,n){this.type===c.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case c._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===c.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==c.dot&&this.type!==c.bracketL&&this.type!==c.parenL&&this.unexpected(),this.finishNode(r,"Super");case c._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case c.name:var i=this.start,a=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(c._function))return this.overrideContext(U.f_expr),this.parseFunction(this.startNodeAt(i,a),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(c.arrow))return this.parseArrowExpression(this.startNodeAt(i,a),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===c.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(c.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,a),[u],!0,t)}return u;case c.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case c.num:case c.string:return this.parseLiteral(this.value);case c._null:case c._true:case c._false:return r=this.startNode(),r.value=this.type===c._null?null:this.type===c._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case c.parenL:var p=this.start,d=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=p),e.parenthesizedBind<0&&(e.parenthesizedBind=p)),d;case c.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(c.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case c.braceL:return this.overrideContext(U.b_expr),this.parseObj(!1,e);case c._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case c._class:return this.parseClass(this.startNode(),!1);case c._new:return this.parseNew();case c.backQuote:return this.parseTemplate();case c._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};R.parseExprAtomDefault=function(){this.unexpected()};R.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===c.parenL&&!e)return this.parseDynamicImport(t);if(this.type===c.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};R.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(c.parenR)?e.options=null:(this.expect(c.comma),this.afterTrailingComma(c.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(c.parenR)||(this.expect(c.comma),this.afterTrailingComma(c.parenR)||this.unexpected())));else if(!this.eat(c.parenR)){var t=this.start;this.eat(c.comma)&&this.eat(c.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};R.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};R.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};R.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};R.shouldParseArrow=function(e){return!this.canInsertSemicolon()};R.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,i=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,u=[],l=!0,p=!1,d=new nt,f=this.yieldPos,m=this.awaitPos,g;for(this.yieldPos=0,this.awaitPos=0;this.type!==c.parenR;)if(l?l=!1:this.expect(c.comma),i&&this.afterTrailingComma(c.parenR,!0)){p=!0;break}else if(this.type===c.ellipsis){g=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var v=this.lastTokEnd,b=this.lastTokEndLoc;if(this.expect(c.parenR),e&&this.shouldParseArrow(u)&&this.eat(c.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(n,r,u,t);(!u.length||p)&&this.unexpected(this.lastTokStart),g&&this.unexpected(g),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,u.length>1?(s=this.startNodeAt(a,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",v,b)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(n,r);return w.expression=s,this.finishNode(w,"ParenthesizedExpression")}else return s};R.parseParenItem=function(e){return e};R.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var ii=[];R.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===c.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(c.parenL)?e.arguments=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ii,this.finishNode(e,"NewExpression")};R.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===c.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
5
+ `),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
6
+ `),cooked:this.value},this.next(),n.tail=this.type===c.backQuote,this.finishNode(n,"TemplateElement")};R.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===c.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(c.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(c.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};R.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===c.name||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===c.star)&&!X.test(this.input.slice(this.lastTokEnd,this.start))};R.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(c.braceR);){if(r)r=!1;else if(this.expect(c.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(c.braceR))break;var i=this.parseProperty(e,t);e||this.checkPropClash(i,s,t),n.properties.push(i)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};R.parseProperty=function(e,t){var n=this.startNode(),r,s,i,a;if(this.options.ecmaVersion>=9&&this.eat(c.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===c.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(i=this.start,a=this.startLoc),e||(r=this.eat(c.star)));var o=this.containsEsc;return this.parsePropertyName(n),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(c.star),this.parsePropertyName(n)):s=!1,this.parsePropertyValue(n,e,r,s,i,a,t,o),this.finishNode(n,"Property")};R.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};R.parsePropertyValue=function(e,t,n,r,s,i,a,o){(n||r)&&this.type===c.colon&&this.unexpected(),this.eat(c.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===c.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==c.comma&&this.type!==c.braceR&&this.type!==c.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,i,this.copyNode(e.key)):this.type===c.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,i,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};R.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(c.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(c.bracketR),e.key;e.computed=!1}return e.key=this.type===c.num||this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};R.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};R.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,i=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(It(t,r.generator)|et|(n?pn:0)),this.expect(c.parenL),r.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=i,this.awaitIdentPos=a,this.finishNode(r,"FunctionExpression")};R.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,i=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(It(n,!1)|Tt),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=i,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")};R.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==c.braceL,i=this.strict,a=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!i||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!i&&!a&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,dn),e.body=this.parseBlock(!1,void 0,a&&!i),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};R.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};R.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var i=s[r];this.checkLValInnerPattern(i,Pt,t?null:n)}};R.parseExprList=function(e,t,n,r){for(var s=[],i=!0;!this.eat(e);){if(i)i=!1;else if(this.expect(c.comma),t&&this.afterTrailingComma(e))break;var a=void 0;n&&this.type===c.comma?a=null:this.type===c.ellipsis?(a=this.parseSpread(r),r&&this.type===c.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):a=this.parseMaybeAssign(!1,r),s.push(a)}return s};R.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&tt)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};R.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};R.parseIdentNode=function(){var e=this.startNode();return this.type===c.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=c.name):this.unexpected(),e};R.parsePrivateIdent=function(){var e=this.startNode();return this.type===c.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};R.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===c.semi||this.canInsertSemicolon()||this.type!==c.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(c.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};R.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Qe=z.prototype;Qe.raise=function(e,t){var n=un(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};Qe.raiseRecoverable=Qe.raise;Qe.curPosition=function(){if(this.options.locations)return new Be(this.curLine,this.pos-this.lineStart)};var Se=z.prototype,ai=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new ai(e))};Se.exitScope=function(){this.scopeStack.pop()};Se.treatFunctionsAsVarInScope=function(e){return e.flags&Ne||!this.inModule&&e.flags&je};Se.declareName=function(e,t,n){var r=!1;if(t===ge){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&je&&delete this.undefinedExports[e]}else if(t===hn){var i=this.currentScope();i.lexical.push(e)}else if(t===fn){var a=this.currentScope();this.treatFunctionsAsVar?r=a.lexical.indexOf(e)>-1:r=a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(e)>-1&&!(u.flags&cn&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){r=!0;break}if(u.var.push(e),this.inModule&&u.flags&je&&delete this.undefinedExports[e],u.flags&tt)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};Se.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};Se.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Se.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tt|Oe|ke))return t}};Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tt|Oe|ke)&&!(t.flags&Tt))return t}};var rt=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new Xe(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},Ve=z.prototype;Ve.startNode=function(){return new rt(this,this.start,this.startLoc)};Ve.startNodeAt=function(e,t){return new rt(this,e,t)};function yn(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ve.finishNode=function(e,t){return yn.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Ve.finishNodeAt=function(e,t,n,r){return yn.call(this,e,t,n,r)};Ve.copyNode=function(e){var t=new rt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var oi="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",bn="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",xn=bn+" Extended_Pictographic",vn=xn,wn=vn+" EBase EComp EMod EPres ExtPict",Sn=wn,ui=Sn,li={9:bn,10:xn,11:vn,12:wn,13:Sn,14:ui},ci="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",pi={9:"",10:"",11:"",12:"",13:"",14:ci},en="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",En="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Cn=En+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",kn=Cn+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",An=kn+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",_n=An+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",fi=_n+" "+oi,hi={9:En,10:Cn,11:kn,12:An,13:_n,14:fi},Tn={};function di(e){var t=Tn[e]={binary:ve(li[e]+" "+en),binaryOfStrings:ve(pi[e]),nonBinary:{General_Category:ve(en),Script:ve(hi[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Je=0,wt=[9,10,11,12,13,14];Je<wt.length;Je+=1)tn=wt[Je],di(tn);var tn,Je,wt,k=z.prototype,Ye=function(t,n){this.parent=t,this.base=n||this};Ye.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};Ye.prototype.sibling=function(){return new Ye(this.parent,this.base)};var ce=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Tn[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ce.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,i=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)};ce.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};ce.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var i=r.charCodeAt(t);if(!(n||this.switchU)||i<=55295||i>=57344||t+1>=s)return i;var a=r.charCodeAt(t+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i};ce.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var i=r.charCodeAt(t),a;return!(n||this.switchU)||i<=55295||i>=57344||t+1>=s||(a=r.charCodeAt(t+1))<56320||a>57343?t+1:t+2};ce.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};ce.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};ce.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};ce.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};ce.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,i=t;s<i.length;s+=1){var a=i[s],o=this.at(r,n);if(o===-1||o!==a)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};k.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,i=0;i<n.length;i++){var a=n.charAt(i);t.indexOf(a)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(a,i+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),a==="u"&&(r=!0),a==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function mi(e){for(var t in e)return!0;return!1}k.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&mi(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};k.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};k.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Ye(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};k.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};k.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};k.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1};k.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};k.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};k.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};k.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};k.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};k.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var s=0;s<n.length;s++){var i=n.charAt(s);n.indexOf(i,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var a=this.regexp_eatModifiers(e);!n&&!a&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var u=a.charAt(o);(a.indexOf(u,o+1)>-1||n.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};k.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};k.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&gi(n);)t+=de(n),e.advance();return t};function gi(e){return e===105||e===109||e===115}k.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};k.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};k.regexp_eatSyntaxCharacter=function(e){var t=e.current();return In(t)?(e.lastIntValue=t,e.advance(),!0):!1};function In(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}k.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!In(n);)e.advance();return e.pos!==t};k.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};k.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,s=n;r<s.length;r+=1){var i=s[r];i.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};k.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};k.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=de(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=de(e.lastIntValue);return!0}return!1};k.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),yi(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function yi(e){return ue(e,!0)||e===36||e===95}k.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),bi(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function bi(e){return we(e,!0)||e===36||e===95||e===8204||e===8205}k.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};k.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1};k.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};k.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};k.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};k.regexp_eatZero=function(e){return e.current()===48&&!st(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};k.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};k.regexp_eatControlLetter=function(e){var t=e.current();return Pn(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Pn(e){return e>=65&&e<=90||e>=97&&e<=122}k.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var i=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=(s-55296)*1024+(a-56320)+65536,!0}e.pos=i,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&xi(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function xi(e){return e>=0&&e<=1114111}k.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};k.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Nn=0,me=1,re=2;k.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(vi(t))return e.lastIntValue=-1,e.advance(),me;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===re&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Nn};function vi(e){return e===100||e===68||e===115||e===83||e===119||e===87}k.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),me}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Nn};k.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Pe(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};k.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return me;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return re;e.raise("Invalid property name")};k.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Rn(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Rn(e){return Pn(e)||e===95}k.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";wi(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function wi(e){return Rn(e)||st(e)}k.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};k.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===re&&e.raise("Negated character class may contain strings"),!0}return!1};k.regexp_classContents=function(e){return e.current()===93?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)};k.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}};k.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Bn(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};k.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};k.regexp_classSetExpression=function(e){var t=me,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===re&&(t=re);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==re&&(t=me);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===re&&(t=re)}};k.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};k.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?me:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};k.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===re&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};k.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null};k.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===re&&(t=re);return t};k.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?me:re};k.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Si(n)||Ei(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Si(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Ei(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}k.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ci(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ci(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}k.regexp_eatClassControlLetter=function(e){var t=e.current();return st(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};k.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};k.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;st(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function st(e){return e>=48&&e<=57}k.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Mn(n=e.current());)e.lastIntValue=16*e.lastIntValue+$n(n),e.advance();return e.pos!==t};function Mn(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function $n(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}k.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1};k.regexp_eatOctalDigit=function(e){var t=e.current();return Bn(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Bn(e){return e>=48&&e<=55}k.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Mn(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+$n(s),e.advance()}return!0};var Rt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Xe(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},$=z.prototype;$.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Rt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};$.getToken=function(){return this.next(),new Rt(this)};typeof Symbol<"u"&&($[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});$.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(c.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};$.readToken=function(e){return ue(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};$.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};$.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=sn(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};$.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Ie(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};$.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&an.test(String.fromCharCode(e)))++this.pos;else break e}}};$.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};$.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(c.ellipsis)):(++this.pos,this.finishToken(c.dot))};$.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(c.assign,2):this.finishOp(c.slash,1)};$.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?c.star:c.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=c.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(c.assign,n+1):this.finishOp(r,n)};$.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(c.assign,3)}return this.finishOp(e===124?c.logicalOR:c.logicalAND,2)}return t===61?this.finishOp(c.assign,2):this.finishOp(e===124?c.bitwiseOR:c.bitwiseAND,1)};$.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};$.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||X.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(c.incDec,2):t===61?this.finishOp(c.assign,2):this.finishOp(c.plusMin,1)};$.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(c.assign,n+1):this.finishOp(c.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(c.relational,n))};$.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(c.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(c.arrow)):this.finishOp(e===61?c.eq:c.prefix,1)};$.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(c.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(c.assign,3)}return this.finishOp(c.coalesce,2)}}return this.finishOp(c.question,1)};$.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),ue(t,!0)||t===92))return this.finishToken(c.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+de(t)+"'")};$.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(c.parenL);case 41:return++this.pos,this.finishToken(c.parenR);case 59:return++this.pos,this.finishToken(c.semi);case 44:return++this.pos,this.finishToken(c.comma);case 91:return++this.pos,this.finishToken(c.bracketL);case 93:return++this.pos,this.finishToken(c.bracketR);case 123:return++this.pos,this.finishToken(c.braceL);case 125:return++this.pos,this.finishToken(c.braceR);case 58:return++this.pos,this.finishToken(c.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(c.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(c.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+de(e)+"'")};$.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};$.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(X.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var i=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(i);var o=this.regexpState||(this.regexpState=new ce(this));o.reset(n,s,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,a)}catch{}return this.finishToken(c.regexp,{pattern:s,flags:a,value:u})};$.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,i=this.pos,a=0,o=0,u=0,l=t??1/0;u<l;++u,++this.pos){var p=this.input.charCodeAt(this.pos),d=void 0;if(r&&p===95){s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=p;continue}if(p>=97?d=p-97+10:p>=65?d=p-65+10:p>=48&&p<=57?d=p-48:d=1/0,d>=e)break;o=p,a=a*e+d}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===i||t!=null&&this.pos-i!==t?null:a};function ki(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function jn(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}$.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=jn(this.input.slice(t,this.pos)),++this.pos):ue(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,n)};$.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=jn(this.input.slice(t,this.pos));return++this.pos,ue(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,s)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),ue(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var i=ki(this.input.slice(t,this.pos),n);return this.finishToken(c.num,i)};$.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};$.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Ie(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(c.string,t)};var On={};$.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===On)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};$.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw On;this.raise(e,t)};$.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===c.template||this.type===c.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(c.dollarBraceL)):(++this.pos,this.finishToken(c.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(c.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Ie(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
7
+ `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};$.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(c.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
8
+ `&&++this.pos;case`
9
+ `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};$.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
10
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return de(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return Ie(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};$.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};$.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(we(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var i=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?ue:we)(a,r)||this.invalidStringToken(i,"Invalid Unicode escape"),e+=de(a),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};$.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=At[e]),this.finishToken(t,e)};var Ai="8.15.0";z.acorn={Parser:z,version:Ai,defaultOptions:Et,Position:Be,SourceLocation:Xe,getLineInfo:un,Node:rt,TokenType:O,tokTypes:c,keywordTypes:At,TokContext:ae,tokContexts:U,isIdentifierChar:we,isIdentifierStart:ue,Token:Rt,isNewLine:Ie,lineBreak:X,lineBreakG:Ks,nonASCIIwhitespace:an};function Vn(e,t){return z.parse(e,t)}function Ln(e,t,n){return z.parseExpressionAt(e,t,n)}var F=class extends Error{line;column;source;filename;constructor(t,n,r,s){let i=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${i}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},Q=class extends F{constructor(t,n,r,s){super(t,n,r,s),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
11
+ `),r=this.line-1,s=Math.max(0,r-t),i=Math.min(n.length-1,r+t),a=[],o=String(i+1).length;for(let u=s;u<=i;u++){let l=String(u+1).padStart(o),p=u===r?">":" ";if(a.push(`${p} ${l} | ${n[u]}`),u===r){let d=" ".repeat(o+4+this.column);a.push(`${d}^ ${this.message.split(" at ")[0]}`)}}return a.join(`
12
+ `)}};function ie(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options}}function q(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function ut(e,t){let n="",r=0,s,i,a="normal",o=[],u=[{type:"top-level",braceDepth:0}],l=0,p=()=>u[u.length-1]?.type||"top-level",d=()=>{let f=u[u.length-1];return f?.type==="class-body"&&l===f.braceDepth+1};for(;r<e.length;){let f=e[r],m=e[r+1];switch(a){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==="'"&&(a="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==='"'&&(a="normal"),r++;continue;case"template-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}if(f==="$"&&m==="{"){n+=m,r+=2,o.push(1),a="normal";continue}f==="`"&&(a="normal"),r++;continue;case"line-comment":n+=f,f===`
13
+ `&&(a="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&m==="/"){n+=m,r+=2,a="normal";continue}r++;continue;case"regex":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}if(f==="["){for(r++;r<e.length&&e[r]!=="]";)n+=e[r],e[r]==="\\"&&r+1<e.length?(n+=e[r+1],r+=2):r++;r<e.length&&(n+=e[r],r++);continue}if(f==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)n+=e[r],r++;a="normal";continue}r++;continue;case"normal":if(o.length>0){if(f==="{")o[o.length-1]++;else if(f==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),n+=f,r++,a="template-string";continue}}if(f==="'"){n+=f,r++,a="single-string";continue}if(f==='"'){n+=f,r++,a="double-string";continue}if(f==="`"){n+=f,r++,a="template-string";continue}if(f==="/"&&m==="/"){n+=f+m,r+=2,a="line-comment";continue}if(f==="/"&&m==="*"){n+=f+m,r+=2,a="block-comment";continue}if(f==="/"){let y=n.trimEnd();if(!y[y.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(y)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(y)){n+=f,r++,a="regex";continue}}break}if(f==="{"){l++,n+=f,r++;continue}if(f==="}"){l--;let y=u[u.length-1];y&&l===y.braceDepth&&u.pop(),n+=f,r++;continue}let g=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(g){let y=g[0].slice(0,-1);n+=y,r+=y.length,u.push({type:"class-body",braceDepth:l});continue}let v=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(v){let y=v[1],S=v[0].length,T=e[r+S],E=null,_=r+S;(T==="?"||T==="!")&&(E=T,_++,E==="!"?t.unsafeFunctions.add(y):t.safeFunctions.add(y)),n+=`function ${y}(`,r=_;let P=it(e,r,"(",")");if(!P){n+=e[r],r++;continue}let{content:N,endPos:j}=P;r=j;let V=$t(N,t,!0);n+=V+")";let L=r;for(;L<e.length&&/\s/.test(e[L]);)L++;if(e[L]===":"){let J=e.slice(L,L+2),ye;for(J===":?"||J===":!"?(L+=2,ye=J===":?"?"safe":"unsafe"):L+=1;L<e.length&&/\s/.test(e[L]);)L++;let Ee=Mt(e,L);Ee&&(s===void 0&&(s=Ee.type,ye&&(i=ye)),r=Ee.endPos)}continue}let b=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),w=(()=>{for(let y=n.length-1;y>=0;y--)if(!/\s/.test(n[y]))return n[y];return`
14
+ `})(),C=w!=="="&&w!==","&&w!=="("&&w!=="["&&w!==">";if(b&&d()&&!C){let y=b[1].length;n+=e.slice(r,r+y),r+=y;continue}if(b&&d()&&C){let y=b[1],S=b[0].length,T=r+S;n+=y+"(",r=T;let E=it(e,r,"(",")");if(!E){n+=e[r],r++;continue}let{content:_,endPos:P}=E;r=P;let N=$t(_,t,!0);n+=N+")";let j=r;for(;j<e.length&&/\s/.test(e[j]);)j++;if(e[j]===":"){let V=e.slice(j,j+2);for(V===":?"||V===":!"?j+=2:j++;j<e.length&&/\s/.test(e[j]);)j++;let L=Mt(e,j);L&&(r=L.endPos)}continue}if(e[r]==="("){let y=it(e,r+1,"(",")");if(!y){n+=e[r],r++;continue}let S=y.content,T=y.endPos,E=T;for(;E<e.length&&/\s/.test(e[E]);)E++;let _;if(e[E]===":"){let P=e.slice(E,E+2);for(P===":?"||P===":!"?E+=2:E++;E<e.length&&/\s/.test(e[E]);)E++;let N=Mt(e,E);if(N)for(_=N.type,E=N.endPos;E<e.length&&/\s/.test(e[E]);)E++}if(e.slice(E,E+2)==="=>"){let P=null,N=S,j=S.trimStart();j.startsWith("?")&&(j.length===1||/\s/.test(j[1]))?(P="?",N=j.slice(1)):j.startsWith("!")&&(j.length===1||/\s/.test(j[1]))&&(P="!",N=j.slice(1));let V=$t(N,t,!1);for(n+=`(${P==="?"?"/* safe */ ":P==="!"?"/* unsafe */ ":""}${V})`,r=T;r<E&&/\s/.test(e[r]);)n+=e[r],r++;_&&(r=E)}else{let P=ut(S,t);n+=`(${P.source})`,r=T}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:i}}function it(e,t,n,r){let s=1,i=t,a=!1,o="";for(;i<e.length&&s>0;){let u=e[i];!a&&(u==="'"||u==='"'||u==="`")?(a=!0,o=u):a&&u===o&&e[i-1]!=="\\"?a=!1:a||(u===n?s++:u===r&&s--),i++}return s!==0?null:{content:e.slice(t,i-1),endPos:i}}function Un(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,s=e[n];if(s==="{"||s==="["){let a=s==="{"?"}":"]",o=it(e,n+1,s,a);return o?{value:e.slice(r,o.endPos),endPos:o.endPos}:null}if(s==="'"||s==='"'||s==="`"){for(n++;n<e.length;){if(e[n]===s&&e[n-1]!=="\\")return n++,{value:e.slice(r,n),endPos:n};n++}return null}if(/[-+\d]/.test(s)){for(;n<e.length&&/[\d.eE+-]/.test(e[n]);)n++;return{value:e.slice(r,n),endPos:n}}let i=e.slice(n).match(/^(true|false|null|undefined)\b/);return i?{value:i[1],endPos:n+i[1].length}:null}function Le(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function Mt(e,t){let n=t,r=0,s=!1,i="",a=!1,o=u=>({type:Le(e.slice(t,u).trim()),endPos:u});for(;n<e.length;){let u=e[n];if(!s&&(u==="'"||u==='"'||u==="`")){s=!0,i=u,a=!0,n++;continue}if(s){if(u===i&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let l=n;for(;l<e.length&&/\s/.test(e[l]);)l++;if(e[l]==="{"&&!e.slice(l+1).match(/^\s*(\w+)\s*:/)||e[l]!=="|"&&e[l]!=="&")return o(n)}continue}n++;continue}if(u==="{"||u==="["||u==="("){r++,a=!0,n++;continue}if(u==="}"||u==="]"||u===")"){if(r--,r===0){n++;let l=n;for(;l<e.length&&/\s/.test(e[l]);)l++;if(e[l]==="|"||e[l]==="&")continue;return o(n)}n++;continue}if(r===0&&u==="{"){if(a)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,a=!0,n++;continue}return o(n)}if(r===0&&(u==="|"||u==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(u)||u==="-"&&/\d/.test(e[n+1]))){let l=n;for(e[l]==="-"&&l++;l<e.length&&/\d/.test(e[l]);)l++;if(l<e.length&&e[l]==="."&&/\d/.test(e[l+1]))for(l++;l<e.length&&/\d/.test(e[l]);)l++;if(l<e.length&&(e[l]==="e"||e[l]==="E"))for(l++,l<e.length&&(e[l]==="+"||e[l]==="-")&&l++;l<e.length&&/\d/.test(e[l]);)l++;for(a=!0,n=l;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:Le(e.slice(t,l).trim()),endPos:l};if(e[n]!=="|"&&e[n]!=="&")return{type:Le(e.slice(t,l).trim()),endPos:l};continue}if(r===0&&/[a-zA-Z_]/.test(u)){let l=n;for(;l<e.length&&/\w/.test(e[l]);)l++;for(a=!0,n=l;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="("){r++,n++;continue}if(n<e.length&&e[n]==="{"&&!e.slice(n+1).match(/^\s*(\w+)\s*:/)){let d=l;for(;d>t&&/\s/.test(e[d-1]);)d--;return{type:Le(e.slice(t,d).trim()),endPos:l}}if(e[n]!=="|"&&e[n]!=="&")return{type:Le(e.slice(t,l).trim()),endPos:l};continue}n++}return a?o(n):null}function lt(e){let t=[],n="",r=0,s=!1,i=!1,a=0;for(;a<e.length;){let o=e[a],u=e[a+1];if(!i&&o==="/"&&u==="/"){s=!0,n+="//",a+=2;continue}if(!s&&o==="/"&&u==="*"){i=!0,n+="/*",a+=2;continue}if(s&&o===`
15
+ `){s=!1,n+=o,a++;continue}if(i&&o==="*"&&u==="/"){i=!1,n+="*/",a+=2;continue}if(s||i){n+=o,a++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,a++}return n.trim()&&t.push(n),t}function $t(e,t,n){let r=ut(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=lt(r),i=!1,a=new Set,o=l=>{if(n&&/^\w+$/.test(l)){if(a.has(l))throw new Error(`Duplicate parameter name '${l}'`);a.add(l)}};return s.map(l=>{let p=l.trim();if(!p)return l;if(n&&p.startsWith("{")&&p.endsWith("}")){let m=p.slice(1,-1);return`{ ${Dn(m,t)} }`}if(n&&p.startsWith("[")&&p.endsWith("]")){let m=p.slice(1,-1);return`[ ${Dn(m,t)} ]`}if(p.startsWith("...")){let m=Fn(p);return m!==-1?p.slice(0,m).trim():l}let d=p.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(d){let[,m,g]=d;return o(m),i=!0,`${m} = ${g}`}if(!Ti(p)){let m=p.match(/^(\w+)\s*=/);return m&&o(m[1]),i=!0,l}let f=Fn(p);if(f!==-1){let m=p.slice(0,f).trim(),g=p.slice(f+1).trim();return o(m),i&&n&&/^\w+$/.test(m),n&&/^\w+$/.test(m)&&t.requiredParams.add(m),`${m} = ${g}`}return l}).join(",")}function Dn(e,t){return lt(e).map(s=>{let i=s.trim();if(!i)return s;let a=i.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(a){let[,l,p]=a;t.requiredParams.add(l);let d=at(p);return`${l} = ${d}`}let o=i.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,l,p]=o;t.requiredParams.add(l);let d=ot(p);return`${l} = ${d}`}let u=i.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(u){let[,l,p]=u;return t.requiredParams.add(l),`${l} = ${p}`}return s}).join(", ")}function at(e){let t=e.slice(1,-1).trim();return`{ ${lt(t).map(s=>{let i=s.trim();if(!i)return s;let a=i.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(a){let[,d,f]=a;return`${d}: ${at(f)}`}let o=i.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,d,f]=o;return`${d}: ${at(f)}`}let u=i.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(u){let[,d,f]=u;return`${d}: ${ot(f)}`}let l=i.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(l){let[,d,f]=l;return`${d}: ${ot(f)}`}let p=i.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(p){let[,d,f]=p;return`${d}: ${f}`}return s}).join(", ")} }`}function ot(e){let t=e.slice(1,-1).trim();return`[ ${lt(t).map(s=>{let i=s.trim();return i?i.startsWith("{")&&i.endsWith("}")?at(i):i.startsWith("[")&&i.endsWith("]")?ot(i):s:s}).join(", ")} ]`}function Ti(e){let t=0,n=!1,r=!1,s=!1,i="";for(let a=0;a<e.length;a++){let o=e[a];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,i=o;continue}if(s){o===i&&e[a-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[a+1]!==">"&&(r=!0))}return n&&!r}function Fn(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let i=e[s];if(!n&&(i==="'"||i==='"'||i==="`")){n=!0,r=i;continue}if(n){i===r&&e[s-1]!=="\\"&&(n=!1);continue}if(i==="("||i==="{"||i==="[")t++;else if(i===")"||i==="}"||i==="]")t--;else if(t===0&&i===":")return s}return-1}function Ii(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,i=r+1;for(;i<e.length&&s>0;)e[i]==="{"?s++:e[i]==="}"&&s--,i++;if(s!==0)return null;let a=e.slice(r,i),o=[n[0].slice(0,-1)+a,a];return o.index=n.index,o}function Hn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let i=n+r[0].length-1+1,a=1,o=i;for(;o<e.length&&a>0;){let l=e[o];l==="{"?a++:l==="}"&&a--,o++}if(a!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let l=e.slice(i,o-1);t+=`try {${l}} catch (__try_err) { return new (__tjs?.MonadicError ?? Error)(__try_err?.message || String(__try_err), 'try', undefined, undefined, __tjs?.getStack?.()) }`,n=o}}else t+=e[n],n++}return t}function Jn(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let i=e.slice(r).match(/^\bwasm\s*\{/);if(i){let a=r,o=r+i[0].length,u=1,l=o;for(;l<e.length&&u>0;){let E=e[l];E==="{"?u++:E==="}"&&u--,l++}if(u!==0){n+=e[r],r++;continue}let p=e.slice(o,l-1),d,f=l,m=e.slice(l).match(/^\s*fallback\s*\{/);if(m){let E=l+m[0].length;u=1;let _=E;for(;_<e.length&&u>0;){let P=e[_];P==="{"?u++:P==="}"&&u--,_++}u===0&&(d=e.slice(E,_-1),f=_)}let v=Ni(p).map(E=>{let _=Ri(e,a,E);return _?`${E}: ${_}`:E}),b={id:`__tjs_wasm_${s}`,body:p,fallback:d,captures:v,start:a,end:f};t.push(b);let w=d??p,C=v.map(E=>E.split(":")[0].trim()),y=C.length>0?C.join(", "):"",S=C.length>0?`globalThis.${b.id}(${y})`:`globalThis.${b.id}()`,T=`(globalThis.${b.id} ? ${S} : (() => {${w}})())`;n+=T,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Pi(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Ni(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s;for(;(s=r.exec(t))!==null;)n.add(s[1]);let i=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,a=new Set;for(;(s=i.exec(t))!==null;)a.add(s[1]);for(let f of n){if(!a.has(f))continue;let m=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),g=new RegExp(`\\.${f}\\b`,"g"),v=t.match(m)?.length||0,b=t.match(g)?.length||0;v<=b&&a.delete(f)}let o=new Set,u=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.exec(t))!==null;)o.add(s[1]);let l=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=l.exec(t))!==null;)o.add(s[1]);let p=new Set(["if","else","for","while","do","switch","case","break","continue","return","function","let","const","var","new","this","true","false","null","undefined","typeof","instanceof","in","of","try","catch","finally","throw","async","await","class","extends","super","import","export","default","from","as","static","get","set","yield","console","Math","Array","Object","String","Number","Boolean","Date","JSON","Promise","Map","Set","WeakMap","WeakSet","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","ArrayBuffer","DataView","Error","TypeError","RangeError","length","push","pop","shift","unshift","slice","splice","map","filter","reduce","forEach","find","findIndex","indexOf","includes","globalThis","window","document","Infinity","NaN","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","eval","wasmBuffer"]),d=[];for(let f of a)!o.has(f)&&!p.has(f)&&!Pi(f)&&d.push(f);return d.sort()}function Ri(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,i=r.match(s);if(!i){let a=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(a);return o?qn(o[1],n):void 0}return qn(i[1],n)}function qn(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let s=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(s)return s[1];let i=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(i)return i[1]}}function Kn(e){let t=`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,n=new RegExp(t+"\\s+IsNot\\s+"+t,"g");e=e.replace(n,"IsNot($1, $2)");let r=new RegExp(t+"\\s+Is\\s+"+t,"g");return e=e.replace(r,"Is($1, $2)"),e}function Zn(e){let t=/^[\s]*[([/+\-`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,s=e.split(`
16
+ `),i=[],a=!1;for(let o=0;o<s.length;o++){let u=s[o],l=o>0?s[o-1]:"";if(a){i.push(u),u.includes("*/")&&(a=!1);continue}let p=u.indexOf("/*"),d=u.indexOf("*/");if(p!==-1&&(d===-1||d<p)){a=!0,i.push(u);continue}if(o>0&&t.test(u)){let f=l.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!n.test(f)&&!r.test(f)){let m=u.match(/^(\s*)/),g=m?m[1]:"",v=u.slice(g.length);i.push(g+";"+v);continue}}i.push(u)}return i.join(`
17
+ `)}function Qn(e){e=e.replace(/\btypeof\s+([a-zA-Z_$][\w$.]*(?:\?\.[\w$]+)*)/g,"TypeOf($1)");let t=[],n=0,r="normal",s=[];for(;n<e.length;){let a=e[n],o=e[n+1];switch(r){case"single-string":if(a==="\\"&&n+1<e.length){n+=2;continue}a==="'"&&(r="normal"),n++;continue;case"double-string":if(a==="\\"&&n+1<e.length){n+=2;continue}a==='"'&&(r="normal"),n++;continue;case"template-string":if(a==="\\"&&n+1<e.length){n+=2;continue}if(a==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}a==="`"&&(r="normal"),n++;continue;case"line-comment":a===`
18
+ `&&(r="normal"),n++;continue;case"block-comment":if(a==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(a==="\\"&&n+1<e.length){n+=2;continue}if(a==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(a==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(a==="{")s[s.length-1]++;else if(a==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(a==="'"){n++,r="single-string";continue}if(a==='"'){n++,r="double-string";continue}if(a==="`"){n++,r="template-string";continue}if(a==="/"&&o==="/"){n+=2,r="line-comment";continue}if(a==="/"&&o==="*"){n+=2,r="block-comment";continue}if(a==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let l=u>=0?e[u]:"";if(!l||/[=(!,;:{[&|?+\-*%<>~^]/.test(l)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(a==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(a==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let i=e;for(let a=t.length-1;a>=0;a--){let{pos:o,op:u}=t[a],l=u==="=="?"Eq":"NotEq",p=Mi(i,o),d=$i(i,o+2),f=i.slice(p,o).trim(),m=i.slice(o+2,d).trim();if(f&&m){let g=i.slice(0,p),v=i.slice(d),w=/[a-zA-Z0-9_$]$/.test(g)?" ":"";i=`${g}${w}${l}(${f}, ${m})${v}`}}return i}function Mi(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,i="";for(;n>=0;){let a=e[n],o=n>0?e[n-1]:"";if(s){a===i&&o!=="\\"&&(s=!1),n--;continue}if((a==='"'||a==="'"||a==="`")&&o!=="\\"){s=!0,i=a,n--;continue}if(a===")"||a==="]"||a==="}"){r++,n--;continue}if(a==="("||a==="["){if(r>0){r--,n--;continue}return n+1}if(a==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(a===";")return n+1;if(/[a-z]/.test(a)){let u=n+1,l=n;for(;l>0&&/[a-z]/i.test(e[l-1]);)l--;let p=e.slice(l,u),d=l>0?e[l-1]:"";if(!/[a-zA-Z0-9_$]/.test(d)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(p))return u;if(p==="new")return l}}if(a===">"&&o==="="||a==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||a==="&"&&o==="&"||a==="|"&&o==="|"||a==="?"||a===":"||a===",")return n+1;n--}return 0}function $i(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return e.length;let r=0,s=!1,i="";for(;n<e.length;){let a=e[n],o=n+1<e.length?e[n+1]:"";if(s){a===i&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((a==='"'||a==="'"||a==="`")&&e[n-1]!=="\\"){s=!0,i=a,n++;continue}if(a==="("||a==="["||a==="{"){r++,n++;continue}if(a===")"||a==="]"||a==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(a===";"||a==="&"&&o==="&"||a==="|"&&o==="|"||a==="?"||a===":"||a===","||(a==="="||a==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function Yn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(r){let s=r[1],i=n+r[0].length,a=s,o=!1,u=e.slice(i).match(/^(['"`])([^]*?)\1\s*/);if(u){let f=i+u[0].length,m=e[f],g=m===void 0||f>=e.length||m!=="="&&m!=="{";if(m==="="||m==="{")a=u[2],o=!0,i=f;else if(g){let v=u[0].trim(),b=u[0].slice(v.length);t+=`const ${s} = Type('${s}', ${v})${b}`,n=f;continue}}let l,p=i,d=e.slice(i).match(/^=\s*/);if(d){i+=d[0].length;let f=e.slice(i).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(f){l=f[0],i+=f[0].length,p=i;let m=e.slice(i).match(/^\s*/);m&&(i+=m[0].length)}}if(e[i]==="{"){let f=i+1,m=1,g=f;for(;g<e.length&&m>0;){let T=e[g];T==="{"?m++:T==="}"&&m--,g++}if(m!==0){t+=e[n],n++;continue}let v=e.slice(f,g-1).trim(),b=g,w=v.match(/description\s*:\s*(['"`])([^]*?)\1/);w&&!o&&(a=w[2]);let C,y=v.match(/example\s*:\s*/);if(y){let T=y.index+y[0].length,E=Un(v,T);E&&(C=E.value.trim())}let S=v.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(S&&C){let T=S[1].trim(),E=S[2].trim(),_=l?`, ${l}`:"";t+=`const ${s} = Type('${a}', (${T}) => { if (!globalThis.__tjs?.validate(${T}, globalThis.__tjs?.infer(${C}))) return false; ${E} }, ${C}${_})`}else if(S){let T=S[1].trim(),E=S[2].trim(),_=l?`, undefined, ${l}`:"";t+=`const ${s} = Type('${a}', (${T}) => { ${E} }${_})`}else if(C){let T=l?`, ${l}`:"";t+=`const ${s} = Type('${a}', undefined, ${C}${T})`}else l?t+=`const ${s} = Type('${a}', ${l})`:t+=`const ${s} = Type('${a}')`;n=b;continue}else if(l){t+=`const ${s} = Type('${a}', ${l})`,n=p;continue}else if(!u){let f=e.slice(i).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(f){let m=f[0];t+=`const ${s} = Type('${s}', ${m})`,n=i+f[0].length;continue}}}t+=e[n],n++}return t}function Xn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(r){let s=r[1],i=r[2],a=n+r[0].length;if(e[a]==="{"){let o=1,u=a+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;if(o===0){let l=e.slice(a+1,u-1).trim(),p=Ii(l,/params\s*:\s*\{/),d=l.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=l.match(/returnContract\s*:\s*['"](\w+)['"]/),m=l.match(/description\s*:\s*(['"])([^]*?)\1/),g=[];p&&g.push(`params: ${p[1]}`),d&&g.push(`returns: ${d[1].trim()}`),f&&g.push(`returnContract: '${f[1]}'`);let v=m?m[2]:s;if(i){let b=i.split(",").map(C=>{let y=C.trim().split("=").map(S=>S.trim());if(y.length===2){let S=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${S}]`}return`'${y[0]}'`}),w=i.split(",").map(C=>C.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${v}', [${b.join(", ")}], (${w.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${v}', { ${g.join(", ")} })`;n=u;continue}}if(e[a]==="("){let o=1,u=a+1;for(;u<e.length&&o>0;)e[u]==="("?o++:e[u]===")"&&o--,u++;if(o===0){let l=e.slice(a+1,u-1).trim(),p=l.indexOf(",");if(p!==-1){let d=l.slice(0,p).trim(),f=l.slice(p+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${d})`}else t+=`const ${s} = FunctionPredicate('${s}', ${l})`;n=u;continue}}}t+=e[n],n++}return t}function er(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(r){let s=r[1],i=r[2],o=n+r[0].length-1+1,u=1,l=o;for(;l<e.length&&u>0;){let C=e[l];C==="{"?u++:C==="}"&&u--,l++}if(u!==0){t+=e[n],n++;continue}let p=e.slice(o,l-1).trim(),d=l,f=i.split(",").map(C=>{let y=C.trim().split("=").map(S=>S.trim());if(y.length===2){let S=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${S}]`}return`'${y[0]}'`}),m=p,g=m.search(/\bdeclaration\s*\{/);if(g!==-1){let C=m.indexOf("{",g),y=1,S=C+1;for(;S<m.length&&y>0;)m[S]==="{"?y++:m[S]==="}"&&y--,S++;m=m.slice(0,g)+m.slice(S)}let v=m.match(/description\s*:\s*(['"`])([^]*?)\1/),b=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),w=v?v[2]:s;if(b){let C=b[1].trim().split(",").map(_=>_.trim()),y=b[2].trim(),S=C[0]||"x",T=C.slice(1),E=T.map(_=>`check${_}`);T.forEach((_,P)=>{y=y.replace(new RegExp(`\\b${_}\\s*\\(`,"g"),`${E[P]}(`)}),t+=`const ${s} = Generic([${f.join(", ")}], (${S}, ${E.join(", ")}) => { ${y} }, '${w}')`}else t+=`const ${s} = Generic([${f.join(", ")}], () => true, '${w}')`;n=d;continue}t+=e[n],n++}return t}function tr(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(r){let s=r[1],i=r[3],a=n+r[0].length;if(e[a]==="{"){let o=a+1,u=1,l=o;for(;l<e.length&&u>0;){let m=e[l];m==="{"?u++:m==="}"&&u--,l++}if(u!==0){t+=e[n],n++;continue}let p=e.slice(o,l-1).trim(),d=l,f=Wn(p);t+=`const ${s} = Union('${i}', [${f.join(", ")}])`,n=d;continue}else{let o=e.indexOf(`
19
+ `,a);o===-1&&(o=e.length);let u=e.slice(a,o).trim();if(u){let l=Wn(u);t+=`const ${s} = Union('${i}', [${l.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Wn(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function nr(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(r){let s=r[1],i=r[3],o=n+r[0].length-1+1,u=1,l=o;for(;l<e.length&&u>0;){let g=e[l];g==="{"?u++:g==="}"&&u--,l++}if(u!==0){t+=e[n],n++;continue}let p=e.slice(o,l-1).trim(),d=l,m=Bi(p).map(([g,v])=>`${g}: ${v}`).join(", ");t+=`const ${s} = Enum('${i}', { ${m} })`,n=d;continue}t+=e[n],n++}return t}function Bi(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let i=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(i){let a=i[1],o=i[2]?.trim();if(o!==void 0){t.push([a,o]);let u=Number(o);isNaN(u)||(n=u+1)}else t.push([a,String(n)]),n++}}return t}function rr(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),i=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!i){if(r===0||e[r-1]===`
20
+ `||e[r-1]===";"||e[r-1]==="}"){let y=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}n+=e[r],r++;continue}let a=i[1],o=i[2],u=r+i[0].length-1,l=Fe(e,u),p=e.slice(u+1,l-1).trim(),d=[],f=0,m=e.slice(u+1,l-1);for(;f<m.length;){let y=m.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!y){f++;continue}let S=y[1],T=!!y[2],E=y[3],_=f+y[0].length-1,P=1,N=_+1;for(;N<m.length&&P>0;)m[N]==="("&&P++,m[N]===")"&&P--,N++;let j=m.slice(_+1,N-1),V=N;for(;V<m.length&&/\s/.test(m[V]);)V++;if(m[V]==="="&&m[V+1]===">"){let be=De(e,u+1+f);throw new Q(`Arrow functions are not allowed in extend blocks (method '${E}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,be)}if(m[V]!=="{"){f++;continue}let L=Fe(m,V),J=m.slice(f,L).trim(),ye=j.split(",").map(be=>be.trim()).filter(be=>be.length>0).map(be=>{let ft=be.match(/^(\w+)\s*:\s*(.+)$/);return ft?`${ft[1]} = ${ft[2]}`:be}).join(", "),Ee=T?"async ":"",Rr=m.slice(V+1,L-1);d.push({name:E,isAsync:T,fullText:`${E}: ${Ee}function(${ye}) {${Rr}}`}),f=L}let g=!t.has(o);g&&t.set(o,new Set);let v=t.get(o);for(let C of d)v.add(C.name);let b=d.map(C=>` ${C.fullText}`).join(`,
21
+ `),w;g?w=`${a}const __ext_${o} = {
22
+ ${b}
23
+ ${a}}
24
+ `:w=`${a}Object.assign(__ext_${o}, {
25
+ ${b}
26
+ ${a}})
27
+ `;for(let C of d)w+=`${a}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${C.name}', __ext_${o}.${C.name}) }
28
+ `;n+=w,r=l}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function sr(e,t){if(t.size===0)return e;let n=new Map;for(let[s,i]of t)for(let a of i)n.has(a)||n.set(a,[]),n.get(a).push(s);let r=e;for(let[s,i]of n){if(!i.includes("String"))continue;let a=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(a,(l,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(l,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let u=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(u,(l,p,d)=>d?`__ext_String.${s}.call(${p})`:`__ext_String.${s}.call(${p}, `)}for(let[s,i]of n){if(!i.includes("Array"))continue;let a=`].${s}(`,o=0,u;for(;(u=r.indexOf(a,o))!==-1;){let l=1,p=u-1,d=!1;for(;p>=0&&l>0;){let f=r[p];d?f===d&&(p===0||r[p-1]!=="\\")&&(d=!1):(f==="]"&&l++,f==="["&&l--,(f==="'"||f==='"'||f==="`")&&(d=f)),p--}if(l===0){let f=r.slice(p+1,u+1),m=r.slice(0,p+1),g=r.slice(u+a.length);g[0]===")"?r=`${m}__ext_Array.${s}.call(${f})${g.slice(1)}`:r=`${m}__ext_Array.${s}.call(${f}, ${g}`}o=u+1}}for(let[s,i]of n){if(!i.includes("Number"))continue;let a=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(a,(o,u,l,p)=>p?`__ext_Number.${l}.call(${u})`:`__ext_Number.${l}.call(${u}, `)}return r}function De(e,t){let n=1,r=0;for(let s=0;s<t&&s<e.length;s++)e[s]===`
29
+ `?(n++,r=0):r++;return{line:n,column:r}}function ir(e,t){let n=t.trim();return/^['"`]/.test(n)?`typeof ${e} === 'string'`:n==="true"||n==="false"?`typeof ${e} === 'boolean'`:n==="null"?`${e} === null`:n==="undefined"?`${e} === undefined`:n.startsWith("[")?`Array.isArray(${e})`:n.startsWith("{")?`(typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e}))`:/^\+\d+/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}) && ${e} >= 0)`:/^-?\d+\.\d+/.test(n)?`typeof ${e} === 'number'`:/^-?\d+$/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}))`:"true"}function ct(e){let t=e.trim();return/^['"`]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":t.startsWith("[")?"array":t.startsWith("{")?"object":/^\+\d+/.test(t)?"non-negative-integer":/^-?\d+\.\d+/.test(t)?"number":/^-?\d+$/.test(t)?"integer":"any"}function Bt(e,t){let n=[],r=0,s="",i=!1;for(let o=0;o<e.length;o++){let u=e[o];if(!i&&(u==="'"||u==='"'||u==="`")){i=u,s+=u;continue}if(i){if(s+=u,u==="\\"){o++,o<e.length&&(s+=e[o]);continue}u===i&&(i=!1);continue}if(u==="("||u==="["||u==="{"){r++,s+=u;continue}if(u===")"||u==="]"||u==="}"){r--,s+=u;continue}if(u===","&&r===0){let l=zn(s.trim(),t);l&&n.push(l),s="";continue}s+=u}let a=s.trim();if(a){let o=zn(a,t);o&&n.push(o)}return n}function zn(e,t){let n=e.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(n.startsWith("..."))return null;let r=n.indexOf("=");if(r===-1)return{name:n.trim(),defaultValue:"",required:!0};let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();return{name:s,defaultValue:i,required:t.has(s)}}function Fe(e,t){let n=1,r=t+1,s=!1,i=!1,a=!1;for(;r<e.length&&n>0;){let o=e[r],u=r+1<e.length?e[r+1]:"";if(i){o===`
30
+ `&&(i=!1),r++;continue}if(a){if(o==="*"&&u==="/"){a=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&u==="/"){i=!0,r+=2;continue}if(o==="/"&&u==="*"){a=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function ar(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,i,a=[];for(;(i=r.exec(e))!==null;){let d=!!i[1],f=!!i[2],m=i[3],g=i.index,v=g,w=i[0].indexOf("function");w>=0&&(v=g+w),a.push({name:m,fullMatchStart:g,funcKeywordStart:v,exported:d,isAsync:f})}for(let d of a)s.has(d.name)||s.set(d.name,[]);let o=new Map;for(let d of a)o.set(d.name,(o.get(d.name)||0)+1);let u=new Set;for(let[d,f]of o)f>1&&u.add(d);if(u.size===0)return{source:e,polymorphicNames:n};for(let d of a){if(!u.has(d.name))continue;let f=e.indexOf("(",d.funcKeywordStart);if(f===-1)continue;let m=1,g=f+1;for(;g<e.length&&m>0;)e[g]==="("&&m++,e[g]===")"&&m--,g++;let v=g-1,b=e.slice(f+1,v),w=g;for(;w<e.length&&e[w]!=="{";)w++;if(w>=e.length)continue;let C=Fe(e,w),y=d.fullMatchStart;for(;y>0&&e[y-1]===" ";)y--;let S=s.get(d.name),T=Bt(b,t);if(b.includes("...")){let _=De(e,d.funcKeywordStart);throw new Q(`Rest parameters are not supported in polymorphic function '${d.name}'. Use separate function names instead.`,_)}S.push({index:S.length+1,start:y,end:C,text:e.slice(y,C),exported:d.exported,isAsync:d.isAsync,params:T})}for(let[d,f]of s){if(f.length<2)continue;let m=f.filter(g=>g.isAsync).length;if(m>0&&m<f.length){let g=De(e,f[0].start);throw new Q(`Polymorphic function '${d}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let v=g+1;v<f.length;v++){let b=f[g],w=f[v];if(b.params.length!==w.params.length)continue;let C=!0;for(let y=0;y<b.params.length;y++){let S=b.params[y].defaultValue?ct(b.params[y].defaultValue):"any",T=w.params[y].defaultValue?ct(w.params[y].defaultValue):"any";if(S!==T){C=!1;break}}if(C){let y=De(e,w.start);throw new Q(`Polymorphic function '${d}': variants ${g+1} and ${v+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,y)}}}let l=[];for(let[d,f]of s)if(!(f.length<2))for(let m of f)l.push({name:d,variant:m});l.sort((d,f)=>f.variant.start-d.variant.start);let p=e;for(let{name:d,variant:f}of l){let m=f.isAsync?"async ":"",g=f.text.replace(new RegExp(`(?:export\\s+)?${m?m.replace(/\s+$/,"\\s+"):""}function\\s+${d}\\s*\\(`),`${m}function ${d}$$${f.index}(`);p=p.slice(0,f.start)+g+p.slice(f.end)}for(let[d,f]of s){if(f.length<2)continue;n.add(d);let m=f[0].isAsync,g=f.some(S=>S.exported),v=m?"async ":"",b=g?"export ":"",w=[...f].sort((S,T)=>{if(S.params.length!==T.params.length)return 0;let E=0,_=0;for(let P of S.params){let N=P.defaultValue?ct(P.defaultValue):"any";N==="non-negative-integer"?E+=3:N==="integer"?E+=2:N!=="any"&&(E+=1)}for(let P of T.params){let N=P.defaultValue?ct(P.defaultValue):"any";N==="non-negative-integer"?_+=3:N==="integer"?_+=2:N!=="any"&&(_+=1)}return _-E}),C=[];for(let S of w){let T=[`__args.length === ${S.params.length}`],E=[];for(let _=0;_<S.params.length;_++){let P=S.params[_];if(E.push(`__args[${_}]`),P.defaultValue){let N=ir(`__args[${_}]`,P.defaultValue);N!=="true"&&T.push(N)}}C.push(` if (${T.join(" && ")}) return ${d}$${S.index}(${E.join(", ")})`)}let y=`
31
+ ${b}${v}function ${d}(...__args) {
32
+ ${C.join(`
33
33
  `)}
34
- return __tjs.typeError('${R}', 'no matching overload', __args)
34
+ return __tjs.typeError('${d}', 'no matching overload', __args)
35
35
  }
36
- `;q+=I}return{source:q,polymorphicNames:Y}}function H9(Z){return Z.replace(/(?<=^|[;\n{])\s*([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(Q,Y)=>{return Q.replace(Y,`const ${Y}`)})}function W9(Z,Q=!1){let Y=[],J=[],X="",K=0;while(K<Z.length){let H=Z.slice(K).match(/^\btest\s+/);if(H){let W=K,z=K+H[0].length,_,q=Z.slice(z).match(/^(['"`])([^]*?)\1\s*/);if(q)_=q[2],z+=q[0].length;if(Z[z]==="{"){let R=z+1,F=1,U=R;while(U<Z.length&&F>0){let O=Z[U];if(O==="{")F++;else if(O==="}")F--;U++}if(F===0){let O=Z.slice(R,U-1).trim(),L=U,B=(Z.slice(0,W).match(/\n/g)||[]).length+1;if(Y.push({description:_,body:O,start:W,end:L,line:B}),!Q)try{Function(O)()}catch(I){let j=_||`test at line ${B}`;J.push(`Test failed: ${j} (line ${B})
37
- ${I.message||I}`)}let A=(Z.slice(W,L).match(/\n/g)||[]).length;X+=`
38
- `.repeat(A),K=L;continue}}}X+=Z[K],K++}return{source:X,tests:Y,errors:J}}function z9(Z,Q){let Y=new Set,J=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,X,K=[];while((X=J.exec(Z))!==null){let W=X[1],z=X[2]?.trim()||"",_=X.index+X[0].length-1,q=d0(Z,_),R=Z.slice(_,q);K.push({className:W,extendsClause:z,bodyStart:_,bodyEnd:q,body:R})}let H=Z;for(let W=K.length-1;W>=0;W--){let{className:z,extendsClause:_,bodyStart:q,bodyEnd:R,body:F}=K[W],U=/\bconstructor\s*\(/g,O,L=[];while((O=U.exec(F))!==null)L.push(O.index);if(L.length<2)continue;Y.add(z);let B=[];for(let T=0;T<L.length;T++){let S=L[T],b=F.indexOf("(",S),y=1,h=b+1;while(h<F.length&&y>0){if(F[h]==="(")y++;if(F[h]===")")y--;h++}let x=F.slice(b+1,h-1),o=h;while(o<F.length&&F[o]!=="{")o++;let B0=d0(F,o),A0=F.slice(o+1,B0-1);B.push({index:T+1,paramStr:x,bodyText:A0,fullStart:S,fullEnd:B0})}let N=F.slice(0,B[0].fullEnd),A=B[B.length-1].fullEnd;N+=F.slice(A);let I=F;for(let T=B.length-1;T>=1;T--){let S=B[T],b=S.fullStart;while(b>0&&I[b-1]===" ")b--;if(b>0&&I[b-1]===`
39
- `)b--;I=I.slice(0,b)+I.slice(S.fullEnd)}let j="";for(let T=1;T<B.length;T++){let S=B[T],b=y1(S.paramStr,Q);if(S.paramStr.includes("...")){let h=u0(Z,q+S.fullStart);throw new Z0(`Rest parameters are not supported in polymorphic constructors for '${z}'.`,h)}j+=`
40
- function ${z}$ctor$${S.index}(${S.paramStr}) {`,j+=`
41
- const __obj = Object.create(${z}.prototype)`,j+=`
42
- ;(function() {${S.bodyText}}).call(__obj)`,j+=`
43
- return __obj`,j+=`
36
+ `;p+=y}return{source:p,polymorphicNames:n}}function or(e){return e.replace(/(?<=^|[;\n{])\s*([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(t,n)=>t.replace(n,`const ${n}`))}function ur(e,t=!1){let n=[],r=[],s="",i=0;for(;i<e.length;){let a=e.slice(i).match(/^\btest\s+/);if(a){let o=i,u=i+a[0].length,l,p=e.slice(u).match(/^(['"`])([^]*?)\1\s*/);if(p&&(l=p[2],u+=p[0].length),e[u]==="{"){let d=u+1,f=1,m=d;for(;m<e.length&&f>0;){let g=e[m];g==="{"?f++:g==="}"&&f--,m++}if(f===0){let g=e.slice(d,m-1).trim(),v=m,b=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:l,body:g,start:o,end:v,line:b}),!t)try{new Function(g)()}catch(y){let S=l||`test at line ${b}`;r.push(`Test failed: ${S} (line ${b})
37
+ ${y.message||y}`)}let C=(e.slice(o,v).match(/\n/g)||[]).length;s+=`
38
+ `.repeat(C),i=v;continue}}}s+=e[i],i++}return{source:s,tests:n,errors:r}}function lr(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,i=[];for(;(s=r.exec(e))!==null;){let o=s[1],u=s[2]?.trim()||"",l=s.index+s[0].length-1,p=Fe(e,l),d=e.slice(l,p);i.push({className:o,extendsClause:u,bodyStart:l,bodyEnd:p,body:d})}let a=e;for(let o=i.length-1;o>=0;o--){let{className:u,extendsClause:l,bodyStart:p,bodyEnd:d,body:f}=i[o],m=/\bconstructor\s*\(/g,g,v=[];for(;(g=m.exec(f))!==null;)v.push(g.index);if(v.length<2)continue;n.add(u);let b=[];for(let _=0;_<v.length;_++){let P=v[_],N=f.indexOf("(",P),j=1,V=N+1;for(;V<f.length&&j>0;)f[V]==="("&&j++,f[V]===")"&&j--,V++;let L=f.slice(N+1,V-1),J=V;for(;J<f.length&&f[J]!=="{";)J++;let ye=Fe(f,J),Ee=f.slice(J+1,ye-1);b.push({index:_+1,paramStr:L,bodyText:Ee,fullStart:P,fullEnd:ye})}let w=f.slice(0,b[0].fullEnd),C=b[b.length-1].fullEnd;w+=f.slice(C);let y=f;for(let _=b.length-1;_>=1;_--){let P=b[_],N=P.fullStart;for(;N>0&&y[N-1]===" ";)N--;N>0&&y[N-1]===`
39
+ `&&N--,y=y.slice(0,N)+y.slice(P.fullEnd)}let S="";for(let _=1;_<b.length;_++){let P=b[_],N=Bt(P.paramStr,t);if(P.paramStr.includes("...")){let V=De(e,p+P.fullStart);throw new Q(`Rest parameters are not supported in polymorphic constructors for '${u}'.`,V)}S+=`
40
+ function ${u}$ctor$${P.index}(${P.paramStr}) {`,S+=`
41
+ const __obj = Object.create(${u}.prototype)`,S+=`
42
+ ;(function() {${P.bodyText}}).call(__obj)`,S+=`
43
+ return __obj`,S+=`
44
44
  }
45
- `}let C=[];for(let T=0;T<B.length;T++){let S=B[T],b=y1(S.paramStr,Q),y=[`a.length === ${b.length}`];for(let h=0;h<b.length;h++){let x=b[h];if(x.defaultValue){let o=X9(`a[${h}]`,x.defaultValue);if(o!=="true")y.push(o)}}if(T===0)C.push(` if (${y.join(" && ")}) return Reflect.construct(t, a)`);else{let h=b.map((x,o)=>`a[${o}]`).join(", ");C.push(` if (${y.join(" && ")}) return ${z}$ctor$${S.index}(${h})`)}}j+=`
46
- function ${z}$dispatch(t, a) {
47
- `,j+=C.join(`
45
+ `}let T=[];for(let _=0;_<b.length;_++){let P=b[_],N=Bt(P.paramStr,t),j=[`a.length === ${N.length}`];for(let V=0;V<N.length;V++){let L=N[V];if(L.defaultValue){let J=ir(`a[${V}]`,L.defaultValue);J!=="true"&&j.push(J)}}if(_===0)T.push(` if (${j.join(" && ")}) return Reflect.construct(t, a)`);else{let V=N.map((L,J)=>`a[${J}]`).join(", ");T.push(` if (${j.join(" && ")}) return ${u}$ctor$${P.index}(${V})`)}}S+=`
46
+ function ${u}$dispatch(t, a) {
47
+ `,S+=T.join(`
48
48
  `)+`
49
- `,j+=` return __tjs.typeError('${z}', 'no matching constructor', a)
50
- `,j+=`}
51
- `,H=H.slice(0,q)+I+H.slice(R);let w=q+I.length;H=H.slice(0,w)+j+H.slice(w)}return{source:H,polyCtorClasses:Y}}function G9(Z,Q=new Set){let Y=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,J="",X=0,K;while((K=Y.exec(Z))!==null){let H=K[1],W=K[2]||"",z=K.index,_=z+K[0].length-1,q=1,R=_+1;while(R<Z.length&&q>0){let F=Z[R];if(F==="{")q++;else if(F==="}")q--;R++}if(q===0){let F=R,U=Z.slice(_,F);if(J+=Z.slice(X,z),J+=`let ${H} = class ${H}${W} ${U}; `,Q.has(H))J+=`${H} = new Proxy(${H}, { apply(t, _, a) { return ${H}$dispatch(t, a) }, construct(t, a) { return ${H}$dispatch(t, a) } });`;else J+=`${H} = new Proxy(${H}, { apply(t, _, a) { return Reflect.construct(t, a) } });`;X=F}}return J+=Z.slice(X),J}function _9(Z){let Q=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now() or Timestamp.from()"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now()"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:Y,message:J}of Q)if(Y.test(Z))throw Error(J);return Z}function q9(Z){let Q=new Set,Y=/\bconst!\s+(\w+)\b/g,J;while((J=Y.exec(Z))!==null)Q.add(J[1]);if(Q.size===0)return Z;Z=Z.replace(/\bconst!\s+/g,"const ");let X=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let K of Q){if(new RegExp(`\\b${K}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(X))throw Error(`Cannot mutate immutable binding '${K}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${K}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(X))throw Error(`Cannot mutate immutable binding '${K}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${K}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(X))throw Error(`Cannot mutate immutable binding '${K}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\b${K}\\s*\\.\\s*(?:${"push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set"})\\s*\\(`,"g").test(X))throw Error(`Cannot call mutating method on immutable binding '${K}'. const! bindings are read-only at compile time.`)}return Z}function F9(Z){if(/(?<![a-zA-Z_$])\bvar\s+/.test(Z))throw Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return Z}function $9(Z){if(/(?<![A-Za-z_$])\beval\s*\(/.test(Z))throw Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(Z))throw Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return Z}function R9(Z){if(!Z.includes("!."))return Z;let Q="",Y=0,J="normal",X=0;while(Y<Z.length){let K=Z[Y],H=Z[Y+1];if(J==="normal"){if(K==="/"&&H==="/"){J="line-comment",Q+=K,Y++;continue}if(K==="/"&&H==="*"){J="block-comment",Q+=K,Y++;continue}if(K==="'"){J="string-single",Q+=K,Y++;continue}if(K==='"'){J="string-double",Q+=K,Y++;continue}if(K==="`"){J="string-template",X++,Q+=K,Y++;continue}if(K==="!"&&H==="."&&Y+2<Z.length&&/[a-zA-Z_$]/.test(Z[Y+2])){let W=Q.length,z=k6(Q);if(z<W){let _=Q.slice(z);Q=Q.slice(0,z);let q=Y+2;while(q<Z.length&&/[\w$]/.test(Z[q]))q++;let R=Z.slice(Y+2,q);Q+=`__tjs.bang(${_},'${R}')`,Y=q;continue}}Q+=K,Y++}else if(J==="line-comment"){if(Q+=K,K===`
52
- `)J="normal";Y++}else if(J==="block-comment")if(Q+=K,K==="*"&&H==="/")Q+=H,J="normal",Y+=2;else Y++;else if(J==="string-single")if(Q+=K,K==="\\")Q+=H||"",Y+=2;else if(K==="'")J="normal",Y++;else Y++;else if(J==="string-double")if(Q+=K,K==="\\")Q+=H||"",Y+=2;else if(K==='"')J="normal",Y++;else Y++;else if(J==="string-template")if(Q+=K,K==="\\")Q+=H||"",Y+=2;else if(K==="`")X--,J=X>0?"string-template":"normal",Y++;else if(K==="$"&&H==="{")Q+=H,Y+=2,J="normal";else Y++;else Q+=K,Y++}return Q}function k6(Z){let Q=Z.length-1;while(Q>=0&&/\s/.test(Z[Q]))Q--;if(Q<0)return Z.length;while(Q>=0){let Y=Z[Q];if(/[\w$]/.test(Y)){while(Q>=0&&/[\w$]/.test(Z[Q]))Q--;if(Q>=0&&Z[Q]==="."){if(Q>=1&&Z[Q-1]==="?")Q-=2;else Q--;continue}return Q+1}else if(Y===")"){if(Q=i8(Z,Q,"(",")"),Q<0)return 0;if(Q--,Q>=0&&/[\w$]/.test(Z[Q]))continue;if(Q>=0&&Z[Q]==="."){if(Q>=1&&Z[Q-1]==="?")Q-=2;else Q--;continue}return Q+1}else if(Y==="]"){if(Q=i8(Z,Q,"[","]"),Q<0)return 0;if(Q--,Q>=0&&/[\w$]/.test(Z[Q]))continue;if(Q>=0&&Z[Q]==="."){if(Q>=1&&Z[Q-1]==="?")Q-=2;else Q--;continue}return Q+1}else return Q+1}return 0}function i8(Z,Q,Y,J){let X=1;Q--;while(Q>=0&&X>0){if(Z[Q]===J)X++;else if(Z[Q]===Y)X--;if(X>0)Q--}return Q}function g6(Z,Q={}){let Y=Z,J,X=new Set,K=new Set,H=new Set,z=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(Z)||Q.vmTarget,_=z?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0};if(z)J="none";let q=Z.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);if(q)J=q[2],Z=Z.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1");let R=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval)\b/,F;while(F=Z.match(R)){let C=F[2];if(C==="TjsStrict")_.tjsEquals=!0,_.tjsClass=!0,_.tjsDate=!0,_.tjsNoeval=!0,_.tjsNoVar=!0,_.tjsStandard=!0;else if(C==="TjsCompat")_.tjsEquals=!1,_.tjsClass=!1,_.tjsDate=!1,_.tjsNoeval=!1,_.tjsNoVar=!1,_.tjsStandard=!1,_.tjsSafeEval=!1;else if(C==="TjsEquals")_.tjsEquals=!0;else if(C==="TjsClass")_.tjsClass=!0;else if(C==="TjsDate")_.tjsDate=!0;else if(C==="TjsNoeval")_.tjsNoeval=!0;else if(C==="TjsNoVar")_.tjsNoVar=!0;else if(C==="TjsStandard")_.tjsStandard=!0;else if(C==="TjsSafeEval")_.tjsSafeEval=!0;Z=Z.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${C}\\s*`),"$1")}if(_.tjsStandard)Z=a8(Z);if(Z=q9(Z),Z=R9(Z),Z=o8(Z),_.tjsEquals&&!Q.vmTarget)Z=s8(Z);Z=r8(Z),Z=e8(Z),Z=t8(Z),Z=Z9(Z),Z=Q9(Z),Z=H9(Z);let{source:U,returnType:O,returnSafety:L}=G1(Z,{originalSource:Y,requiredParams:X,unsafeFunctions:K,safeFunctions:H});Z=U;let B=Y9(Z);Z=B.source,Z=n8(Z);let N=K9(Z,X);Z=N.source;let A=c8(Z);Z=A.source;let I=W9(Z,Q.dangerouslySkipTests);Z=I.source;let j=z9(Z,X);Z=j.source;for(let C of j.polyCtorClasses)K.add(`${C}$dispatch`);if(_.tjsClass)Z=G9(Z,j.polyCtorClasses);if(_.tjsDate)Z=_9(Z);if(_.tjsNoeval)Z=$9(Z);if(_.tjsNoVar)Z=F9(Z);return Z=J9(Z,B.extensions),{source:Z,returnType:O,returnSafety:L,moduleSafety:J,tjsModes:_,originalSource:Y,requiredParams:X,unsafeFunctions:K,safeFunctions:H,wasmBlocks:A.blocks,tests:I.tests,testErrors:I.errors,polymorphicNames:N.polymorphicNames,extensions:B.extensions}}function U9(Z,Q={}){let{filename:Y="<source>",colonShorthand:J=!0,vmTarget:X=!1}=Q,{source:K,returnType:H,returnSafety:W,moduleSafety:z,originalSource:_,requiredParams:q,unsafeFunctions:R,safeFunctions:F,wasmBlocks:U,tests:O,testErrors:L}=J?g6(Z,{vmTarget:X}):{source:Z,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:Z,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[]};try{return{ast:f8(K,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:H,returnSafety:W,moduleSafety:z,originalSource:_,requiredParams:q,unsafeFunctions:R,safeFunctions:F,wasmBlocks:U,tests:O,testErrors:L}}catch(B){let N=B.loc||{line:1,column:0};throw new Z0(B.message.replace(/\s*\(\d+:\d+\)$/,""),N,_,Y)}}function O9(Z,Q){for(let J of Z.body){if(J.type==="ImportDeclaration")throw new Z0("Imports are not supported. All atoms must be registered with the VM.",J.loc?.start||{line:1,column:0},void 0,Q);if(J.type==="ExportNamedDeclaration"||J.type==="ExportDefaultDeclaration")throw new Z0("Exports are not supported. The function is automatically exported.",J.loc?.start||{line:1,column:0},void 0,Q);if(J.type==="ClassDeclaration")throw new Z0("Classes are not supported. Agent99 uses functional composition.",J.loc?.start||{line:1,column:0},void 0,Q)}let Y=Z.body.filter((J)=>J.type==="FunctionDeclaration");if(Y.length===0)throw new Z0("Source must contain a function declaration",{line:1,column:0},void 0,Q);if(Y.length>1){let J=Y[1];throw new Z0("Only a single function per agent is allowed",J.loc?.start||{line:1,column:0},void 0,Q)}return Y[0]}function I9(Z,Q){let Y={params:{}};if(!Q.loc)return Y;let J=Z.substring(0,Q.start),X=[...J.matchAll(/\/\*#([\s\S]*?)\*\//g)];if(X.length>0){let q=X[X.length-1],R=J.substring(q.index+q[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(R)){let F=q[1],U=F.split(`
53
- `),O=U.filter((L)=>L.trim().length>0).reduce((L,B)=>{let N=B.match(/^(\s*)/)?.[1].length||0;return Math.min(L,N)},1/0);if(O>0&&O<1/0)F=U.map((L)=>L.slice(O)).join(`
54
- `);return Y.description=F.trim(),Y}}let K=J.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!K)return Y;let H=K[0],W=H.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);if(W)Y.description=W[1].trim();let z=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,_;while((_=z.exec(H))!==null)Y.params[_[1]]=_[2].trim();return Y}function z0(Z){switch(Z.type){case"Literal":{let Q=Z.value;if(Q===null)return{kind:"null"};if(typeof Q==="string")return{kind:"string"};if(typeof Q==="number"){let Y=Z.raw;if(Y&&Y.includes("."))return{kind:"number"};return{kind:"integer"}}if(typeof Q==="boolean")return{kind:"boolean"};return{kind:"any"}}case"ArrayExpression":{let Q=Z.elements;if(Q.length===0)return{kind:"array",items:{kind:"any"}};let Y=Q.filter((H)=>H!=null).map((H)=>z0(H));if(Y.length===0)return{kind:"array",items:{kind:"any"}};let J=new Map;for(let H of Y){let W=JSON.stringify(H);if(!J.has(W))J.set(W,H)}let X=[...J.values()];return{kind:"array",items:X.length===1?X[0]:{kind:"union",members:X}}}case"ObjectExpression":{let Q=Z.properties,Y={};for(let J of Q)if(J.type==="Property"&&J.key.type==="Identifier"){let X=J.key.name;Y[X]=z0(J.value)}return{kind:"object",shape:Y}}case"LogicalExpression":{let{operator:Q,left:Y,right:J}=Z;if(Q==="||")return z0(Y);if(Q==="&&")return z0(J);if(Q==="??")return z0(J);return{kind:"any"}}case"BinaryExpression":{let{operator:Q,left:Y,right:J}=Z;if(Q==="|"){let X=z0(Y),K=z0(J);if(K.kind==="null")return{...X,nullable:!0};if(X.kind==="null")return{...K,nullable:!0};return{kind:"union",members:[X,K]}}return{kind:"any"}}case"Identifier":{if(Z.name==="undefined")return{kind:"undefined"};return{kind:"any"}}case"UnaryExpression":{let{operator:Q,argument:Y}=Z;if(Q==="+"&&Y.type==="Literal"){if(typeof Y.value==="number")return{kind:"non-negative-integer"}}if(Q==="-"&&Y.type==="Literal"){if(typeof Y.value==="number"){let X=Y.raw;if(X&&X.includes("."))return{kind:"number"};return{kind:"integer"}}}return{kind:"any"}}default:return{kind:"any"}}}function f1(Z,Q){if(Z.type==="Identifier")return{name:Z.name,type:{kind:"any"},required:!0};if(Z.type==="AssignmentPattern"){let{left:Y,right:J}=Z;if(Y.type!=="Identifier")throw new d("Only simple parameter names are supported",l(Z));let X=Y.name,K=Q?.has(X)??!1,H=z0(J),W=F0(J);return{name:X,type:H,required:K,default:K?null:W,example:W,loc:{start:Z.start,end:Z.end}}}if(Z.type==="ObjectPattern"){let Y=Z.properties,J={},X={};for(let K of Y)if(K.type==="Property"){let H=K.key.type==="Identifier"?K.key.name:String(K.key.value);if(K.value.type==="Identifier")J[H]={kind:"any"},X[H]={name:H,type:{kind:"any"},required:!0};else if(K.value.type==="AssignmentPattern"){let W=f1(K.value,Q),z=Q?.has(H)??!1;J[H]=W.type,X[H]={name:H,type:W.type,required:z,default:z?null:W.example,example:W.example}}}return{name:"__destructured__",type:{kind:"object",shape:J,destructuredParams:X},required:!0}}throw new d(`Unsupported parameter pattern: ${Z.type}`,l(Z))}function F0(Z){switch(Z.type){case"Literal":return Z.value;case"ArrayExpression":return Z.elements.map((Q)=>Q?F0(Q):null);case"ObjectExpression":{let Q={};for(let Y of Z.properties)if(Y.type==="Property"&&Y.key.type==="Identifier")Q[Y.key.name]=F0(Y.value);return Q}case"UnaryExpression":if(Z.operator==="-"){let Q=F0(Z.argument);return typeof Q==="number"?-Q:void 0}if(Z.operator==="+"){let Q=F0(Z.argument);return typeof Q==="number"?+Q:void 0}return;case"BinaryExpression":{let{operator:Q,left:Y}=Z;if(Q==="|")return F0(Y);return}case"LogicalExpression":{let{operator:Q,left:Y,right:J}=Z;if(Q==="&&"){if(Y.type==="Literal"&&Y.value===null)return null}if(Q==="||")return F0(Y)??F0(J);if(Q==="??")return F0(Y)??F0(J);return}default:return}}function B9(Z){try{let Q=h8(Z,0,{ecmaVersion:2022});return z0(Q)}catch{return{kind:"any"}}}function F1(Z){switch(Z.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:Z.items?F1(Z.items):{}};case"object":if(Z.shape){let Q={};for(let[Y,J]of Object.entries(Z.shape))Q[Y]=F1(J);return{type:"object",properties:Q,additionalProperties:!1}}return{type:"object"};case"union":if(Z.members)return{oneOf:Z.members.map(F1)};return{};default:return{}}}function y6(Z){let Q={},Y=[];for(let[J,X]of Object.entries(Z))if(Q[J]=F1(X.type),X.required)Y.push(J);return{type:"object",properties:Q,required:Y.length>0?Y:void 0,additionalProperties:!1}}function L9(Z,Q,Y,J={},X){let K=I9(Q,Z),H=new Map;for(let B of Z.params){let N=f1(B,X);if(N.name==="__destructured__"&&N.type.kind==="object"&&N.type.destructuredParams)for(let[A,I]of Object.entries(N.type.destructuredParams))H.set(A,{...I,description:K.params[A]});else N.description=K.params[N.name],H.set(N.name,N)}let W;if(Y)W=B9(Y);let z={depth:0,locals:new Map,parameters:H,atoms:new Set(Object.keys(J.atoms||{})),warnings:[],source:Q,filename:J.filename||"<source>",options:J},_=$0(Z.body,z),q=[],R=[],F=[];for(let[B,N]of H.entries())if(N.required)R.push(B);else if(N.default!==void 0)F.push({name:B,defaultValue:N.default});else R.push(B);if(R.length>0)q.push({op:"varsImport",keys:R});for(let{name:B,defaultValue:N}of F)q.push({op:"varsImport",keys:[B]}),q.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:B},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:B,value:N}]});q.push(..._);let U=Object.fromEntries(H),O={name:Z.id?.name||"anonymous",description:K.description,parameters:U,returns:W},L=y6(U);return{ast:{op:"seq",steps:q,inputSchema:L},signature:O,warnings:z.warnings}}function $0(Z,Q){let Y=[];for(let J of Z.body){let X=l0(J,Q);if(X)if(Array.isArray(X))Y.push(...X);else Y.push(X)}return Y}function l0(Z,Q){switch(Z.type){case"VariableDeclaration":return f6(Z,Q);case"ExpressionStatement":return h6(Z,Q);case"IfStatement":return m6(Z,Q);case"WhileStatement":return u6(Z,Q);case"ForOfStatement":return d6(Z,Q);case"TryStatement":return l6(Z,Q);case"ReturnStatement":return p6(Z,Q);case"ThrowStatement":throw new d("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",l(Z),Q.source,Q.filename);case"BlockStatement":return{op:"scope",steps:$0(Z,H0(Q))};case"EmptyStatement":return null;default:throw new d(`Unsupported statement type: ${Z.type}`,l(Z),Q.source,Q.filename)}}function f6(Z,Q){let Y=[],J=Z.kind==="const",X=J?"constSet":"varSet";for(let K of Z.declarations){if(K.id.type!=="Identifier")throw new d("Only simple variable names are supported",l(K),Q.source,Q.filename);let H=K.id.name;if(K.init){let{step:W,resultVar:z}=T0(K.init,Q,H,J);if(W)Y.push(W);else if(z!==H)Y.push({op:X,key:H,value:z});let _=z0(K.init);Q.locals.set(H,_)}else{if(J)throw new d("const declarations must be initialized",l(K),Q.source,Q.filename);Y.push({op:"varSet",key:H,value:null}),Q.locals.set(H,{kind:"any",nullable:!0})}}return Y}function h6(Z,Q){let Y=Z.expression;if(Y.type==="AssignmentExpression")return x6(Y,Q);if(Y.type==="CallExpression"){let{step:J,resultVar:X}=T0(Y,Q);if(J)return J;if(X)return{op:"varSet",key:"_",value:X};return null}return Q.warnings.push({message:"Expression statement has no effect",line:l(Z).line,column:l(Z).column}),null}function x6(Z,Q){if(Z.left.type!=="Identifier")throw new d("Only simple variable assignment is supported",l(Z),Q.source,Q.filename);let Y=Z.left.name,{step:J,resultVar:X}=T0(Z.right,Q,Y);if(J)return J;return{op:"varSet",key:Y,value:X}}function m6(Z,Q){let Y=m(Z.test,Q),J=Z.consequent.type==="BlockStatement"?$0(Z.consequent,H0(Q)):[l0(Z.consequent,Q)].filter(Boolean),X;if(Z.alternate)X=Z.alternate.type==="BlockStatement"?$0(Z.alternate,H0(Q)):[l0(Z.alternate,Q)].filter(Boolean);return{op:"if",condition:Y,then:J,...X&&{else:X}}}function u6(Z,Q){let Y=m(Z.test,Q),J=Z.body.type==="BlockStatement"?$0(Z.body,H0(Q)):[l0(Z.body,Q)].filter(Boolean);return{op:"while",condition:Y,body:J}}function d6(Z,Q){let Y;if(Z.left.type==="VariableDeclaration"){let H=Z.left.declarations[0];if(H.id.type!=="Identifier")throw new d("Only simple variable names are supported in for...of",l(Z.left),Q.source,Q.filename);Y=H.id.name}else if(Z.left.type==="Identifier")Y=Z.left.name;else throw new d("Unsupported for...of left-hand side",l(Z.left),Q.source,Q.filename);let J=n(Z.right,Q),X=H0(Q);X.locals.set(Y,{kind:"any"});let K=Z.body.type==="BlockStatement"?$0(Z.body,X):[l0(Z.body,X)].filter(Boolean);return{op:"map",items:J,as:Y,steps:K}}function l6(Z,Q){let Y=$0(Z.block,H0(Q)),J,X;if(Z.handler){let K=H0(Q);if(Z.handler.param?.type==="Identifier")X=Z.handler.param.name,K.locals.set(X,{kind:"any"});J=$0(Z.handler.body,K)}return{op:"try",try:Y,...J&&{catch:J},...X&&{catchParam:X}}}function p6(Z,Q){if(!Z.argument)return{op:"return",value:{}};let{step:Y,resultVar:J}=T0(Z.argument,Q,"__returnVal__");if(Y)return[Y,{op:"return",value:J}];return{op:"return",value:n(Z.argument,Q)}}var N9=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),i6=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),p0=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),n6=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function c6(Z){if(Z.callee.type==="Identifier"){let Q=Z.callee.name;return i6.has(Q)||p0.has(Q)}if(Z.callee.type==="MemberExpression"){let Q=Z.callee;if(Q.object.type==="Identifier"){let Y=Q.object.name;if(N9.has(Y)||p0.has(Y))return!0}if(Q.property.type==="Identifier"){let Y=Q.property.name;if(n6.has(Y))return!0}}return!1}function o6(Z){if(Z.object.type==="Identifier"){let Q=Z.object.name;return N9.has(Q)||p0.has(Q)}return!1}var M9={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function a6(Z){if(Z.callee.type==="Identifier"){let Q=Z.callee.name;if(p0.has(Q))return M9[Q]||`${Q} is not available in AsyncJS.`}if(Z.callee.type==="MemberExpression"){let Q=Z.callee;if(Q.object.type==="Identifier"){let Y=Q.object.name;if(p0.has(Y))return M9[Y]||`${Y} is not available in AsyncJS.`}}return null}function j9(Z){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[Z]||" Use factory functions or object literals instead."}function T0(Z,Q,Y,J){let X=J?"constSet":"varSet";if(Z.type==="ChainExpression")return T0(Z.expression,Q,Y,J);if(Z.type==="NewExpression"){let H=Z,W="constructor";if(H.callee.type==="Identifier")W=H.callee.name;let z=j9(W);throw new d(`The 'new' keyword is not supported in AsyncJS.${z}`,l(Z),Q.source,Q.filename)}if(Z.type==="CallExpression"){let H=a6(Z);if(H)throw new d(H,l(Z),Q.source,Q.filename)}if(Z.type==="CallExpression"&&c6(Z)){let H=m(Z,Q);if(Y)return{step:{op:X,key:Y,value:H},resultVar:Y};return{step:null,resultVar:H}}if(Z.type==="MemberExpression"&&o6(Z)){let H=m(Z,Q);if(Y)return{step:{op:X,key:Y,value:H},resultVar:Y};return{step:null,resultVar:H}}if(Z.type==="CallExpression")return s6(Z,Q,Y,J);if(Z.type==="TemplateLiteral")return t6(Z,Q,Y,J);if(Z.type==="BinaryExpression"||Z.type==="LogicalExpression"||Z.type==="UnaryExpression"){let H=m(Z,Q);if(Y)return{step:{op:X,key:Y,value:H},resultVar:Y};return{step:null,resultVar:H}}return{step:null,resultVar:n(Z,Q)}}function s6(Z,Q,Y,J){let X,K=!1,H;if(Z.callee.type==="Identifier")X=Z.callee.name;else if(Z.callee.type==="MemberExpression"){let z=Z.callee;if(z.property.type==="Identifier")X=z.property.name,K=!0,H=n(z.object,Q);else throw new d("Computed method names are not supported",l(Z),Q.source,Q.filename)}else throw new d("Only named function calls are supported",l(Z),Q.source,Q.filename);if(K)return r6(X,H,Z.arguments,Q,Y,J);if(X==="console"&&Z.callee.type==="MemberExpression");let W=e6(Z,Q);return{step:{op:X,...W,...Y&&{result:Y},...Y&&J&&{resultConst:!0}},resultVar:Y}}function r6(Z,Q,Y,J,X,K){switch(Z){case"map":if(Y.length>0&&(Y[0].type==="ArrowFunctionExpression"||Y[0].type==="FunctionExpression")){let H=Y[0],W=H.params[0],z=W?.type==="Identifier"?W.name:"item",_=H0(J);_.locals.set(z,{kind:"any"});let q;if(H.body.type==="BlockStatement")q=$0(H.body,_);else{let{step:R,resultVar:F}=T0(H.body,_,"result");q=R?[R]:[{op:"varSet",key:"result",value:F}]}return{step:{op:"map",items:Q,as:z,steps:q,...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}break;case"filter":if(Y.length>0&&(Y[0].type==="ArrowFunctionExpression"||Y[0].type==="FunctionExpression")){let H=Y[0],W=H.params[0],z=W?.type==="Identifier"?W.name:"item",_=H0(J);_.locals.set(z,{kind:"any"});let q;if(H.body.type==="BlockStatement")throw new d("filter callback must be an expression, not a block",l(Y[0]),J.source,J.filename);else q=m(H.body,_);return{step:{op:"filter",items:Q,as:z,condition:q,...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}break;case"find":if(Y.length>0&&(Y[0].type==="ArrowFunctionExpression"||Y[0].type==="FunctionExpression")){let H=Y[0],W=H.params[0],z=W?.type==="Identifier"?W.name:"item",_=H0(J);_.locals.set(z,{kind:"any"});let q;if(H.body.type==="BlockStatement")throw new d("find callback must be an expression, not a block",l(Y[0]),J.source,J.filename);else q=m(H.body,_);return{step:{op:"find",items:Q,as:z,condition:q,...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}break;case"reduce":if(Y.length>=2&&(Y[0].type==="ArrowFunctionExpression"||Y[0].type==="FunctionExpression")){let H=Y[0],W=H.params[0],z=H.params[1],_=W?.type==="Identifier"?W.name:"acc",q=z?.type==="Identifier"?z.name:"item",R=H0(J);R.locals.set(_,{kind:"any"}),R.locals.set(q,{kind:"any"});let F;if(H.body.type==="BlockStatement")F=$0(H.body,R);else{let{step:O,resultVar:L}=T0(H.body,R,"result");F=O?[O]:[{op:"varSet",key:"result",value:L}]}let U=n(Y[1],J);return{step:{op:"reduce",items:Q,as:q,accumulator:_,initial:U,steps:F,...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}break;case"slice":break;case"push":return{step:{op:"push",list:Q,item:n(Y[0],J),...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X};case"join":return{step:{op:"join",list:Q,sep:Y.length>0?n(Y[0],J):"",...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X};case"split":return{step:{op:"split",str:Q,sep:Y.length>0?n(Y[0],J):"",...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}return J.warnings.push({message:`Unknown method '${Z}' - treating as atom call`,line:0,column:0}),{step:{op:Z,receiver:Q,args:Y.map((H)=>n(H,J)),...X&&{result:X},...X&&K&&{resultConst:!0}},resultVar:X}}function t6(Z,Q,Y,J){let X="",K={};for(let H=0;H<Z.quasis.length;H++)if(X+=Z.quasis[H].value.cooked||Z.quasis[H].value.raw,H<Z.expressions.length){let W=Z.expressions[H],z=`_${H}`;K[z]=n(W,Q),X+=`{{${z}}}`}return{step:{op:"template",tmpl:X,vars:K,...Y&&{result:Y},...Y&&J&&{resultConst:!0}},resultVar:Y}}function m(Z,Q){switch(Z.type){case"Literal":return{$expr:"literal",value:Z.value};case"Identifier":return{$expr:"ident",name:Z.name};case"MemberExpression":{let Y=Z,J=m(Y.object,Q),X=Y.optional===!0;if(Y.computed){let H=Y.property;if(H.type==="Literal")return{$expr:"member",object:J,property:String(H.value),computed:!0,...X&&{optional:!0}};throw new d("Computed member access with variables not yet supported",l(Z),Q.source,Q.filename)}let K=Y.property.name;return{$expr:"member",object:J,property:K,...X&&{optional:!0}}}case"ChainExpression":return m(Z.expression,Q);case"BinaryExpression":{let Y=Z;return{$expr:"binary",op:Y.operator,left:m(Y.left,Q),right:m(Y.right,Q)}}case"LogicalExpression":{let Y=Z;return{$expr:"logical",op:Y.operator,left:m(Y.left,Q),right:m(Y.right,Q)}}case"UnaryExpression":{let Y=Z;return{$expr:"unary",op:Y.operator,argument:m(Y.argument,Q)}}case"ConditionalExpression":{let Y=Z;return{$expr:"conditional",test:m(Y.test,Q),consequent:m(Y.consequent,Q),alternate:m(Y.alternate,Q)}}case"ArrayExpression":return{$expr:"array",elements:Z.elements.filter((J)=>J!==null).map((J)=>m(J,Q))};case"ObjectExpression":{let Y=Z,J=[];for(let X of Y.properties)if(X.type==="Property"){let K=X.key.type==="Identifier"?X.key.name:String(X.key.value);J.push({key:K,value:m(X.value,Q)})}return{$expr:"object",properties:J}}case"CallExpression":{let Y=Z;if(Y.callee.type==="MemberExpression"){let J=Y.callee,X=J.property.type==="Identifier"?J.property.name:String(J.property.value),K=J.optional===!0||Y.optional===!0;return{$expr:"methodCall",object:m(J.object,Q),method:X,arguments:Y.arguments.map((H)=>m(H,Q)),...K&&{optional:!0}}}if(Y.callee.type==="Identifier")return{$expr:"call",callee:Y.callee.name,arguments:Y.arguments.map((X)=>m(X,Q))};throw new d("Complex function calls in expressions should be lifted to statements",l(Z),Q.source,Q.filename)}case"NewExpression":{let Y=Z,J="constructor";if(Y.callee.type==="Identifier")J=Y.callee.name;let X=j9(J);throw new d(`The 'new' keyword is not supported in AsyncJS.${X}`,l(Z),Q.source,Q.filename)}case"TemplateLiteral":throw new d("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",l(Z),Q.source,Q.filename);default:throw new d(`Unsupported expression type in condition: ${Z.type}`,l(Z),Q.source,Q.filename)}}function n(Z,Q){switch(Z.type){case"Literal":return Z.value;case"Identifier":return Z.name;case"MemberExpression":{let Y=Z;if(Y.optional===!0)return m(Z,Q);let X=n(Y.object,Q);if(X&&typeof X==="object"&&X.$expr){let H=Y.computed?String(Y.property.value):Y.property.name;return{$expr:"member",object:X,property:H,...Y.computed&&{computed:!0}}}if(Y.computed)return`${X}[${n(Y.property,Q)}]`;let K=Y.property.name;if(typeof X==="string")return`${X}.${K}`;if(X&&X.$kind==="arg")return{$kind:"arg",path:`${X.path}.${K}`};return`${X}.${K}`}case"ChainExpression":return n(Z.expression,Q);case"ArrayExpression":return Z.elements.map((Y)=>Y?n(Y,Q):null);case"ObjectExpression":{let Y={};for(let J of Z.properties)if(J.type==="Property"){let X=J.key.type==="Identifier"?J.key.name:String(J.key.value);Y[X]=n(J.value,Q)}return Y}case"TemplateLiteral":return m(Z,Q);case"CallExpression":return m(Z,Q);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return m(Z,Q);default:return null}}function e6(Z,Q){if(Z.arguments.length===1&&Z.arguments[0].type==="ObjectExpression"){let Y=Z.arguments[0],J={};for(let X of Y.properties)if(X.type==="Property"){let K=X.key.type==="Identifier"?X.key.name:String(X.key.value);J[K]=n(X.value,Q)}return J}return{args:Z.arguments.map((Y)=>n(Y,Q))}}function w9(Z,Q={}){let{ast:Y,returnType:J,originalSource:X,requiredParams:K}=U9(Z,{filename:Q.filename,colonShorthand:!0,vmTarget:!0}),H=O9(Y,Q.filename),{ast:W,signature:z,warnings:_}=L9(H,X,J,Q,K);return{ast:W,signature:z,warnings:_}}var Q7=10;class Y7{atoms;constructor(Z={}){this.atoms={...n1,...Z}}get builder(){return new r(this.atoms)}get Agent(){return new r(this.atoms)}get A99(){return this.Agent}resolve(Z){return this.atoms[Z]}getTools(Z="all"){let Q=Object.values(this.atoms);if(Array.isArray(Z))Q=Q.filter((Y)=>Z.includes(Y.op));else if(Z==="flow"){let Y=["seq","if","while","return","try","varSet","varGet","scope"];Q=Q.filter((J)=>Y.includes(J.op))}return Q.map((Y)=>({type:"function",function:{name:Y.op,description:Y.docs,parameters:Y.inputSchema?.schema??{}}}))}async run(Z,Q={},Y={}){let J;if(typeof Z==="string")if(O1(Z))J=I1(Z);else try{J=w9(Z).ast}catch(U){throw Error(`AJS transpilation failed: ${U.message}`)}else J=Z;let X=Y.fuel??1000,K=Y.timeoutMs??X*Q7,H=Y.capabilities??{},W=[];if(!H.store){let U=new Map,O=!1;H.store={get:async(L)=>{if(!O)O=!0,W.push("Using default in-memory store (not suitable for production)");return U.get(L)},set:async(L,B)=>{if(!O)O=!0,W.push("Using default in-memory store (not suitable for production)");U.set(L,B)}}}let z=new AbortController,_=setTimeout(()=>z.abort(),K);if(Y.signal)Y.signal.addEventListener("abort",()=>z.abort());let q={fuel:{current:X},args:Q,state:{},consts:new Set,capabilities:H,resolver:(U)=>this.resolve(U),output:void 0,signal:z.signal,costOverrides:Y.costOverrides,context:Y.context,warnings:W};if(Y.trace)q.trace=[];if(J.op!=="seq")throw Error("Root AST must be 'seq'. Ensure you're passing a transpiled agent (use ajs`...` or transpile()).");let R=J.inputSchema;if(R&&!Z7(Q,R)){let U=new s("Input validation failed: args do not match expected schema","vm.run");return{result:U,error:U,fuelUsed:0,trace:q.trace,warnings:W.length>0?W:void 0}}try{await Promise.race([this.resolve("seq")?.exec(J,q),new Promise((U,O)=>{if(z.signal.addEventListener("abort",()=>{O(Error(`Execution timeout after ${K}ms (fuel: ${X}). Consider increasing fuel or optimizing your agent.`))}),z.signal.aborted)O(Error(`Execution timeout after ${K}ms (fuel: ${X}). Consider increasing fuel or optimizing your agent.`))})])}catch(U){if(U.message?.includes("timeout")||U.message?.includes("aborted")||z.signal.aborted)q.error=new s(`Execution timeout after ${K}ms (fuel: ${X}). Consider increasing fuel or optimizing your agent.`,"vm.run");else throw U}finally{clearTimeout(_)}if(q.error&&q.output===void 0)q.output=q.error;let F=[...W,...q.warnings??[]];return{result:q.output,error:q.error,fuelUsed:X-q.fuel.current,trace:q.trace,warnings:F.length>0?F:void 0}}}import{s as v}from"tosijs-schema";var A9=P("storeVectorize",v.object({text:v.string,model:v.string.optional}),v.array(v.number),async({text:Z},Q)=>{let Y=Q.capabilities.vector;if(!Y)throw Error("Capability 'vector' missing. Ensure vector battery is loaded.");let J=M(Z,Q);return Y.embed(J)},{docs:"Generate embeddings using vector battery",cost:20}),V9=P("storeCreateCollection",v.object({collection:v.string,dimension:v.number.optional}),void 0,async({collection:Z,dimension:Q},Y)=>{let J=Y.capabilities.store;if(!J?.createCollection)throw Error("Capability 'store' missing or does not support createCollection.");let X=M(Z,Y),K=M(Q,Y);return J.createCollection(X,void 0,K)},{docs:"Create a vector store collection",cost:5}),D9=P("storeVectorAdd",v.object({collection:v.string,doc:v.any}),void 0,async({collection:Z,doc:Q},Y)=>{let J=Y.capabilities.store;if(!J?.vectorAdd)throw Error("Capability 'store' missing or does not support vectorAdd.");let X=M(Z,Y),K=M(Q,Y);return J.vectorAdd(X,K)},{docs:"Add a document to a vector store collection",cost:5}),T9=P("storeSearch",v.object({collection:v.string,queryVector:v.array(v.number),k:v.number.optional,filter:v.record(v.any).optional}),v.array(v.any),async({collection:Z,queryVector:Q,k:Y,filter:J},X)=>{let K=X.capabilities.store;if(!K?.vectorSearch)throw Error("Capability 'store' missing or does not support vectorSearch.");let H=M(Z,X),W=M(Q,X),z=M(Y,X)??5,_=M(J,X);return K.vectorSearch(H,W,z,_)},{docs:"Search vector store",cost:(Z,Q)=>5+(M(Z.k,Q)??5)}),C9=P("llmPredictBattery",v.object({system:v.string.optional,user:v.string,tools:v.array(v.any).optional,responseFormat:v.any.optional}),v.object({role:v.string.optional,content:v.string.optional,tool_calls:v.array(v.any).optional}),async({system:Z,user:Q,tools:Y,responseFormat:J},X)=>{let K=X.capabilities.llmBattery;if(!K?.predict)throw Error("Capability 'llmBattery' missing or invalid.");let H=M(Z,X)??"You are a helpful agent.",W=M(Q,X),z=M(Y,X),_=M(J,X);return K.predict(H,W,z,_)},{docs:"Generate completion using LLM battery",cost:100}),P9=P("llmVision",v.object({system:v.string.optional,prompt:v.string,images:v.array(v.string),responseFormat:v.any.optional}),v.object({role:v.string.optional,content:v.string.optional,tool_calls:v.array(v.any).optional}),async({system:Z,prompt:Q,images:Y,responseFormat:J},X)=>{let K=X.capabilities.llmBattery;if(!K?.predict)throw Error("Capability 'llmBattery' missing or invalid.");let H=M(Z,X)??"You analyze images accurately and concisely.",W=M(Q,X),z=M(Y,X)??[],_=M(J,X);return K.predict(H,{text:W,images:z},void 0,_)},{docs:"Analyze images using a vision model",timeoutMs:120000,cost:150});var g7={storeCreateCollection:V9,storeSearch:T9,storeVectorAdd:D9,storeVectorize:A9,llmPredictBattery:C9,llmVision:P9};export{VZ as xmlParse,d9 as whileLoop,BZ as vectorSearch,s9 as varsLet,a9 as varsImport,r9 as varsExport,n9 as varSet,o9 as varGet,PZ as uuid,p9 as tryCatch,NZ as transpileCode,WZ as template,OZ as storeSet,IZ as storeQuery,vZ as storeProcedure,UZ as storeGet,KZ as split,Q0 as seq,t9 as scope,jZ as runCode,l9 as ret,M as resolveValue,I1 as resolveProcedureToken,kZ as releaseProcedure,zZ as regexMatch,QZ as reduce,CZ as random,JZ as push,P0 as procedureStore,GZ as pick,_Z as omit,qZ as merge,DZ as memoize,e9 as map,MZ as llmPredict,XZ as len,FZ as keys,AZ as jsonStringify,wZ as jsonParse,HZ as join,O1 as isProcedureToken,b9 as isAgentError,u9 as iff,B1 as hash,YZ as find,ZZ as filter,RZ as fetch,p as evaluateExpr,i9 as errorAtom,P as defineAtom,L0 as createChildScope,n1 as coreAtoms,c9 as constSet,bZ as consoleWarn,SZ as consoleLog,EZ as consoleError,gZ as clearExpiredProcedures,TZ as cache,R0 as builtins,g7 as batteryAtoms,LZ as agentRun,U1 as PROCEDURE_TOKEN_PREFIX,E9 as DEFAULT_PROCEDURE_TTL,v9 as DEFAULT_MAX_AST_SIZE,Y7 as AgentVM,s as AgentError};
55
-
56
- //# debugId=708AF18D1EB3E92564756E2164756E21
49
+ `,S+=` return __tjs.typeError('${u}', 'no matching constructor', a)
50
+ `,S+=`}
51
+ `,a=a.slice(0,p)+y+a.slice(d);let E=p+y.length;a=a.slice(0,E)+S+a.slice(E)}return{source:a,polyCtorClasses:n}}function cr(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,i;for(;(i=n.exec(e))!==null;){let a=i[1],o=i[2]||"",u=i.index,l=u+i[0].length-1,p=1,d=l+1;for(;d<e.length&&p>0;){let f=e[d];f==="{"?p++:f==="}"&&p--,d++}if(p===0){let f=d,m=e.slice(l,f);r+=e.slice(s,u),r+=`let ${a} = class ${a}${o} ${m}; `,t.has(a)?r+=`${a} = new Proxy(${a}, { apply(t, _, a) { return ${a}$dispatch(t, a) }, construct(t, a) { return ${a}$dispatch(t, a) } });`:r+=`${a} = new Proxy(${a}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function pr(e){let t=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now() or Timestamp.from()"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now()"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:n,message:r}of t)if(n.test(e))throw new Error(r);return e}function fr(e){let t=new Set,n=/\bconst!\s+(\w+)\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);if(t.size===0)return e;e=e.replace(/\bconst!\s+/g,"const ");let s=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let i of t){if(new RegExp(`\\b${i}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${i}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${i}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${i}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${i}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${i}'. const! bindings are read-only at compile time.`);let l="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${i}\\s*\\.\\s*(?:${l})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${i}'. const! bindings are read-only at compile time.`)}return e}function hr(e){if(/(?<![a-zA-Z_$])\bvar\s+/.test(e))throw new Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return e}function dr(e){if(/(?<![A-Za-z_$])\beval\s*\(/.test(e))throw new Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(e))throw new Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return e}function mr(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let i=e[n],a=e[n+1];if(r==="normal"){if(i==="/"&&a==="/"){r="line-comment",t+=i,n++;continue}if(i==="/"&&a==="*"){r="block-comment",t+=i,n++;continue}if(i==="'"){r="string-single",t+=i,n++;continue}if(i==='"'){r="string-double",t+=i,n++;continue}if(i==="`"){r="string-template",s++,t+=i,n++;continue}if(i==="!"&&a==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,u=ji(t);if(u<o){let l=t.slice(u);t=t.slice(0,u);let p=n+2;for(;p<e.length&&/[\w$]/.test(e[p]);)p++;let d=e.slice(n+2,p);t+=`__tjs.bang(${l},'${d}')`,n=p;continue}}t+=i,n++}else r==="line-comment"?(t+=i,i===`
52
+ `&&(r="normal"),n++):r==="block-comment"?(t+=i,i==="*"&&a==="/"?(t+=a,r="normal",n+=2):n++):r==="string-single"?(t+=i,i==="\\"?(t+=a||"",n+=2):(i==="'"&&(r="normal"),n++)):r==="string-double"?(t+=i,i==="\\"?(t+=a||"",n+=2):(i==='"'&&(r="normal"),n++)):r==="string-template"?(t+=i,i==="\\"?(t+=a||"",n+=2):i==="`"?(s--,r=s>0?"string-template":"normal",n++):i==="$"&&a==="{"?(t+=a,n+=2,r="normal"):n++):(t+=i,n++)}return t}function ji(e){let t=e.length-1;for(;t>=0&&/\s/.test(e[t]);)t--;if(t<0)return e.length;for(;t>=0;){let n=e[t];if(/[\w$]/.test(n)){for(;t>=0&&/[\w$]/.test(e[t]);)t--;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n===")"){if(t=Gn(e,t,"(",")"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n==="]"){if(t=Gn(e,t,"[","]"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else return t+1}return 0}function Gn(e,t,n,r){let s=1;for(t--;t>=0&&s>0;)e[t]===r?s++:e[t]===n&&s--,s>0&&t--;return t}function Oi(e,t={}){let n=e,r,s=new Set,i=new Set,a=new Set,u=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e)||t.vmTarget,l=u?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0};u&&(r="none");let p=e.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);p&&(r=p[2],e=e.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1"));let d=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval)\b/,f;for(;f=e.match(d);){let T=f[2];T==="TjsStrict"?(l.tjsEquals=!0,l.tjsClass=!0,l.tjsDate=!0,l.tjsNoeval=!0,l.tjsNoVar=!0,l.tjsStandard=!0):T==="TjsCompat"?(l.tjsEquals=!1,l.tjsClass=!1,l.tjsDate=!1,l.tjsNoeval=!1,l.tjsNoVar=!1,l.tjsStandard=!1,l.tjsSafeEval=!1):T==="TjsEquals"?l.tjsEquals=!0:T==="TjsClass"?l.tjsClass=!0:T==="TjsDate"?l.tjsDate=!0:T==="TjsNoeval"?l.tjsNoeval=!0:T==="TjsNoVar"?l.tjsNoVar=!0:T==="TjsStandard"?l.tjsStandard=!0:T==="TjsSafeEval"&&(l.tjsSafeEval=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${T}\\s*`),"$1")}l.tjsStandard&&(e=Zn(e)),e=fr(e),e=mr(e),e=Kn(e),l.tjsEquals&&!t.vmTarget&&(e=Qn(e)),e=Yn(e),e=er(e),e=Xn(e),e=tr(e),e=nr(e),e=or(e);let{source:m,returnType:g,returnSafety:v}=ut(e,{originalSource:n,requiredParams:s,unsafeFunctions:i,safeFunctions:a});e=m;let b=rr(e);e=b.source,e=Hn(e);let w=ar(e,s);e=w.source;let C=Jn(e);e=C.source;let y=ur(e,t.dangerouslySkipTests);e=y.source;let S=lr(e,s);e=S.source;for(let T of S.polyCtorClasses)i.add(`${T}$dispatch`);return l.tjsClass&&(e=cr(e,S.polyCtorClasses)),l.tjsDate&&(e=pr(e)),l.tjsNoeval&&(e=dr(e)),l.tjsNoVar&&(e=hr(e)),e=sr(e,b.extensions),{source:e,returnType:g,returnSafety:v,moduleSafety:r,tjsModes:l,originalSource:n,requiredParams:s,unsafeFunctions:i,safeFunctions:a,wasmBlocks:C.blocks,tests:y.tests,testErrors:y.errors,polymorphicNames:w.polymorphicNames,extensions:b.extensions}}function gr(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1}=t,{source:i,returnType:a,returnSafety:o,moduleSafety:u,originalSource:l,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:v}=r?Oi(e,{vmTarget:s}):{source:e,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:e,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[]};try{return{ast:Vn(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:a,returnSafety:o,moduleSafety:u,originalSource:l,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:v}}catch(b){let w=b.loc||{line:1,column:0};throw new Q(b.message.replace(/\s*\(\d+:\d+\)$/,""),w,l,n)}}function yr(e,t){for(let r of e.body){if(r.type==="ImportDeclaration")throw new Q("Imports are not supported. All atoms must be registered with the VM.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration")throw new Q("Exports are not supported. The function is automatically exported.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ClassDeclaration")throw new Q("Classes are not supported. Agent99 uses functional composition.",r.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(r=>r.type==="FunctionDeclaration");if(n.length===0)throw new Q("Source must contain a function declaration",{line:1,column:0},void 0,t);if(n.length>1){let r=n[1];throw new Q("Only a single function per agent is allowed",r.loc?.start||{line:1,column:0},void 0,t)}return n[0]}function br(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),s=[...r.matchAll(/\/\*#([\s\S]*?)\*\//g)];if(s.length>0){let p=s[s.length-1],d=r.substring(p.index+p[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(d)){let f=p[1],m=f.split(`
53
+ `),g=m.filter(v=>v.trim().length>0).reduce((v,b)=>{let w=b.match(/^(\s*)/)?.[1].length||0;return Math.min(v,w)},1/0);return g>0&&g<1/0&&(f=m.map(v=>v.slice(g)).join(`
54
+ `)),n.description=f.trim(),n}}let i=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!i)return n;let a=i[0],o=a.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let u=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,l;for(;(l=u.exec(a))!==null;)n.params[l[1]]=l[2].trim();return n}function oe(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(a=>a!=null).map(a=>oe(a));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let a of n){let o=JSON.stringify(a);r.has(o)||r.set(o,a)}let s=[...r.values()];return{kind:"array",items:s.length===1?s[0]:{kind:"union",members:s}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let s=r.key.name;n[s]=oe(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?oe(n):t==="&&"||t==="??"?oe(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=oe(n),i=oe(r);return i.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...i,nullable:!0}:{kind:"union",members:[s,i]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function jt(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new F("Only simple parameter names are supported",q(e));let s=n.name,i=t?.has(s)??!1,a=oe(r),o=pe(r);return{name:s,type:a,required:i,default:i?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let i of n)if(i.type==="Property"){let a=i.key.type==="Identifier"?i.key.name:String(i.key.value);if(i.value.type==="Identifier")r[a]={kind:"any"},s[a]={name:a,type:{kind:"any"},required:!0};else if(i.value.type==="AssignmentPattern"){let o=jt(i.value,t),u=t?.has(a)??!1;r[a]=o.type,s[a]={name:a,type:o.type,required:u,default:u?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new F(`Unsupported parameter pattern: ${e.type}`,q(e))}function pe(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?pe(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=pe(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=pe(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=pe(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?pe(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?pe(n)??pe(r):void 0}default:return}}function xr(e){try{let t=Ln(e,0,{ecmaVersion:2022});return oe(t)}catch{return{kind:"any"}}}function pt(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?pt(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=pt(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(pt)}:{};default:return{}}}function Vi(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=pt(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function wr(e,t,n,r={},s){let i=br(t,e),a=new Map;for(let b of e.params){let w=jt(b,s);if(w.name==="__destructured__"&&w.type.kind==="object"&&w.type.destructuredParams)for(let[C,y]of Object.entries(w.type.destructuredParams))a.set(C,{...y,description:i.params[C]});else w.description=i.params[w.name],a.set(w.name,w)}let o;n&&(o=xr(n));let u={depth:0,locals:new Map,parameters:a,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r},l=fe(e.body,u),p=[],d=[],f=[];for(let[b,w]of a.entries())w.required?d.push(b):w.default!==void 0?f.push({name:b,defaultValue:w.default}):d.push(b);d.length>0&&p.push({op:"varsImport",keys:d});for(let{name:b,defaultValue:w}of f)p.push({op:"varsImport",keys:[b]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:b},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:b,value:w}]});p.push(...l);let m=Object.fromEntries(a),g={name:e.id?.name||"anonymous",description:i.description,parameters:m,returns:o},v=Vi(m);return{ast:{op:"seq",steps:p,inputSchema:v},signature:g,warnings:u.warnings}}function fe(e,t){let n=[];for(let r of e.body){let s=Ue(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Ue(e,t){switch(e.type){case"VariableDeclaration":return Li(e,t);case"ExpressionStatement":return Di(e,t);case"IfStatement":return Ui(e,t);case"WhileStatement":return qi(e,t);case"ForOfStatement":return Wi(e,t);case"TryStatement":return zi(e,t);case"ReturnStatement":return Gi(e,t);case"ThrowStatement":throw new F("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",q(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:fe(e,ie(t))};case"EmptyStatement":return null;default:throw new F(`Unsupported statement type: ${e.type}`,q(e),t.source,t.filename)}}function Li(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let i of e.declarations){if(i.id.type!=="Identifier")throw new F("Only simple variable names are supported",q(i),t.source,t.filename);let a=i.id.name;if(i.init){let{step:o,resultVar:u}=Ae(i.init,t,a,r);o?n.push(o):u!==a&&n.push({op:s,key:a,value:u});let l=oe(i.init);t.locals.set(a,l)}else{if(r)throw new F("const declarations must be initialized",q(i),t.source,t.filename);n.push({op:"varSet",key:a,value:null}),t.locals.set(a,{kind:"any",nullable:!0})}}return n}function Di(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Fi(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=Ae(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:q(e).line,column:q(e).column}),null}function Fi(e,t){if(e.left.type!=="Identifier")throw new F("Only simple variable assignment is supported",q(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=Ae(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function Ui(e,t){let n=D(e.test,t),r=e.consequent.type==="BlockStatement"?fe(e.consequent,ie(t)):[Ue(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?fe(e.alternate,ie(t)):[Ue(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function qi(e,t){let n=D(e.test,t),r=e.body.type==="BlockStatement"?fe(e.body,ie(t)):[Ue(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Wi(e,t){let n;if(e.left.type==="VariableDeclaration"){let a=e.left.declarations[0];if(a.id.type!=="Identifier")throw new F("Only simple variable names are supported in for...of",q(e.left),t.source,t.filename);n=a.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new F("Unsupported for...of left-hand side",q(e.left),t.source,t.filename);let r=G(e.right,t),s=ie(t);s.locals.set(n,{kind:"any"});let i=e.body.type==="BlockStatement"?fe(e.body,s):[Ue(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:i}}function zi(e,t){let n=fe(e.block,ie(t)),r,s;if(e.handler){let i=ie(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,i.locals.set(s,{kind:"any"})),r=fe(e.handler.body,i)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function Gi(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=Ae(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:G(e.argument,t)}}var Sr=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Hi=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),qe=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),Ji=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function Ki(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Hi.has(t)||qe.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Sr.has(n)||qe.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Ji.has(n))return!0}}return!1}function Zi(e){if(e.object.type==="Identifier"){let t=e.object.name;return Sr.has(t)||qe.has(t)}return!1}var vr={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function Qi(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(qe.has(t))return vr[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(qe.has(n))return vr[n]||`${n} is not available in AsyncJS.`}}return null}function Er(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function Ae(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return Ae(e.expression,t,n,r);if(e.type==="NewExpression"){let a=e,o="constructor";a.callee.type==="Identifier"&&(o=a.callee.name);let u=Er(o);throw new F(`The 'new' keyword is not supported in AsyncJS.${u}`,q(e),t.source,t.filename)}if(e.type==="CallExpression"){let a=Qi(e);if(a)throw new F(a,q(e),t.source,t.filename)}if(e.type==="CallExpression"&&Ki(e)){let a=D(e,t);return n?{step:{op:s,key:n,value:a},resultVar:n}:{step:null,resultVar:a}}if(e.type==="MemberExpression"&&Zi(e)){let a=D(e,t);return n?{step:{op:s,key:n,value:a},resultVar:n}:{step:null,resultVar:a}}if(e.type==="CallExpression")return Yi(e,t,n,r);if(e.type==="TemplateLiteral")return ea(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let a=D(e,t);return n?{step:{op:s,key:n,value:a},resultVar:n}:{step:null,resultVar:a}}return{step:null,resultVar:G(e,t)}}function Yi(e,t,n,r){let s,i=!1,a;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let u=e.callee;if(u.property.type==="Identifier")s=u.property.name,i=!0,a=G(u.object,t);else throw new F("Computed method names are not supported",q(e),t.source,t.filename)}else throw new F("Only named function calls are supported",q(e),t.source,t.filename);if(i)return Xi(s,a,e.arguments,t,n,r);s==="console"&&e.callee.type;let o=ta(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function Xi(e,t,n,r,s,i){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let a=n[0],o=a.params[0],u=o?.type==="Identifier"?o.name:"item",l=ie(r);l.locals.set(u,{kind:"any"});let p;if(a.body.type==="BlockStatement")p=fe(a.body,l);else{let{step:d,resultVar:f}=Ae(a.body,l,"result");p=d?[d]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:u,steps:p,...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let a=n[0],o=a.params[0],u=o?.type==="Identifier"?o.name:"item",l=ie(r);l.locals.set(u,{kind:"any"});let p;if(a.body.type==="BlockStatement")throw new F("filter callback must be an expression, not a block",q(n[0]),r.source,r.filename);return p=D(a.body,l),{step:{op:"filter",items:t,as:u,condition:p,...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let a=n[0],o=a.params[0],u=o?.type==="Identifier"?o.name:"item",l=ie(r);l.locals.set(u,{kind:"any"});let p;if(a.body.type==="BlockStatement")throw new F("find callback must be an expression, not a block",q(n[0]),r.source,r.filename);return p=D(a.body,l),{step:{op:"find",items:t,as:u,condition:p,...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let a=n[0],o=a.params[0],u=a.params[1],l=o?.type==="Identifier"?o.name:"acc",p=u?.type==="Identifier"?u.name:"item",d=ie(r);d.locals.set(l,{kind:"any"}),d.locals.set(p,{kind:"any"});let f;if(a.body.type==="BlockStatement")f=fe(a.body,d);else{let{step:g,resultVar:v}=Ae(a.body,d,"result");f=g?[g]:[{op:"varSet",key:"result",value:v}]}let m=G(n[1],r);return{step:{op:"reduce",items:t,as:p,accumulator:l,initial:m,steps:f,...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:G(n[0],r),...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?G(n[0],r):"",...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?G(n[0],r):"",...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(a=>G(a,r)),...s&&{result:s},...s&&i&&{resultConst:!0}},resultVar:s}}function ea(e,t,n,r){let s="",i={};for(let a=0;a<e.quasis.length;a++)if(s+=e.quasis[a].value.cooked||e.quasis[a].value.raw,a<e.expressions.length){let o=e.expressions[a],u=`_${a}`;i[u]=G(o,t),s+=`{{${u}}}`}return{step:{op:"template",tmpl:s,vars:i,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function D(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=D(n.object,t),s=n.optional===!0;if(n.computed){let a=n.property;if(a.type==="Literal")return{$expr:"member",object:r,property:String(a.value),computed:!0,...s&&{optional:!0}};throw new F("Computed member access with variables not yet supported",q(e),t.source,t.filename)}let i=n.property.name;return{$expr:"member",object:r,property:i,...s&&{optional:!0}}}case"ChainExpression":return D(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:D(n.left,t),right:D(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:D(n.left,t),right:D(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:D(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:D(n.test,t),consequent:D(n.consequent,t),alternate:D(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>D(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let i=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:i,value:D(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),i=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:D(r.object,t),method:s,arguments:n.arguments.map(a=>D(a,t)),...i&&{optional:!0}}}if(n.callee.type==="Identifier")return{$expr:"call",callee:n.callee.name,arguments:n.arguments.map(s=>D(s,t))};throw new F("Complex function calls in expressions should be lifted to statements",q(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=Er(r);throw new F(`The 'new' keyword is not supported in AsyncJS.${s}`,q(e),t.source,t.filename)}case"TemplateLiteral":throw new F("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",q(e),t.source,t.filename);default:throw new F(`Unsupported expression type in condition: ${e.type}`,q(e),t.source,t.filename)}}function G(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return D(e,t);let s=G(n.object,t);if(s&&typeof s=="object"&&s.$expr){let a=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:a,...n.computed&&{computed:!0}}}if(n.computed)return`${s}[${G(n.property,t)}]`;let i=n.property.name;return typeof s=="string"?`${s}.${i}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${i}`}:`${s}.${i}`}case"ChainExpression":return G(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?G(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=G(r.value,t)}return n}case"TemplateLiteral":return D(e,t);case"CallExpression":return D(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return D(e,t);default:return null}}function ta(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let s of n.properties)if(s.type==="Property"){let i=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[i]=G(s.value,t)}return r}return{args:e.arguments.map(n=>G(n,t))}}function Cr(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:i}=gr(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),a=yr(n,t.filename),{ast:o,signature:u,warnings:l}=wr(a,s,r,t,i);return{ast:o,signature:u,warnings:l}}var ra=10,kr=class{atoms;constructor(t={}){this.atoms={...zt,...t}}get builder(){return new Me(this.atoms)}get Agent(){return new Me(this.atoms)}get A99(){return this.Agent}resolve(t){return this.atoms[t]}getTools(t="all"){let n=Object.values(this.atoms);if(Array.isArray(t))n=n.filter(r=>t.includes(r.op));else if(t==="flow"){let r=["seq","if","while","return","try","varSet","varGet","scope"];n=n.filter(s=>r.includes(s.op))}return n.map(r=>({type:"function",function:{name:r.op,description:r.docs,parameters:r.inputSchema?.schema??{}}}))}async run(t,n={},r={}){let s;if(typeof t=="string")if(mt(t))s=gt(t);else try{s=Cr(t).ast}catch(g){throw new Error(`AJS transpilation failed: ${g.message}`)}else s=t;let i=r.fuel??1e3,a=r.timeoutMs??i*ra,o=r.capabilities??{},u=[];if(!o.store){let g=new Map,v=!1;o.store={get:async b=>(v||(v=!0,u.push("Using default in-memory store (not suitable for production)")),g.get(b)),set:async(b,w)=>{v||(v=!0,u.push("Using default in-memory store (not suitable for production)")),g.set(b,w)}}}let l=new AbortController,p=setTimeout(()=>l.abort(),a);r.signal&&r.signal.addEventListener("abort",()=>l.abort());let d={fuel:{current:i},args:n,state:{},consts:new Set,capabilities:o,resolver:g=>this.resolve(g),output:void 0,signal:l.signal,costOverrides:r.costOverrides,context:r.context,warnings:u};if(r.trace&&(d.trace=[]),s.op!=="seq")throw new Error("Root AST must be 'seq'. Ensure you're passing a transpiled agent (use ajs`...` or transpile()).");let f=s.inputSchema;if(f&&!na(n,f)){let g=new K("Input validation failed: args do not match expected schema","vm.run");return{result:g,error:g,fuelUsed:0,trace:d.trace,warnings:u.length>0?u:void 0}}try{await Promise.race([this.resolve("seq")?.exec(s,d),new Promise((g,v)=>{l.signal.addEventListener("abort",()=>{v(new Error(`Execution timeout after ${a}ms (fuel: ${i}). Consider increasing fuel or optimizing your agent.`))}),l.signal.aborted&&v(new Error(`Execution timeout after ${a}ms (fuel: ${i}). Consider increasing fuel or optimizing your agent.`))})])}catch(g){if(g.message?.includes("timeout")||g.message?.includes("aborted")||l.signal.aborted)d.error=new K(`Execution timeout after ${a}ms (fuel: ${i}). Consider increasing fuel or optimizing your agent.`,"vm.run");else throw g}finally{clearTimeout(p)}d.error&&d.output===void 0&&(d.output=d.error);let m=[...u,...d.warnings??[]];return{result:d.output,error:d.error,fuelUsed:i-d.fuel.current,trace:d.trace,warnings:m.length>0?m:void 0}}};import{s as M}from"tosijs-schema";var Ar=I("storeVectorize",M.object({text:M.string,model:M.string.optional}),M.array(M.number),async({text:e},t)=>{let n=t.capabilities.vector;if(!n)throw new Error("Capability 'vector' missing. Ensure vector battery is loaded.");let r=x(e,t);return n.embed(r)},{docs:"Generate embeddings using vector battery",cost:20}),_r=I("storeCreateCollection",M.object({collection:M.string,dimension:M.number.optional}),void 0,async({collection:e,dimension:t},n)=>{let r=n.capabilities.store;if(!r?.createCollection)throw new Error("Capability 'store' missing or does not support createCollection.");let s=x(e,n),i=x(t,n);return r.createCollection(s,void 0,i)},{docs:"Create a vector store collection",cost:5}),Tr=I("storeVectorAdd",M.object({collection:M.string,doc:M.any}),void 0,async({collection:e,doc:t},n)=>{let r=n.capabilities.store;if(!r?.vectorAdd)throw new Error("Capability 'store' missing or does not support vectorAdd.");let s=x(e,n),i=x(t,n);return r.vectorAdd(s,i)},{docs:"Add a document to a vector store collection",cost:5}),Ir=I("storeSearch",M.object({collection:M.string,queryVector:M.array(M.number),k:M.number.optional,filter:M.record(M.any).optional}),M.array(M.any),async({collection:e,queryVector:t,k:n,filter:r},s)=>{let i=s.capabilities.store;if(!i?.vectorSearch)throw new Error("Capability 'store' missing or does not support vectorSearch.");let a=x(e,s),o=x(t,s),u=x(n,s)??5,l=x(r,s);return i.vectorSearch(a,o,u,l)},{docs:"Search vector store",cost:(e,t)=>5+(x(e.k,t)??5)}),Pr=I("llmPredictBattery",M.object({system:M.string.optional,user:M.string,tools:M.array(M.any).optional,responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,user:t,tools:n,responseFormat:r},s)=>{let i=s.capabilities.llmBattery;if(!i?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let a=x(e,s)??"You are a helpful agent.",o=x(t,s),u=x(n,s),l=x(r,s);return i.predict(a,o,u,l)},{docs:"Generate completion using LLM battery",cost:100}),Nr=I("llmVision",M.object({system:M.string.optional,prompt:M.string,images:M.array(M.string),responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,prompt:t,images:n,responseFormat:r},s)=>{let i=s.capabilities.llmBattery;if(!i?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let a=x(e,s)??"You analyze images accurately and concisely.",o=x(t,s),u=x(n,s)??[],l=x(r,s);return i.predict(a,{text:o,images:u},void 0,l)},{docs:"Analyze images using a vision model",timeoutMs:12e4,cost:150});var ja={storeCreateCollection:_r,storeSearch:Ir,storeVectorAdd:Tr,storeVectorize:Ar,llmPredictBattery:Pr,llmVision:Nr};export{K as AgentError,kr as AgentVM,Br as DEFAULT_MAX_AST_SIZE,$r as DEFAULT_PROCEDURE_TTL,dt as PROCEDURE_TOKEN_PREFIX,Ss as agentRun,ja as batteryAtoms,he as builtins,Is as cache,Os as clearExpiredProcedures,$s as consoleError,Rs as consoleLog,Ms as consoleWarn,Kr as constSet,zt as coreAtoms,xe as createChildScope,I as defineAtom,Hr as errorAtom,W as evaluateExpr,gs as fetch,ns as filter,ss as find,yt as hash,qr as iff,Mr as isAgentError,mt as isProcedureToken,us as join,ks as jsonParse,As as jsonStringify,ds as keys,as as len,ws as llmPredict,ts as map,Ts as memoize,hs as merge,fs as omit,ps as pick,Te as procedureStore,is as push,Ps as random,rs as reduce,cs as regexMatch,js as releaseProcedure,gt as resolveProcedureToken,x as resolveValue,zr as ret,Cs as runCode,es as scope,ee as seq,os as split,ys as storeGet,Bs as storeProcedure,xs as storeQuery,bs as storeSet,ls as template,Es as transpileCode,Gr as tryCatch,Ns as uuid,Zr as varGet,Jr as varSet,Xr as varsExport,Qr as varsImport,Yr as varsLet,vs as vectorSearch,Wr as whileLoop,_s as xmlParse};
55
+ //# sourceMappingURL=tjs-vm.js.map