tjs-lang 0.8.3 → 0.8.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,62 +1,62 @@
1
- import{s as h,validate as dt,filter as zt}from"tosijs-schema";var ze=Symbol.for("tjs.equals");function He(e,t){if(e!==null&&typeof e=="object"&&typeof e[ze]=="function")return e[ze](t);if(t!==null&&typeof t=="object"&&typeof t[ze]=="function")return t[ze](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,a)=>He(s,t[a]));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=>He(e[s],t[s]))}var H=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 Or(e){return e instanceof H||e&&e.$error===!0}var _e=new Map,Dr=3600*1e3,Lr=100*1024,mt="proc_";function gt(e){return typeof e=="string"&&e.startsWith(mt)}function yt(e){let t=_e.get(e);if(!t)throw new Error(`Procedure not found: ${e}`);if(Date.now()>t.expiresAt)throw _e.delete(e),new Error(`Procedure expired: ${e}`);return t.ast}function Vr(){return typeof crypto<"u"&&crypto.randomUUID?mt+crypto.randomUUID():mt+Math.random().toString(36).slice(2)+Date.now().toString(36)}var Gt=new Set(["__proto__","constructor","prototype"]);function Dt(e){if(Gt.has(e))throw new Error(`Security Error: Access to '${e}' is forbidden`)}var Fr=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","metadata.google.internal"]);function Ur(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return!0;let n=t.hostname.toLowerCase();return!!(Fr.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 qr(e){return!!(/\([^)]*[+*][^)]*\)[+*]/.test(e)||/\(([^|)]+)\|\1\)[+*]/.test(e)||/\(\.\*\)\+/.test(e)||/\(\.\+\)\+/.test(e)||/\(\[.*\]\+\)\+/.test(e))}function xe(e){return{...e,state:Object.create(e.state)}}function Wr(e,t){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r){let a=e[s],i=t[s];i!==a&&(n[s]=i)}return n}function w(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(Gt.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]=w(e[r],t);return n}return Array.isArray(e)?e.map(n=>w(n,t)):e}function Ee(e,t,n){return new Proxy(t,{get(r,s){if(s in r)return r[s];let a=n?.[s];throw a?new Error(`${e}.${s} is not available. ${a}`):new Error(`${e}.${s} is not supported in AsyncJS. Check docs for available ${e} methods.`)}})}function Ae(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:Ae(e[0])};if(t==="object"){let n={},r=[];for(let[s,a]of Object.entries(e))n[s]=Ae(a),r.push(s);return{type:"object",properties:n,required:r}}return{}}var he={Math:Ee("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:Ee("JSON",{parse:e=>JSON.parse(e),stringify:(e,t,n)=>JSON.stringify(e,t,n)}),console:Ee("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:Ee("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:Ee("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:Ee("String",{fromCharCode:(...e)=>String.fromCharCode(...e),fromCodePoint:(...e)=>String.fromCodePoint(...e)}),Number:Ee("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=Ae(t),r=zt(e,n);if(r instanceof Error)throw r;return r},Schema:{...h,response:(e,t)=>{let n=t?.schema!=null?t.schema:Ae(t);return{type:"json_schema",json_schema:{name:e,strict:!0,schema:n}}},fromExample:e=>Ae(e),isValid:(e,t)=>t?.schema!=null?dt(e,t):dt(e,Ae(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:a=0,hours:i=0,minutes:o=0,seconds:l=0,ms:u=0}={}){let p=new globalThis.Date(n.getTime());return r&&p.setFullYear(p.getFullYear()+r),s&&p.setMonth(p.getMonth()+s),a&&p.setDate(p.getDate()+a),i&&p.setHours(p.getHours()+i),o&&p.setMinutes(p.getMinutes()+o),l&&p.setSeconds(p.getSeconds()+l),u&&p.setMilliseconds(p.getMilliseconds()+u),e(p)},diff(r,s="ms"){let a=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime(),i=n.getTime()-a;switch(s){case"seconds":return i/1e3;case"minutes":return i/6e4;case"hours":return i/36e5;case"days":return i/864e5;default:return i}},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})()},Ge={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."},zr=.01,Lt=1e-4,Vt=.001,Gr=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-=zr,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 Ge)throw new Error(Ge[e.name]);return}case"member":{let n=W(e.object,t);if(e.optional&&n==null)return;let r=typeof e.property=="object"&&e.property!==null?W(e.property,t):e.property;return Dt(String(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*Lt,t.fuel.current<=0)){t.error=new H("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 He(n,r);case"!=":return!He(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(a=>W(a,t)),s=typeof r[0]=="string"?r[0]:"Error";t.error=new H(s,"Error");return}if(e.callee in he){let r=he[e.callee];if(typeof r=="function"){let s=e.arguments.map(a=>W(a,t));return r(...s)}}throw t.resolver(e.callee)?new Error(`Atom calls in expressions not yet supported: ${e.callee}`):e.callee in Ge?new Error(Ge[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(Dt(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 a=e.arguments.map(o=>W(o,t)),i=s.apply(n,a);if(t.fuel&&Gr.has(r)){let o=0;if(typeof i=="string"?o=i.length*Lt:Array.isArray(i)?o=i.length*Vt:typeof i=="object"&&i!==null&&(o=Object.keys(i).length*Vt),t.fuel.current-=o,t.fuel.current<=0){t.error=new H("Out of Fuel",`expr.${r}`);return}}return i}default:throw new Error(`Unknown expression type: ${e.$expr}`)}}function P(e,t,n,r,s={}){let{docs:a="",timeoutMs:i=1e3,cost:o=1}=typeof s=="string"?{docs:s}:s;return{op:e,inputSchema:t,outputSchema:n,exec:async(u,p)=>{let{op:d,result:f,...m}=u;if(p.error)return;let g=p.trace?{...p.state}:null,b=p.fuel.current,x,E;try{let S=p.costOverrides?.[e],y=S!==void 0?S:o,C=typeof y=="function"?y(m,p):y;if((p.fuel.current-=C)<=0){p.error=new H("Out of Fuel",e);return}let k=p.timeoutOverrides?.[e],v=k!==void 0?k:i,A=typeof v=="function"?v(m,p):v,N,I=async()=>r(u,p);if(x=A>0?await Promise.race([I(),new Promise((R,j)=>{N=setTimeout(()=>j(new Error(`Atom '${e}' timed out`)),A)})]).finally(()=>clearTimeout(N)):await I(),u.result){if(p.consts.has(u.result))throw new Error(`Cannot reassign const variable '${u.result}'`);if(x!==void 0&&n&&!dt(x,n)){p.error=new H(`Output validation failed for '${e}'`,e);return}p.state[u.result]=x,u.resultConst&&p.consts.add(u.result)}}catch(S){E=S.message||String(S),p.error=new H(E,e,S)}finally{if(p.trace&&g){let S=Wr(g,p.state);p.trace.push({op:e,input:m,stateDiff:S,result:x,error:E,fuelBefore:b,fuelAfter:p.fuel.current,timestamp:new Date().toISOString()})}}},docs:a,timeoutMs:i,cost:o,create:u=>({op:e,...u})}}var X=P("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}),Hr=P("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 X.exec({op:"seq",steps:e.then},t):e.else&&await X.exec({op:"seq",steps:e.else},t)},{docs:"If/Else",timeoutMs:0,cost:.1}),Jr=P("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 X.exec({op:"seq",steps:e.body},t),t.output!==void 0||t.error)return}},{docs:"While Loop",timeoutMs:0,cost:.1}),Kr=P("return",void 0,h.any,async(e,t)=>{if(t.error)return t.output=t.error,t.error;if("value"in e){let r=w(e.value,t);if(!t.localCall&&r!==void 0&&r!==null&&!Or(r)&&(typeof r!="object"||Array.isArray(r))){let s=new H(`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=zt(n,e.schema);r instanceof Error||(n=r)}}return t.output=n,n},{docs:"Return",cost:.1}),Zr=P("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 X.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 X.exec({op:"seq",steps:e.catch},t)}},{docs:"Try/Catch",timeoutMs:0,cost:.1}),Qr=P("Error",h.object({args:h.array(h.any).optional}),void 0,async(e,t)=>{let n=e.args?.[0]??"Error";t.error=new H(String(n),"Error")},{docs:"Trigger error flow",cost:.1}),Yr=P("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]=w(t,n)},{docs:"Set Variable",cost:.1}),Xr=P("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]=w(t,n),n.consts.add(e)},{docs:"Set Const Variable (immutable)",cost:.1}),es=P("varGet",h.object({key:h.string}),h.any,async({key:e},t)=>w(e,t),{docs:"Get Variable",cost:.1}),ts=P("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]=w({$kind:"arg",path:n},t);else for(let[n,r]of Object.entries(e))t.state[n]=w({$kind:"arg",path:r},t)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:.2}),ns=P("varsLet",h.record(h.any),void 0,async(e,t)=>{for(let n of Object.keys(e))n==="op"||n==="result"||(t.state[n]=w(e[n],t))},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:.1}),rs=P("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]=w(r,t);else for(let[r,s]of Object.entries(e))n[r]=w(s,t);return n},{docs:"Export variables from the current scope, with optional renaming.",cost:.2}),ss=P("scope",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{let n=xe(t);await X.exec({op:"seq",steps:e},n),n.output!==void 0&&(t.output=n.output)},{docs:"Create new scope",timeoutMs:0,cost:.1}),Ft=256,is=P("callLocal",h.object({name:h.string,args:h.array(h.any)}),void 0,async({name:e,args:t},n)=>{let r=n.helpers?.[e];if(!r)return n.error=new H(`Unknown helper: ${e}`,"callLocal"),n.error;let s=(n.callDepth??0)+1;if(s>Ft)return n.error=new H(`Maximum helper call depth (${Ft}) exceeded \u2014 likely infinite recursion in '${e}'`,"callLocal"),n.error;let a=t.map(o=>w(o,n)),i={...n,state:{},consts:new Set,output:void 0,error:void 0,localCall:!0,callDepth:s};for(let o=0;o<r.paramNames.length;o++)i.state[r.paramNames[o]]=a[o];return await X.exec({op:"seq",steps:r.steps},i),i.error&&(n.error=i.error),i.output},{docs:"Invoke a local helper function by name",timeoutMs:0,cost:.1}),as=P("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=[],a=w(e,r);if(!Array.isArray(a))throw new Error("map: items is not an array");for(let i of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=i,await X.exec({op:"seq",steps:n},o),s.push(o.state.result??null)}return s},{docs:"Map Array",timeoutMs:0,cost:1}),os=P("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=[],a=w(e,r);if(!Array.isArray(a))throw new Error("filter: items is not an array");for(let i of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=i,W(n,o)&&s.push(i)}return s},{docs:"Filter Array",timeoutMs:0,cost:1}),ls=P("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},a)=>{let i=w(e,a),o=w(r,a);if(!Array.isArray(i))throw new Error("reduce: items is not an array");let l=o;for(let u of i){if(a.signal?.aborted)throw new Error("Execution aborted");let p=xe(a);p.state[t]=u,p.state[n]=l,await X.exec({op:"seq",steps:s},p),l=p.state.result??l}return l},{docs:"Reduce Array",timeoutMs:0,cost:1}),us=P("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=w(e,r);if(!Array.isArray(s))throw new Error("find: items is not an array");for(let a of s){if(r.signal?.aborted)throw new Error("Execution aborted");let i=xe(r);if(i.state[t]=a,W(n,i))return a}return null},{docs:"Find in Array",timeoutMs:0,cost:1}),cs=P("push",h.object({list:h.array(h.any),item:h.any}),h.array(h.any),async({list:e,item:t},n)=>{let r=w(e,n),s=w(t,n);return Array.isArray(r)&&r.push(s),r},{docs:"Push to Array",cost:1}),ps=P("len",h.object({list:h.any}),h.number,async({list:e},t)=>{let n=w(e,t);return Array.isArray(n)||typeof n=="string"?n.length:0},{docs:"Length",cost:1}),fs=P("split",h.object({str:h.string,sep:h.string}),h.array(h.string),async({str:e,sep:t},n)=>w(e,n).split(w(t,n)),{docs:"Split String",cost:1}),hs=P("join",h.object({list:h.array(h.string),sep:h.string}),h.string,async({list:e,sep:t},n)=>w(e,n).join(w(t,n)),{docs:"Join String",cost:1}),ds=P("template",h.object({tmpl:h.string,vars:h.record(h.any)}),h.string,async({tmpl:e,vars:t},n)=>w(e,n).replace(/\{\{(\w+)\}\}/g,(s,a)=>String(w(t[a],n)??"")),{docs:"String Template",cost:1}),ms=P("regexMatch",h.object({pattern:h.string,value:h.any}),h.boolean,async({pattern:e,value:t},n)=>{if(qr(e))throw new Error(`Suspicious regex pattern rejected (potential ReDoS): ${e}`);let r=w(t,n);return new RegExp(e).test(r)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),gs=P("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=w(e,n),s=w(t,n),a={};return r&&Array.isArray(s)&&s.forEach(i=>a[i]=r[i]),a},{docs:"Pick Keys",cost:1}),ys=P("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=w(e,n),s=new Set(w(t,n)),a={};return r&&Object.keys(r).forEach(i=>{s.has(i)||(a[i]=r[i])}),a},{docs:"Omit Keys",cost:1}),bs=P("merge",h.object({a:h.record(h.any),b:h.record(h.any)}),h.record(h.any),async({a:e,b:t},n)=>({...w(e,n),...w(t,n)}),{docs:"Merge Objects",cost:1}),xs=P("keys",h.object({obj:h.record(h.any)}),h.array(h.string),async({obj:e},t)=>Object.keys(w(e,t)??{}),{docs:"Object Keys",cost:1}),Ut=10,qt="X-Agent-Depth";function vs(e,t){try{let r=new URL(e).hostname.toLowerCase();for(let s of t){let a=s.toLowerCase();if(a.startsWith("*.")){let i=a.slice(1);if(r.endsWith(i)||r===a.slice(2))return!0}else if(r===a)return!0}return!1}catch{return!1}}var ws=P("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=w(e.url,t),r=w(e.method,t),s=w(e.headers,t)||{},a=w(e.body,t),i=w(e.responseType,t),o=t.context?.requestDepth??0;if(o>=Ut)throw new Error(`Agent request depth exceeded (max ${Ut}). This prevents recursive agent loops.`);if(t.capabilities.fetch)return t.capabilities.fetch(n,{method:r,headers:{...s,[qt]:String(o+1)},body:a,signal:t.signal,responseType:i});let l=t.context?.allowedFetchDomains;if(l){if(!vs(n,l))throw new Error(`Fetch blocked: domain not in allowlist. Allowed: ${l.join(", ")}`)}else{if(Ur(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(u){throw u.message.includes("allowedFetchDomains")?u:new Error(`Invalid URL: ${n}`,{cause:u})}}if(typeof globalThis.fetch=="function"){let u=await globalThis.fetch(n,{method:r,headers:{...s,[qt]:String(o+1)},body:a?JSON.stringify(a):void 0,signal:t.signal});if(i==="dataUrl"){let d=await u.arrayBuffer(),f=new Uint8Array(d),m="";for(let x=0;x<f.length;x++)m+=String.fromCharCode(f[x]);let g=btoa(m);return`data:${u.headers.get("content-type")||"application/octet-stream"};base64,${g}`}let p=u.headers.get("content-type");return i==="json"||p&&p.includes("application/json")?u.json():u.text()}throw new Error("Capability 'fetch' missing and no global fetch available")},{docs:"HTTP Fetch",timeoutMs:3e4,cost:5}),Ss=P("storeGet",h.object({key:h.string}),h.any,async({key:e},t)=>{let n=w(e,t);return t.capabilities.store?.get(n)},{docs:"Store Get",cost:5}),Es=P("storeSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{let r=w(e,n),s=w(t,n);return n.capabilities.store?.set(r,s)},{docs:"Store Set",cost:5}),ks=P("storeQuery",h.object({query:h.any}),h.array(h.any),async({query:e},t)=>t.capabilities.store?.query?.(w(e,t))??[],{docs:"Store Query",cost:5}),Cs=P("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?.(w(e,r),w(t,r),w(n,r))??[],{docs:"Vector Search",cost:(e,t)=>5+(w(e.k,t)??5)}),As=P("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(w(e,n),w(t,n))},{docs:"LLM Predict",timeoutMs:12e4,cost:100}),_s=P("agentRun",h.object({agentId:h.any,input:h.any}),h.any,async({agentId:e,input:t},n)=>{let r=w(e,n),s=w(t,n),a=s;if(s&&typeof s=="object"&&!Array.isArray(s)){a={};for(let o in s)a[o]=w(s[o],n)}if(gt(r)){let o=yt(r),l={...n,args:a,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(o,l),l.error)throw new Error(l.error.message||"Sub-agent failed");return l.output}if(r&&typeof r=="object"&&"op"in r){let o={...n,args:a,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(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 i=await n.capabilities.agent.run(r,a);if(i&&typeof i=="object"&&"fuelUsed"in i&&typeof i.fuelUsed=="number"){if(i.error)throw new Error(i.error.message||"Sub-agent failed");return i.result}return i},{docs:"Run Sub-Agent (accepts procedure token, AST, or agent ID)",cost:1}),Ts=P("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=w(e,t);try{return t.capabilities.code.transpile(n)}catch(r){throw new Error(`Code transpilation failed: ${r.message}`,{cause:r})}},{docs:"Transpile AsyncJS code to AST",cost:1}),Wt=10,Is=P("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>=Wt)throw new Error(`runCode recursion limit exceeded (max ${Wt}). 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=w(e,n),a=t?w(t,n):{},i;try{i=n.capabilities.code.transpile(s)}catch(l){throw new Error(`Code transpilation failed: ${l.message}`,{cause:l})}if(i.op!=="seq")throw new Error("Transpiled code must be a seq node");let o=xe(n);if(o.args=a,o.output=void 0,o.runCodeDepth=r+1,await X.exec(i,o),o.error){n.error=o.error;return}return o.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),Ps=P("jsonParse",h.object({str:h.string}),h.any,async({str:e},t)=>JSON.parse(w(e,t)),{docs:"Parse JSON",cost:1}),Ns=P("jsonStringify",h.object({value:h.any}),h.string,async({value:e},t)=>JSON.stringify(w(e,t)),{docs:"Stringify JSON",cost:1}),Rs=P("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(w(e,t))},{docs:"Parse XML",cost:1}),Ms=P("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=w(e,n)??await bt.exec({value:t,algorithm:"SHA-256"},n);if(n.memo.has(r))return n.memo.get(r);let s=xe(n);await X.exec({op:"seq",steps:t},s);let a=s.output??s.state.result;return n.memo.set(r,a),a},{docs:"Memoize steps result in memory",cost:1}),$s=P("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 a=`cache:${w(e,r)??await bt.exec({value:t,algorithm:"SHA-256"},r)}`,i=await r.capabilities.store.get(a);if(i)if(typeof i=="object"&&i._exp){if(Date.now()<i._exp)return i.val}else return i;let o=xe(r);await X.exec({op:"seq",steps:t},o);let l=o.output??o.state.result,u=Date.now()+(n??24*3600*1e3);if((r.fuel.current-=5)<=0)throw new Error("Out of Fuel");return await r.capabilities.store.set(a,{val:l,_exp:u}),l},{docs:"Cache steps result in store with TTL",cost:5}),js=P("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 a=w(n,s)??"float",i=w(r,s)??10,o=w(e,s)??0,l=w(t,s)??1;if(a==="base36"){let f="0123456789abcdefghijklmnopqrstuvwxyz",m="";if(typeof crypto<"u"&&crypto.getRandomValues){let g=new Uint8Array(i);crypto.getRandomValues(g);for(let b=0;b<i;b++)m+=f[g[b]%36]}else for(let g=0;g<i;g++)m+=f.charAt(Math.floor(Math.random()*36));return m}let u;if(typeof crypto<"u"&&crypto.getRandomValues){let f=new Uint32Array(1);crypto.getRandomValues(f),u=f[0]/4294967296}else u=Math.random();let p=l-o,d=u*p+o;return a==="integer"?Math.floor(d):d},{docs:"Generate Random",cost:1}),Bs=P("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}),bt=P("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(w(e,n)),s=w(t,n)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let o=new TextEncoder().encode(r),l=await crypto.subtle.digest(s,o);return Array.from(new Uint8Array(l)).map(p=>p.toString(16).padStart(2,"0")).join("")}let a=0;for(let i=0;i<r.length;i++){let o=r.charCodeAt(i);a=(a<<5)-a+o,a|=0}return String(a)},{docs:"Hash a value",cost:1}),Os=P("consoleLog",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(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}),Ds=P("consoleWarn",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(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}),Ls=P("consoleError",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.error=new H(r,"console.error")},{docs:"Emit error and stop",cost:.1}),Vs=P("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=w(e,r),a=t?w(t,r):Dr,i=n?w(n,r):Lr;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>i)throw new Error(`AST too large: ${o.length} bytes exceeds limit of ${i} bytes. Consider reducing AST size or using a shorter TTL.`);let l=Vr(),u=Date.now();return _e.set(l,{ast:s,createdAt:u,expiresAt:u+a}),l},{docs:"Store an AST and return a token for later execution",cost:1}),Fs=P("releaseProcedure",h.object({token:h.string}),h.boolean,async({token:e},t)=>{let n=w(e,t);return _e.delete(n)},{docs:"Release a stored procedure by token",cost:.1}),Us=P("clearExpiredProcedures",void 0,h.number,async()=>{let e=Date.now(),t=0;for(let[n,r]of _e)e>r.expiresAt&&(_e.delete(n),t++);return t},{docs:"Clear all expired procedures and return count",cost:.5}),Ht={seq:X,if:Hr,while:Jr,return:Kr,try:Zr,Error:Qr,varSet:Yr,constSet:Xr,varGet:es,varsImport:ts,varsLet:ns,varsExport:rs,scope:ss,callLocal:is,map:as,filter:os,reduce:ls,find:us,push:cs,len:ps,split:fs,join:hs,template:ds,regexMatch:ms,pick:gs,omit:ys,merge:bs,keys:xs,httpFetch:ws,storeGet:Ss,storeSet:Es,storeQuery:ks,storeVectorSearch:Cs,llmPredict:As,agentRun:_s,transpileCode:Ts,runCode:Is,jsonParse:Ps,jsonStringify:Ns,xmlParse:Rs,memoize:Ms,cache:$s,random:js,uuid:Bs,hash:bt,consoleLog:Os,consoleWarn:Ds,consoleError:Ls,storeProcedure:Vs,releaseProcedure:Fs,clearExpiredProcedures:Us};var qs=new Set(["true","false","null","undefined","and","or","not"]);function Ws(e,t){let n=e.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),r=[],s=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,a;for(;(a=s.exec(n))!==null;)r.push(a[1]);let o=[...new Set(r)].filter(l=>!qs.has(l)&&!(l in t)&&!new RegExp(`\\b${l}\\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 Je(e,t){Ws(e,t);let n=zs(e),r=Yt(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 zs(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 Yt(e,t,n){return Gs(e,t,n)}function Gs(e,t,n){let{node:r,pos:s}=Jt(e,t,n);for(;e[s]==="||";){s++;let{node:a,pos:i}=Jt(e,s,n);r={$expr:"logical",op:"||",left:r,right:a},s=i}return{node:r,pos:s}}function Jt(e,t,n){let{node:r,pos:s}=Kt(e,t,n);for(;e[s]==="&&";){s++;let{node:a,pos:i}=Kt(e,s,n);r={$expr:"logical",op:"&&",left:r,right:a},s=i}return{node:r,pos:s}}function Kt(e,t,n){let{node:r,pos:s}=Zt(e,t,n),a=["==","!=",">","<",">=","<="];for(;a.includes(e[s]);){let i=e[s++],{node:o,pos:l}=Zt(e,s,n);r={$expr:"binary",op:i,left:r,right:o},s=l}return{node:r,pos:s}}function Zt(e,t,n){let{node:r,pos:s}=Qt(e,t,n);for(;e[s]==="+"||e[s]==="-";){let a=e[s++],{node:i,pos:o}=Qt(e,s,n);r={$expr:"binary",op:a,left:r,right:i},s=o}return{node:r,pos:s}}function Qt(e,t,n){let{node:r,pos:s}=xt(e,t,n);for(;e[s]==="*"||e[s]==="/"||e[s]==="%";){let a=e[s++],{node:i,pos:o}=xt(e,s,n);r={$expr:"binary",op:a,left:r,right:i},s=o}return{node:r,pos:s}}function xt(e,t,n){if(e[t]==="!"||e[t]==="-"){let r=e[t++],{node:s,pos:a}=xt(e,t,n);return{node:{$expr:"unary",op:r,argument:s},pos:a}}return Hs(e,t,n)}function Hs(e,t,n){let r=e[t];if(r==="("){let{node:s,pos:a}=Yt(e,t+1,n);return{node:s,pos:a+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},a=t+1;for(;e[a]===".";){a++;let i=e[a++];s={$expr:"member",object:s,property:i}}return{node:s,pos:a}}return{node:{$expr:"literal",value:null},pos:t+1}}var je=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 a=>{let i=n.atoms[r];return n.add(i.create(a)),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 a=new e(this.atoms);r(a);let i;if(s){let u=new e(this.atoms);s(u),i=u.steps}let o=Je(t,n),l=this.atoms.if;return this.add(l.create({condition:o,then:a.steps,else:i}))}while(t,n,r){let s=new e(this.atoms);r(s);let a=Je(t,n),i=this.atoms.while;return this.add(i.create({condition:a,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 a=this.atoms.map;return this.add(a.create({items:t,as:n,steps:s.steps}))}filter(t,n,r,s={}){let a=Je(r,s),i=this.atoms.filter;return this.add(i.create({items:t,as:n,condition:a}))}find(t,n,r,s={}){let a=Je(r,s),i=this.atoms.find;return this.add(i.create({items:t,as:n,condition:a}))}reduce(t,n,r,s,a){let i=new e(this.atoms);a(i);let o=this.atoms.reduce;return this.add(o.create({items:t,as:n,accumulator:r,initial:s,steps:i.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 a=this.atoms.cache;return this.add(a.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 a=new e(this.atoms);t.catch(a),r=a.steps}let s=this.atoms.try;return this.add(s.create({try:n.steps,catch:r}))}};import{validate as ha}from"tosijs-schema";var Js=[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],sn=[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],Ks="\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",an="\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",vt={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"},wt="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:wt,"5module":wt+" export import",6:wt+" const class extends export import super"},Qs=/^in(stanceof)?$/,Ys=new RegExp("["+an+"]"),Xs=new RegExp("["+an+Ks+"]");function Et(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&&Ys.test(String.fromCharCode(e)):t===!1?!1:Et(e,sn)}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&&Xs.test(String.fromCharCode(e)):t===!1?!1:Et(e,sn)||Et(e,Js)}var D=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 ne(e,t){return new D(e,{beforeExpr:!0,binop:t})}var re={beforeExpr:!0},Q={startsExpr:!0},_t={};function O(e,t){return t===void 0&&(t={}),t.keyword=e,_t[e]=new D(e,t)}var c={num:new D("num",Q),regexp:new D("regexp",Q),string:new D("string",Q),name:new D("name",Q),privateId:new D("privateId",Q),eof:new D("eof"),bracketL:new D("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new D("]"),braceL:new D("{",{beforeExpr:!0,startsExpr:!0}),braceR:new D("}"),parenL:new D("(",{beforeExpr:!0,startsExpr:!0}),parenR:new D(")"),comma:new D(",",re),semi:new D(";",re),colon:new D(":",re),dot:new D("."),question:new D("?",re),questionDot:new D("?."),arrow:new D("=>",re),template:new D("template"),invalidTemplate:new D("invalidTemplate"),ellipsis:new D("...",re),backQuote:new D("`",Q),dollarBraceL:new D("${",{beforeExpr:!0,startsExpr:!0}),eq:new D("=",{beforeExpr:!0,isAssign:!0}),assign:new D("_=",{beforeExpr:!0,isAssign:!0}),incDec:new D("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new D("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ne("||",1),logicalAND:ne("&&",2),bitwiseOR:ne("|",3),bitwiseXOR:ne("^",4),bitwiseAND:ne("&",5),equality:ne("==/!=/===/!==",6),relational:ne("</>/<=/>=",7),bitShift:ne("<</>>/>>>",8),plusMin:new D("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ne("%",10),star:ne("*",10),slash:ne("/",10),starstar:new D("**",{beforeExpr:!0}),coalesce:ne("??",1),_break:O("break"),_case:O("case",re),_catch:O("catch"),_continue:O("continue"),_debugger:O("debugger"),_default:O("default",re),_do:O("do",{isLoop:!0,beforeExpr:!0}),_else:O("else",re),_finally:O("finally"),_for:O("for",{isLoop:!0}),_function:O("function",Q),_if:O("if"),_return:O("return",re),_switch:O("switch"),_throw:O("throw",re),_try:O("try"),_var:O("var"),_const:O("const"),_while:O("while",{isLoop:!0}),_with:O("with"),_new:O("new",{beforeExpr:!0,startsExpr:!0}),_this:O("this",Q),_super:O("super",Q),_class:O("class",Q),_extends:O("extends",re),_export:O("export"),_import:O("import",Q),_null:O("null",Q),_true:O("true",Q),_false:O("false",Q),_in:O("in",{beforeExpr:!0,binop:7}),_instanceof:O("instanceof",{beforeExpr:!0,binop:7}),_typeof:O("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:O("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:O("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Y=/\r\n?|\n|\u2028|\u2029/,ei=new RegExp(Y.source,"g");function Te(e){return e===10||e===13||e===8232||e===8233}function on(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(Te(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ln=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,K=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,un=Object.prototype,ti=un.hasOwnProperty,ni=un.toString,Ie=Object.hasOwn||(function(e,t){return ti.call(e,t)}),Xt=Array.isArray||(function(e){return ni.call(e)==="[object Array]"}),en=Object.create(null);function ve(e){return en[e]||(en[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 ri=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Oe=function(t,n){this.line=t,this.column=n};Oe.prototype.offset=function(t){return new Oe(this.line,this.column+t)};var et=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function cn(e,t){for(var n=1,r=0;;){var s=on(e,r,t);if(s<0)return new Oe(n,t-r);++n,r=s}}var kt={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},tn=!1;function si(e){var t={};for(var n in kt)t[n]=e&&Ie(e,n)?e[n]:kt[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!tn&&typeof console=="object"&&console.warn&&(tn=!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),Xt(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return Xt(t.onComment)&&(t.onComment=ii(t,t.onComment)),t}function ii(e,t){return function(n,r,s,a,i,o){var l={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(l.loc=new et(this,i,o)),e.ranges&&(l.range=[s,a]),t.push(l)}}var De=1,Pe=2,Tt=4,pn=8,It=16,fn=32,tt=64,hn=128,ke=256,Le=512,nt=De|Pe|ke;function Pt(e,t){return Pe|(e?Tt:0)|(t?pn:0)}var Ze=0,Nt=1,ge=2,dn=3,mn=4,gn=5,G=function(t,n,r){this.options=t=si(t),this.sourceFile=t.sourceFile,this.keywords=ve(Zs[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=vt[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=ve(s);var a=(s?s+" ":"")+vt.strict;this.reservedWordsStrict=ve(a),this.reservedWordsStrictBind=ve(a+" "+vt.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(Y).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(De),this.regexpState=null,this.privateNameStack=[]},ce={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}};G.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};ce.inFunction.get=function(){return(this.currentVarScope().flags&Pe)>0};ce.inGenerator.get=function(){return(this.currentVarScope().flags&pn)>0};ce.inAsync.get=function(){return(this.currentVarScope().flags&Tt)>0};ce.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Le))return!1;if(n&Pe)return(n&Tt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};ce.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&tt)>0||this.options.allowSuperOutsideMethod};ce.allowDirectSuper.get=function(){return(this.currentThisScope().flags&hn)>0};ce.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};ce.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Le)||n&Pe&&!(n&It))return!0}return!1};ce.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ke)>0};G.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};G.parse=function(t,n){return new this(n,t).parse()};G.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};G.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(G.prototype,ce);var Z=G.prototype,ai=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){K.lastIndex=e,e+=K.exec(this.input)[0].length;var t=ai.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){K.lastIndex=e+t[0].length;var n=K.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||Y.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,K.lastIndex=e,e+=K.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||Y.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 rt=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 T=G.prototype;T.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 a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Rt={kind:"loop"},oi={kind:"switch"};T.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;K.lastIndex=this.pos;var t=K.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 a=this.input.slice(n,s);if(!Qs.test(a))return!0}return!1};T.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;K.lastIndex=this.pos;var e=K.exec(this.input),t=this.pos+e[0].length,n;return!Y.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))};T.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;K.lastIndex=this.pos;var n=K.exec(this.input),r=this.pos+n[0].length;if(Y.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||we(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;K.lastIndex=s;var i=K.exec(this.input);if(i&&Y.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,l;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!we(l=this.input.charCodeAt(o))&&!(l>55295&&l<56320)))return!1}var u=this.input.charCodeAt(r);return ue(u,!0)||u===92};T.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};T.isUsing=function(e){return this.isUsingKeyword(!1,e)};T.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=c._var,a="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 a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);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){K.lastIndex=this.pos;var i=K.exec(this.input),o=this.pos+i[0].length,l=this.input.charCodeAt(o);if(l===40||l===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 u=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(u)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),u==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,u),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)}};T.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")};T.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};T.parseDoStatement=function(e){return this.next(),this.labels.push(Rt),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")};T.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Rt),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 a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(e,l,t)}var u=this.containsEsc,p=new rt,d=this.start,f=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===c._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===c._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===d&&!u&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&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))};T.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))};T.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Be|(n?0:Ct),!1,t)};T.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")};T.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")};T.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(oi),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")};T.parseThrowStatement=function(e){return this.next(),Y.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 li=[];T.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?fn:0),this.checkLValPattern(e,t?mn:ge),this.expect(c.parenR),e};T.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")};T.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};T.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Rt),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};T.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")};T.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};T.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===c._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var u=this.labels[l];if(u.statementStart===e.start)u.statementStart=this.start,u.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")};T.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};T.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")};T.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")};T.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")};T.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};T.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Nt:ge,!1)};var Be=1,Ct=2,yn=4;T.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&Be&&(e.id=t&yn&&this.type!==c.name?null:this.parseIdent(),e.id&&!(t&Ct)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Nt:ge:dn));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Pt(e.async,e.generator)),t&Be||(e.id=this.type===c.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&Be?"FunctionDeclaration":"FunctionExpression")};T.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};T.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(),a=!1;for(s.body=[],this.expect(c.braceL);this.type!==c.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&ui(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.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")};T.parseClassElement=function(e){if(this.eat(c.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="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()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(c.star)&&(s=!0),!r&&!a&&!s){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=l:r=l)}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||i!=="method"||s||a){var u=!n.static&&Qe(n,"constructor"),p=u&&e;u&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=u?"constructor":i,this.parseClassMethod(n,s,a,p)}else this.parseClassField(n);return n};T.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};T.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)};T.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&&Qe(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};T.parseClassField=function(e){return Qe(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Qe(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(c.eq)?(this.enterScope(Le|tt),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};T.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ke|tt);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")};T.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)};T.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};T.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};T.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],a=0;a<n.length;++a){var i=n[a];Ie(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function ui(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 Qe(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}T.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")};T.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")};T.parseExportDeclaration=function(e){return this.parseStatement(null)};T.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,Be|yn,!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}};T.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Ie(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};T.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 a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var l=o[i];l&&this.checkPatternExport(e,l)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};T.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)}};T.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};T.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")};T.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};T.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=li,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")};T.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")};T.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportDefaultSpecifier")};T.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")};T.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};T.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;Ie(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};T.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")};T.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return ri.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};T.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)};T.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 ie=G.prototype;ie.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 a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.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};ie.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 a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};ie.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};ie.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")};ie.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()};ie.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!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 i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),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};ie.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};ie.parseBindingListItem=function(e){return e};ie.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")};ie.checkLValSimple=function(e,t,n){t===void 0&&(t=Ze);var r=t!==Ze;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&&(Ie(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==gn&&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")}};ie.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ze),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var l=o[i];l&&this.checkLValInnerPattern(l,t,n)}break;default:this.checkLValSimple(e,t,n)}};ie.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ze),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 oe=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},q={b_stat:new oe("{",!1),b_expr:new oe("{",!0),b_tmpl:new oe("${",!1),p_stat:new oe("(",!1),p_expr:new oe("(",!0),q_tmpl:new oe("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new oe("function",!1),f_expr:new oe("function",!0),f_expr_gen:new oe("function",!0,!1,null,!0),f_gen:new oe("function",!1,!1,null,!0)},Ne=G.prototype;Ne.initialContext=function(){return[q.b_stat]};Ne.curContext=function(){return this.context[this.context.length-1]};Ne.braceIsBlock=function(e){var t=this.curContext();return t===q.f_expr||t===q.f_stat?!0:e===c.colon&&(t===q.b_stat||t===q.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?Y.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===q.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Ne.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};Ne.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};Ne.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===q.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)?q.b_stat:q.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(q.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?q.p_stat:q.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()!==q.p_stat)&&!(e===c._return&&Y.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===q.b_stat)?this.context.push(q.f_expr):this.context.push(q.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()===q.q_tmpl?this.context.pop():this.context.push(q.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===q.f_expr?this.context[t]=q.f_expr_gen:this.context[t]=q.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 M=G.prototype;M.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 a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="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 i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};M.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===c.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(c.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};M.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new rt,r=!0);var o=this.start,l=this.startLoc;(this.type===c.parenL||this.type===c.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var u=this.parseMaybeConditional(e,t);if(n&&(u=n.call(this,u,o,l)),this.type.isAssign){var p=this.startNodeAt(o,l);return p.operator=this.value,this.type===c.eq&&(u=this.toAssignable(u,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=u.start&&(t.shorthandAssign=-1),this.type===c.eq?this.checkLValPattern(u):this.checkLValSimple(u),p.left=u,this.next(),p.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(p,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),u};M.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 a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(c.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};M.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)};M.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==c._in)&&a>r){var i=this.type===c.logicalOR||this.type===c.logicalAND,o=this.type===c.coalesce;o&&(a=c.logicalAND.binop);var l=this.value;this.next();var u=this.start,p=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),u,p,a,s),f=this.buildBinary(t,n,e,d,l,i||o);return(i&&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};M.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};M.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===c.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(e,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&bn(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&At(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===c.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==c._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(s,a);u.operator=this.value,u.prefix=!1,u.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(u,"UpdateExpression")}}if(!n&&this.eat(c.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function bn(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&bn(e.expression)}function At(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&At(e.expression)||e.type==="ParenthesizedExpression"&&At(e.expression)}M.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 a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};M.parseSubscripts=function(e,t,n,r,s){for(var a=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,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var l=this.startNodeAt(t,n);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}e=o}};M.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};M.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};M.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,l=o&&this.eat(c.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var u=this.eat(c.bracketL);if(u||l&&this.type!==c.parenL&&this.type!==c.backQuote||this.eat(c.dot)){var p=this.startNodeAt(t,n);p.object=e,u?(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=!!u,o&&(p.optional=l),e=this.finishNode(p,"MemberExpression")}else if(!r&&this.eat(c.parenL)){var d=new rt,f=this.yieldPos,m=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var b=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,d);if(s&&!l&&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,b,i);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var x=this.startNodeAt(t,n);x.callee=e,x.arguments=b,o&&(x.optional=l),e=this.finishNode(x,"CallExpression")}else if(this.type===c.backQuote){(l||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var E=this.startNodeAt(t,n);E.tag=e,E.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(E,"TaggedTemplateExpression")}return e};M.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 a=this.start,i=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(c._function))return this.overrideContext(q.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(c.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[l],!1,t);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===c.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(c.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[l],!0,t)}return l;case c.regexp:var u=this.value;return r=this.parseLiteral(u.value),r.regex={pattern:u.pattern,flags:u.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(q.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()}};M.parseExprAtomDefault=function(){this.unexpected()};M.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()};M.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")};M.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")};M.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")};M.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};M.shouldParseArrow=function(e){return!this.canInsertSemicolon()};M.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,l=[],u=!0,p=!1,d=new rt,f=this.yieldPos,m=this.awaitPos,g;for(this.yieldPos=0,this.awaitPos=0;this.type!==c.parenR;)if(u?u=!1:this.expect(c.comma),a&&this.afterTrailingComma(c.parenR,!0)){p=!0;break}else if(this.type===c.ellipsis){g=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var b=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(c.parenR),e&&this.shouldParseArrow(l)&&this.eat(c.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(n,r,l,t);(!l.length||p)&&this.unexpected(this.lastTokStart),g&&this.unexpected(g),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,l.length>1?(s=this.startNodeAt(i,o),s.expressions=l,this.finishNodeAt(s,"SequenceExpression",b,x)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var E=this.startNodeAt(n,r);return E.expression=s,this.finishNode(E,"ParenthesizedExpression")}else return s};M.parseParenItem=function(e){return e};M.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var ci=[];M.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=ci,this.finishNode(e,"NewExpression")};M.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,`
1
+ import{s as h,validate as ft,filter as Qt}from"tosijs-schema";function qt(e,t){return(e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),!!(e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)}var H=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 Br(e){return e instanceof H||e&&e.$error===!0}var _e=new Map,Or=3600*1e3,Dr=100*1024,ht="proc_";function dt(e){return typeof e=="string"&&e.startsWith(ht)}function mt(e){let t=_e.get(e);if(!t)throw new Error(`Procedure not found: ${e}`);if(Date.now()>t.expiresAt)throw _e.delete(e),new Error(`Procedure expired: ${e}`);return t.ast}function Lr(){return typeof crypto<"u"&&crypto.randomUUID?ht+crypto.randomUUID():ht+Math.random().toString(36).slice(2)+Date.now().toString(36)}var Yt=new Set(["__proto__","constructor","prototype"]);function Wt(e){if(Yt.has(e))throw new Error(`Security Error: Access to '${e}' is forbidden`)}var Vr=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","metadata.google.internal"]);function Fr(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return!0;let n=t.hostname.toLowerCase();return!!(Vr.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 Ur(e){return!!(/\([^)]*[+*][^)]*\)[+*]/.test(e)||/\(([^|)]+)\|\1\)[+*]/.test(e)||/\(\.\*\)\+/.test(e)||/\(\.\+\)\+/.test(e)||/\(\[.*\]\+\)\+/.test(e))}function xe(e){return{...e,state:Object.create(e.state)}}function qr(e,t){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r){let a=e[s],i=t[s];i!==a&&(n[s]=i)}return n}function w(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(Yt.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]=w(e[r],t);return n}return Array.isArray(e)?e.map(n=>w(n,t)):e}function Ee(e,t,n){return new Proxy(t,{get(r,s){if(s in r)return r[s];let a=n?.[s];throw a?new Error(`${e}.${s} is not available. ${a}`):new Error(`${e}.${s} is not supported in AsyncJS. Check docs for available ${e} methods.`)}})}function Ae(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:Ae(e[0])};if(t==="object"){let n={},r=[];for(let[s,a]of Object.entries(e))n[s]=Ae(a),r.push(s);return{type:"object",properties:n,required:r}}return{}}var he={Math:Ee("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:Ee("JSON",{parse:e=>JSON.parse(e),stringify:(e,t,n)=>JSON.stringify(e,t,n)}),console:Ee("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:Ee("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:Ee("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:Ee("String",{fromCharCode:(...e)=>String.fromCharCode(...e),fromCodePoint:(...e)=>String.fromCodePoint(...e)}),Number:Ee("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=Ae(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:Ae(t);return{type:"json_schema",json_schema:{name:e,strict:!0,schema:n}}},fromExample:e=>Ae(e),isValid:(e,t)=>t?.schema!=null?ft(e,t):ft(e,Ae(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:a=0,hours:i=0,minutes:o=0,seconds:l=0,ms:u=0}={}){let p=new globalThis.Date(n.getTime());return r&&p.setFullYear(p.getFullYear()+r),s&&p.setMonth(p.getMonth()+s),a&&p.setDate(p.getDate()+a),i&&p.setHours(p.getHours()+i),o&&p.setMinutes(p.getMinutes()+o),l&&p.setSeconds(p.getSeconds()+l),u&&p.setMilliseconds(p.getMilliseconds()+u),e(p)},diff(r,s="ms"){let a=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime(),i=n.getTime()-a;switch(s){case"seconds":return i/1e3;case"minutes":return i/6e4;case"hours":return i/36e5;case"days":return i/864e5;default:return i}},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."},Wr=.01,zt=1e-4,Gt=.001,zr=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-=Wr,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=typeof e.property=="object"&&e.property!==null?W(e.property,t):e.property;return Wt(String(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*zt,t.fuel.current<=0)){t.error=new H("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 qt(n,r);case"!=":return!qt(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(a=>W(a,t)),s=typeof r[0]=="string"?r[0]:"Error";t.error=new H(s,"Error");return}if(e.callee in he){let r=he[e.callee];if(typeof r=="function"){let s=e.arguments.map(a=>W(a,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(Wt(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 a=e.arguments.map(o=>W(o,t)),i=s.apply(n,a);if(t.fuel&&zr.has(r)){let o=0;if(typeof i=="string"?o=i.length*zt:Array.isArray(i)?o=i.length*Gt:typeof i=="object"&&i!==null&&(o=Object.keys(i).length*Gt),t.fuel.current-=o,t.fuel.current<=0){t.error=new H("Out of Fuel",`expr.${r}`);return}}return i}default:throw new Error(`Unknown expression type: ${e.$expr}`)}}function P(e,t,n,r,s={}){let{docs:a="",timeoutMs:i=1e3,cost:o=1,effects:l="pure"}=typeof s=="string"?{docs:s}:s;return{op:e,inputSchema:t,outputSchema:n,exec:async(p,d)=>{let{op:f,result:m,...g}=p;if(d.error)return;let b=d.trace?{...d.state}:null,x=d.fuel.current,S,E;try{let y=d.costOverrides?.[e],C=y!==void 0?y:o,k=typeof C=="function"?C(g,d):C;if((d.fuel.current-=k)<=0){d.error=new H("Out of Fuel",e);return}let v=d.timeoutOverrides?.[e],A=v!==void 0?v:i,N=typeof A=="function"?A(g,d):A,I,R=async()=>r(p,d);if(S=N>0?await Promise.race([R(),new Promise((B,V)=>{I=setTimeout(()=>V(new Error(`Atom '${e}' timed out`)),N)})]).finally(()=>clearTimeout(I)):await R(),p.result){if(d.consts.has(p.result))throw new Error(`Cannot reassign const variable '${p.result}'`);if(S!==void 0&&n&&!ft(S,n)){d.error=new H(`Output validation failed for '${e}'`,e);return}d.state[p.result]=S,p.resultConst&&d.consts.add(p.result)}}catch(y){E=y.message||String(y),d.error=new H(E,e,y)}finally{if(d.trace&&b){let y=qr(b,d.state);d.trace.push({op:e,input:g,stateDiff:y,result:S,error:E,fuelBefore:x,fuelAfter:d.fuel.current,timestamp:new Date().toISOString()})}}},docs:a,timeoutMs:i,cost:o,effects:l,create:p=>({op:e,...p})}}var X=P("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}),Gr=P("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 X.exec({op:"seq",steps:e.then},t):e.else&&await X.exec({op:"seq",steps:e.else},t)},{docs:"If/Else",timeoutMs:0,cost:.1}),Hr=P("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 X.exec({op:"seq",steps:e.body},t),t.output!==void 0||t.error)return}},{docs:"While Loop",timeoutMs:0,cost:.1}),Jr=P("return",void 0,h.any,async(e,t)=>{if(t.error)return t.output=t.error,t.error;if("value"in e){let r=w(e.value,t);if(!t.localCall&&r!==void 0&&r!==null&&!Br(r)&&(typeof r!="object"||Array.isArray(r))){let s=new H(`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}),Kr=P("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 X.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 X.exec({op:"seq",steps:e.catch},t)}},{docs:"Try/Catch",timeoutMs:0,cost:.1}),Zr=P("Error",h.object({args:h.array(h.any).optional}),void 0,async(e,t)=>{let n=e.args?.[0]??"Error";t.error=new H(String(n),"Error")},{docs:"Trigger error flow",cost:.1}),Qr=P("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]=w(t,n)},{docs:"Set Variable",cost:.1}),Yr=P("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]=w(t,n),n.consts.add(e)},{docs:"Set Const Variable (immutable)",cost:.1}),Xr=P("varGet",h.object({key:h.string}),h.any,async({key:e},t)=>w(e,t),{docs:"Get Variable",cost:.1}),es=P("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]=w({$kind:"arg",path:n},t);else for(let[n,r]of Object.entries(e))t.state[n]=w({$kind:"arg",path:r},t)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:.2}),ts=P("varsLet",h.record(h.any),void 0,async(e,t)=>{for(let n of Object.keys(e))n==="op"||n==="result"||(t.state[n]=w(e[n],t))},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:.1}),ns=P("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]=w(r,t);else for(let[r,s]of Object.entries(e))n[r]=w(s,t);return n},{docs:"Export variables from the current scope, with optional renaming.",cost:.2}),rs=P("scope",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{let n=xe(t);await X.exec({op:"seq",steps:e},n),n.output!==void 0&&(t.output=n.output)},{docs:"Create new scope",timeoutMs:0,cost:.1}),Ht=256,ss=P("callLocal",h.object({name:h.string,args:h.array(h.any)}),void 0,async({name:e,args:t},n)=>{let r=n.helpers?.[e];if(!r)return n.error=new H(`Unknown helper: ${e}`,"callLocal"),n.error;let s=(n.callDepth??0)+1;if(s>Ht)return n.error=new H(`Maximum helper call depth (${Ht}) exceeded \u2014 likely infinite recursion in '${e}'`,"callLocal"),n.error;let a=t.map(o=>w(o,n)),i={...n,state:{},consts:new Set,output:void 0,error:void 0,localCall:!0,callDepth:s};for(let o=0;o<r.paramNames.length;o++)i.state[r.paramNames[o]]=a[o];return await X.exec({op:"seq",steps:r.steps},i),i.error&&(n.error=i.error),i.output},{docs:"Invoke a local helper function by name",timeoutMs:0,cost:.1}),is=P("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=[],a=w(e,r);if(!Array.isArray(a))throw new Error("map: items is not an array");for(let i of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=i,await X.exec({op:"seq",steps:n},o),s.push(o.state.result??null)}return s},{docs:"Map Array",timeoutMs:0,cost:1}),as=P("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=[],a=w(e,r);if(!Array.isArray(a))throw new Error("filter: items is not an array");for(let i of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=i,W(n,o)&&s.push(i)}return s},{docs:"Filter Array",timeoutMs:0,cost:1}),os=P("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},a)=>{let i=w(e,a),o=w(r,a);if(!Array.isArray(i))throw new Error("reduce: items is not an array");let l=o;for(let u of i){if(a.signal?.aborted)throw new Error("Execution aborted");let p=xe(a);p.state[t]=u,p.state[n]=l,await X.exec({op:"seq",steps:s},p),l=p.state.result??l}return l},{docs:"Reduce Array",timeoutMs:0,cost:1}),ls=P("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=w(e,r);if(!Array.isArray(s))throw new Error("find: items is not an array");for(let a of s){if(r.signal?.aborted)throw new Error("Execution aborted");let i=xe(r);if(i.state[t]=a,W(n,i))return a}return null},{docs:"Find in Array",timeoutMs:0,cost:1}),us=P("push",h.object({list:h.array(h.any),item:h.any}),h.array(h.any),async({list:e,item:t},n)=>{let r=w(e,n),s=w(t,n);return Array.isArray(r)&&r.push(s),r},{docs:"Push to Array",cost:1}),cs=P("len",h.object({list:h.any}),h.number,async({list:e},t)=>{let n=w(e,t);return Array.isArray(n)||typeof n=="string"?n.length:0},{docs:"Length",cost:1}),ps=P("split",h.object({str:h.string,sep:h.string}),h.array(h.string),async({str:e,sep:t},n)=>w(e,n).split(w(t,n)),{docs:"Split String",cost:1}),fs=P("join",h.object({list:h.array(h.string),sep:h.string}),h.string,async({list:e,sep:t},n)=>w(e,n).join(w(t,n)),{docs:"Join String",cost:1}),hs=P("template",h.object({tmpl:h.string,vars:h.record(h.any)}),h.string,async({tmpl:e,vars:t},n)=>w(e,n).replace(/\{\{(\w+)\}\}/g,(s,a)=>String(w(t[a],n)??"")),{docs:"String Template",cost:1}),ds=P("regexMatch",h.object({pattern:h.string,value:h.any}),h.boolean,async({pattern:e,value:t},n)=>{if(Ur(e))throw new Error(`Suspicious regex pattern rejected (potential ReDoS): ${e}`);let r=w(t,n);return new RegExp(e).test(r)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),ms=P("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=w(e,n),s=w(t,n),a={};return r&&Array.isArray(s)&&s.forEach(i=>a[i]=r[i]),a},{docs:"Pick Keys",cost:1}),gs=P("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=w(e,n),s=new Set(w(t,n)),a={};return r&&Object.keys(r).forEach(i=>{s.has(i)||(a[i]=r[i])}),a},{docs:"Omit Keys",cost:1}),ys=P("merge",h.object({a:h.record(h.any),b:h.record(h.any)}),h.record(h.any),async({a:e,b:t},n)=>({...w(e,n),...w(t,n)}),{docs:"Merge Objects",cost:1}),bs=P("keys",h.object({obj:h.record(h.any)}),h.array(h.string),async({obj:e},t)=>Object.keys(w(e,t)??{}),{docs:"Object Keys",cost:1}),Jt=10,Kt="X-Agent-Depth";function xs(e,t){try{let r=new URL(e).hostname.toLowerCase();for(let s of t){let a=s.toLowerCase();if(a.startsWith("*.")){let i=a.slice(1);if(r.endsWith(i)||r===a.slice(2))return!0}else if(r===a)return!0}return!1}catch{return!1}}var vs=P("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=w(e.url,t),r=w(e.method,t),s=w(e.headers,t)||{},a=w(e.body,t),i=w(e.responseType,t),o=t.context?.requestDepth??0;if(o>=Jt)throw new Error(`Agent request depth exceeded (max ${Jt}). This prevents recursive agent loops.`);if(t.capabilities.fetch)return t.capabilities.fetch(n,{method:r,headers:{...s,[Kt]:String(o+1)},body:a,signal:t.signal,responseType:i});let l=t.context?.allowedFetchDomains;if(l){if(!xs(n,l))throw new Error(`Fetch blocked: domain not in allowlist. Allowed: ${l.join(", ")}`)}else{if(Fr(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(u){throw u.message.includes("allowedFetchDomains")?u:new Error(`Invalid URL: ${n}`,{cause:u})}}if(typeof globalThis.fetch=="function"){let u=await globalThis.fetch(n,{method:r,headers:{...s,[Kt]:String(o+1)},body:a?JSON.stringify(a):void 0,signal:t.signal});if(i==="dataUrl"){let d=await u.arrayBuffer(),f=new Uint8Array(d),m="";for(let x=0;x<f.length;x++)m+=String.fromCharCode(f[x]);let g=btoa(m);return`data:${u.headers.get("content-type")||"application/octet-stream"};base64,${g}`}let p=u.headers.get("content-type");return i==="json"||p&&p.includes("application/json")?u.json():u.text()}throw new Error("Capability 'fetch' missing and no global fetch available")},{docs:"HTTP Fetch",timeoutMs:3e4,cost:5}),ws=P("storeGet",h.object({key:h.string}),h.any,async({key:e},t)=>{let n=w(e,t);return t.capabilities.store?.get(n)},{docs:"Store Get",cost:5}),Ss=P("storeSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{let r=w(e,n),s=w(t,n);return n.capabilities.store?.set(r,s)},{docs:"Store Set",cost:5}),Es=P("storeQuery",h.object({query:h.any}),h.array(h.any),async({query:e},t)=>t.capabilities.store?.query?.(w(e,t))??[],{docs:"Store Query",cost:5}),ks=P("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?.(w(e,r),w(t,r),w(n,r))??[],{docs:"Vector Search",cost:(e,t)=>5+(w(e.k,t)??5)}),Cs=P("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(w(e,n),w(t,n))},{docs:"LLM Predict",timeoutMs:12e4,cost:100}),As=P("agentRun",h.object({agentId:h.any,input:h.any}),h.any,async({agentId:e,input:t},n)=>{let r=w(e,n),s=w(t,n),a=s;if(s&&typeof s=="object"&&!Array.isArray(s)){a={};for(let o in s)a[o]=w(s[o],n)}if(dt(r)){let o=mt(r),l={...n,args:a,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(o,l),l.error)throw new Error(l.error.message||"Sub-agent failed");return l.output}if(r&&typeof r=="object"&&"op"in r){let o={...n,args:a,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(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 i=await n.capabilities.agent.run(r,a);if(i&&typeof i=="object"&&"fuelUsed"in i&&typeof i.fuelUsed=="number"){if(i.error)throw new Error(i.error.message||"Sub-agent failed");return i.result}return i},{docs:"Run Sub-Agent (accepts procedure token, AST, or agent ID)",cost:1}),_s=P("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=w(e,t);try{return t.capabilities.code.transpile(n)}catch(r){throw new Error(`Code transpilation failed: ${r.message}`,{cause:r})}},{docs:"Transpile AsyncJS code to AST",cost:1}),Zt=10,Ts=P("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>=Zt)throw new Error(`runCode recursion limit exceeded (max ${Zt}). 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=w(e,n),a=t?w(t,n):{},i;try{i=n.capabilities.code.transpile(s)}catch(l){throw new Error(`Code transpilation failed: ${l.message}`,{cause:l})}if(i.op!=="seq")throw new Error("Transpiled code must be a seq node");let o=xe(n);if(o.args=a,o.output=void 0,o.runCodeDepth=r+1,await X.exec(i,o),o.error){n.error=o.error;return}return o.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),Is=P("jsonParse",h.object({str:h.string}),h.any,async({str:e},t)=>JSON.parse(w(e,t)),{docs:"Parse JSON",cost:1}),Ps=P("jsonStringify",h.object({value:h.any}),h.string,async({value:e},t)=>JSON.stringify(w(e,t)),{docs:"Stringify JSON",cost:1}),Ns=P("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(w(e,t))},{docs:"Parse XML",cost:1}),Rs=P("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=w(e,n)??await gt.exec({value:t,algorithm:"SHA-256"},n);if(n.memo.has(r))return n.memo.get(r);let s=xe(n);await X.exec({op:"seq",steps:t},s);let a=s.output??s.state.result;return n.memo.set(r,a),a},{docs:"Memoize steps result in memory",cost:1}),Ms=P("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 a=`cache:${w(e,r)??await gt.exec({value:t,algorithm:"SHA-256"},r)}`,i=await r.capabilities.store.get(a);if(i)if(typeof i=="object"&&i._exp){if(Date.now()<i._exp)return i.val}else return i;let o=xe(r);await X.exec({op:"seq",steps:t},o);let l=o.output??o.state.result,u=Date.now()+(n??24*3600*1e3);if((r.fuel.current-=5)<=0)throw new Error("Out of Fuel");return await r.capabilities.store.set(a,{val:l,_exp:u}),l},{docs:"Cache steps result in store with TTL",cost:5}),$s=P("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 a=w(n,s)??"float",i=w(r,s)??10,o=w(e,s)??0,l=w(t,s)??1;if(a==="base36"){let f="0123456789abcdefghijklmnopqrstuvwxyz",m="";if(typeof crypto<"u"&&crypto.getRandomValues){let g=new Uint8Array(i);crypto.getRandomValues(g);for(let b=0;b<i;b++)m+=f[g[b]%36]}else for(let g=0;g<i;g++)m+=f.charAt(Math.floor(Math.random()*36));return m}let u;if(typeof crypto<"u"&&crypto.getRandomValues){let f=new Uint32Array(1);crypto.getRandomValues(f),u=f[0]/4294967296}else u=Math.random();let p=l-o,d=u*p+o;return a==="integer"?Math.floor(d):d},{docs:"Generate Random",cost:1}),js=P("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}),gt=P("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(w(e,n)),s=w(t,n)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let o=new TextEncoder().encode(r),l=await crypto.subtle.digest(s,o);return Array.from(new Uint8Array(l)).map(p=>p.toString(16).padStart(2,"0")).join("")}let a=0;for(let i=0;i<r.length;i++){let o=r.charCodeAt(i);a=(a<<5)-a+o,a|=0}return String(a)},{docs:"Hash a value",cost:1}),Bs=P("consoleLog",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(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}),Os=P("consoleWarn",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(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}),Ds=P("consoleError",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=w(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.error=new H(r,"console.error")},{docs:"Emit error and stop",cost:.1}),Ls=P("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=w(e,r),a=t?w(t,r):Or,i=n?w(n,r):Dr;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>i)throw new Error(`AST too large: ${o.length} bytes exceeds limit of ${i} bytes. Consider reducing AST size or using a shorter TTL.`);let l=Lr(),u=Date.now();return _e.set(l,{ast:s,createdAt:u,expiresAt:u+a}),l},{docs:"Store an AST and return a token for later execution",cost:1}),Vs=P("releaseProcedure",h.object({token:h.string}),h.boolean,async({token:e},t)=>{let n=w(e,t);return _e.delete(n)},{docs:"Release a stored procedure by token",cost:.1}),Fs=P("clearExpiredProcedures",void 0,h.number,async()=>{let e=Date.now(),t=0;for(let[n,r]of _e)e>r.expiresAt&&(_e.delete(n),t++);return t},{docs:"Clear all expired procedures and return count",cost:.5}),yt={seq:X,if:Gr,while:Hr,return:Jr,try:Kr,Error:Zr,varSet:Qr,constSet:Yr,varGet:Xr,varsImport:es,varsLet:ts,varsExport:ns,scope:rs,callLocal:ss,map:is,filter:as,reduce:os,find:ls,push:us,len:cs,split:ps,join:fs,template:hs,regexMatch:ds,pick:ms,omit:gs,merge:ys,keys:bs,httpFetch:vs,storeGet:ws,storeSet:Ss,storeQuery:Es,storeVectorSearch:ks,llmPredict:Cs,agentRun:As,transpileCode:_s,runCode:Ts,jsonParse:Is,jsonStringify:Ps,xmlParse:Ns,memoize:Rs,cache:Ms,random:$s,uuid:js,hash:gt,consoleLog:Bs,consoleWarn:Os,consoleError:Ds,storeProcedure:Ls,releaseProcedure:Vs,clearExpiredProcedures:Fs},Us=["httpFetch","storeGet","storeSet","storeQuery","storeVectorSearch","llmPredict","agentRun","transpileCode","runCode","random","uuid","consoleLog","consoleWarn","consoleError","storeProcedure","releaseProcedure","clearExpiredProcedures","cache","memoize"];for(let e of Us){let t=yt[e];t&&(t.effects="io")}var qs=new Set(["true","false","null","undefined","and","or","not"]);function Ws(e,t){let n=e.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),r=[],s=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,a;for(;(a=s.exec(n))!==null;)r.push(a[1]);let o=[...new Set(r)].filter(l=>!qs.has(l)&&!(l in t)&&!new RegExp(`\\b${l}\\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 Ge(e,t){Ws(e,t);let n=zs(e),r=rn(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 zs(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 rn(e,t,n){return Gs(e,t,n)}function Gs(e,t,n){let{node:r,pos:s}=Xt(e,t,n);for(;e[s]==="||";){s++;let{node:a,pos:i}=Xt(e,s,n);r={$expr:"logical",op:"||",left:r,right:a},s=i}return{node:r,pos:s}}function Xt(e,t,n){let{node:r,pos:s}=en(e,t,n);for(;e[s]==="&&";){s++;let{node:a,pos:i}=en(e,s,n);r={$expr:"logical",op:"&&",left:r,right:a},s=i}return{node:r,pos:s}}function en(e,t,n){let{node:r,pos:s}=tn(e,t,n),a=["==","!=",">","<",">=","<="];for(;a.includes(e[s]);){let i=e[s++],{node:o,pos:l}=tn(e,s,n);r={$expr:"binary",op:i,left:r,right:o},s=l}return{node:r,pos:s}}function tn(e,t,n){let{node:r,pos:s}=nn(e,t,n);for(;e[s]==="+"||e[s]==="-";){let a=e[s++],{node:i,pos:o}=nn(e,s,n);r={$expr:"binary",op:a,left:r,right:i},s=o}return{node:r,pos:s}}function nn(e,t,n){let{node:r,pos:s}=bt(e,t,n);for(;e[s]==="*"||e[s]==="/"||e[s]==="%";){let a=e[s++],{node:i,pos:o}=bt(e,s,n);r={$expr:"binary",op:a,left:r,right:i},s=o}return{node:r,pos:s}}function bt(e,t,n){if(e[t]==="!"||e[t]==="-"){let r=e[t++],{node:s,pos:a}=bt(e,t,n);return{node:{$expr:"unary",op:r,argument:s},pos:a}}return Hs(e,t,n)}function Hs(e,t,n){let r=e[t];if(r==="("){let{node:s,pos:a}=rn(e,t+1,n);return{node:s,pos:a+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},a=t+1;for(;e[a]===".";){a++;let i=e[a++];s={$expr:"member",object:s,property:i}}return{node:s,pos:a}}return{node:{$expr:"literal",value:null},pos:t+1}}var je=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 a=>{let i=n.atoms[r];return n.add(i.create(a)),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 a=new e(this.atoms);r(a);let i;if(s){let u=new e(this.atoms);s(u),i=u.steps}let o=Ge(t,n),l=this.atoms.if;return this.add(l.create({condition:o,then:a.steps,else:i}))}while(t,n,r){let s=new e(this.atoms);r(s);let a=Ge(t,n),i=this.atoms.while;return this.add(i.create({condition:a,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 a=this.atoms.map;return this.add(a.create({items:t,as:n,steps:s.steps}))}filter(t,n,r,s={}){let a=Ge(r,s),i=this.atoms.filter;return this.add(i.create({items:t,as:n,condition:a}))}find(t,n,r,s={}){let a=Ge(r,s),i=this.atoms.find;return this.add(i.create({items:t,as:n,condition:a}))}reduce(t,n,r,s,a){let i=new e(this.atoms);a(i);let o=this.atoms.reduce;return this.add(o.create({items:t,as:n,accumulator:r,initial:s,steps:i.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 a=this.atoms.cache;return this.add(a.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 a=new e(this.atoms);t.catch(a),r=a.steps}let s=this.atoms.try;return this.add(s.create({try:n.steps,catch:r}))}};import{validate as ha}from"tosijs-schema";var Js=[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],cn=[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],Ks="\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",pn="\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"},Qs=/^in(stanceof)?$/,Ys=new RegExp("["+pn+"]"),Xs=new RegExp("["+pn+Ks+"]");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&&Ys.test(String.fromCharCode(e)):t===!1?!1:St(e,cn)}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&&Xs.test(String.fromCharCode(e)):t===!1?!1:St(e,cn)||St(e,Js)}var D=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 ne(e,t){return new D(e,{beforeExpr:!0,binop:t})}var re={beforeExpr:!0},Q={startsExpr:!0},At={};function O(e,t){return t===void 0&&(t={}),t.keyword=e,At[e]=new D(e,t)}var c={num:new D("num",Q),regexp:new D("regexp",Q),string:new D("string",Q),name:new D("name",Q),privateId:new D("privateId",Q),eof:new D("eof"),bracketL:new D("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new D("]"),braceL:new D("{",{beforeExpr:!0,startsExpr:!0}),braceR:new D("}"),parenL:new D("(",{beforeExpr:!0,startsExpr:!0}),parenR:new D(")"),comma:new D(",",re),semi:new D(";",re),colon:new D(":",re),dot:new D("."),question:new D("?",re),questionDot:new D("?."),arrow:new D("=>",re),template:new D("template"),invalidTemplate:new D("invalidTemplate"),ellipsis:new D("...",re),backQuote:new D("`",Q),dollarBraceL:new D("${",{beforeExpr:!0,startsExpr:!0}),eq:new D("=",{beforeExpr:!0,isAssign:!0}),assign:new D("_=",{beforeExpr:!0,isAssign:!0}),incDec:new D("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new D("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ne("||",1),logicalAND:ne("&&",2),bitwiseOR:ne("|",3),bitwiseXOR:ne("^",4),bitwiseAND:ne("&",5),equality:ne("==/!=/===/!==",6),relational:ne("</>/<=/>=",7),bitShift:ne("<</>>/>>>",8),plusMin:new D("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ne("%",10),star:ne("*",10),slash:ne("/",10),starstar:new D("**",{beforeExpr:!0}),coalesce:ne("??",1),_break:O("break"),_case:O("case",re),_catch:O("catch"),_continue:O("continue"),_debugger:O("debugger"),_default:O("default",re),_do:O("do",{isLoop:!0,beforeExpr:!0}),_else:O("else",re),_finally:O("finally"),_for:O("for",{isLoop:!0}),_function:O("function",Q),_if:O("if"),_return:O("return",re),_switch:O("switch"),_throw:O("throw",re),_try:O("try"),_var:O("var"),_const:O("const"),_while:O("while",{isLoop:!0}),_with:O("with"),_new:O("new",{beforeExpr:!0,startsExpr:!0}),_this:O("this",Q),_super:O("super",Q),_class:O("class",Q),_extends:O("extends",re),_export:O("export"),_import:O("import",Q),_null:O("null",Q),_true:O("true",Q),_false:O("false",Q),_in:O("in",{beforeExpr:!0,binop:7}),_instanceof:O("instanceof",{beforeExpr:!0,binop:7}),_typeof:O("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:O("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:O("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Y=/\r\n?|\n|\u2028|\u2029/,ei=new RegExp(Y.source,"g");function Te(e){return e===10||e===13||e===8232||e===8233}function fn(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(Te(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var hn=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,K=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,dn=Object.prototype,ti=dn.hasOwnProperty,ni=dn.toString,Ie=Object.hasOwn||(function(e,t){return ti.call(e,t)}),sn=Array.isArray||(function(e){return ni.call(e)==="[object Array]"}),an=Object.create(null);function ve(e){return an[e]||(an[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 ri=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Oe=function(t,n){this.line=t,this.column=n};Oe.prototype.offset=function(t){return new Oe(this.line,this.column+t)};var Ye=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function mn(e,t){for(var n=1,r=0;;){var s=fn(e,r,t);if(s<0)return new Oe(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},on=!1;function si(e){var t={};for(var n in Et)t[n]=e&&Ie(e,n)?e[n]:Et[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!on&&typeof console=="object"&&console.warn&&(on=!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),sn(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return sn(t.onComment)&&(t.onComment=ii(t,t.onComment)),t}function ii(e,t){return function(n,r,s,a,i,o){var l={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(l.loc=new Ye(this,i,o)),e.ranges&&(l.range=[s,a]),t.push(l)}}var De=1,Pe=2,_t=4,gn=8,Tt=16,yn=32,Xe=64,bn=128,ke=256,Le=512,et=De|Pe|ke;function It(e,t){return Pe|(e?_t:0)|(t?gn:0)}var Je=0,Pt=1,ge=2,xn=3,vn=4,wn=5,G=function(t,n,r){this.options=t=si(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 a=(s?s+" ":"")+xt.strict;this.reservedWordsStrict=ve(a),this.reservedWordsStrictBind=ve(a+" "+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(Y).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(De),this.regexpState=null,this.privateNameStack=[]},ce={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}};G.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};ce.inFunction.get=function(){return(this.currentVarScope().flags&Pe)>0};ce.inGenerator.get=function(){return(this.currentVarScope().flags&gn)>0};ce.inAsync.get=function(){return(this.currentVarScope().flags&_t)>0};ce.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Le))return!1;if(n&Pe)return(n&_t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};ce.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&Xe)>0||this.options.allowSuperOutsideMethod};ce.allowDirectSuper.get=function(){return(this.currentThisScope().flags&bn)>0};ce.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};ce.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Le)||n&Pe&&!(n&Tt))return!0}return!1};ce.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ke)>0};G.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};G.parse=function(t,n){return new this(n,t).parse()};G.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};G.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(G.prototype,ce);var Z=G.prototype,ai=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){K.lastIndex=e,e+=K.exec(this.input)[0].length;var t=ai.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){K.lastIndex=e+t[0].length;var n=K.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||Y.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,K.lastIndex=e,e+=K.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||Y.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 tt=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 T=G.prototype;T.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 a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Nt={kind:"loop"},oi={kind:"switch"};T.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;K.lastIndex=this.pos;var t=K.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 a=this.input.slice(n,s);if(!Qs.test(a))return!0}return!1};T.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;K.lastIndex=this.pos;var e=K.exec(this.input),t=this.pos+e[0].length,n;return!Y.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))};T.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;K.lastIndex=this.pos;var n=K.exec(this.input),r=this.pos+n[0].length;if(Y.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||we(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;K.lastIndex=s;var i=K.exec(this.input);if(i&&Y.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,l;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!we(l=this.input.charCodeAt(o))&&!(l>55295&&l<56320)))return!1}var u=this.input.charCodeAt(r);return ue(u,!0)||u===92};T.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};T.isUsing=function(e){return this.isUsingKeyword(!1,e)};T.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=c._var,a="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 a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);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){K.lastIndex=this.pos;var i=K.exec(this.input),o=this.pos+i[0].length,l=this.input.charCodeAt(o);if(l===40||l===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 u=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(u)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),u==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,u),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)}};T.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")};T.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};T.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")};T.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 a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(e,l,t)}var u=this.containsEsc,p=new tt,d=this.start,f=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===c._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===c._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===d&&!u&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&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))};T.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))};T.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Be|(n?0:kt),!1,t)};T.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")};T.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")};T.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(oi),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")};T.parseThrowStatement=function(e){return this.next(),Y.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 li=[];T.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?yn:0),this.checkLValPattern(e,t?vn:ge),this.expect(c.parenR),e};T.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")};T.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};T.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")};T.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")};T.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};T.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===c._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var u=this.labels[l];if(u.statementStart===e.start)u.statementStart=this.start,u.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")};T.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};T.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")};T.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")};T.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")};T.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};T.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 Be=1,kt=2,Sn=4;T.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===c.star&&t&kt&&this.unexpected(),e.generator=this.eat(c.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Be&&(e.id=t&Sn&&this.type!==c.name?null:this.parseIdent(),e.id&&!(t&kt)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Pt:ge:xn));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(It(e.async,e.generator)),t&Be||(e.id=this.type===c.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&Be?"FunctionDeclaration":"FunctionExpression")};T.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};T.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(),a=!1;for(s.body=[],this.expect(c.braceL);this.type!==c.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&ui(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.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")};T.parseClassElement=function(e){if(this.eat(c.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="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()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(c.star)&&(s=!0),!r&&!a&&!s){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=l:r=l)}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||i!=="method"||s||a){var u=!n.static&&Ke(n,"constructor"),p=u&&e;u&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=u?"constructor":i,this.parseClassMethod(n,s,a,p)}else this.parseClassField(n);return n};T.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};T.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)};T.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&&Ke(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};T.parseClassField=function(e){return Ke(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Ke(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(c.eq)?(this.enterScope(Le|Xe),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};T.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ke|Xe);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")};T.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)};T.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};T.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};T.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],a=0;a<n.length;++a){var i=n[a];Ie(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function ui(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 Ke(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}T.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")};T.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")};T.parseExportDeclaration=function(e){return this.parseStatement(null)};T.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,Be|Sn,!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}};T.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Ie(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};T.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 a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var l=o[i];l&&this.checkPatternExport(e,l)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};T.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)}};T.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};T.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")};T.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};T.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=li,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")};T.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")};T.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportDefaultSpecifier")};T.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")};T.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};T.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;Ie(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};T.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")};T.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return ri.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};T.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)};T.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 ie=G.prototype;ie.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 a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.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};ie.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 a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};ie.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};ie.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")};ie.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()};ie.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!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 i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),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};ie.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};ie.parseBindingListItem=function(e){return e};ie.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")};ie.checkLValSimple=function(e,t,n){t===void 0&&(t=Je);var r=t!==Je;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&&(Ie(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==wn&&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")}};ie.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Je),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var l=o[i];l&&this.checkLValInnerPattern(l,t,n)}break;default:this.checkLValSimple(e,t,n)}};ie.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Je),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 oe=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},q={b_stat:new oe("{",!1),b_expr:new oe("{",!0),b_tmpl:new oe("${",!1),p_stat:new oe("(",!1),p_expr:new oe("(",!0),q_tmpl:new oe("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new oe("function",!1),f_expr:new oe("function",!0),f_expr_gen:new oe("function",!0,!1,null,!0),f_gen:new oe("function",!1,!1,null,!0)},Ne=G.prototype;Ne.initialContext=function(){return[q.b_stat]};Ne.curContext=function(){return this.context[this.context.length-1]};Ne.braceIsBlock=function(e){var t=this.curContext();return t===q.f_expr||t===q.f_stat?!0:e===c.colon&&(t===q.b_stat||t===q.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?Y.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===q.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Ne.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};Ne.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};Ne.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===q.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)?q.b_stat:q.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(q.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?q.p_stat:q.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()!==q.p_stat)&&!(e===c._return&&Y.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===q.b_stat)?this.context.push(q.f_expr):this.context.push(q.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()===q.q_tmpl?this.context.pop():this.context.push(q.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===q.f_expr?this.context[t]=q.f_expr_gen:this.context[t]=q.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 M=G.prototype;M.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 a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="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 i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};M.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===c.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(c.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};M.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new tt,r=!0);var o=this.start,l=this.startLoc;(this.type===c.parenL||this.type===c.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var u=this.parseMaybeConditional(e,t);if(n&&(u=n.call(this,u,o,l)),this.type.isAssign){var p=this.startNodeAt(o,l);return p.operator=this.value,this.type===c.eq&&(u=this.toAssignable(u,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=u.start&&(t.shorthandAssign=-1),this.type===c.eq?this.checkLValPattern(u):this.checkLValSimple(u),p.left=u,this.next(),p.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(p,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),u};M.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 a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(c.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};M.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)};M.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==c._in)&&a>r){var i=this.type===c.logicalOR||this.type===c.logicalAND,o=this.type===c.coalesce;o&&(a=c.logicalAND.binop);var l=this.value;this.next();var u=this.start,p=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),u,p,a,s),f=this.buildBinary(t,n,e,d,l,i||o);return(i&&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};M.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};M.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===c.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(e,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&En(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Ct(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===c.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==c._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(s,a);u.operator=this.value,u.prefix=!1,u.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(u,"UpdateExpression")}}if(!n&&this.eat(c.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function En(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&En(e.expression)}function Ct(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Ct(e.expression)||e.type==="ParenthesizedExpression"&&Ct(e.expression)}M.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 a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};M.parseSubscripts=function(e,t,n,r,s){for(var a=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,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var l=this.startNodeAt(t,n);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}e=o}};M.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};M.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};M.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,l=o&&this.eat(c.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var u=this.eat(c.bracketL);if(u||l&&this.type!==c.parenL&&this.type!==c.backQuote||this.eat(c.dot)){var p=this.startNodeAt(t,n);p.object=e,u?(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=!!u,o&&(p.optional=l),e=this.finishNode(p,"MemberExpression")}else if(!r&&this.eat(c.parenL)){var d=new tt,f=this.yieldPos,m=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var b=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,d);if(s&&!l&&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,b,i);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var x=this.startNodeAt(t,n);x.callee=e,x.arguments=b,o&&(x.optional=l),e=this.finishNode(x,"CallExpression")}else if(this.type===c.backQuote){(l||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var S=this.startNodeAt(t,n);S.tag=e,S.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(S,"TaggedTemplateExpression")}return e};M.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 a=this.start,i=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(c._function))return this.overrideContext(q.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(c.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[l],!1,t);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===c.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(c.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[l],!0,t)}return l;case c.regexp:var u=this.value;return r=this.parseLiteral(u.value),r.regex={pattern:u.pattern,flags:u.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(q.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()}};M.parseExprAtomDefault=function(){this.unexpected()};M.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()};M.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")};M.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")};M.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")};M.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};M.shouldParseArrow=function(e){return!this.canInsertSemicolon()};M.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,l=[],u=!0,p=!1,d=new tt,f=this.yieldPos,m=this.awaitPos,g;for(this.yieldPos=0,this.awaitPos=0;this.type!==c.parenR;)if(u?u=!1:this.expect(c.comma),a&&this.afterTrailingComma(c.parenR,!0)){p=!0;break}else if(this.type===c.ellipsis){g=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var b=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(c.parenR),e&&this.shouldParseArrow(l)&&this.eat(c.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(n,r,l,t);(!l.length||p)&&this.unexpected(this.lastTokStart),g&&this.unexpected(g),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,l.length>1?(s=this.startNodeAt(i,o),s.expressions=l,this.finishNodeAt(s,"SequenceExpression",b,x)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var S=this.startNodeAt(n,r);return S.expression=s,this.finishNode(S,"ParenthesizedExpression")}else return s};M.parseParenItem=function(e){return e};M.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var ci=[];M.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=ci,this.finishNode(e,"NewExpression")};M.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
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")};M.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")};M.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)&&!Y.test(this.input.slice(this.lastTokEnd,this.start))};M.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 a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};M.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;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)&&(a=this.start,i=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,a,i,t,o),this.finishNode(n,"Property")};M.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")};M.parsePropertyValue=function(e,t,n,r,s,a,i,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,i),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,a,this.copyNode(e.key)):this.type===c.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};M.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")};M.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};M.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=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(Pt(t,r.generator)|tt|(n?hn: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=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};M.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.enterScope(Pt(n,!1)|It),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=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};M.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==c.braceL,a=this.strict,i=!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);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,gn),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=l}this.exitScope()};M.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};M.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Nt,t?null:n)}};M.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(c.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===c.comma?i=null:this.type===c.ellipsis?(i=this.parseSpread(r),r&&this.type===c.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};M.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&nt)&&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"))}};M.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};M.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};M.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};M.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")};M.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 Ye=G.prototype;Ye.raise=function(e,t){var n=cn(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};Ye.raiseRecoverable=Ye.raise;Ye.curPosition=function(){if(this.options.locations)return new Oe(this.curLine,this.pos-this.lineStart)};var Se=G.prototype,pi=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new pi(e))};Se.exitScope=function(){this.scopeStack.pop()};Se.treatFunctionsAsVarInScope=function(e){return e.flags&Pe||!this.inModule&&e.flags&De};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&De&&delete this.undefinedExports[e]}else if(t===mn){var a=this.currentScope();a.lexical.push(e)}else if(t===dn){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(e)>-1&&!(l.flags&fn&&l.lexical[0]===e)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(e)>-1){r=!0;break}if(l.var.push(e),this.inModule&&l.flags&De&&delete this.undefinedExports[e],l.flags&nt)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&(nt|Le|ke))return t}};Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(nt|Le|ke)&&!(t.flags&It))return t}};var st=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new et(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},Ve=G.prototype;Ve.startNode=function(){return new st(this,this.start,this.startLoc)};Ve.startNodeAt=function(e,t){return new st(this,e,t)};function xn(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 xn.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Ve.finishNodeAt=function(e,t,n,r){return xn.call(this,e,t,n,r)};Ve.copyNode=function(e){var t=new st(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var fi="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",vn="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",wn=vn+" Extended_Pictographic",Sn=wn,En=Sn+" EBase EComp EMod EPres ExtPict",kn=En,hi=kn,di={9:vn,10:wn,11:Sn,12:En,13:kn,14:hi},mi="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",gi={9:"",10:"",11:"",12:"",13:"",14:mi},nn="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",Cn="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",An=Cn+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",_n=An+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Tn=_n+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",In=Tn+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",yi=In+" "+fi,bi={9:Cn,10:An,11:_n,12:Tn,13:In,14:yi},Pn={};function xi(e){var t=Pn[e]={binary:ve(di[e]+" "+nn),binaryOfStrings:ve(gi[e]),nonBinary:{General_Category:ve(nn),Script:ve(bi[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(Ke=0,St=[9,10,11,12,13,14];Ke<St.length;Ke+=1)rn=St[Ke],xi(rn);var rn,Ke,St,_=G.prototype,Xe=function(t,n){this.parent=t,this.base=n||this};Xe.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};Xe.prototype.sibling=function(){return new Xe(this.parent,this.base)};var pe=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=Pn[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};pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=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=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};_.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function vi(e){for(var t in e)return!0;return!1}_.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&vi(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};_.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")}};_.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Xe(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")};_.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};_.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};_.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};_.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};_.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};_.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};_.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)};_.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};_.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 a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var l=i.charAt(o);(i.indexOf(l,o+1)>-1||n.indexOf(l)>-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};_.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};_.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&wi(n);)t+=de(n),e.advance();return t};function wi(e){return e===105||e===109||e===115}_.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)};_.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};_.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Nn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Nn(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}_.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Nn(n);)e.advance();return e.pos!==t};_.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};_.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 a=s[r];a.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}};_.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};_.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};_.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),Si(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Si(e){return ue(e,!0)||e===36||e===95}_.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),Ei(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ei(e){return we(e,!0)||e===36||e===95||e===8204||e===8205}_.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)};_.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};_.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};_.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)};_.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};_.regexp_eatZero=function(e){return e.current()===48&&!it(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};_.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};_.regexp_eatControlLetter=function(e){var t=e.current();return Rn(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Rn(e){return e>=65&&e<=90||e>=97&&e<=122}_.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 a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&ki(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function ki(e){return e>=0&&e<=1114111}_.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};_.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 Mn=0,me=1,se=2;_.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Ci(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===se&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Mn};function Ci(e){return e===100||e===68||e===115||e===83||e===119||e===87}_.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 Mn};_.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Ie(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};_.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return me;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return se;e.raise("Invalid property name")};_.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";$n(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function $n(e){return Rn(e)||e===95}_.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Ai(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Ai(e){return $n(e)||it(e)}_.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};_.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===se&&e.raise("Negated character class may contain strings"),!0}return!1};_.regexp_classContents=function(e){return e.current()===93?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)};_.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")}}};_.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||On(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};_.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)};_.regexp_classSetExpression=function(e){var t=me,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===se&&(t=se);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==se&&(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===se&&(t=se)}};_.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};_.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?me:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};_.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===se&&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};_.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};_.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===se&&(t=se);return t};_.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?me:se};_.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()&&_i(n)||Ti(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function _i(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 Ti(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}_.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ii(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ii(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}_.regexp_eatClassControlLetter=function(e){var t=e.current();return it(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};_.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};_.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;it(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function it(e){return e>=48&&e<=57}_.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;jn(n=e.current());)e.lastIntValue=16*e.lastIntValue+Bn(n),e.advance();return e.pos!==t};function jn(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Bn(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}_.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};_.regexp_eatOctalDigit=function(e){var t=e.current();return On(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function On(e){return e>=48&&e<=55}_.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!jn(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Bn(s),e.advance()}return!0};var Mt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new et(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},B=G.prototype;B.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 Mt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};B.getToken=function(){return this.next(),new Mt(this)};typeof Symbol<"u"&&(B[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});B.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())};B.readToken=function(e){return ue(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};B.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};B.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=on(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())};B.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&&!Te(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())};B.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&&ln.test(String.fromCharCode(e)))++this.pos;else break e}}};B.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)};B.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))};B.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)};B.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)};B.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)};B.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};B.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||Y.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)};B.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))};B.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)};B.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)};B.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)+"'")};B.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)+"'")};B.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};B.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(Y.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 a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(s,i)}catch{}return this.finishToken(c.regexp,{pattern:s,flags:i,value:l})};B.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,l=0,u=t??1/0;l<u;++l,++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"),l===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,i=i*e+d}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function Pi(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Dn(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}B.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=Dn(this.input.slice(t,this.pos)),++this.pos):ue(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,n)};B.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=Dn(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 a=Pi(this.input.slice(t,this.pos),n);return this.finishToken(c.num,a)};B.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};B.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)):(Te(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(c.string,t)};var Ln={};B.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Ln)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};B.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ln;this.raise(e,t)};B.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(Te(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}};B.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]===`
6
+ `),cooked:this.value},this.next(),n.tail=this.type===c.backQuote,this.finishNode(n,"TemplateElement")};M.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")};M.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)&&!Y.test(this.input.slice(this.lastTokEnd,this.start))};M.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 a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};M.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;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)&&(a=this.start,i=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,a,i,t,o),this.finishNode(n,"Property")};M.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")};M.parsePropertyValue=function(e,t,n,r,s,a,i,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,i),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,a,this.copyNode(e.key)):this.type===c.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};M.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")};M.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};M.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=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)|Xe|(n?bn: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=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};M.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=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=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};M.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==c.braceL,a=this.strict,i=!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);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,wn),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=l}this.exitScope()};M.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};M.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Pt,t?null:n)}};M.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(c.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===c.comma?i=null:this.type===c.ellipsis?(i=this.parseSpread(r),r&&this.type===c.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};M.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&et)&&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"))}};M.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};M.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};M.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};M.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")};M.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 Ze=G.prototype;Ze.raise=function(e,t){var n=mn(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};Ze.raiseRecoverable=Ze.raise;Ze.curPosition=function(){if(this.options.locations)return new Oe(this.curLine,this.pos-this.lineStart)};var Se=G.prototype,pi=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new pi(e))};Se.exitScope=function(){this.scopeStack.pop()};Se.treatFunctionsAsVarInScope=function(e){return e.flags&Pe||!this.inModule&&e.flags&De};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&De&&delete this.undefinedExports[e]}else if(t===vn){var a=this.currentScope();a.lexical.push(e)}else if(t===xn){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(e)>-1&&!(l.flags&yn&&l.lexical[0]===e)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(e)>-1){r=!0;break}if(l.var.push(e),this.inModule&&l.flags&De&&delete this.undefinedExports[e],l.flags&et)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&(et|Le|ke))return t}};Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(et|Le|ke)&&!(t.flags&Tt))return t}};var nt=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new Ye(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},Ve=G.prototype;Ve.startNode=function(){return new nt(this,this.start,this.startLoc)};Ve.startNodeAt=function(e,t){return new nt(this,e,t)};function kn(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 kn.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Ve.finishNodeAt=function(e,t,n,r){return kn.call(this,e,t,n,r)};Ve.copyNode=function(e){var t=new nt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var fi="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",Cn="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",An=Cn+" Extended_Pictographic",_n=An,Tn=_n+" EBase EComp EMod EPres ExtPict",In=Tn,hi=In,di={9:Cn,10:An,11:_n,12:Tn,13:In,14:hi},mi="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",gi={9:"",10:"",11:"",12:"",13:"",14:mi},ln="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",Pn="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",Nn=Pn+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Rn=Nn+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Mn=Rn+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",$n=Mn+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",yi=$n+" "+fi,bi={9:Pn,10:Nn,11:Rn,12:Mn,13:$n,14:yi},jn={};function xi(e){var t=jn[e]={binary:ve(di[e]+" "+ln),binaryOfStrings:ve(gi[e]),nonBinary:{General_Category:ve(ln),Script:ve(bi[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(He=0,wt=[9,10,11,12,13,14];He<wt.length;He+=1)un=wt[He],xi(un);var un,He,wt,_=G.prototype,Qe=function(t,n){this.parent=t,this.base=n||this};Qe.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};Qe.prototype.sibling=function(){return new Qe(this.parent,this.base)};var pe=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=jn[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};pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=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=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};_.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function vi(e){for(var t in e)return!0;return!1}_.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&vi(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};_.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")}};_.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Qe(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")};_.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};_.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};_.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};_.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};_.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};_.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};_.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)};_.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};_.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 a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var l=i.charAt(o);(i.indexOf(l,o+1)>-1||n.indexOf(l)>-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};_.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};_.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&wi(n);)t+=de(n),e.advance();return t};function wi(e){return e===105||e===109||e===115}_.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)};_.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};_.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Bn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Bn(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}_.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Bn(n);)e.advance();return e.pos!==t};_.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};_.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 a=s[r];a.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}};_.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};_.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};_.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),Si(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Si(e){return ue(e,!0)||e===36||e===95}_.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),Ei(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ei(e){return we(e,!0)||e===36||e===95||e===8204||e===8205}_.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)};_.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};_.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};_.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)};_.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};_.regexp_eatZero=function(e){return e.current()===48&&!rt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};_.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};_.regexp_eatControlLetter=function(e){var t=e.current();return On(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function On(e){return e>=65&&e<=90||e>=97&&e<=122}_.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 a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&ki(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function ki(e){return e>=0&&e<=1114111}_.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};_.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 Dn=0,me=1,se=2;_.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Ci(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===se&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Dn};function Ci(e){return e===100||e===68||e===115||e===83||e===119||e===87}_.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 Dn};_.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Ie(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};_.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return me;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return se;e.raise("Invalid property name")};_.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Ln(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Ln(e){return On(e)||e===95}_.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Ai(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Ai(e){return Ln(e)||rt(e)}_.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};_.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===se&&e.raise("Negated character class may contain strings"),!0}return!1};_.regexp_classContents=function(e){return e.current()===93?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)};_.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")}}};_.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||Un(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};_.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)};_.regexp_classSetExpression=function(e){var t=me,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===se&&(t=se);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==se&&(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===se&&(t=se)}};_.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};_.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?me:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};_.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===se&&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};_.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};_.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===se&&(t=se);return t};_.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?me:se};_.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()&&_i(n)||Ti(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function _i(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 Ti(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}_.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ii(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ii(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}_.regexp_eatClassControlLetter=function(e){var t=e.current();return rt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};_.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};_.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;rt(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function rt(e){return e>=48&&e<=57}_.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Vn(n=e.current());)e.lastIntValue=16*e.lastIntValue+Fn(n),e.advance();return e.pos!==t};function Vn(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Fn(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}_.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};_.regexp_eatOctalDigit=function(e){var t=e.current();return Un(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Un(e){return e>=48&&e<=55}_.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Vn(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Fn(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 Ye(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},j=G.prototype;j.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()};j.getToken=function(){return this.next(),new Rt(this)};typeof Symbol<"u"&&(j[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});j.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())};j.readToken=function(e){return ue(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};j.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};j.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=fn(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())};j.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&&!Te(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())};j.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&&hn.test(String.fromCharCode(e)))++this.pos;else break e}}};j.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)};j.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))};j.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)};j.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)};j.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)};j.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};j.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||Y.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)};j.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))};j.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)};j.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)};j.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)+"'")};j.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)+"'")};j.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};j.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(Y.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 a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(s,i)}catch{}return this.finishToken(c.regexp,{pattern:s,flags:i,value:l})};j.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,l=0,u=t??1/0;l<u;++l,++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"),l===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,i=i*e+d}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function Pi(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function qn(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}j.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=qn(this.input.slice(t,this.pos)),++this.pos):ue(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,n)};j.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=qn(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 a=Pi(this.input.slice(t,this.pos),n);return this.finishToken(c.num,a)};j.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};j.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)):(Te(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(c.string,t)};var Wn={};j.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Wn)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};j.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Wn;this.raise(e,t)};j.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(Te(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}};j.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
8
  `&&++this.pos;case`
9
- `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};B.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 Te(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};B.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};B.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 a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var i=this.readCodePoint();(t?ue:we)(i,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=de(i),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};B.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=_t[e]),this.finishToken(t,e)};var Ni="8.15.0";G.acorn={Parser:G,version:Ni,defaultOptions:kt,Position:Oe,SourceLocation:et,getLineInfo:cn,Node:st,TokenType:D,tokTypes:c,keywordTypes:_t,TokContext:oe,tokContexts:q,isIdentifierChar:we,isIdentifierStart:ue,Token:Mt,isNewLine:Te,lineBreak:Y,lineBreakG:ei,nonASCIIwhitespace:ln};function Vn(e,t){return G.parse(e,t)}function Fn(e,t,n){return G.parseExpressionAt(e,t,n)}var V=class extends Error{line;column;source;filename;constructor(t,n,r,s){let a=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${a}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},z=class extends V{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(`
9
+ `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};j.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 Te(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};j.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};j.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 a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var i=this.readCodePoint();(t?ue:we)(i,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=de(i),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};j.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=At[e]),this.finishToken(t,e)};var Ni="8.15.0";G.acorn={Parser:G,version:Ni,defaultOptions:Et,Position:Oe,SourceLocation:Ye,getLineInfo:mn,Node:nt,TokenType:D,tokTypes:c,keywordTypes:At,TokContext:oe,tokContexts:q,isIdentifierChar:we,isIdentifierStart:ue,Token:Rt,isNewLine:Te,lineBreak:Y,lineBreakG:ei,nonASCIIwhitespace:hn};function zn(e,t){return G.parse(e,t)}function Gn(e,t,n){return G.parseExpressionAt(e,t,n)}var F=class extends Error{line;column;source;filename;constructor(t,n,r,s){let a=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${a}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},z=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
11
  `),r=this.line-1,s=Math.max(0,r-t),a=Math.min(n.length-1,r+t),i=[],o=String(a+1).length;for(let l=s;l<=a;l++){let u=String(l+1).padStart(o),p=l===r?">":" ";if(i.push(`${p} ${u} | ${n[l]}`),l===r){let d=" ".repeat(o+4+this.column);i.push(`${d}^ ${this.message.split(" at ")[0]}`)}}return i.join(`
12
- `)}};function ae(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,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function F(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Mi(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,a=r+1;for(;a<e.length&&s>0;)e[a]==="{"?s++:e[a]==="}"&&s--,a++;if(s!==0)return null;let i=e.slice(r,a),o=[n[0].slice(0,-1)+i,i];return o.index=n.index,o}function Gn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let a=n+r[0].length-1+1,i=1,o=a;for(;o<e.length&&i>0;){let u=e[o];u==="{"?i++:u==="}"&&i--,o++}if(i!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let u=e.slice(a,o-1);t+=`try {${u}} 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 Hn(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let i=r,o=r+a[0].length,l=1,u=o;for(;u<e.length&&l>0;){let v=e[u];v==="{"?l++:v==="}"&&l--,u++}if(l!==0){n+=e[r],r++;continue}let p=e.slice(o,u-1),d,f=u,m=e.slice(u).match(/^\s*fallback\s*\{/);if(m){let v=u+m[0].length;l=1;let A=v;for(;A<e.length&&l>0;){let N=e[A];N==="{"?l++:N==="}"&&l--,A++}l===0&&(d=e.slice(v,A-1),f=A)}let b=Bi(p).map(v=>{let A=Oi(e,i,v);return A?`${v}: ${A}`:v}),x={id:`__tjs_wasm_${s}`,body:p,fallback:d,captures:b,start:i,end:f};t.push(x);let E=d??p,S=b.map(v=>v.split(":")[0].trim()),y=S.length>0?S.join(", "):"",C=S.length>0?`globalThis.${x.id}(${y})`:`globalThis.${x.id}()`,k=`(globalThis.${x.id} ? ${C} : (() => {${E}})())`;n+=k,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Jn(e){let t=[],n="",r=0;for(;r<e.length;){let s=/^\b(export\s+)?wasm\s+function\s+(\w+)\s*\(/,a=e.slice(r).match(s);if(!a){n+=e[r],r++;continue}let i=!!a[1],o=a[2],l=r,u=r+a[0].length,p=1,d=u;for(;d<e.length&&p>0;)e[d]==="("?p++:e[d]===")"&&p--,d++;if(p!==0){n+=e[r],r++;continue}let f=e.slice(u,d-1);if(f.match(/^\s*!/))throw new z(`Unsafe wasm functions (with \`!\` marker) are reserved for a future phase. Remove the bang from \`wasm function ${o}\` to declare it as a regular (pure) wasm function, or wait until the unsafe variant is implemented.`,ye(e,l));let g,b=d,x=e.slice(d).match(/^\s*:\s*(\w+)/);x&&(g=x[1],b=d+x[0].length);let E=e.slice(b).match(/^\s*\{/);if(!E){n+=e[r],r++;continue}let S=b+E[0].length,y=1,C=S;for(;C<e.length&&y>0;)e[C]==="{"?y++:e[C]==="}"&&y--,C++;if(y!==0){n+=e[r],r++;continue}let k=e.slice(S,C-1),v=$i(f),A=`__tjs_wasm_${o}`,N={id:A,name:o,returnType:g,body:k,captures:v,start:l,end:C};t.push(N);let I=v.map(U=>U.split(":")[0].trim()),j=`${i?"export ":""}function ${o}(${I.join(", ")}) { return globalThis.${A}(${I.join(", ")}) }`;n+=j,r=C}return{source:n,blocks:t}}function Kn(e,t){let{loader:n,importerPath:r}=t;if(!n)return{source:e,blocks:[]};let s=[],a=new Set;function i(u,p){if(!a.has(u.id)){s.push(u),a.add(u.id);for(let[d,f]of p){if(d===u.name||a.has(f.id))continue;new RegExp(`\\b${d}\\s*\\(`).test(u.body)&&i(f,p)}}}let o=/^(\s*)import\s*\{([^}]*?)\}\s*from\s*(['"])([^'"]+)\3\s*;?\s*$/gm;return{source:e.replace(o,(u,p,d,f,m)=>{let g=n.load(m,r);if(!g)return u;let b=new Map;for(let k of g.parseResult.wasmBlocks)k.name&&b.set(k.name,k);if(b.size===0)return u;let x=d.split(",").map(k=>k.trim()).filter(k=>k.length>0),E=[],S=[];for(let k of x){let v=k.match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!v){S.push(k);continue}let A=v[1],N=v[2]??v[1],I=b.get(A);if(!I){S.push(k);continue}i(I,b);let R=I.captures.map(j=>j.split(":")[0].trim());E.push(`function ${N}(${R.join(", ")}) { return globalThis.${I.id}(${R.join(", ")}) }`)}let y=E.join(`
13
- `);if(S.length===0)return y?`${p}${y}`:`${p}`;let C=`${p}import { ${S.join(", ")} } from '${m}'`;return y?`${C}
14
- ${p}${y}`:C}),blocks:s}}function $i(e){let t=e.trim();return t?t.split(",").map(n=>n.trim()).filter(n=>n.length>0):[]}function ji(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Bi(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 a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i=new Set;for(;(s=a.exec(t))!==null;)i.add(s[1]);for(let f of n){if(!i.has(f))continue;let m=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),g=new RegExp(`\\.${f}\\b`,"g"),b=t.match(m)?.length||0,x=t.match(g)?.length||0;b<=x&&i.delete(f)}let o=new Set,l=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=l.exec(t))!==null;)o.add(s[1]);let u=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.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 i)!o.has(f)&&!p.has(f)&&!ji(f)&&d.push(f);return d.sort()}function Oi(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(s);if(!a){let i=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(i);return o?Un(o[1],n):void 0}return Un(a[1],n)}function Un(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 a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function Zn(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 Qn(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(`
12
+ `)}};function ae(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,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function U(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Mi(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,a=r+1;for(;a<e.length&&s>0;)e[a]==="{"?s++:e[a]==="}"&&s--,a++;if(s!==0)return null;let i=e.slice(r,a),o=[n[0].slice(0,-1)+i,i];return o.index=n.index,o}function Qn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let a=n+r[0].length-1+1,i=1,o=a;for(;o<e.length&&i>0;){let u=e[o];u==="{"?i++:u==="}"&&i--,o++}if(i!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let u=e.slice(a,o-1);t+=`try {${u}} 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 Yn(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let i=r,o=r+a[0].length,l=1,u=o;for(;u<e.length&&l>0;){let v=e[u];v==="{"?l++:v==="}"&&l--,u++}if(l!==0){n+=e[r],r++;continue}let p=e.slice(o,u-1),d,f=u,m=e.slice(u).match(/^\s*fallback\s*\{/);if(m){let v=u+m[0].length;l=1;let A=v;for(;A<e.length&&l>0;){let N=e[A];N==="{"?l++:N==="}"&&l--,A++}l===0&&(d=e.slice(v,A-1),f=A)}let b=Bi(p).map(v=>{let A=Oi(e,i,v);return A?`${v}: ${A}`:v}),x={id:`__tjs_wasm_${s}`,body:p,fallback:d,captures:b,start:i,end:f};t.push(x);let S=d??p,E=b.map(v=>v.split(":")[0].trim()),y=E.length>0?E.join(", "):"",C=E.length>0?`globalThis.${x.id}(${y})`:`globalThis.${x.id}()`,k=`(globalThis.${x.id} ? ${C} : (() => {${S}})())`;n+=k,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Xn(e){let t=[],n="",r=0;for(;r<e.length;){let s=/^\b(export\s+)?wasm\s+function\s+(\w+)\s*\(/,a=e.slice(r).match(s);if(!a){n+=e[r],r++;continue}let i=!!a[1],o=a[2],l=r,u=r+a[0].length,p=1,d=u;for(;d<e.length&&p>0;)e[d]==="("?p++:e[d]===")"&&p--,d++;if(p!==0){n+=e[r],r++;continue}let f=e.slice(u,d-1);if(f.match(/^\s*!/))throw new z(`Unsafe wasm functions (with \`!\` marker) are reserved for a future phase. Remove the bang from \`wasm function ${o}\` to declare it as a regular (pure) wasm function, or wait until the unsafe variant is implemented.`,ye(e,l));let g,b=d,x=e.slice(d).match(/^\s*:\s*(\w+)/);x&&(g=x[1],b=d+x[0].length);let S=e.slice(b).match(/^\s*\{/);if(!S){n+=e[r],r++;continue}let E=b+S[0].length,y=1,C=E;for(;C<e.length&&y>0;)e[C]==="{"?y++:e[C]==="}"&&y--,C++;if(y!==0){n+=e[r],r++;continue}let k=e.slice(E,C-1),v=$i(f),A=`__tjs_wasm_${o}`,N={id:A,name:o,returnType:g,body:k,captures:v,start:l,end:C};t.push(N);let I=v.map(V=>V.split(":")[0].trim()),B=`${i?"export ":""}function ${o}(${I.join(", ")}) { return globalThis.${A}(${I.join(", ")}) }`;n+=B,r=C}return{source:n,blocks:t}}function er(e,t){let{loader:n,importerPath:r}=t;if(!n)return{source:e,blocks:[]};let s=[],a=new Set;function i(u,p){if(!a.has(u.id)){s.push(u),a.add(u.id);for(let[d,f]of p){if(d===u.name||a.has(f.id))continue;new RegExp(`\\b${d}\\s*\\(`).test(u.body)&&i(f,p)}}}let o=/^(\s*)import\s*\{([^}]*?)\}\s*from\s*(['"])([^'"]+)\3\s*;?\s*$/gm;return{source:e.replace(o,(u,p,d,f,m)=>{let g=n.load(m,r);if(!g)return u;let b=new Map;for(let k of g.parseResult.wasmBlocks)k.name&&b.set(k.name,k);if(b.size===0)return u;let x=d.split(",").map(k=>k.trim()).filter(k=>k.length>0),S=[],E=[];for(let k of x){let v=k.match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!v){E.push(k);continue}let A=v[1],N=v[2]??v[1],I=b.get(A);if(!I){E.push(k);continue}i(I,b);let R=I.captures.map(B=>B.split(":")[0].trim());S.push(`function ${N}(${R.join(", ")}) { return globalThis.${I.id}(${R.join(", ")}) }`)}let y=S.join(`
13
+ `);if(E.length===0)return y?`${p}${y}`:`${p}`;let C=`${p}import { ${E.join(", ")} } from '${m}'`;return y?`${C}
14
+ ${p}${y}`:C}),blocks:s}}function $i(e){let t=e.trim();return t?t.split(",").map(n=>n.trim()).filter(n=>n.length>0):[]}function ji(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Bi(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 a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i=new Set;for(;(s=a.exec(t))!==null;)i.add(s[1]);for(let f of n){if(!i.has(f))continue;let m=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),g=new RegExp(`\\.${f}\\b`,"g"),b=t.match(m)?.length||0,x=t.match(g)?.length||0;b<=x&&i.delete(f)}let o=new Set,l=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=l.exec(t))!==null;)o.add(s[1]);let u=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.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 i)!o.has(f)&&!p.has(f)&&!ji(f)&&d.push(f);return d.sort()}function Oi(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(s);if(!a){let i=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(i);return o?Hn(o[1],n):void 0}return Hn(a[1],n)}function Hn(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 a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function tr(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 nr(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(`
15
15
  `),a=[],i=!1;for(let o=0;o<s.length;o++){let l=s[o],u=o>0?s[o-1]:"";if(i){a.push(l),l.includes("*/")&&(i=!1);continue}let p=l.indexOf("/*"),d=l.indexOf("*/");if(p!==-1&&(d===-1||d<p)){i=!0,a.push(l);continue}if(o>0&&t.test(l)){let f=u.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!n.test(f)&&!r.test(f)){let m=l.match(/^(\s*)/),g=m?m[1]:"",b=l.slice(g.length);a.push(g+";"+b);continue}}a.push(l)}return a.join(`
16
16
  `)}function Di(e){let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
17
- `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let l=n-1;for(;l>=0&&/\s/.test(e[l]);)l--;let u=l>=0?e[l]:"";if(!u||/[=(!,;:{[&|?+\-*%<>~^]/.test(u)||l>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,l-10),l+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let l=n+6;for(;l<e.length&&/\s/.test(e[l]);)l++;if(l<e.length&&/[a-zA-Z_$]/.test(e[l])){let u=l;for(;l<e.length&&/[\w$]/.test(e[l]);)l++;for(;l<e.length;)if(e[l]==="."&&/[a-zA-Z_$]/.test(e[l+1]??""))for(l++;l<e.length&&/[\w$]/.test(e[l]);)l++;else if(e[l]==="?"&&e[l+1]==="."&&/[a-zA-Z_$]/.test(e[l+2]??""))for(l+=2;l<e.length&&/[\w$]/.test(e[l]);)l++;else break;t.push({keywordStart:n,operandEnd:l,operand:e.slice(u,l)}),n=l;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Yn(e){e=Di(e);let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
18
- `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let l=n-1;for(;l>=0&&/\s/.test(e[l]);)l--;let u=l>=0?e[l]:"";if(!u||/[=(!,;:{[&|?+\-*%<>~^]/.test(u)||l>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,l-10),l+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:l}=t[i],u=l==="=="?"Eq":"NotEq",p=Li(a,o),d=Vi(a,o+2),f=a.slice(p,o).trim(),m=a.slice(o+2,d).trim();if(f&&m){let g=a.slice(0,p),b=a.slice(d),E=/[a-zA-Z0-9_$]$/.test(g)?" ":"";a=`${g}${E}${u}(${f}, ${m})${b}`}}return a}function Li(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,a="";for(;n>=0;){let i=e[n],o=n>0?e[n-1]:"";if(s){i===a&&o!=="\\"&&(s=!1),n--;continue}if((i==='"'||i==="'"||i==="`")&&o!=="\\"){s=!0,a=i,n--;continue}if(i===")"||i==="]"||i==="}"){r++,n--;continue}if(i==="("||i==="["){if(r>0){r--,n--;continue}return n+1}if(i==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(i===";")return n+1;if(/[a-z]/.test(i)){let l=n+1,u=n;for(;u>0&&/[a-z]/i.test(e[u-1]);)u--;let p=e.slice(u,l),d=u>0?e[u-1]:"";if(!/[a-zA-Z0-9_$]/.test(d)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(p))return l;if(p==="new")return u}}if(i===">"&&o==="="||i==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===",")return n+1;n--}return 0}function Vi(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,a="";for(;n<e.length;){let i=e[n],o=n+1<e.length?e[n+1]:"";if(s){i===a&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((i==='"'||i==="'"||i==="`")&&e[n-1]!=="\\"){s=!0,a=i,n++;continue}if(i==="("||i==="["||i==="{"){r++,n++;continue}if(i===")"||i==="]"||i==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(i===";"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===","||(i==="="||i==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function Xn(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],a=n+r[0].length,i=s,o=!1,l=e.slice(a).match(/^(['"`])([^]*?)\1\s*/);if(l){let f=a+l[0].length,m=e[f],g=m===void 0||f>=e.length||m!=="="&&m!=="{";if(m==="="||m==="{")i=l[2],o=!0,a=f;else if(g){let b=l[0].trim(),x=l[0].slice(b.length);t+=`const ${s} = Type('${s}', ${b})${x}`,n=f;continue}}let u,p=a,d=e.slice(a).match(/^=\s*/);if(d){a+=d[0].length;let f=e.slice(a).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(f){u=f[0],a+=f[0].length,p=a;let m=e.slice(a).match(/^\s*/);m&&(a+=m[0].length)}}if(e[a]==="{"){let f=a+1,m=1,g=f;for(;g<e.length&&m>0;){let k=e[g];k==="{"?m++:k==="}"&&m--,g++}if(m!==0){t+=e[n],n++;continue}let b=e.slice(f,g-1).trim(),x=g,E=b.match(/description\s*:\s*(['"`])([^]*?)\1/);E&&!o&&(i=E[2]);let S,y=b.match(/example\s*:\s*/);if(y){let k=y.index+y[0].length,v=br(b,k);v&&(S=v.value.trim())}let C=b.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(C&&S){let k=C[1].trim(),v=C[2].trim(),A=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { if (!globalThis.__tjs?.validate(${k}, globalThis.__tjs?.infer(${S}))) return false; ${v} }, ${S}${A})`}else if(C){let k=C[1].trim(),v=C[2].trim(),A=u?`, undefined, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { ${v} }${A})`}else if(S){let k=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', undefined, ${S}${k})`}else u?t+=`const ${s} = Type('${i}', ${u})`:t+=`const ${s} = Type('${i}')`;n=x;continue}else if(u){t+=`const ${s} = Type('${i}', ${u})`,n=p;continue}else if(!l){let f=e.slice(a).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(f){let m=f[0];t+=`const ${s} = Type('${s}', ${m})`,n=a+f[0].length;continue}}}t+=e[n],n++}return t}function er(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],a=r[2],i=n+r[0].length;if(e[i]==="{"){let o=1,l=i+1;for(;l<e.length&&o>0;)e[l]==="{"?o++:e[l]==="}"&&o--,l++;if(o===0){let u=e.slice(i+1,l-1).trim(),p=Mi(u,/params\s*:\s*\{/),d=u.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=u.match(/returnContract\s*:\s*['"](\w+)['"]/),m=u.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 b=m?m[2]:s;if(a){let x=a.split(",").map(S=>{let y=S.trim().split("=").map(C=>C.trim());if(y.length===2){let C=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${C}]`}return`'${y[0]}'`}),E=a.split(",").map(S=>S.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${b}', [${x.join(", ")}], (${E.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${b}', { ${g.join(", ")} })`;n=l;continue}}if(e[i]==="("){let o=1,l=i+1;for(;l<e.length&&o>0;)e[l]==="("?o++:e[l]===")"&&o--,l++;if(o===0){let u=e.slice(i+1,l-1).trim(),p=u.indexOf(",");if(p!==-1){let d=u.slice(0,p).trim(),f=u.slice(p+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${d})`}else t+=`const ${s} = FunctionPredicate('${s}', ${u})`;n=l;continue}}}t+=e[n],n++}return t}function tr(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],a=r[2],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let S=e[u];S==="{"?l++:S==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=a.split(",").map(S=>{let y=S.trim().split("=").map(C=>C.trim());if(y.length===2){let C=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${C}]`}return`'${y[0]}'`}),m=p,g=m.search(/\bdeclaration\s*\{/);if(g!==-1){let S=m.indexOf("{",g),y=1,C=S+1;for(;C<m.length&&y>0;)m[C]==="{"?y++:m[C]==="}"&&y--,C++;m=m.slice(0,g)+m.slice(C)}let b=m.match(/description\s*:\s*(['"`])([^]*?)\1/),x=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),E=b?b[2]:s;if(x){let S=x[1].trim().split(",").map(A=>A.trim()),y=x[2].trim(),C=S[0]||"x",k=S.slice(1),v=k.map(A=>`check${A}`);k.forEach((A,N)=>{y=y.replace(new RegExp(`\\b${A}\\s*\\(`,"g"),`${v[N]}(`)}),t+=`const ${s} = Generic([${f.join(", ")}], (${C}, ${v.join(", ")}) => { ${y} }, '${E}')`}else t+=`const ${s} = Generic([${f.join(", ")}], () => true, '${E}')`;n=d;continue}t+=e[n],n++}return t}function nr(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],a=r[3],i=n+r[0].length;if(e[i]==="{"){let o=i+1,l=1,u=o;for(;u<e.length&&l>0;){let m=e[u];m==="{"?l++:m==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=qn(p);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=d;continue}else{let o=e.indexOf(`
19
- `,i);o===-1&&(o=e.length);let l=e.slice(i,o).trim();if(l){let u=qn(l);t+=`const ${s} = Union('${a}', [${u.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function qn(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function rr(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],a=r[3],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let g=e[u];g==="{"?l++:g==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,m=Fi(p).map(([g,b])=>`${g}: ${b}`).join(", ");t+=`const ${s} = Enum('${a}', { ${m} })`,n=d;continue}t+=e[n],n++}return t}function Fi(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let a=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let i=a[1],o=a[2]?.trim();if(o!==void 0){t.push([i,o]);let l=Number(o);isNaN(l)||(n=l+1)}else t.push([i,String(n)]),n++}}return t}function sr(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),a=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){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 i=a[1],o=a[2],l=r+a[0].length-1,u=Fe(e,l),p=e.slice(l+1,u-1).trim(),d=[],f=0,m=e.slice(l+1,u-1);for(;f<m.length;){let y=m.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!y){f++;continue}let C=y[1],k=!!y[2],v=y[3],A=f+y[0].length-1,N=1,I=A+1;for(;I<m.length&&N>0;)m[I]==="("&&N++,m[I]===")"&&N--,I++;let R=m.slice(A+1,I-1),j=I;for(;j<m.length&&/\s/.test(m[j]);)j++;if(m[j]==="="&&m[j+1]===">"){let be=ye(e,l+1+f);throw new z(`Arrow functions are not allowed in extend blocks (method '${v}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,be)}if(m[j]!=="{"){f++;continue}let U=Fe(m,j),te=m.slice(f,U).trim(),Re=R.split(",").map(be=>be.trim()).filter(be=>be.length>0).map(be=>{let ht=be.match(/^(\w+)\s*:\s*(.+)$/);return ht?`${ht[1]} = ${ht[2]}`:be}).join(", "),Me=k?"async ":"",$e=m.slice(j+1,U-1);d.push({name:v,isAsync:k,fullText:`${v}: ${Me}function(${Re}) {${$e}}`}),f=U}let g=!t.has(o);g&&t.set(o,new Set);let b=t.get(o);for(let S of d)b.add(S.name);let x=d.map(S=>` ${S.fullText}`).join(`,
21
- `),E;g?E=`${i}const __ext_${o} = {
17
+ `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let l=n-1;for(;l>=0&&/\s/.test(e[l]);)l--;let u=l>=0?e[l]:"";if(!u||/[=(!,;:{[&|?+\-*%<>~^]/.test(u)||l>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,l-10),l+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let l=n+6;for(;l<e.length&&/\s/.test(e[l]);)l++;if(l<e.length&&/[a-zA-Z_$]/.test(e[l])){let u=l;for(;l<e.length&&/[\w$]/.test(e[l]);)l++;for(;l<e.length;)if(e[l]==="."&&/[a-zA-Z_$]/.test(e[l+1]??""))for(l++;l<e.length&&/[\w$]/.test(e[l]);)l++;else if(e[l]==="?"&&e[l+1]==="."&&/[a-zA-Z_$]/.test(e[l+2]??""))for(l+=2;l<e.length&&/[\w$]/.test(e[l]);)l++;else break;t.push({keywordStart:n,operandEnd:l,operand:e.slice(u,l)}),n=l;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function rr(e){e=Di(e);let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
18
+ `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let l=n-1;for(;l>=0&&/\s/.test(e[l]);)l--;let u=l>=0?e[l]:"";if(!u||/[=(!,;:{[&|?+\-*%<>~^]/.test(u)||l>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,l-10),l+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:l}=t[i],u=l==="=="?"Eq":"NotEq",p=Li(a,o),d=Vi(a,o+2),f=a.slice(p,o).trim(),m=a.slice(o+2,d).trim();if(f&&m){let g=a.slice(0,p),b=a.slice(d),S=/[a-zA-Z0-9_$]$/.test(g)?" ":"";a=`${g}${S}${u}(${f}, ${m})${b}`}}return a}function Li(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,a="";for(;n>=0;){let i=e[n],o=n>0?e[n-1]:"";if(s){i===a&&o!=="\\"&&(s=!1),n--;continue}if((i==='"'||i==="'"||i==="`")&&o!=="\\"){s=!0,a=i,n--;continue}if(i===")"||i==="]"||i==="}"){r++,n--;continue}if(i==="("||i==="["){if(r>0){r--,n--;continue}return n+1}if(i==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(i===";")return n+1;if(/[a-z]/.test(i)){let l=n+1,u=n;for(;u>0&&/[a-z]/i.test(e[u-1]);)u--;let p=e.slice(u,l),d=u>0?e[u-1]:"";if(!/[a-zA-Z0-9_$]/.test(d)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(p))return l;if(p==="new")return u}}if(i===">"&&o==="="||i==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===",")return n+1;n--}return 0}function Vi(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,a="";for(;n<e.length;){let i=e[n],o=n+1<e.length?e[n+1]:"";if(s){i===a&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((i==='"'||i==="'"||i==="`")&&e[n-1]!=="\\"){s=!0,a=i,n++;continue}if(i==="("||i==="["||i==="{"){r++,n++;continue}if(i===")"||i==="]"||i==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(i===";"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===","||(i==="="||i==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function sr(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],a=n+r[0].length,i=s,o=!1,l=e.slice(a).match(/^(['"`])([^]*?)\1\s*/);if(l){let f=a+l[0].length,m=e[f],g=m===void 0||f>=e.length||m!=="="&&m!=="{";if(m==="="||m==="{")i=l[2],o=!0,a=f;else if(g){let b=l[0].trim(),x=l[0].slice(b.length);t+=`const ${s} = Type('${s}', ${b})${x}`,n=f;continue}}let u,p=a,d=e.slice(a).match(/^=\s*/);if(d){a+=d[0].length;let f=e.slice(a).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(f){u=f[0],a+=f[0].length,p=a;let m=e.slice(a).match(/^\s*/);m&&(a+=m[0].length)}}if(e[a]==="{"){let f=a+1,m=1,g=f;for(;g<e.length&&m>0;){let k=e[g];k==="{"?m++:k==="}"&&m--,g++}if(m!==0){t+=e[n],n++;continue}let b=e.slice(f,g-1).trim(),x=g,S=b.match(/description\s*:\s*(['"`])([^]*?)\1/);S&&!o&&(i=S[2]);let E,y=b.match(/example\s*:\s*/);if(y){let k=y.index+y[0].length,v=Er(b,k);v&&(E=v.value.trim())}let C=b.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(C&&E){let k=C[1].trim(),v=C[2].trim(),A=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { if (!globalThis.__tjs?.validate(${k}, globalThis.__tjs?.infer(${E}))) return false; ${v} }, ${E}${A})`}else if(C){let k=C[1].trim(),v=C[2].trim(),A=u?`, undefined, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { ${v} }${A})`}else if(E){let k=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', undefined, ${E}${k})`}else u?t+=`const ${s} = Type('${i}', ${u})`:t+=`const ${s} = Type('${i}')`;n=x;continue}else if(u){t+=`const ${s} = Type('${i}', ${u})`,n=p;continue}else if(!l){let f=e.slice(a).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(f){let m=f[0];t+=`const ${s} = Type('${s}', ${m})`,n=a+f[0].length;continue}}}t+=e[n],n++}return t}function ir(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],a=r[2],i=n+r[0].length;if(e[i]==="{"){let o=1,l=i+1;for(;l<e.length&&o>0;)e[l]==="{"?o++:e[l]==="}"&&o--,l++;if(o===0){let u=e.slice(i+1,l-1).trim(),p=Mi(u,/params\s*:\s*\{/),d=u.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=u.match(/returnContract\s*:\s*['"](\w+)['"]/),m=u.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 b=m?m[2]:s;if(a){let x=a.split(",").map(E=>{let y=E.trim().split("=").map(C=>C.trim());if(y.length===2){let C=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${C}]`}return`'${y[0]}'`}),S=a.split(",").map(E=>E.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${b}', [${x.join(", ")}], (${S.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${b}', { ${g.join(", ")} })`;n=l;continue}}if(e[i]==="("){let o=1,l=i+1;for(;l<e.length&&o>0;)e[l]==="("?o++:e[l]===")"&&o--,l++;if(o===0){let u=e.slice(i+1,l-1).trim(),p=u.indexOf(",");if(p!==-1){let d=u.slice(0,p).trim(),f=u.slice(p+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${d})`}else t+=`const ${s} = FunctionPredicate('${s}', ${u})`;n=l;continue}}}t+=e[n],n++}return t}function ar(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],a=r[2],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let E=e[u];E==="{"?l++:E==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=a.split(",").map(E=>{let y=E.trim().split("=").map(C=>C.trim());if(y.length===2){let C=y[1]==="any"||y[1]==="undefined"?"null":y[1];return`['${y[0]}', ${C}]`}return`'${y[0]}'`}),m=p,g=m.search(/\bdeclaration\s*\{/);if(g!==-1){let E=m.indexOf("{",g),y=1,C=E+1;for(;C<m.length&&y>0;)m[C]==="{"?y++:m[C]==="}"&&y--,C++;m=m.slice(0,g)+m.slice(C)}let b=m.match(/description\s*:\s*(['"`])([^]*?)\1/),x=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),S=b?b[2]:s;if(x){let E=x[1].trim().split(",").map(A=>A.trim()),y=x[2].trim(),C=E[0]||"x",k=E.slice(1),v=k.map(A=>`check${A}`);k.forEach((A,N)=>{y=y.replace(new RegExp(`\\b${A}\\s*\\(`,"g"),`${v[N]}(`)}),t+=`const ${s} = Generic([${f.join(", ")}], (${C}, ${v.join(", ")}) => { ${y} }, '${S}')`}else t+=`const ${s} = Generic([${f.join(", ")}], () => true, '${S}')`;n=d;continue}t+=e[n],n++}return t}function or(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],a=r[3],i=n+r[0].length;if(e[i]==="{"){let o=i+1,l=1,u=o;for(;u<e.length&&l>0;){let m=e[u];m==="{"?l++:m==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=Jn(p);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=d;continue}else{let o=e.indexOf(`
19
+ `,i);o===-1&&(o=e.length);let l=e.slice(i,o).trim();if(l){let u=Jn(l);t+=`const ${s} = Union('${a}', [${u.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Jn(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function lr(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],a=r[3],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let g=e[u];g==="{"?l++:g==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,m=Fi(p).map(([g,b])=>`${g}: ${b}`).join(", ");t+=`const ${s} = Enum('${a}', { ${m} })`,n=d;continue}t+=e[n],n++}return t}function Fi(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let a=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let i=a[1],o=a[2]?.trim();if(o!==void 0){t.push([i,o]);let l=Number(o);isNaN(l)||(n=l+1)}else t.push([i,String(n)]),n++}}return t}function ur(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),a=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){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 i=a[1],o=a[2],l=r+a[0].length-1,u=Fe(e,l),p=e.slice(l+1,u-1).trim(),d=[],f=0,m=e.slice(l+1,u-1);for(;f<m.length;){let y=m.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!y){f++;continue}let C=y[1],k=!!y[2],v=y[3],A=f+y[0].length-1,N=1,I=A+1;for(;I<m.length&&N>0;)m[I]==="("&&N++,m[I]===")"&&N--,I++;let R=m.slice(A+1,I-1),B=I;for(;B<m.length&&/\s/.test(m[B]);)B++;if(m[B]==="="&&m[B+1]===">"){let be=ye(e,l+1+f);throw new z(`Arrow functions are not allowed in extend blocks (method '${v}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,be)}if(m[B]!=="{"){f++;continue}let V=Fe(m,B),te=m.slice(f,V).trim(),Re=R.split(",").map(be=>be.trim()).filter(be=>be.length>0).map(be=>{let pt=be.match(/^(\w+)\s*:\s*(.+)$/);return pt?`${pt[1]} = ${pt[2]}`:be}).join(", "),Me=k?"async ":"",$e=m.slice(B+1,V-1);d.push({name:v,isAsync:k,fullText:`${v}: ${Me}function(${Re}) {${$e}}`}),f=V}let g=!t.has(o);g&&t.set(o,new Set);let b=t.get(o);for(let E of d)b.add(E.name);let x=d.map(E=>` ${E.fullText}`).join(`,
21
+ `),S;g?S=`${i}const __ext_${o} = {
22
22
  ${x}
23
23
  ${i}}
24
- `:E=`${i}Object.assign(__ext_${o}, {
24
+ `:S=`${i}Object.assign(__ext_${o}, {
25
25
  ${x}
26
26
  ${i}})
27
- `;for(let S of d)E+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${S.name}', __ext_${o}.${S.name}) }
28
- `;n+=E,r=u}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function ir(e,t){if(t.size===0)return e;let n=new Map;for(let[s,a]of t)for(let i of a)n.has(i)||n.set(i,[]),n.get(i).push(s);let r=e;for(let[s,a]of n){if(!a.includes("String"))continue;let i=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(i,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let l=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(l,(u,p,d)=>d?`__ext_String.${s}.call(${p})`:`__ext_String.${s}.call(${p}, `)}for(let[s,a]of n){if(!a.includes("Array"))continue;let i=`].${s}(`,o=0,l;for(;(l=r.indexOf(i,o))!==-1;){let u=1,p=l-1,d=!1;for(;p>=0&&u>0;){let f=r[p];d?f===d&&(p===0||r[p-1]!=="\\")&&(d=!1):(f==="]"&&u++,f==="["&&u--,(f==="'"||f==='"'||f==="`")&&(d=f)),p--}if(u===0){let f=r.slice(p+1,l+1),m=r.slice(0,p+1),g=r.slice(l+i.length);g[0]===")"?r=`${m}__ext_Array.${s}.call(${f})${g.slice(1)}`:r=`${m}__ext_Array.${s}.call(${f}, ${g}`}o=l+1}}for(let[s,a]of n){if(!a.includes("Number"))continue;let i=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(i,(o,l,u,p)=>p?`__ext_Number.${u}.call(${l})`:`__ext_Number.${u}.call(${l}, `)}return r}function ye(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 ar(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 at(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 $t(e,t){let n=[],r=0,s="",a=!1;for(let o=0;o<e.length;o++){let l=e[o];if(!a&&(l==="'"||l==='"'||l==="`")){a=l,s+=l;continue}if(a){if(s+=l,l==="\\"){o++,o<e.length&&(s+=e[o]);continue}l===a&&(a=!1);continue}if(l==="("||l==="["||l==="{"){r++,s+=l;continue}if(l===")"||l==="]"||l==="}"){r--,s+=l;continue}if(l===","&&r===0){let u=Wn(s.trim(),t);u&&n.push(u),s="";continue}s+=l}let i=s.trim();if(i){let o=Wn(i,t);o&&n.push(o)}return n}function Wn(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(),a=n.slice(r+1).trim();return{name:s,defaultValue:a,required:t.has(s)}}function Fe(e,t){let n=1,r=t+1,s=!1,a=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r],l=r+1<e.length?e[r+1]:"";if(a){o===`
30
- `&&(a=!1),r++;continue}if(i){if(o==="*"&&l==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&l==="/"){a=!0,r+=2;continue}if(o==="/"&&l==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function or(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,a,i=[];for(;(a=r.exec(e))!==null;){let d=!!a[1],f=!!a[2],m=a[3],g=a.index,b=g,E=a[0].indexOf("function");E>=0&&(b=g+E),i.push({name:m,fullMatchStart:g,funcKeywordStart:b,exported:d,isAsync:f})}for(let d of i)s.has(d.name)||s.set(d.name,[]);let o=new Map;for(let d of i)o.set(d.name,(o.get(d.name)||0)+1);let l=new Set;for(let[d,f]of o)f>1&&l.add(d);if(l.size===0)return{source:e,polymorphicNames:n};for(let d of i){if(!l.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 b=g-1,x=e.slice(f+1,b),E=g;for(;E<e.length&&e[E]!=="{";)E++;if(E>=e.length)continue;let S=Fe(e,E),y=d.fullMatchStart;for(;y>0&&e[y-1]===" ";)y--;let C=s.get(d.name),k=$t(x,t);if(x.includes("...")){let A=ye(e,d.funcKeywordStart);throw new z(`Rest parameters are not supported in polymorphic function '${d.name}'. Use separate function names instead.`,A)}C.push({index:C.length+1,start:y,end:S,text:e.slice(y,S),exported:d.exported,isAsync:d.isAsync,params:k})}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=ye(e,f[0].start);throw new z(`Polymorphic function '${d}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let b=g+1;b<f.length;b++){let x=f[g],E=f[b];if(x.params.length!==E.params.length)continue;let S=!0;for(let y=0;y<x.params.length;y++){let C=x.params[y].defaultValue?at(x.params[y].defaultValue):"any",k=E.params[y].defaultValue?at(E.params[y].defaultValue):"any";if(C!==k){S=!1;break}}if(S){let y=ye(e,E.start);throw new z(`Polymorphic function '${d}': variants ${g+1} and ${b+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,y)}}}let u=[];for(let[d,f]of s)if(!(f.length<2))for(let m of f)u.push({name:d,variant:m});u.sort((d,f)=>f.variant.start-d.variant.start);let p=e;for(let{name:d,variant:f}of u){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(C=>C.exported),b=m?"async ":"",x=g?"export ":"",E=[...f].sort((C,k)=>{if(C.params.length!==k.params.length)return 0;let v=0,A=0;for(let N of C.params){let I=N.defaultValue?at(N.defaultValue):"any";I==="non-negative-integer"?v+=3:I==="integer"?v+=2:I!=="any"&&(v+=1)}for(let N of k.params){let I=N.defaultValue?at(N.defaultValue):"any";I==="non-negative-integer"?A+=3:I==="integer"?A+=2:I!=="any"&&(A+=1)}return A-v}),S=[];for(let C of E){let k=[`__args.length === ${C.params.length}`],v=[];for(let A=0;A<C.params.length;A++){let N=C.params[A];if(v.push(`__args[${A}]`),N.defaultValue){let I=ar(`__args[${A}]`,N.defaultValue);I!=="true"&&k.push(I)}}S.push(` if (${k.join(" && ")}) return ${d}$${C.index}(${v.join(", ")})`)}let y=`
27
+ `;for(let E of d)S+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${E.name}', __ext_${o}.${E.name}) }
28
+ `;n+=S,r=u}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function cr(e,t){if(t.size===0)return e;let n=new Map;for(let[s,a]of t)for(let i of a)n.has(i)||n.set(i,[]),n.get(i).push(s);let r=e;for(let[s,a]of n){if(!a.includes("String"))continue;let i=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(i,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let l=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(l,(u,p,d)=>d?`__ext_String.${s}.call(${p})`:`__ext_String.${s}.call(${p}, `)}for(let[s,a]of n){if(!a.includes("Array"))continue;let i=`].${s}(`,o=0,l;for(;(l=r.indexOf(i,o))!==-1;){let u=1,p=l-1,d=!1;for(;p>=0&&u>0;){let f=r[p];d?f===d&&(p===0||r[p-1]!=="\\")&&(d=!1):(f==="]"&&u++,f==="["&&u--,(f==="'"||f==='"'||f==="`")&&(d=f)),p--}if(u===0){let f=r.slice(p+1,l+1),m=r.slice(0,p+1),g=r.slice(l+i.length);g[0]===")"?r=`${m}__ext_Array.${s}.call(${f})${g.slice(1)}`:r=`${m}__ext_Array.${s}.call(${f}, ${g}`}o=l+1}}for(let[s,a]of n){if(!a.includes("Number"))continue;let i=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(i,(o,l,u,p)=>p?`__ext_Number.${u}.call(${l})`:`__ext_Number.${u}.call(${l}, `)}return r}function ye(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 pr(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 st(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 Mt(e,t){let n=[],r=0,s="",a=!1;for(let o=0;o<e.length;o++){let l=e[o];if(!a&&(l==="'"||l==='"'||l==="`")){a=l,s+=l;continue}if(a){if(s+=l,l==="\\"){o++,o<e.length&&(s+=e[o]);continue}l===a&&(a=!1);continue}if(l==="("||l==="["||l==="{"){r++,s+=l;continue}if(l===")"||l==="]"||l==="}"){r--,s+=l;continue}if(l===","&&r===0){let u=Kn(s.trim(),t);u&&n.push(u),s="";continue}s+=l}let i=s.trim();if(i){let o=Kn(i,t);o&&n.push(o)}return n}function Kn(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(),a=n.slice(r+1).trim();return{name:s,defaultValue:a,required:t.has(s)}}function Fe(e,t){let n=1,r=t+1,s=!1,a=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r],l=r+1<e.length?e[r+1]:"";if(a){o===`
30
+ `&&(a=!1),r++;continue}if(i){if(o==="*"&&l==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&l==="/"){a=!0,r+=2;continue}if(o==="/"&&l==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function fr(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,a,i=[];for(;(a=r.exec(e))!==null;){let d=!!a[1],f=!!a[2],m=a[3],g=a.index,b=g,S=a[0].indexOf("function");S>=0&&(b=g+S),i.push({name:m,fullMatchStart:g,funcKeywordStart:b,exported:d,isAsync:f})}for(let d of i)s.has(d.name)||s.set(d.name,[]);let o=new Map;for(let d of i)o.set(d.name,(o.get(d.name)||0)+1);let l=new Set;for(let[d,f]of o)f>1&&l.add(d);if(l.size===0)return{source:e,polymorphicNames:n};for(let d of i){if(!l.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 b=g-1,x=e.slice(f+1,b),S=g;for(;S<e.length&&e[S]!=="{";)S++;if(S>=e.length)continue;let E=Fe(e,S),y=d.fullMatchStart;for(;y>0&&e[y-1]===" ";)y--;let C=s.get(d.name),k=Mt(x,t);if(x.includes("...")){let A=ye(e,d.funcKeywordStart);throw new z(`Rest parameters are not supported in polymorphic function '${d.name}'. Use separate function names instead.`,A)}C.push({index:C.length+1,start:y,end:E,text:e.slice(y,E),exported:d.exported,isAsync:d.isAsync,params:k})}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=ye(e,f[0].start);throw new z(`Polymorphic function '${d}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let b=g+1;b<f.length;b++){let x=f[g],S=f[b];if(x.params.length!==S.params.length)continue;let E=!0;for(let y=0;y<x.params.length;y++){let C=x.params[y].defaultValue?st(x.params[y].defaultValue):"any",k=S.params[y].defaultValue?st(S.params[y].defaultValue):"any";if(C!==k){E=!1;break}}if(E){let y=ye(e,S.start);throw new z(`Polymorphic function '${d}': variants ${g+1} and ${b+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,y)}}}let u=[];for(let[d,f]of s)if(!(f.length<2))for(let m of f)u.push({name:d,variant:m});u.sort((d,f)=>f.variant.start-d.variant.start);let p=e;for(let{name:d,variant:f}of u){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(C=>C.exported),b=m?"async ":"",x=g?"export ":"",S=[...f].sort((C,k)=>{if(C.params.length!==k.params.length)return 0;let v=0,A=0;for(let N of C.params){let I=N.defaultValue?st(N.defaultValue):"any";I==="non-negative-integer"?v+=3:I==="integer"?v+=2:I!=="any"&&(v+=1)}for(let N of k.params){let I=N.defaultValue?st(N.defaultValue):"any";I==="non-negative-integer"?A+=3:I==="integer"?A+=2:I!=="any"&&(A+=1)}return A-v}),E=[];for(let C of S){let k=[`__args.length === ${C.params.length}`],v=[];for(let A=0;A<C.params.length;A++){let N=C.params[A];if(v.push(`__args[${A}]`),N.defaultValue){let I=pr(`__args[${A}]`,N.defaultValue);I!=="true"&&k.push(I)}}E.push(` if (${k.join(" && ")}) return ${d}$${C.index}(${v.join(", ")})`)}let y=`
31
31
  ${x}${b}function ${d}(...__args) {
32
- ${S.join(`
32
+ ${E.join(`
33
33
  `)}
34
34
  return __tjs.typeError('${d}', 'no matching overload', __args)
35
35
  }
36
- `;p+=y}return{source:p,polymorphicNames:n}}function lr(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="",a=0;for(;a<e.length;){let i=e.slice(a).match(/^\btest\s+/);if(i){let o=a,l=a+i[0].length,u,p=e.slice(l).match(/^(['"`])([^]*?)\1\s*/);if(p&&(u=p[2],l+=p[0].length),e[l]==="{"){let d=l+1,f=1,m=d,g=null,b=!1;for(;m<e.length&&f>0;){let x=e[m];if(b){b=!1,m++;continue}if(x==="\\"&&g){b=!0,m++;continue}if(g){x===g&&(g=null),m++;continue}if(x==="/"&&e[m+1]==="/"){let E=e.indexOf(`
37
- `,m);m=E===-1?e.length:E+1;continue}if(x==="/"&&e[m+1]==="*"){let E=e.indexOf("*/",m+2);m=E===-1?e.length:E+2;continue}if(x==="'"||x==='"'||x==="`"){g=x,m++;continue}x==="{"?f++:x==="}"&&f--,m++}if(f===0){let x=e.slice(d,m-1).trim(),E=m,S=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:u,body:x,start:o,end:E,line:S}),!t)try{new Function(x)()}catch(k){let v=u||`test at line ${S}`;r.push(`Test failed: ${v} (line ${S})
38
- ${k.message||k}`)}let C=(e.slice(o,E).match(/\n/g)||[]).length;s+=`
39
- `.repeat(C),a=E;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function cr(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,a=[];for(;(s=r.exec(e))!==null;){let o=s[1],l=s[2]?.trim()||"",u=s.index+s[0].length-1,p=Fe(e,u),d=e.slice(u,p);a.push({className:o,extendsClause:l,bodyStart:u,bodyEnd:p,body:d})}let i=e;for(let o=a.length-1;o>=0;o--){let{className:l,extendsClause:u,bodyStart:p,bodyEnd:d,body:f}=a[o],m=/\bconstructor\s*\(/g,g,b=[];for(;(g=m.exec(f))!==null;)b.push(g.index);if(b.length<2)continue;n.add(l);let x=[];for(let k=0;k<b.length;k++){let v=b[k],A=f.indexOf("(",v),N=1,I=A+1;for(;I<f.length&&N>0;)f[I]==="("&&N++,f[I]===")"&&N--,I++;let R=f.slice(A+1,I-1),j=I;for(;j<f.length&&f[j]!=="{";)j++;let U=Fe(f,j),te=f.slice(j+1,U-1);x.push({index:k+1,paramStr:R,bodyText:te,fullStart:v,fullEnd:U})}let E=f;for(let k=x.length-1;k>=1;k--){let v=x[k],A=v.fullStart;for(;A>0&&E[A-1]===" ";)A--;A>0&&E[A-1]===`
40
- `&&A--,E=E.slice(0,A)+E.slice(v.fullEnd)}let S="";for(let k=1;k<x.length;k++){let v=x[k],A=$t(v.paramStr,t);if(v.paramStr.includes("...")){let I=ye(e,p+v.fullStart);throw new z(`Rest parameters are not supported in polymorphic constructors for '${l}'.`,I)}S+=`
41
- function ${l}$ctor$${v.index}(${v.paramStr}) {`,S+=`
42
- const __obj = Object.create(${l}.prototype)`,S+=`
43
- ;(function() {${v.bodyText}}).call(__obj)`,S+=`
44
- return __obj`,S+=`
36
+ `;p+=y}return{source:p,polymorphicNames:n}}function hr(e){return e.replace(/(?<=^|[;\n{])\s*([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(t,n)=>t.replace(n,`const ${n}`))}function dr(e,t=!1){let n=[],r=[],s="",a=0;for(;a<e.length;){let i=e.slice(a).match(/^\btest\s+/);if(i){let o=a,l=a+i[0].length,u,p=e.slice(l).match(/^(['"`])([^]*?)\1\s*/);if(p&&(u=p[2],l+=p[0].length),e[l]==="{"){let d=l+1,f=1,m=d,g=null,b=!1;for(;m<e.length&&f>0;){let x=e[m];if(b){b=!1,m++;continue}if(x==="\\"&&g){b=!0,m++;continue}if(g){x===g&&(g=null),m++;continue}if(x==="/"&&e[m+1]==="/"){let S=e.indexOf(`
37
+ `,m);m=S===-1?e.length:S+1;continue}if(x==="/"&&e[m+1]==="*"){let S=e.indexOf("*/",m+2);m=S===-1?e.length:S+2;continue}if(x==="'"||x==='"'||x==="`"){g=x,m++;continue}x==="{"?f++:x==="}"&&f--,m++}if(f===0){let x=e.slice(d,m-1).trim(),S=m,E=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:u,body:x,start:o,end:S,line:E}),!t)try{new Function(x)()}catch(k){let v=u||`test at line ${E}`;r.push(`Test failed: ${v} (line ${E})
38
+ ${k.message||k}`)}let C=(e.slice(o,S).match(/\n/g)||[]).length;s+=`
39
+ `.repeat(C),a=S;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function mr(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,a=[];for(;(s=r.exec(e))!==null;){let o=s[1],l=s[2]?.trim()||"",u=s.index+s[0].length-1,p=Fe(e,u),d=e.slice(u,p);a.push({className:o,extendsClause:l,bodyStart:u,bodyEnd:p,body:d})}let i=e;for(let o=a.length-1;o>=0;o--){let{className:l,extendsClause:u,bodyStart:p,bodyEnd:d,body:f}=a[o],m=/\bconstructor\s*\(/g,g,b=[];for(;(g=m.exec(f))!==null;)b.push(g.index);if(b.length<2)continue;n.add(l);let x=[];for(let k=0;k<b.length;k++){let v=b[k],A=f.indexOf("(",v),N=1,I=A+1;for(;I<f.length&&N>0;)f[I]==="("&&N++,f[I]===")"&&N--,I++;let R=f.slice(A+1,I-1),B=I;for(;B<f.length&&f[B]!=="{";)B++;let V=Fe(f,B),te=f.slice(B+1,V-1);x.push({index:k+1,paramStr:R,bodyText:te,fullStart:v,fullEnd:V})}let S=f;for(let k=x.length-1;k>=1;k--){let v=x[k],A=v.fullStart;for(;A>0&&S[A-1]===" ";)A--;A>0&&S[A-1]===`
40
+ `&&A--,S=S.slice(0,A)+S.slice(v.fullEnd)}let E="";for(let k=1;k<x.length;k++){let v=x[k],A=Mt(v.paramStr,t);if(v.paramStr.includes("...")){let I=ye(e,p+v.fullStart);throw new z(`Rest parameters are not supported in polymorphic constructors for '${l}'.`,I)}E+=`
41
+ function ${l}$ctor$${v.index}(${v.paramStr}) {`,E+=`
42
+ const __obj = Object.create(${l}.prototype)`,E+=`
43
+ ;(function() {${v.bodyText}}).call(__obj)`,E+=`
44
+ return __obj`,E+=`
45
45
  }
46
- `}let y=[];for(let k=0;k<x.length;k++){let v=x[k],A=$t(v.paramStr,t),N=[`a.length === ${A.length}`];for(let I=0;I<A.length;I++){let R=A[I];if(R.defaultValue){let j=ar(`a[${I}]`,R.defaultValue);j!=="true"&&N.push(j)}}if(k===0)y.push(` if (${N.join(" && ")}) return Reflect.construct(t, a)`);else{let I=A.map((R,j)=>`a[${j}]`).join(", ");y.push(` if (${N.join(" && ")}) return ${l}$ctor$${v.index}(${I})`)}}S+=`
46
+ `}let y=[];for(let k=0;k<x.length;k++){let v=x[k],A=Mt(v.paramStr,t),N=[`a.length === ${A.length}`];for(let I=0;I<A.length;I++){let R=A[I];if(R.defaultValue){let B=pr(`a[${I}]`,R.defaultValue);B!=="true"&&N.push(B)}}if(k===0)y.push(` if (${N.join(" && ")}) return Reflect.construct(t, a)`);else{let I=A.map((R,B)=>`a[${B}]`).join(", ");y.push(` if (${N.join(" && ")}) return ${l}$ctor$${v.index}(${I})`)}}E+=`
47
47
  function ${l}$dispatch(t, a) {
48
- `,S+=y.join(`
48
+ `,E+=y.join(`
49
49
  `)+`
50
- `,S+=` return __tjs.typeError('${l}', 'no matching constructor', a)
51
- `,S+=`}
52
- `,i=i.slice(0,p)+E+i.slice(d);let C=p+E.length;i=i.slice(0,C)+S+i.slice(C)}return{source:i,polyCtorClasses:n}}function pr(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,a;for(;(a=n.exec(e))!==null;){let i=a[1],o=a[2]||"",l=a.index,u=l+a[0].length-1,p=1,d=u+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(u,f);r+=e.slice(s,l),r+=`let ${i} = class ${i}${o} ${m}; `,t.has(i)?r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return ${i}$dispatch(t, a) }, construct(t, a) { return ${i}$dispatch(t, a) } });`:r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function fr(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 hr(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 a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);let u="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${a}\\s*\\.\\s*(?:${u})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function dr(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 mr(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 gr(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let a=e[n],i=e[n+1];if(r==="normal"){if(a==="/"&&i==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&i==="*"){r="block-comment",t+=a,n++;continue}if(a==="'"){r="string-single",t+=a,n++;continue}if(a==='"'){r="string-double",t+=a,n++;continue}if(a==="`"){r="string-template",s++,t+=a,n++;continue}if(a==="!"&&i==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,l=Ui(t);if(l<o){let u=t.slice(l);t=t.slice(0,l);let p=n+2;for(;p<e.length&&/[\w$]/.test(e[p]);)p++;let d=e.slice(n+2,p);t+=`__tjs.bang(${u},'${d}')`,n=p;continue}}t+=a,n++}else r==="line-comment"?(t+=a,a===`
53
- `&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function Ui(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=zn(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=zn(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 zn(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 yr(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,s="normal",a=[];for(;r<e.length;){let o=e[r],l=e[r+1];switch(s){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(s="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(s="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&l==="{"){r+=2,a.push(1),s="normal";continue}o==="`"&&(s="normal"),r++;continue;case"line-comment":o===`
54
- `&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&l==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&l==="/"){r+=2,s="line-comment";continue}if(o==="/"&&l==="*"){r+=2,s="block-comment";continue}if(o==="/"){let u=r-1;for(;u>=0&&/\s/.test(e[u]);)u--;let p=u>=0?e[u]:"";if(!p||/[=(!,;:{[&|?+\-*%<>~^]/.test(p)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let u=r+4;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let p=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;let d=u,f=e.slice(p,d),m=u;for(;m<e.length&&/\s/.test(e[m]);)m++;if(m<e.length&&e[m]===":"&&e[m+1]!==":"){let b=m+1;for(;b<e.length&&/[ \t]/.test(e[b]);)b++;let x=qi(e,b);if(x>b){let E=e.slice(b,x).trim();t.set(f,E),n.push({start:d,end:x,replacement:""}),r=x;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let i=e;for(let o=n.length-1;o>=0;o--){let l=n[o];i=i.slice(0,l.start)+l.replacement+i.slice(l.end)}return{source:i,annotations:t}}function qi(e,t){let n=t,r=0,s=0,a=0,i="normal",o=[];for(;n<e.length;){let l=e[n];if(i==="sq"){if(l==="\\"){n+=2;continue}l==="'"&&(i="normal"),n++;continue}if(i==="dq"){if(l==="\\"){n+=2;continue}l==='"'&&(i="normal"),n++;continue}if(i==="tpl"){if(l==="\\"){n+=2;continue}if(l==="$"&&e[n+1]==="{"){o.push(1),i="normal",n+=2;continue}l==="`"&&(i="normal"),n++;continue}if(o.length>0){if(l==="{")o[o.length-1]++;else if(l==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),i="tpl",n++;continue}}if(l==="'"){i="sq",n++;continue}if(l==='"'){i="dq",n++;continue}if(l==="`"){i="tpl",n++;continue}if(l==="("?r++:l===")"?r--:l==="{"?s++:l==="}"?s--:l==="["?a++:l==="]"&&a--,r===0&&s===0&&a===0&&(l==="="||l===","||l===";"||l===`
55
- `))return n;n++}return n}function ct(e,t){let n="",r=0,s,a,i="normal",o=[],l=[{type:"top-level",braceDepth:0}],u=0,p=()=>l[l.length-1]?.type||"top-level",d=()=>{let f=l[l.length-1];return f?.type==="class-body"&&u===f.braceDepth+1};for(;r<e.length;){let f=e[r],m=e[r+1];switch(i){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==="'"&&(i="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==='"'&&(i="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),i="normal";continue}f==="`"&&(i="normal"),r++;continue;case"line-comment":n+=f,f===`
56
- `&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&m==="/"){n+=m,r+=2,i="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++;i="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++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&m==="/"){n+=f+m,r+=2,i="line-comment";continue}if(f==="/"&&m==="*"){n+=f+m,r+=2,i="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++,i="regex";continue}}break}if(f==="{"){u++,n+=f,r++;continue}if(f==="}"){u--;let y=l[l.length-1];y&&u===y.braceDepth&&l.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,l.push({type:"class-body",braceDepth:u});continue}let b=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(b){let y=b[1],C=b[0].length,k=e[r+C],v,A=r+C;(k==="?"||k==="!")&&(v=k,A++,v==="!"?t.unsafeFunctions.add(y):t.safeFunctions.add(y)),n+=`function ${y}(`,r=A;let N=ot(e,r,"(",")");if(!N){n+=e[r],r++;continue}let{content:I,endPos:R}=N;r=R;let j=Bt(I,t,!0);n+=j+")";let U=r;for(;U<e.length&&/\s/.test(e[U]);)U++;if(e[U]===":"){let Re=e.slice(U,U+2),Me;for(Re===":?"||Re===":!"?(U+=2,Me=Re===":?"?"safe":"unsafe"):U+=1;U<e.length&&/\s/.test(e[U]);)U++;let $e=jt(e,U);$e&&(s===void 0&&(s=$e.type,Me&&(a=Me)),r=$e.endPos)}let te=r;for(;te<e.length&&/\s/.test(e[te]);)te++;if(e[te]==="="&&e[te+1]===">")throw new z("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",ye(t.originalSource,te),t.originalSource);continue}let x=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),E=(()=>{for(let y=n.length-1;y>=0;y--)if(!/\s/.test(n[y]))return n[y];return`
57
- `})(),S=E!=="="&&E!==","&&E!=="("&&E!=="["&&E!==">";if(x&&d()&&!S){let y=x[1].length;n+=e.slice(r,r+y),r+=y;continue}if(x&&d()&&S){let y=x[1],C=x[0].length,k=r+C;n+=y+"(",r=k;let v=ot(e,r,"(",")");if(!v){n+=e[r],r++;continue}let{content:A,endPos:N}=v;r=N;let I=Bt(A,t,!0);n+=I+")";let R=r;for(;R<e.length&&/\s/.test(e[R]);)R++;if(e[R]===":"){let U=e.slice(R,R+2);for(U===":?"||U===":!"?R+=2:R++;R<e.length&&/\s/.test(e[R]);)R++;let te=jt(e,R);te&&(r=te.endPos)}let j=r;for(;j<e.length&&/\s/.test(e[j]);)j++;if(e[j]==="="&&e[j+1]===">")throw new z("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",ye(t.originalSource,j),t.originalSource);continue}if(e[r]==="("){let y=ot(e,r+1,"(",")");if(!y){n+=e[r],r++;continue}let C=y.content,k=y.endPos,v=k;for(;v<e.length&&/\s/.test(e[v]);)v++;let A;if(e[v]===":"){let N=e.slice(v,v+2);for(N===":?"||N===":!"?v+=2:v++;v<e.length&&/\s/.test(e[v]);)v++;let I=jt(e,v);if(I)for(A=I.type,v=I.endPos;v<e.length&&/\s/.test(e[v]);)v++}if(e.slice(v,v+2)==="=>"){let N=null,I=C,R=C.trimStart();R.startsWith("?")&&(R.length===1||/\s/.test(R[1]))?(N="?",I=R.slice(1)):R.startsWith("!")&&(R.length===1||/\s/.test(R[1]))&&(N="!",I=R.slice(1));let j=Bt(I,t,!1);for(n+=`(${N==="?"?"/* safe */ ":N==="!"?"/* unsafe */ ":""}${j})`,r=k;r<v&&/\s/.test(e[r]);)n+=e[r],r++;A&&(r=v)}else{let N=ct(C,t);n+=`(${N.source})`,r=k}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:a}}function ot(e,t,n,r){let s=1,a=t,i=!1,o="";for(;a<e.length&&s>0;){let l=e[a];!i&&(l==="'"||l==='"'||l==="`")?(i=!0,o=l):i&&l===o&&e[a-1]!=="\\"?i=!1:i||(l===n?s++:l===r&&s--),a++}return s!==0?null:{content:e.slice(t,a-1),endPos:a}}function br(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 i=s==="{"?"}":"]",o=ot(e,n+1,s,i);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 a=e.slice(n).match(/^(true|false|null|undefined)\b/);return a?{value:a[1],endPos:n+a[1].length}:null}function Ue(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function jt(e,t){let n=t,r=0,s=!1,a="",i=!1,o=l=>({type:Ue(e.slice(t,l).trim()),endPos:l});for(;n<e.length;){let l=e[n];if(!s&&(l==="'"||l==='"'||l==="`")){s=!0,a=l,i=!0,n++;continue}if(s){if(l===a&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let u=n;for(;u<e.length&&/\s/.test(e[u]);)u++;if(e[u]==="{"&&!e.slice(u+1).match(/^\s*(\w+)\s*:/)||e[u]!=="|"&&e[u]!=="&")return o(n)}continue}n++;continue}if(l==="{"||l==="["||l==="("){r++,i=!0,n++;continue}if(l==="}"||l==="]"||l===")"){if(r--,r===0){n++;let u=n;for(;u<e.length&&/\s/.test(e[u]);)u++;if(e[u]==="|"||e[u]==="&")continue;return o(n)}n++;continue}if(r===0&&l==="{"){if(i)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,i=!0,n++;continue}return o(n)}if(r===0&&(l==="|"||l==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(l)||l==="-"&&/\d/.test(e[n+1]))){let u=n;for(e[u]==="-"&&u++;u<e.length&&/\d/.test(e[u]);)u++;if(u<e.length&&e[u]==="."&&/\d/.test(e[u+1]))for(u++;u<e.length&&/\d/.test(e[u]);)u++;if(u<e.length&&(e[u]==="e"||e[u]==="E"))for(u++,u<e.length&&(e[u]==="+"||e[u]==="-")&&u++;u<e.length&&/\d/.test(e[u]);)u++;for(i=!0,n=u;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:Ue(e.slice(t,u).trim()),endPos:u};if(e[n]!=="|"&&e[n]!=="&")return{type:Ue(e.slice(t,u).trim()),endPos:u};continue}if(r===0&&/[a-zA-Z_]/.test(l)){let u=n;for(;u<e.length&&/\w/.test(e[u]);)u++;for(i=!0,n=u;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=u;for(;d>t&&/\s/.test(e[d-1]);)d--;return{type:Ue(e.slice(t,d).trim()),endPos:u}}if(e[n]!=="|"&&e[n]!=="&")return{type:Ue(e.slice(t,u).trim()),endPos:u};continue}n++}return i?o(n):null}function pt(e){let t=[],n="",r=0,s=!1,a=!1,i=0;for(;i<e.length;){let o=e[i],l=e[i+1];if(!a&&o==="/"&&l==="/"){s=!0,n+="//",i+=2;continue}if(!s&&o==="/"&&l==="*"){a=!0,n+="/*",i+=2;continue}if(s&&o===`
58
- `){s=!1,n+=o,i++;continue}if(a&&o==="*"&&l==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function Bt(e,t,n){let r=ct(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=pt(r),a=!1,i=new Set,o=u=>{if(n&&/^\w+$/.test(u)){if(i.has(u))throw new Error(`Duplicate parameter name '${u}'`);i.add(u)}};return s.map(u=>{let p=u.trim();if(!p)return u;if(n&&p.startsWith("{")&&p.endsWith("}")){let m=p.slice(1,-1);return`{ ${xr(m,t)} }`}if(n&&p.startsWith("[")&&p.endsWith("]")){let m=p.slice(1,-1);return`[ ${xr(m,t)} ]`}if(p.startsWith("...")){let m=vr(p);return m!==-1?p.slice(0,m).trim():u}let d=p.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(d){let[,m,g]=d;return o(m),a=!0,`${m} = ${g}`}if(!Wi(p)){let m=p.match(/^(\w+)\s*=/);return m&&o(m[1]),a=!0,u}let f=vr(p);if(f!==-1){let m=p.slice(0,f).trim(),g=p.slice(f+1).trim();return o(m),a&&n&&/^\w+$/.test(m),n&&/^\w+$/.test(m)&&t.requiredParams.add(m),`${m} = ${g}`}return u}).join(",")}function xr(e,t){return pt(e).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,u,p]=i;t.requiredParams.add(u);let d=lt(p);return`${u} = ${d}`}let o=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,u,p]=o;t.requiredParams.add(u);let d=ut(p);return`${u} = ${d}`}let l=a.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(l){let[,u,p]=l;return t.requiredParams.add(u),`${u} = ${p}`}return s}).join(", ")}function lt(e){let t=e.slice(1,-1).trim();return`{ ${pt(t).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,d,f]=i;return`${d}: ${lt(f)}`}let o=a.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,d,f]=o;return`${d}: ${lt(f)}`}let l=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(l){let[,d,f]=l;return`${d}: ${ut(f)}`}let u=a.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(u){let[,d,f]=u;return`${d}: ${ut(f)}`}let p=a.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(p){let[,d,f]=p;return`${d}: ${f}`}return s}).join(", ")} }`}function ut(e){let t=e.slice(1,-1).trim();return`[ ${pt(t).map(s=>{let a=s.trim();return a?a.startsWith("{")&&a.endsWith("}")?lt(a):a.startsWith("[")&&a.endsWith("]")?ut(a):s:s}).join(", ")} ]`}function Wi(e){let t=0,n=!1,r=!1,s=!1,a="";for(let i=0;i<e.length;i++){let o=e[i];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,a=o;continue}if(s){o===a&&e[i-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[i+1]!==">"&&(r=!0))}return n&&!r}function vr(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let a=e[s];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[s-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return s}return-1}function zi(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let s=r;for(t+=r,n++;n<e.length&&e[n]!==s;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2),a=s===-1?e.slice(n):e.slice(n,s+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let s=e.indexOf(`
59
- `,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function Gi(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),l=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,u=l?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0};l&&(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|TjsSafeAssign)\b/,f;for(;f=e.match(d);){let R=f[2];R==="TjsStrict"?(u.tjsEquals=!0,u.tjsClass=!0,u.tjsDate=!0,u.tjsNoeval=!0,u.tjsNoVar=!0,u.tjsStandard=!0,u.tjsSafeAssign=!0):R==="TjsCompat"?(u.tjsEquals=!1,u.tjsClass=!1,u.tjsDate=!1,u.tjsNoeval=!1,u.tjsNoVar=!1,u.tjsStandard=!1,u.tjsSafeEval=!1,u.tjsSafeAssign=!1):R==="TjsEquals"?u.tjsEquals=!0:R==="TjsClass"?u.tjsClass=!0:R==="TjsDate"?u.tjsDate=!0:R==="TjsNoeval"?u.tjsNoeval=!0:R==="TjsNoVar"?u.tjsNoVar=!0:R==="TjsStandard"?u.tjsStandard=!0:R==="TjsSafeEval"?u.tjsSafeEval=!0:R==="TjsSafeAssign"&&(u.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${R}\\s*`),"$1")}e=zi(e),u.tjsStandard&&(e=Qn(e)),e=hr(e),e=gr(e);let m=yr(e);e=m.source;let g=m.annotations,b=Jn(e);e=b.source,e=Zn(e),u.tjsEquals&&!t.vmTarget&&(e=Yn(e)),e=Xn(e),e=tr(e),e=er(e),e=nr(e),e=rr(e),e=lr(e);let x=Kn(e,{loader:t.moduleLoader,importerPath:t.filename});e=x.source;let{source:E,returnType:S,returnSafety:y}=ct(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=E;let C=sr(e);e=C.source,e=Gn(e);let k=or(e,s);e=k.source;let v=Hn(e);e=v.source;let A=[...b.blocks,...x.blocks,...v.blocks],N=ur(e,t.dangerouslySkipTests);e=N.source;let I=cr(e,s);e=I.source;for(let R of I.polyCtorClasses)a.add(`${R}$dispatch`);return u.tjsClass&&(e=pr(e,I.polyCtorClasses)),u.tjsDate&&(e=fr(e)),u.tjsNoeval&&(e=mr(e)),u.tjsNoVar&&(e=dr(e)),e=ir(e,C.extensions),{source:e,returnType:S,returnSafety:y,moduleSafety:r,tjsModes:u,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:A,tests:N.tests,testErrors:N.errors,polymorphicNames:k.polymorphicNames,extensions:C.extensions,letAnnotations:g}}function wr(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1,dialect:a}=t,{source:i,returnType:o,returnSafety:l,moduleSafety:u,originalSource:p,requiredParams:d,unsafeFunctions:f,safeFunctions:m,wasmBlocks:g,tests:b,testErrors:x,letAnnotations:E,tjsModes:S}=r?Gi(e,{vmTarget:s,dialect:a,moduleLoader:t.moduleLoader,filename:t.filename}):{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:[],letAnnotations:new Map,tjsModes:{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}};try{return{ast:Vn(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:o,returnSafety:l,moduleSafety:u,originalSource:p,requiredParams:d,unsafeFunctions:f,safeFunctions:m,wasmBlocks:g,tests:b,testErrors:x,letAnnotations:E,tjsModes:S}}catch(y){let C=y.loc||{line:1,column:0};throw new z(y.message.replace(/\s*\(\d+:\d+\)$/,""),C,p,n)}}function Sr(e,t){for(let a of e.body){if(a.type==="ImportDeclaration")throw new z("Imports are not supported. All atoms must be registered with the VM.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration")throw new z("Exports are not supported. The function is automatically exported.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ClassDeclaration")throw new z("Classes are not supported. Agent99 uses functional composition.",a.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(a=>a.type==="FunctionDeclaration");if(n.length===0)throw new z("Source must contain a function declaration",{line:1,column:0},void 0,t);let r=n[n.length-1],s=new Map;for(let a=0;a<n.length-1;a++){let i=n[a],o=i.id?.name;if(!o)throw new z("Helper function must have a name",i.loc?.start||{line:1,column:0},void 0,t);if(s.has(o))throw new z(`Duplicate helper function name: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);if(o===r.id?.name)throw new z(`Helper function cannot share a name with the entry function: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);s.set(o,i)}return{entry:r,helpers:s}}function Er(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(`
60
- `),g=m.filter(b=>b.trim().length>0).reduce((b,x)=>{let E=x.match(/^(\s*)/)?.[1].length||0;return Math.min(b,E)},1/0);return g>0&&g<1/0&&(f=m.map(b=>b.slice(g)).join(`
61
- `)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let l=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,u;for(;(u=l.exec(i))!==null;)n.params[u[1]]=u[2].trim();return n}function ee(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(i=>i!=null).map(i=>ee(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}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]=ee(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ee(n):t==="&&"||t==="??"?ee(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ee(n),a=ee(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>Hi(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ee(t.body)),{kind:"function",params:n,returns:r}}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 Hi(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ee(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Ot(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 V("Only simple parameter names are supported",F(e));let s=n.name,a=t?.has(s)??!1,i=ee(r),o=fe(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ot(a.value,t),l=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:l,default:l?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new V(`Unsupported parameter pattern: ${e.type}`,F(e))}function fe(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?fe(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=fe(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=fe(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=fe(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?fe(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?fe(n)??fe(r):void 0}default:return}}function kr(e){try{let t=Fn(e,0,{ecmaVersion:2022});return ee(t)}catch{return{kind:"any"}}}function ft(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?ft(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=ft(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(ft)}:{};default:return{}}}function Ji(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=ft(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function Ar(e,t,n,r={},s,a){let i=Er(t,e),o=new Map;for(let S of e.params){let y=Ot(S,s);if(y.name==="__destructured__"&&y.type.kind==="object"&&y.type.destructuredParams)for(let[C,k]of Object.entries(y.type.destructuredParams))o.set(C,{...k,description:i.params[C]});else y.description=i.params[y.name],o.set(y.name,y)}let l;n&&(l=kr(n));let u={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},p=le(e.body,u),d=[],f=[],m=[];for(let[S,y]of o.entries())y.required?f.push(S):y.default!==void 0?m.push({name:S,defaultValue:y.default}):f.push(S);f.length>0&&d.push({op:"varsImport",keys:f});for(let{name:S,defaultValue:y}of m)d.push({op:"varsImport",keys:[S]}),d.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:S},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:S,value:y}]});d.push(...p);let g=Object.fromEntries(o),b={name:e.id?.name||"anonymous",description:i.description,parameters:g,returns:l},x=Ji(g),E=u.helperSteps&&u.helperSteps.size>0?Object.fromEntries(u.helperSteps):void 0;return{ast:{op:"seq",steps:d,inputSchema:x,...E&&{helpers:E}},signature:b,warnings:u.warnings}}function le(e,t){let n=[];for(let r of e.body){let s=qe(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function qe(e,t){switch(e.type){case"VariableDeclaration":return Ki(e,t);case"ExpressionStatement":return Zi(e,t);case"IfStatement":return Yi(e,t);case"WhileStatement":return Xi(e,t);case"ForOfStatement":return ea(e,t);case"TryStatement":return ta(e,t);case"ReturnStatement":return na(e,t);case"ThrowStatement":throw new V("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",F(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:le(e,ae(t))};case"EmptyStatement":return null;default:throw new V(`Unsupported statement type: ${e.type}`,F(e),t.source,t.filename)}}function Ki(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new V("Only simple variable names are supported",F(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:l}=Ce(a.init,t,i,r);o?n.push(o):l!==i&&n.push({op:s,key:i,value:l});let u=ee(a.init);t.locals.set(i,u)}else{if(r)throw new V("const declarations must be initialized",F(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function Zi(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Qi(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=Ce(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:F(e).line,column:F(e).column}),null}function Qi(e,t){if(e.left.type!=="Identifier")throw new V("Only simple variable assignment is supported",F(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=Ce(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function Yi(e,t){let n=L(e.test,t),r=e.consequent.type==="BlockStatement"?le(e.consequent,ae(t)):[qe(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?le(e.alternate,ae(t)):[qe(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function Xi(e,t){let n=L(e.test,t),r=e.body.type==="BlockStatement"?le(e.body,ae(t)):[qe(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function ea(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new V("Only simple variable names are supported in for...of",F(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new V("Unsupported for...of left-hand side",F(e.left),t.source,t.filename);let r=J(e.right,t),s=ae(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?le(e.body,s):[qe(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function ta(e,t){let n=le(e.block,ae(t)),r,s;if(e.handler){let a=ae(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=le(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function na(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=Ce(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:J(e.argument,t)}}var _r=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),ra=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),We=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),sa=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 ia(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return ra.has(t)||We.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(_r.has(n)||We.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(sa.has(n))return!0}}return!1}function aa(e){if(e.object.type==="Identifier"){let t=e.object.name;return _r.has(t)||We.has(t)}return!1}var Cr={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 oa(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(We.has(t))return Cr[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(We.has(n))return Cr[n]||`${n} is not available in AsyncJS.`}}return null}function Tr(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 Ce(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return Ce(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let l=Tr(o);throw new V(`The 'new' keyword is not supported in AsyncJS.${l}`,F(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=oa(e);if(i)throw new V(i,F(e),t.source,t.filename)}if(e.type==="CallExpression"&&ia(e)){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&aa(e)){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return la(e,t,n,r);if(e.type==="TemplateLiteral")return pa(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:J(e,t)}}function la(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let l=e.callee;if(l.property.type==="Identifier")s=l.property.name,a=!0,i=J(l.object,t);else throw new V("Computed method names are not supported",F(e),t.source,t.filename)}else throw new V("Only named function calls are supported",F(e),t.source,t.filename);if(a)return ca(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let l=ua(s,t,e),u=e.arguments.map(p=>J(p,t));if(u.length!==l.length)throw new V(`Helper '${s}' expects ${l.length} argument(s), got ${u.length}`,F(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:u,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=fa(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function ua(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new V(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??F(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=le(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function ca(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")p=le(i.body,u);else{let{step:d,resultVar:f}=Ce(i.body,u,"result");p=d?[d]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:l,steps:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")throw new V("filter callback must be an expression, not a block",F(n[0]),r.source,r.filename);return p=L(i.body,u),{step:{op:"filter",items:t,as:l,condition:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")throw new V("find callback must be an expression, not a block",F(n[0]),r.source,r.filename);return p=L(i.body,u),{step:{op:"find",items:t,as:l,condition:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=i.params[1],u=o?.type==="Identifier"?o.name:"acc",p=l?.type==="Identifier"?l.name:"item",d=ae(r);d.locals.set(u,{kind:"any"}),d.locals.set(p,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=le(i.body,d);else{let{step:g,resultVar:b}=Ce(i.body,d,"result");f=g?[g]:[{op:"varSet",key:"result",value:b}]}let m=J(n[1],r);return{step:{op:"reduce",items:t,as:p,accumulator:u,initial:m,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:J(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?J(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?J(n[0],r):"",...s&&{result:s},...s&&a&&{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(i=>J(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function pa(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],l=`_${i}`;a[l]=J(o,t),s+=`{{${l}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function L(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=L(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:L(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return L(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:L(n.left,t),right:L(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:L(n.left,t),right:L(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:L(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:L(n.test,t),consequent:L(n.consequent,t),alternate:L(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>L(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:L(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),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:L(r.object,t),method:s,arguments:n.arguments.map(i=>L(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new V(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,F(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>L(s,t))}}throw new V("Complex function calls in expressions should be lifted to statements",F(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=Tr(r);throw new V(`The 'new' keyword is not supported in AsyncJS.${s}`,F(e),t.source,t.filename)}case"TemplateLiteral":throw new V("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",F(e),t.source,t.filename);default:throw new V(`Unsupported expression type in condition: ${e.type}`,F(e),t.source,t.filename)}}function J(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 L(e,t);let s=J(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return L(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return J(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?J(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]=J(r.value,t)}return n}case"TemplateLiteral":return L(e,t);case"CallExpression":return L(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return L(e,t);default:return null}}function fa(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 a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=J(s.value,t)}return r}return{args:e.arguments.map(n=>J(n,t))}}function Ir(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=wr(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=Sr(n,t.filename),{ast:l,signature:u,warnings:p}=Ar(i,s,r,t,a,o.size>0?o:void 0);return{ast:l,signature:u,warnings:p}}var da=6e4,Pr=class{atoms;_defaultRunTimeout;constructor(t={}){this.atoms={...Ht,...t}}get defaultRunTimeout(){if(this._defaultRunTimeout===void 0){let t=0;for(let n of Object.values(this.atoms)){let r=n.timeoutMs??1e3;r>0&&r>t&&(t=r)}this._defaultRunTimeout=Math.max(da,t*2)}return this._defaultRunTimeout}get builder(){return new je(this.atoms)}get Agent(){return new je(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(gt(t))s=yt(t);else try{s=Ir(t).ast}catch(g){throw new Error(`AJS transpilation failed: ${g.message}`,{cause:g})}else s=t;let a=r.fuel??1e3,i=r.timeoutMs??this.defaultRunTimeout,o=r.capabilities??{},l=[];if(!o.store){let g=new Map,b=!1;o.store={get:async x=>(b||(b=!0,l.push("Using default in-memory store (not suitable for production)")),g.get(x)),set:async(x,E)=>{b||(b=!0,l.push("Using default in-memory store (not suitable for production)")),g.set(x,E)}}}let u=new AbortController,p=setTimeout(()=>u.abort(),i);r.signal&&r.signal.addEventListener("abort",()=>u.abort());let d={fuel:{current:a},args:n,state:{},consts:new Set,capabilities:o,resolver:g=>this.resolve(g),output:void 0,signal:u.signal,costOverrides:r.costOverrides,timeoutOverrides:r.timeoutOverrides,context:r.context,warnings:l,helpers:s.helpers};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&&!ha(n,f)){let g=new H("Input validation failed: args do not match expected schema","vm.run");return{result:g,error:g,fuelUsed:0,trace:d.trace,warnings:l.length>0?l:void 0}}try{await Promise.race([this.resolve("seq")?.exec(s,d),new Promise((g,b)=>{u.signal.addEventListener("abort",()=>{b(new Error(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`))}),u.signal.aborted&&b(new Error(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`))})])}catch(g){if(g.message?.includes("timeout")||g.message?.includes("aborted")||u.signal.aborted)d.error=new H(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`,"vm.run");else throw g}finally{clearTimeout(p)}d.error&&d.output===void 0&&(d.output=d.error);let m=[...l,...d.warnings??[]];return{result:d.output,error:d.error,fuelUsed:a-d.fuel.current,trace:d.trace,warnings:m.length>0?m:void 0}}};import{s as $}from"tosijs-schema";var Nr=P("storeVectorize",$.object({text:$.string,model:$.string.optional}),$.array($.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=w(e,t);return n.embed(r)},{docs:"Generate embeddings using vector battery",cost:20,timeoutMs:6e4}),Rr=P("storeCreateCollection",$.object({collection:$.string,dimension:$.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=w(e,n),a=w(t,n);return r.createCollection(s,void 0,a)},{docs:"Create a vector store collection",cost:5}),Mr=P("storeVectorAdd",$.object({collection:$.string,doc:$.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=w(e,n),a=w(t,n);return r.vectorAdd(s,a)},{docs:"Add a document to a vector store collection",cost:5,timeoutMs:6e4}),$r=P("storeSearch",$.object({collection:$.string,queryVector:$.array($.number),k:$.number.optional,filter:$.record($.any).optional}),$.array($.any),async({collection:e,queryVector:t,k:n,filter:r},s)=>{let a=s.capabilities.store;if(!a?.vectorSearch)throw new Error("Capability 'store' missing or does not support vectorSearch.");let i=w(e,s),o=w(t,s),l=w(n,s)??5,u=w(r,s);return a.vectorSearch(i,o,l,u)},{docs:"Search vector store",cost:(e,t)=>5+(w(e.k,t)??5)}),jr=P("llmPredictBattery",$.object({system:$.string.optional,user:$.union([$.string,$.array($.any)]),tools:$.array($.any).optional,responseFormat:$.any.optional}),$.object({role:$.string.optional,content:$.string.optional,tool_calls:$.array($.any).optional}),async({system:e,user:t,tools:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=w(e,s)??"You are a helpful agent.",o=w(t,s),l=w(n,s),u=w(r,s);return a.predict(i,o,l,u)},{docs:"Generate completion using LLM battery",cost:100,timeoutMs:12e4}),Br=P("llmVision",$.object({system:$.string.optional,prompt:$.string,images:$.array($.string),responseFormat:$.any.optional}),$.object({role:$.string.optional,content:$.string.optional,tool_calls:$.array($.any).optional}),async({system:e,prompt:t,images:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=w(e,s)??"You analyze images accurately and concisely.",o=w(t,s),l=w(n,s)??[],u=w(r,s);return a.predict(i,{text:o,images:l},void 0,u)},{docs:"Analyze images using a vision model",timeoutMs:12e4,cost:150});var Ka={storeCreateCollection:Rr,storeSearch:$r,storeVectorAdd:Mr,storeVectorize:Nr,llmPredictBattery:jr,llmVision:Br};export{H as AgentError,Pr as AgentVM,Lr as DEFAULT_MAX_AST_SIZE,Dr as DEFAULT_PROCEDURE_TTL,Ft as MAX_CALL_DEPTH,mt as PROCEDURE_TOKEN_PREFIX,_s as agentRun,Ka as batteryAtoms,he as builtins,$s as cache,is as callLocal,Us as clearExpiredProcedures,Ls as consoleError,Os as consoleLog,Ds as consoleWarn,Xr as constSet,Ht as coreAtoms,xe as createChildScope,P as defineAtom,Qr as errorAtom,W as evaluateExpr,ws as fetch,os as filter,us as find,bt as hash,Hr as iff,Or as isAgentError,gt as isProcedureToken,hs as join,Ps as jsonParse,Ns as jsonStringify,xs as keys,ps as len,As as llmPredict,as as map,Ms as memoize,bs as merge,ys as omit,gs as pick,_e as procedureStore,cs as push,js as random,ls as reduce,ms as regexMatch,Fs as releaseProcedure,yt as resolveProcedureToken,w as resolveValue,Kr as ret,Is as runCode,ss as scope,X as seq,fs as split,Ss as storeGet,Vs as storeProcedure,ks as storeQuery,Es as storeSet,ds as template,Ts as transpileCode,Zr as tryCatch,Bs as uuid,es as varGet,Yr as varSet,rs as varsExport,ts as varsImport,ns as varsLet,Cs as vectorSearch,Jr as whileLoop,Rs as xmlParse};
50
+ `,E+=` return __tjs.typeError('${l}', 'no matching constructor', a)
51
+ `,E+=`}
52
+ `,i=i.slice(0,p)+S+i.slice(d);let C=p+S.length;i=i.slice(0,C)+E+i.slice(C)}return{source:i,polyCtorClasses:n}}function gr(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,a;for(;(a=n.exec(e))!==null;){let i=a[1],o=a[2]||"",l=a.index,u=l+a[0].length-1,p=1,d=u+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(u,f);r+=e.slice(s,l),r+=`let ${i} = class ${i}${o} ${m}; `,t.has(i)?r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return ${i}$dispatch(t, a) }, construct(t, a) { return ${i}$dispatch(t, a) } });`:r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function yr(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 br(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 a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);let u="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${a}\\s*\\.\\s*(?:${u})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function xr(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 vr(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 wr(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let a=e[n],i=e[n+1];if(r==="normal"){if(a==="/"&&i==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&i==="*"){r="block-comment",t+=a,n++;continue}if(a==="'"){r="string-single",t+=a,n++;continue}if(a==='"'){r="string-double",t+=a,n++;continue}if(a==="`"){r="string-template",s++,t+=a,n++;continue}if(a==="!"&&i==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,l=Ui(t);if(l<o){let u=t.slice(l);t=t.slice(0,l);let p=n+2;for(;p<e.length&&/[\w$]/.test(e[p]);)p++;let d=e.slice(n+2,p);t+=`__tjs.bang(${u},'${d}')`,n=p;continue}}t+=a,n++}else r==="line-comment"?(t+=a,a===`
53
+ `&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function Ui(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=Zn(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=Zn(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 Zn(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 Sr(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,s="normal",a=[];for(;r<e.length;){let o=e[r],l=e[r+1];switch(s){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(s="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(s="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&l==="{"){r+=2,a.push(1),s="normal";continue}o==="`"&&(s="normal"),r++;continue;case"line-comment":o===`
54
+ `&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&l==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&l==="/"){r+=2,s="line-comment";continue}if(o==="/"&&l==="*"){r+=2,s="block-comment";continue}if(o==="/"){let u=r-1;for(;u>=0&&/\s/.test(e[u]);)u--;let p=u>=0?e[u]:"";if(!p||/[=(!,;:{[&|?+\-*%<>~^]/.test(p)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let u=r+4;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let p=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;let d=u,f=e.slice(p,d),m=u;for(;m<e.length&&/\s/.test(e[m]);)m++;if(m<e.length&&e[m]===":"&&e[m+1]!==":"){let b=m+1;for(;b<e.length&&/[ \t]/.test(e[b]);)b++;let x=qi(e,b);if(x>b){let S=e.slice(b,x).trim();t.set(f,S),n.push({start:d,end:x,replacement:""}),r=x;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let i=e;for(let o=n.length-1;o>=0;o--){let l=n[o];i=i.slice(0,l.start)+l.replacement+i.slice(l.end)}return{source:i,annotations:t}}function qi(e,t){let n=t,r=0,s=0,a=0,i="normal",o=[];for(;n<e.length;){let l=e[n];if(i==="sq"){if(l==="\\"){n+=2;continue}l==="'"&&(i="normal"),n++;continue}if(i==="dq"){if(l==="\\"){n+=2;continue}l==='"'&&(i="normal"),n++;continue}if(i==="tpl"){if(l==="\\"){n+=2;continue}if(l==="$"&&e[n+1]==="{"){o.push(1),i="normal",n+=2;continue}l==="`"&&(i="normal"),n++;continue}if(o.length>0){if(l==="{")o[o.length-1]++;else if(l==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),i="tpl",n++;continue}}if(l==="'"){i="sq",n++;continue}if(l==='"'){i="dq",n++;continue}if(l==="`"){i="tpl",n++;continue}if(l==="("?r++:l===")"?r--:l==="{"?s++:l==="}"?s--:l==="["?a++:l==="]"&&a--,r===0&&s===0&&a===0&&(l==="="||l===","||l===";"||l===`
55
+ `))return n;n++}return n}function lt(e,t){let n="",r=0,s,a,i="normal",o=[],l=[{type:"top-level",braceDepth:0}],u=0,p=()=>l[l.length-1]?.type||"top-level",d=()=>{let f=l[l.length-1];return f?.type==="class-body"&&u===f.braceDepth+1};for(;r<e.length;){let f=e[r],m=e[r+1];switch(i){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==="'"&&(i="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==='"'&&(i="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),i="normal";continue}f==="`"&&(i="normal"),r++;continue;case"line-comment":n+=f,f===`
56
+ `&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&m==="/"){n+=m,r+=2,i="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++;i="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++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&m==="/"){n+=f+m,r+=2,i="line-comment";continue}if(f==="/"&&m==="*"){n+=f+m,r+=2,i="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++,i="regex";continue}}break}if(f==="{"){u++,n+=f,r++;continue}if(f==="}"){u--;let y=l[l.length-1];y&&u===y.braceDepth&&l.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,l.push({type:"class-body",braceDepth:u});continue}let b=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(b){let y=b[1],C=b[0].length,k=e[r+C],v,A=r+C;(k==="?"||k==="!")&&(v=k,A++,v==="!"?t.unsafeFunctions.add(y):t.safeFunctions.add(y)),n+=`function ${y}(`,r=A;let N=it(e,r,"(",")");if(!N){n+=e[r],r++;continue}let{content:I,endPos:R}=N;r=R;let B=jt(I,t,!0);n+=B+")";let V=r;for(;V<e.length&&/\s/.test(e[V]);)V++;if(e[V]===":"){let Re=e.slice(V,V+2),Me;for(Re===":?"||Re===":!"?(V+=2,Me=Re===":?"?"safe":"unsafe"):V+=1;V<e.length&&/\s/.test(e[V]);)V++;let $e=$t(e,V);$e&&(s===void 0&&(s=$e.type,Me&&(a=Me)),r=$e.endPos)}let te=r;for(;te<e.length&&/\s/.test(e[te]);)te++;if(e[te]==="="&&e[te+1]===">")throw new z("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",ye(t.originalSource,te),t.originalSource);continue}let x=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),S=(()=>{for(let y=n.length-1;y>=0;y--)if(!/\s/.test(n[y]))return n[y];return`
57
+ `})(),E=S!=="="&&S!==","&&S!=="("&&S!=="["&&S!==">";if(x&&d()&&!E){let y=x[1].length;n+=e.slice(r,r+y),r+=y;continue}if(x&&d()&&E){let y=x[1],C=x[0].length,k=r+C;n+=y+"(",r=k;let v=it(e,r,"(",")");if(!v){n+=e[r],r++;continue}let{content:A,endPos:N}=v;r=N;let I=jt(A,t,!0);n+=I+")";let R=r;for(;R<e.length&&/\s/.test(e[R]);)R++;if(e[R]===":"){let V=e.slice(R,R+2);for(V===":?"||V===":!"?R+=2:R++;R<e.length&&/\s/.test(e[R]);)R++;let te=$t(e,R);te&&(r=te.endPos)}let B=r;for(;B<e.length&&/\s/.test(e[B]);)B++;if(e[B]==="="&&e[B+1]===">")throw new z("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",ye(t.originalSource,B),t.originalSource);continue}if(e[r]==="("){let y=it(e,r+1,"(",")");if(!y){n+=e[r],r++;continue}let C=y.content,k=y.endPos,v=k;for(;v<e.length&&/\s/.test(e[v]);)v++;let A;if(e[v]===":"){let N=e.slice(v,v+2);for(N===":?"||N===":!"?v+=2:v++;v<e.length&&/\s/.test(e[v]);)v++;let I=$t(e,v);if(I)for(A=I.type,v=I.endPos;v<e.length&&/\s/.test(e[v]);)v++}if(e.slice(v,v+2)==="=>"){let N=null,I=C,R=C.trimStart();R.startsWith("?")&&(R.length===1||/\s/.test(R[1]))?(N="?",I=R.slice(1)):R.startsWith("!")&&(R.length===1||/\s/.test(R[1]))&&(N="!",I=R.slice(1));let B=jt(I,t,!1);for(n+=`(${N==="?"?"/* safe */ ":N==="!"?"/* unsafe */ ":""}${B})`,r=k;r<v&&/\s/.test(e[r]);)n+=e[r],r++;A&&(r=v)}else{let N=lt(C,t);n+=`(${N.source})`,r=k}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:a}}function it(e,t,n,r){let s=1,a=t,i=!1,o="";for(;a<e.length&&s>0;){let l=e[a];!i&&(l==="'"||l==='"'||l==="`")?(i=!0,o=l):i&&l===o&&e[a-1]!=="\\"?i=!1:i||(l===n?s++:l===r&&s--),a++}return s!==0?null:{content:e.slice(t,a-1),endPos:a}}function Er(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 i=s==="{"?"}":"]",o=it(e,n+1,s,i);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 a=e.slice(n).match(/^(true|false|null|undefined)\b/);return a?{value:a[1],endPos:n+a[1].length}:null}function Ue(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function $t(e,t){let n=t,r=0,s=!1,a="",i=!1,o=l=>({type:Ue(e.slice(t,l).trim()),endPos:l});for(;n<e.length;){let l=e[n];if(!s&&(l==="'"||l==='"'||l==="`")){s=!0,a=l,i=!0,n++;continue}if(s){if(l===a&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let u=n;for(;u<e.length&&/\s/.test(e[u]);)u++;if(e[u]==="{"&&!e.slice(u+1).match(/^\s*(\w+)\s*:/)||e[u]!=="|"&&e[u]!=="&")return o(n)}continue}n++;continue}if(l==="{"||l==="["||l==="("){r++,i=!0,n++;continue}if(l==="}"||l==="]"||l===")"){if(r--,r===0){n++;let u=n;for(;u<e.length&&/\s/.test(e[u]);)u++;if(e[u]==="|"||e[u]==="&")continue;return o(n)}n++;continue}if(r===0&&l==="{"){if(i)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,i=!0,n++;continue}return o(n)}if(r===0&&(l==="|"||l==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(l)||l==="-"&&/\d/.test(e[n+1]))){let u=n;for(e[u]==="-"&&u++;u<e.length&&/\d/.test(e[u]);)u++;if(u<e.length&&e[u]==="."&&/\d/.test(e[u+1]))for(u++;u<e.length&&/\d/.test(e[u]);)u++;if(u<e.length&&(e[u]==="e"||e[u]==="E"))for(u++,u<e.length&&(e[u]==="+"||e[u]==="-")&&u++;u<e.length&&/\d/.test(e[u]);)u++;for(i=!0,n=u;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:Ue(e.slice(t,u).trim()),endPos:u};if(e[n]!=="|"&&e[n]!=="&")return{type:Ue(e.slice(t,u).trim()),endPos:u};continue}if(r===0&&/[a-zA-Z_]/.test(l)){let u=n;for(;u<e.length&&/\w/.test(e[u]);)u++;for(i=!0,n=u;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=u;for(;d>t&&/\s/.test(e[d-1]);)d--;return{type:Ue(e.slice(t,d).trim()),endPos:u}}if(e[n]!=="|"&&e[n]!=="&")return{type:Ue(e.slice(t,u).trim()),endPos:u};continue}n++}return i?o(n):null}function ut(e){let t=[],n="",r=0,s=!1,a=!1,i=0;for(;i<e.length;){let o=e[i],l=e[i+1];if(!a&&o==="/"&&l==="/"){s=!0,n+="//",i+=2;continue}if(!s&&o==="/"&&l==="*"){a=!0,n+="/*",i+=2;continue}if(s&&o===`
58
+ `){s=!1,n+=o,i++;continue}if(a&&o==="*"&&l==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function jt(e,t,n){let r=lt(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=ut(r),a=!1,i=new Set,o=u=>{if(n&&/^\w+$/.test(u)){if(i.has(u))throw new Error(`Duplicate parameter name '${u}'`);i.add(u)}};return s.map(u=>{let p=u.trim();if(!p)return u;if(n&&p.startsWith("{")&&p.endsWith("}")){let m=p.slice(1,-1);return`{ ${kr(m,t)} }`}if(n&&p.startsWith("[")&&p.endsWith("]")){let m=p.slice(1,-1);return`[ ${kr(m,t)} ]`}if(p.startsWith("...")){let m=Cr(p);return m!==-1?p.slice(0,m).trim():u}let d=p.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(d){let[,m,g]=d;return o(m),a=!0,`${m} = ${g}`}if(!Wi(p)){let m=p.match(/^(\w+)\s*=/);return m&&o(m[1]),a=!0,u}let f=Cr(p);if(f!==-1){let m=p.slice(0,f).trim(),g=p.slice(f+1).trim();return o(m),a&&n&&/^\w+$/.test(m),n&&/^\w+$/.test(m)&&t.requiredParams.add(m),`${m} = ${g}`}return u}).join(",")}function kr(e,t){return ut(e).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,u,p]=i;t.requiredParams.add(u);let d=at(p);return`${u} = ${d}`}let o=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,u,p]=o;t.requiredParams.add(u);let d=ot(p);return`${u} = ${d}`}let l=a.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(l){let[,u,p]=l;return t.requiredParams.add(u),`${u} = ${p}`}return s}).join(", ")}function at(e){let t=e.slice(1,-1).trim();return`{ ${ut(t).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,d,f]=i;return`${d}: ${at(f)}`}let o=a.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,d,f]=o;return`${d}: ${at(f)}`}let l=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(l){let[,d,f]=l;return`${d}: ${ot(f)}`}let u=a.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(u){let[,d,f]=u;return`${d}: ${ot(f)}`}let p=a.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`[ ${ut(t).map(s=>{let a=s.trim();return a?a.startsWith("{")&&a.endsWith("}")?at(a):a.startsWith("[")&&a.endsWith("]")?ot(a):s:s}).join(", ")} ]`}function Wi(e){let t=0,n=!1,r=!1,s=!1,a="";for(let i=0;i<e.length;i++){let o=e[i];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,a=o;continue}if(s){o===a&&e[i-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[i+1]!==">"&&(r=!0))}return n&&!r}function Cr(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let a=e[s];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[s-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return s}return-1}function zi(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let s=r;for(t+=r,n++;n<e.length&&e[n]!==s;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2),a=s===-1?e.slice(n):e.slice(n,s+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let s=e.indexOf(`
59
+ `,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function Gi(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),l=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,u=l?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0};l&&(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|TjsSafeAssign)\b/,f;for(;f=e.match(d);){let R=f[2];R==="TjsStrict"?(u.tjsEquals=!0,u.tjsClass=!0,u.tjsDate=!0,u.tjsNoeval=!0,u.tjsNoVar=!0,u.tjsStandard=!0,u.tjsSafeAssign=!0):R==="TjsCompat"?(u.tjsEquals=!1,u.tjsClass=!1,u.tjsDate=!1,u.tjsNoeval=!1,u.tjsNoVar=!1,u.tjsStandard=!1,u.tjsSafeEval=!1,u.tjsSafeAssign=!1):R==="TjsEquals"?u.tjsEquals=!0:R==="TjsClass"?u.tjsClass=!0:R==="TjsDate"?u.tjsDate=!0:R==="TjsNoeval"?u.tjsNoeval=!0:R==="TjsNoVar"?u.tjsNoVar=!0:R==="TjsStandard"?u.tjsStandard=!0:R==="TjsSafeEval"?u.tjsSafeEval=!0:R==="TjsSafeAssign"&&(u.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${R}\\s*`),"$1")}e=zi(e),u.tjsStandard&&(e=nr(e)),e=br(e),e=wr(e);let m=Sr(e);e=m.source;let g=m.annotations,b=Xn(e);e=b.source,e=tr(e),u.tjsEquals&&!t.vmTarget&&(e=rr(e)),e=sr(e),e=ar(e),e=ir(e),e=or(e),e=lr(e),e=hr(e);let x=er(e,{loader:t.moduleLoader,importerPath:t.filename});e=x.source;let{source:S,returnType:E,returnSafety:y}=lt(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=S;let C=ur(e);e=C.source,e=Qn(e);let k=fr(e,s);e=k.source;let v=Yn(e);e=v.source;let A=[...b.blocks,...x.blocks,...v.blocks],N=dr(e,t.dangerouslySkipTests);e=N.source;let I=mr(e,s);e=I.source;for(let R of I.polyCtorClasses)a.add(`${R}$dispatch`);return u.tjsClass&&(e=gr(e,I.polyCtorClasses)),u.tjsDate&&(e=yr(e)),u.tjsNoeval&&(e=vr(e)),u.tjsNoVar&&(e=xr(e)),e=cr(e,C.extensions),{source:e,returnType:E,returnSafety:y,moduleSafety:r,tjsModes:u,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:A,tests:N.tests,testErrors:N.errors,polymorphicNames:k.polymorphicNames,extensions:C.extensions,letAnnotations:g}}function Ar(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1,dialect:a}=t,{source:i,returnType:o,returnSafety:l,moduleSafety:u,originalSource:p,requiredParams:d,unsafeFunctions:f,safeFunctions:m,wasmBlocks:g,tests:b,testErrors:x,letAnnotations:S,tjsModes:E}=r?Gi(e,{vmTarget:s,dialect:a,moduleLoader:t.moduleLoader,filename:t.filename}):{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:[],letAnnotations:new Map,tjsModes:{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}};try{return{ast:zn(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:o,returnSafety:l,moduleSafety:u,originalSource:p,requiredParams:d,unsafeFunctions:f,safeFunctions:m,wasmBlocks:g,tests:b,testErrors:x,letAnnotations:S,tjsModes:E}}catch(y){let C=y.loc||{line:1,column:0};throw new z(y.message.replace(/\s*\(\d+:\d+\)$/,""),C,p,n)}}function _r(e,t){for(let a of e.body){if(a.type==="ImportDeclaration")throw new z("Imports are not supported. All atoms must be registered with the VM.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration")throw new z("Exports are not supported. The function is automatically exported.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ClassDeclaration")throw new z("Classes are not supported. Agent99 uses functional composition.",a.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(a=>a.type==="FunctionDeclaration");if(n.length===0)throw new z("Source must contain a function declaration",{line:1,column:0},void 0,t);let r=n[n.length-1],s=new Map;for(let a=0;a<n.length-1;a++){let i=n[a],o=i.id?.name;if(!o)throw new z("Helper function must have a name",i.loc?.start||{line:1,column:0},void 0,t);if(s.has(o))throw new z(`Duplicate helper function name: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);if(o===r.id?.name)throw new z(`Helper function cannot share a name with the entry function: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);s.set(o,i)}return{entry:r,helpers:s}}function Tr(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(`
60
+ `),g=m.filter(b=>b.trim().length>0).reduce((b,x)=>{let S=x.match(/^(\s*)/)?.[1].length||0;return Math.min(b,S)},1/0);return g>0&&g<1/0&&(f=m.map(b=>b.slice(g)).join(`
61
+ `)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let l=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,u;for(;(u=l.exec(i))!==null;)n.params[u[1]]=u[2].trim();return n}function ee(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(i=>i!=null).map(i=>ee(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}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]=ee(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ee(n):t==="&&"||t==="??"?ee(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ee(n),a=ee(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>Hi(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ee(t.body)),{kind:"function",params:n,returns:r}}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 Hi(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ee(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Bt(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",U(e));let s=n.name,a=t?.has(s)??!1,i=ee(r),o=fe(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Bt(a.value,t),l=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:l,default:l?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}`,U(e))}function fe(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?fe(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=fe(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=fe(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=fe(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?fe(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?fe(n)??fe(r):void 0}default:return}}function Ir(e){try{let t=Gn(e,0,{ecmaVersion:2022});return ee(t)}catch{return{kind:"any"}}}function ct(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?ct(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=ct(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(ct)}:{};default:return{}}}function Ji(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=ct(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function Nr(e,t,n,r={},s,a){let i=Tr(t,e),o=new Map;for(let E of e.params){let y=Bt(E,s);if(y.name==="__destructured__"&&y.type.kind==="object"&&y.type.destructuredParams)for(let[C,k]of Object.entries(y.type.destructuredParams))o.set(C,{...k,description:i.params[C]});else y.description=i.params[y.name],o.set(y.name,y)}let l;n&&(l=Ir(n));let u={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},p=le(e.body,u),d=[],f=[],m=[];for(let[E,y]of o.entries())y.required?f.push(E):y.default!==void 0?m.push({name:E,defaultValue:y.default}):f.push(E);f.length>0&&d.push({op:"varsImport",keys:f});for(let{name:E,defaultValue:y}of m)d.push({op:"varsImport",keys:[E]}),d.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:E},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:E,value:y}]});d.push(...p);let g=Object.fromEntries(o),b={name:e.id?.name||"anonymous",description:i.description,parameters:g,returns:l},x=Ji(g),S=u.helperSteps&&u.helperSteps.size>0?Object.fromEntries(u.helperSteps):void 0;return{ast:{op:"seq",steps:d,inputSchema:x,...S&&{helpers:S}},signature:b,warnings:u.warnings}}function le(e,t){let n=[];for(let r of e.body){let s=qe(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function qe(e,t){switch(e.type){case"VariableDeclaration":return Ki(e,t);case"ExpressionStatement":return Zi(e,t);case"IfStatement":return Yi(e,t);case"WhileStatement":return Xi(e,t);case"ForOfStatement":return ea(e,t);case"TryStatement":return ta(e,t);case"ReturnStatement":return na(e,t);case"ThrowStatement":throw new F("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",U(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:le(e,ae(t))};case"EmptyStatement":return null;default:throw new F(`Unsupported statement type: ${e.type}`,U(e),t.source,t.filename)}}function Ki(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new F("Only simple variable names are supported",U(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:l}=Ce(a.init,t,i,r);o?n.push(o):l!==i&&n.push({op:s,key:i,value:l});let u=ee(a.init);t.locals.set(i,u)}else{if(r)throw new F("const declarations must be initialized",U(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function Zi(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Qi(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=Ce(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:U(e).line,column:U(e).column}),null}function Qi(e,t){if(e.left.type!=="Identifier")throw new F("Only simple variable assignment is supported",U(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=Ce(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function Yi(e,t){let n=L(e.test,t),r=e.consequent.type==="BlockStatement"?le(e.consequent,ae(t)):[qe(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?le(e.alternate,ae(t)):[qe(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function Xi(e,t){let n=L(e.test,t),r=e.body.type==="BlockStatement"?le(e.body,ae(t)):[qe(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function ea(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new F("Only simple variable names are supported in for...of",U(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new F("Unsupported for...of left-hand side",U(e.left),t.source,t.filename);let r=J(e.right,t),s=ae(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?le(e.body,s):[qe(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function ta(e,t){let n=le(e.block,ae(t)),r,s;if(e.handler){let a=ae(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=le(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function na(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=Ce(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:J(e.argument,t)}}var Rr=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),ra=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),We=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),sa=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 ia(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return ra.has(t)||We.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Rr.has(n)||We.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(sa.has(n))return!0}}return!1}function aa(e){if(e.object.type==="Identifier"){let t=e.object.name;return Rr.has(t)||We.has(t)}return!1}var Pr={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 oa(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(We.has(t))return Pr[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(We.has(n))return Pr[n]||`${n} is not available in AsyncJS.`}}return null}function Mr(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 Ce(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return Ce(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let l=Mr(o);throw new F(`The 'new' keyword is not supported in AsyncJS.${l}`,U(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=oa(e);if(i)throw new F(i,U(e),t.source,t.filename)}if(e.type==="CallExpression"&&ia(e)){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&aa(e)){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return la(e,t,n,r);if(e.type==="TemplateLiteral")return pa(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=L(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:J(e,t)}}function la(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let l=e.callee;if(l.property.type==="Identifier")s=l.property.name,a=!0,i=J(l.object,t);else throw new F("Computed method names are not supported",U(e),t.source,t.filename)}else throw new F("Only named function calls are supported",U(e),t.source,t.filename);if(a)return ca(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let l=ua(s,t,e),u=e.arguments.map(p=>J(p,t));if(u.length!==l.length)throw new F(`Helper '${s}' expects ${l.length} argument(s), got ${u.length}`,U(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:u,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=fa(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function ua(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new F(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??U(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=le(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function ca(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")p=le(i.body,u);else{let{step:d,resultVar:f}=Ce(i.body,u,"result");p=d?[d]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:l,steps:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")throw new F("filter callback must be an expression, not a block",U(n[0]),r.source,r.filename);return p=L(i.body,u),{step:{op:"filter",items:t,as:l,condition:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")throw new F("find callback must be an expression, not a block",U(n[0]),r.source,r.filename);return p=L(i.body,u),{step:{op:"find",items:t,as:l,condition:p,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],l=i.params[1],u=o?.type==="Identifier"?o.name:"acc",p=l?.type==="Identifier"?l.name:"item",d=ae(r);d.locals.set(u,{kind:"any"}),d.locals.set(p,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=le(i.body,d);else{let{step:g,resultVar:b}=Ce(i.body,d,"result");f=g?[g]:[{op:"varSet",key:"result",value:b}]}let m=J(n[1],r);return{step:{op:"reduce",items:t,as:p,accumulator:u,initial:m,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:J(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?J(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?J(n[0],r):"",...s&&{result:s},...s&&a&&{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(i=>J(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function pa(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],l=`_${i}`;a[l]=J(o,t),s+=`{{${l}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function L(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=L(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:L(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return L(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:L(n.left,t),right:L(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:L(n.left,t),right:L(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:L(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:L(n.test,t),consequent:L(n.consequent,t),alternate:L(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>L(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:L(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),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:L(r.object,t),method:s,arguments:n.arguments.map(i=>L(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new F(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,U(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>L(s,t))}}throw new F("Complex function calls in expressions should be lifted to statements",U(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=Mr(r);throw new F(`The 'new' keyword is not supported in AsyncJS.${s}`,U(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",U(e),t.source,t.filename);default:throw new F(`Unsupported expression type in condition: ${e.type}`,U(e),t.source,t.filename)}}function J(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 L(e,t);let s=J(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return L(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return J(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?J(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]=J(r.value,t)}return n}case"TemplateLiteral":return L(e,t);case"CallExpression":return L(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return L(e,t);default:return null}}function fa(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 a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=J(s.value,t)}return r}return{args:e.arguments.map(n=>J(n,t))}}function $r(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=Ar(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=_r(n,t.filename),{ast:l,signature:u,warnings:p}=Nr(i,s,r,t,a,o.size>0?o:void 0);return{ast:l,signature:u,warnings:p}}var da=6e4,jr=class{atoms;_defaultRunTimeout;constructor(t={}){this.atoms={...yt,...t}}get defaultRunTimeout(){if(this._defaultRunTimeout===void 0){let t=0;for(let n of Object.values(this.atoms)){let r=n.timeoutMs??1e3;r>0&&r>t&&(t=r)}this._defaultRunTimeout=Math.max(da,t*2)}return this._defaultRunTimeout}get builder(){return new je(this.atoms)}get Agent(){return new je(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(dt(t))s=mt(t);else try{s=$r(t).ast}catch(g){throw new Error(`AJS transpilation failed: ${g.message}`,{cause:g})}else s=t;let a=r.fuel??1e3,i=r.timeoutMs??this.defaultRunTimeout,o=r.capabilities??{},l=[];if(!o.store){let g=new Map,b=!1;o.store={get:async x=>(b||(b=!0,l.push("Using default in-memory store (not suitable for production)")),g.get(x)),set:async(x,S)=>{b||(b=!0,l.push("Using default in-memory store (not suitable for production)")),g.set(x,S)}}}let u=new AbortController,p=setTimeout(()=>u.abort(),i);r.signal&&r.signal.addEventListener("abort",()=>u.abort());let d={fuel:{current:a},args:n,state:{},consts:new Set,capabilities:o,resolver:g=>this.resolve(g),output:void 0,signal:u.signal,costOverrides:r.costOverrides,timeoutOverrides:r.timeoutOverrides,context:r.context,warnings:l,helpers:s.helpers};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&&!ha(n,f)){let g=new H("Input validation failed: args do not match expected schema","vm.run");return{result:g,error:g,fuelUsed:0,trace:d.trace,warnings:l.length>0?l:void 0}}try{await Promise.race([this.resolve("seq")?.exec(s,d),new Promise((g,b)=>{u.signal.addEventListener("abort",()=>{b(new Error(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`))}),u.signal.aborted&&b(new Error(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`))})])}catch(g){if(g.message?.includes("timeout")||g.message?.includes("aborted")||u.signal.aborted)d.error=new H(`Execution timeout after ${i}ms. Pass a higher \`timeoutMs\` to vm.run() or set per-atom \`timeoutOverrides\` for slow IO atoms.`,"vm.run");else throw g}finally{clearTimeout(p)}d.error&&d.output===void 0&&(d.output=d.error);let m=[...l,...d.warnings??[]];return{result:d.output,error:d.error,fuelUsed:a-d.fuel.current,trace:d.trace,warnings:m.length>0?m:void 0}}};import{s as $}from"tosijs-schema";var Ot=P("storeVectorize",$.object({text:$.string,model:$.string.optional}),$.array($.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=w(e,t);return n.embed(r)},{docs:"Generate embeddings using vector battery",cost:20,timeoutMs:6e4}),Dt=P("storeCreateCollection",$.object({collection:$.string,dimension:$.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=w(e,n),a=w(t,n);return r.createCollection(s,void 0,a)},{docs:"Create a vector store collection",cost:5}),Lt=P("storeVectorAdd",$.object({collection:$.string,doc:$.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=w(e,n),a=w(t,n);return r.vectorAdd(s,a)},{docs:"Add a document to a vector store collection",cost:5,timeoutMs:6e4}),Vt=P("storeSearch",$.object({collection:$.string,queryVector:$.array($.number),k:$.number.optional,filter:$.record($.any).optional}),$.array($.any),async({collection:e,queryVector:t,k:n,filter:r},s)=>{let a=s.capabilities.store;if(!a?.vectorSearch)throw new Error("Capability 'store' missing or does not support vectorSearch.");let i=w(e,s),o=w(t,s),l=w(n,s)??5,u=w(r,s);return a.vectorSearch(i,o,l,u)},{docs:"Search vector store",cost:(e,t)=>5+(w(e.k,t)??5)}),Ft=P("llmPredictBattery",$.object({system:$.string.optional,user:$.union([$.string,$.array($.any)]),tools:$.array($.any).optional,responseFormat:$.any.optional}),$.object({role:$.string.optional,content:$.string.optional,tool_calls:$.array($.any).optional}),async({system:e,user:t,tools:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=w(e,s)??"You are a helpful agent.",o=w(t,s),l=w(n,s),u=w(r,s);return a.predict(i,o,l,u)},{docs:"Generate completion using LLM battery",cost:100,timeoutMs:12e4}),Ut=P("llmVision",$.object({system:$.string.optional,prompt:$.string,images:$.array($.string),responseFormat:$.any.optional}),$.object({role:$.string.optional,content:$.string.optional,tool_calls:$.array($.any).optional}),async({system:e,prompt:t,images:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=w(e,s)??"You analyze images accurately and concisely.",o=w(t,s),l=w(n,s)??[],u=w(r,s);return a.predict(i,{text:o,images:l},void 0,u)},{docs:"Analyze images using a vision model",timeoutMs:12e4,cost:150});for(let e of[Ot,Dt,Lt,Vt,Ft,Ut])e.effects="io";var Ka={storeCreateCollection:Dt,storeSearch:Vt,storeVectorAdd:Lt,storeVectorize:Ot,llmPredictBattery:Ft,llmVision:Ut};export{H as AgentError,jr as AgentVM,Dr as DEFAULT_MAX_AST_SIZE,Or as DEFAULT_PROCEDURE_TTL,Us as EFFECTFUL_CORE_OPS,Ht as MAX_CALL_DEPTH,ht as PROCEDURE_TOKEN_PREFIX,As as agentRun,Ka as batteryAtoms,he as builtins,Ms as cache,ss as callLocal,Fs as clearExpiredProcedures,Ds as consoleError,Bs as consoleLog,Os as consoleWarn,Yr as constSet,yt as coreAtoms,xe as createChildScope,P as defineAtom,Zr as errorAtom,W as evaluateExpr,vs as fetch,as as filter,ls as find,gt as hash,Gr as iff,Br as isAgentError,dt as isProcedureToken,fs as join,Is as jsonParse,Ps as jsonStringify,bs as keys,cs as len,Cs as llmPredict,is as map,Rs as memoize,ys as merge,gs as omit,ms as pick,_e as procedureStore,us as push,$s as random,os as reduce,ds as regexMatch,Vs as releaseProcedure,mt as resolveProcedureToken,w as resolveValue,Jr as ret,Ts as runCode,rs as scope,X as seq,ps as split,ws as storeGet,Ls as storeProcedure,Es as storeQuery,Ss as storeSet,hs as template,_s as transpileCode,Kr as tryCatch,js as uuid,Xr as varGet,Qr as varSet,ns as varsExport,es as varsImport,ts as varsLet,ks as vectorSearch,Hr as whileLoop,Ns as xmlParse};
62
62
  //# sourceMappingURL=tjs-vm.js.map