tjs-lang 0.7.7 → 0.7.8

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.
Files changed (59) hide show
  1. package/CLAUDE.md +90 -33
  2. package/bin/docs.js +4 -1
  3. package/demo/docs.json +45 -11
  4. package/demo/src/examples.test.ts +1 -0
  5. package/demo/src/imports.test.ts +16 -4
  6. package/demo/src/imports.ts +60 -15
  7. package/demo/src/playground-shared.ts +9 -8
  8. package/demo/src/tfs-worker.js +205 -147
  9. package/demo/src/tjs-playground.ts +34 -10
  10. package/demo/src/ts-playground.ts +24 -8
  11. package/dist/index.js +118 -101
  12. package/dist/index.js.map +4 -4
  13. package/dist/src/lang/bool-coercion.d.ts +50 -0
  14. package/dist/src/lang/docs.d.ts +31 -6
  15. package/dist/src/lang/linter.d.ts +8 -0
  16. package/dist/src/lang/parser-transforms.d.ts +18 -0
  17. package/dist/src/lang/parser-types.d.ts +2 -0
  18. package/dist/src/lang/parser.d.ts +3 -0
  19. package/dist/src/lang/runtime.d.ts +34 -0
  20. package/dist/src/lang/types.d.ts +9 -1
  21. package/dist/src/rbac/index.d.ts +1 -1
  22. package/dist/src/vm/runtime.d.ts +1 -1
  23. package/dist/tjs-eval.js +38 -36
  24. package/dist/tjs-eval.js.map +4 -4
  25. package/dist/tjs-from-ts.js +20 -20
  26. package/dist/tjs-from-ts.js.map +3 -3
  27. package/dist/tjs-lang.js +85 -83
  28. package/dist/tjs-lang.js.map +4 -4
  29. package/dist/tjs-vm.js +47 -45
  30. package/dist/tjs-vm.js.map +4 -4
  31. package/llms.txt +79 -0
  32. package/package.json +3 -2
  33. package/src/cli/commands/convert.test.ts +16 -21
  34. package/src/lang/bool-coercion.test.ts +203 -0
  35. package/src/lang/bool-coercion.ts +314 -0
  36. package/src/lang/codegen.test.ts +137 -0
  37. package/src/lang/docs.test.ts +328 -1
  38. package/src/lang/docs.ts +424 -24
  39. package/src/lang/emitters/ast.ts +11 -12
  40. package/src/lang/emitters/dts.test.ts +41 -0
  41. package/src/lang/emitters/dts.ts +9 -0
  42. package/src/lang/emitters/js-tests.ts +9 -4
  43. package/src/lang/emitters/js.ts +182 -2
  44. package/src/lang/inference.ts +54 -0
  45. package/src/lang/linter.test.ts +104 -1
  46. package/src/lang/linter.ts +124 -1
  47. package/src/lang/parser-params.ts +31 -0
  48. package/src/lang/parser-transforms.ts +304 -0
  49. package/src/lang/parser-types.ts +2 -0
  50. package/src/lang/parser.test.ts +73 -1
  51. package/src/lang/parser.ts +34 -1
  52. package/src/lang/runtime.ts +98 -0
  53. package/src/lang/types.ts +6 -0
  54. package/src/rbac/index.ts +2 -2
  55. package/src/rbac/rules.tjs.d.ts +9 -0
  56. package/src/vm/atoms/batteries.ts +2 -2
  57. package/src/vm/runtime.ts +10 -3
  58. package/dist/src/rbac/rules.d.ts +0 -184
  59. package/src/rbac/rules.js +0 -338
package/dist/tjs-vm.js CHANGED
@@ -1,58 +1,60 @@
1
- import{s as h,validate as ht,filter as qt}from"tosijs-schema";var We=Symbol.for("tjs.equals");function Ge(e,t){if(e!==null&&typeof e=="object"&&typeof e[We]=="function")return e[We](t);if(t!==null&&typeof t=="object"&&typeof t[We]=="function")return t[We](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if(e===t||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>Ge(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=>Ge(e[s],t[s]))}var K=class{$error=!0;message;op;cause;constructor(t,n,r){this.message=t,this.op=n,this.cause=r}toString(){return`AgentError[${this.op}]: ${this.message}`}toJSON(){return{$error:!0,message:this.message,op:this.op}}};function Mr(e){return e instanceof K||e&&e.$error===!0}var Te=new Map,$r=3600*1e3,Br=100*1024,dt="proc_";function mt(e){return typeof e=="string"&&e.startsWith(dt)}function gt(e){let t=Te.get(e);if(!t)throw new Error(`Procedure not found: ${e}`);if(Date.now()>t.expiresAt)throw Te.delete(e),new Error(`Procedure expired: ${e}`);return t.ast}function jr(){return typeof crypto<"u"&&crypto.randomUUID?dt+crypto.randomUUID():dt+Math.random().toString(36).slice(2)+Date.now().toString(36)}var Wt=new Set(["__proto__","constructor","prototype"]);function Ot(e){if(Wt.has(e))throw new Error(`Security Error: Access to '${e}' is forbidden`)}var Or=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","metadata.google.internal"]);function Vr(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return!0;let n=t.hostname.toLowerCase();return!!(Or.has(n)||n.endsWith(".internal")||n.endsWith(".local")||n==="169.254.169.254"||/^10\./.test(n)||/^192\.168\./.test(n)||/^172\.(1[6-9]|2\d|3[01])\./.test(n))}catch{return!0}}function Lr(e){return!!(/\([^)]*[+*][^)]*\)[+*]/.test(e)||/\(([^|)]+)\|\1\)[+*]/.test(e)||/\(\.\*\)\+/.test(e)||/\(\.\+\)\+/.test(e)||/\(\[.*\]\+\)\+/.test(e))}function xe(e){return{...e,state:Object.create(e.state)}}function Dr(e,t){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r){let a=e[s],i=t[s];i!==a&&(n[s]=i)}return n}function x(e,t){if(e&&typeof e=="object"&&e.$kind==="arg")return t.args[e.path];if(e&&typeof e=="object"&&e.$expr)return W(e,t);if(typeof e=="string"){if(e.startsWith("args.")&&!("args"in t.state))return t.args[e.replace("args.","")];if(e.includes(".")){let n=e.split(".");for(let s of n)if(Wt.has(s))throw new Error(`Security Error: Access to '${s}' is forbidden`);let r=t.state[n[0]];if(r!==void 0){for(let s=1;s<n.length;s++)r=r?.[n[s]];return r}}return e in t.state?t.state[e]:e}if(e&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object){let n={};for(let r of Object.keys(e))n[r]=x(e[r],t);return n}return Array.isArray(e)?e.map(n=>x(n,t)):e}function Ce(e,t,n){return new Proxy(t,{get(r,s){if(s in r)return r[s];let 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 _e(e){if(e===null)return{type:"null"};if(e===void 0)return{};if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e;if(typeof e=="object"&&e!==null&&"schema"in e&&typeof e.schema=="object")return e.schema;let t=typeof e;if(t==="string")return{type:"string"};if(t==="number")return Number.isInteger(e)?{type:"integer"}:{type:"number"};if(t==="boolean")return{type:"boolean"};if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:_e(e[0])};if(t==="object"){let n={},r=[];for(let[s,a]of Object.entries(e))n[s]=_e(a),r.push(s);return{type:"object",properties:n,required:r}}return{}}var he={Math:Ce("Math",{PI:Math.PI,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,SQRT2:Math.SQRT2,SQRT1_2:Math.SQRT1_2,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc,sign:Math.sign,sqrt:Math.sqrt,cbrt:Math.cbrt,pow:Math.pow,exp:Math.exp,expm1:Math.expm1,log:Math.log,log2:Math.log2,log10:Math.log10,log1p:Math.log1p,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,asinh:Math.asinh,acosh:Math.acosh,atanh:Math.atanh,hypot:Math.hypot,min:Math.min,max:Math.max,clz32:Math.clz32,imul:Math.imul,fround:Math.fround,random:()=>{if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]/4294967296}return Math.random()}}),JSON:Ce("JSON",{parse:e=>JSON.parse(e),stringify:(e,t,n)=>JSON.stringify(e,t,n)}),console:Ce("console",{log:(...e)=>{},warn:(...e)=>{},error:(...e)=>{},info:(...e)=>{}},{table:"Use console.log with JSON.stringify for structured data.",dir:"Use console.log instead.",trace:"Stack traces are not available in AsyncJS."}),Array:Ce("Array",{isArray:e=>Array.isArray(e),from:(e,t,n)=>Array.from(e,t,n),of:(...e)=>Array.of(...e)},{prototype:"Prototype access is not allowed."}),Object:Ce("Object",{keys:e=>Object.keys(e),values:e=>Object.values(e),entries:e=>Object.entries(e),fromEntries:e=>Object.fromEntries(e),assign:(e,...t)=>Object.assign({},e,...t),hasOwn:(e,t)=>Object.hasOwn(e,t)},{prototype:"Prototype access is not allowed.",create:"Use object literals instead.",defineProperty:"Property descriptors are not supported.",getPrototypeOf:"Prototype access is not allowed.",setPrototypeOf:"Prototype modification is not allowed."}),String:Ce("String",{fromCharCode:(...e)=>String.fromCharCode(...e),fromCodePoint:(...e)=>String.fromCodePoint(...e)}),Number:Ce("Number",{isNaN:Number.isNaN,isFinite:Number.isFinite,isInteger:Number.isInteger,isSafeInteger:Number.isSafeInteger,parseFloat,parseInt,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,NaN:Number.NaN,EPSILON:Number.EPSILON}),parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,undefined:void 0,null:null,NaN:NaN,Infinity:1/0,filter:(e,t)=>{let n=_e(t),r=qt(e,n);if(r instanceof Error)throw r;return r},Schema:{...h,response:(e,t)=>{let n=t?.schema!=null?t.schema:_e(t);return{type:"json_schema",json_schema:{name:e,strict:!0,schema:n}}},fromExample:e=>_e(e),isValid:(e,t)=>t?.schema!=null?ht(e,t):ht(e,_e(t))},Set:(e=[])=>{let t=[...new globalThis.Set(e)];return{add(n){return t.includes(n)||t.push(n),this},remove(n){let r=t.indexOf(n);return r!==-1&&t.splice(r,1),this},clear(){return t.length=0,this},has(n){return t.includes(n)},get size(){return t.length},toArray(){return[...t]},union(n){let r=n?.toArray?.()??n??[];return he.Set([...t,...r])},intersection(n){let r=n?.toArray?.()??n??[];return he.Set(t.filter(s=>r.includes(s)))},diff(n){let r=n?.toArray?.()??n??[];return he.Set(t.filter(s=>!r.includes(s)))},forEach(n){t.forEach(n)},map(n){return he.Set(t.map(n))},filter(n){return he.Set(t.filter(n))},toJSON(){return[...t]}}},Date:(()=>{let e=n=>({get value(){return n.toISOString()},get timestamp(){return n.getTime()},get year(){return n.getFullYear()},get month(){return n.getMonth()+1},get day(){return n.getDate()},get hours(){return n.getHours()},get minutes(){return n.getMinutes()},get seconds(){return n.getSeconds()},get dayOfWeek(){return n.getDay()},add({years:r=0,months:s=0,days: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."},Fr=.01,Vt=1e-4,Lt=.001,Ur=new Set(["concat","slice","map","filter","flatMap","flat","toReversed","toSorted","toSpliced","repeat","padStart","padEnd","split","join","replace","replaceAll","substring","substr","trim","trimStart","trimEnd","toLowerCase","toUpperCase","match","matchAll","parse","stringify"]);function W(e,t){if(e==null||typeof e!="object"||!("$expr"in e))return e;if(t.fuel&&(t.fuel.current-=Fr,t.fuel.current<=0))throw new Error("Out of Fuel");switch(e.$expr){case"literal":return e.value;case"ident":{if(e.name in t.state)return t.state[e.name];if(e.name in t.args)return t.args[e.name];if(e.name in he)return he[e.name];if(e.name in ze)throw new Error(ze[e.name]);return}case"member":{let n=W(e.object,t);if(e.optional&&n==null)return;let r=e.property;return Ot(r),n?.[r]}case"binary":{let n=W(e.left,t),r=W(e.right,t);switch(e.op){case"+":{let s=n+r;if(typeof s=="string"&&t.fuel&&(t.fuel.current-=s.length*Vt,t.fuel.current<=0)){t.error=new K("Out of Fuel","expr.concat");return}return s}case"-":return n-r;case"*":return n*r;case"/":return n/r;case"%":return n%r;case"**":return n**r;case">":return n>r;case"<":return n<r;case">=":return n>=r;case"<=":return n<=r;case"==":return Ge(n,r);case"!=":return!Ge(n,r);case"===":return n===r;case"!==":return n!==r;default:throw new Error(`Unknown binary operator: ${e.op}`)}}case"unary":{let n=W(e.argument,t);switch(e.op){case"!":return!n;case"-":return-n;case"+":return+n;case"typeof":return typeof n;default:throw new Error(`Unknown unary operator: ${e.op}`)}}case"logical":{let n=W(e.left,t);return e.op==="&&"?n&&W(e.right,t):e.op==="??"?n??W(e.right,t):n||W(e.right,t)}case"conditional":{let n=W(e.test,t);return W(n?e.consequent:e.alternate,t)}case"array":return e.elements.map(n=>W(n,t));case"object":{let n={};for(let r of e.properties)n[r.key]=W(r.value,t);return n}case"call":{if(e.callee==="Error"){let r=e.arguments.map(a=>W(a,t)),s=typeof r[0]=="string"?r[0]:"Error";t.error=new K(s,"Error");return}if(e.callee in he){let r=he[e.callee];if(typeof r=="function"){let s=e.arguments.map(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(Ot(r),n==null)throw new Error(`Cannot call method '${r}' on ${n}`);let s=n[r];if(typeof s!="function")throw new Error(`'${r}' is not a function`);let a=e.arguments.map(o=>W(o,t)),i=s.apply(n,a);if(t.fuel&&Ur.has(r)){let o=0;if(typeof i=="string"?o=i.length*Vt:Array.isArray(i)?o=i.length*Lt:typeof i=="object"&&i!==null&&(o=Object.keys(i).length*Lt),t.fuel.current-=o,t.fuel.current<=0){t.error=new K("Out of Fuel",`expr.${r}`);return}}return i}default:throw new Error(`Unknown expression type: ${e.$expr}`)}}function I(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,v=p.fuel.current,y,w;try{let C=p.costOverrides?.[e],b=C!==void 0?C:o,S=typeof b=="function"?b(m,p):b;if((p.fuel.current-=S)<=0){p.error=new K("Out of Fuel",e);return}let k,E=async()=>r(u,p);if(y=i>0?await Promise.race([E(),new Promise((T,P)=>{k=setTimeout(()=>P(new Error(`Atom '${e}' timed out`)),i)})]).finally(()=>clearTimeout(k)):await E(),u.result){if(p.consts.has(u.result))throw new Error(`Cannot reassign const variable '${u.result}'`);if(y!==void 0&&n&&!ht(y,n)){p.error=new K(`Output validation failed for '${e}'`,e);return}p.state[u.result]=y,u.resultConst&&p.consts.add(u.result)}}catch(C){w=C.message||String(C),p.error=new K(w,e,C)}finally{if(p.trace&&g){let C=Dr(g,p.state);p.trace.push({op:e,input:m,stateDiff:C,result:y,error:w,fuelBefore:v,fuelAfter:p.fuel.current,timestamp:new Date().toISOString()})}}},docs:a,timeoutMs:i,cost:o,create:u=>({op:e,...u})}}var ee=I("seq",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{for(let n of e){if(t.output!==void 0||t.error)return;let r=t.resolver(n.op);if(!r)throw new Error(`Unknown Atom: ${n.op}`);await r.exec(n,t)}},{docs:"Sequence",timeoutMs:0,cost:.1}),qr=I("if",h.object({condition:h.any,then:h.array(h.any),else:h.array(h.any).optional}),void 0,async(e,t)=>{W(e.condition,t)?await ee.exec({op:"seq",steps:e.then},t):e.else&&await ee.exec({op:"seq",steps:e.else},t)},{docs:"If/Else",timeoutMs:0,cost:.1}),Wr=I("while",h.object({condition:h.any,body:h.array(h.any)}),void 0,async(e,t)=>{for(;W(e.condition,t);){if(t.signal?.aborted)throw new Error("Execution aborted");if((t.fuel.current-=.1)<=0)throw new Error("Out of Fuel");if(await ee.exec({op:"seq",steps:e.body},t),t.output!==void 0)return}},{docs:"While Loop",timeoutMs:0,cost:.1}),zr=I("return",void 0,h.any,async(e,t)=>{if(t.error)return t.output=t.error,t.error;if("value"in e){let r=x(e.value,t);if(r!=null&&!Mr(r)&&(typeof r!="object"||Array.isArray(r))){let s=new K(`Agent must return an object, got ${Array.isArray(r)?"array":typeof r}`,"return");return t.error=s,t.output=s,s}return t.output=r,r}let n={};if(e.schema?.properties){for(let r of Object.keys(e.schema.properties))n[r]=t.state[r];if(e.filter!==!1){let r=qt(n,e.schema);r instanceof Error||(n=r)}}return t.output=n,n},{docs:"Return",cost:.1}),Gr=I("try",h.object({try:h.array(h.any),catch:h.array(h.any).optional,catchParam:h.string.optional}),void 0,async(e,t)=>{if(await ee.exec({op:"seq",steps:e.try},t),t.error&&e.catch){let n=e.catchParam||"error";t.state[n]=t.error.message,t.state.errorOp=t.error.op,t.error=void 0,await ee.exec({op:"seq",steps:e.catch},t)}},{docs:"Try/Catch",timeoutMs:0,cost:.1}),Hr=I("Error",h.object({args:h.array(h.any).optional}),void 0,async(e,t)=>{let n=e.args?.[0]??"Error";t.error=new K(String(n),"Error")},{docs:"Trigger error flow",cost:.1}),Jr=I("varSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{if(n.consts.has(e))throw new Error(`Cannot reassign const variable '${e}'`);n.state[e]=x(t,n)},{docs:"Set Variable",cost:.1}),Kr=I("constSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{if(n.consts.has(e))throw new Error(`Cannot reassign const variable '${e}'`);if(e in n.state)throw new Error(`Cannot redeclare variable '${e}' as const`);n.state[e]=x(t,n),n.consts.add(e)},{docs:"Set Const Variable (immutable)",cost:.1}),Zr=I("varGet",h.object({key:h.string}),h.any,async({key:e},t)=>x(e,t),{docs:"Get Variable",cost:.1}),Qr=I("varsImport",h.object({keys:h.union([h.array(h.string),h.record(h.string)])}),void 0,async({keys:e},t)=>{if(Array.isArray(e))for(let n of e)t.state[n]=x({$kind:"arg",path:n},t);else for(let[n,r]of Object.entries(e))t.state[n]=x({$kind:"arg",path:r},t)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:.2}),Yr=I("varsLet",h.record(h.any),void 0,async(e,t)=>{for(let n of Object.keys(e))n==="op"||n==="result"||(t.state[n]=x(e[n],t))},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:.1}),Xr=I("varsExport",h.object({keys:h.union([h.array(h.string),h.record(h.string)])}),h.record(h.any),async({keys:e},t)=>{let n={};if(Array.isArray(e))for(let r of e)n[r]=x(r,t);else for(let[r,s]of Object.entries(e))n[r]=x(s,t);return n},{docs:"Export variables from the current scope, with optional renaming.",cost:.2}),es=I("scope",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{let n=xe(t);await ee.exec({op:"seq",steps:e},n),n.output!==void 0&&(t.output=n.output)},{docs:"Create new scope",timeoutMs:0,cost:.1}),ts=I("map",h.object({items:h.array(h.any),as:h.string,steps:h.array(h.any)}),h.array(h.any),async({items:e,as:t,steps:n},r)=>{let s=[],a=x(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 ee.exec({op:"seq",steps:n},o),s.push(o.state.result??null)}return s},{docs:"Map Array",timeoutMs:0,cost:1}),ns=I("filter",h.object({items:h.array(h.any),as:h.string,condition:h.any}),h.array(h.any),async({items:e,as:t,condition:n},r)=>{let s=[],a=x(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}),rs=I("reduce",h.object({items:h.array(h.any),as:h.string,accumulator:h.string,initial:h.any,steps:h.array(h.any)}),h.any,async({items:e,as:t,accumulator:n,initial:r,steps:s},a)=>{let i=x(e,a),o=x(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 ee.exec({op:"seq",steps:s},p),l=p.state.result??l}return l},{docs:"Reduce Array",timeoutMs:0,cost:1}),ss=I("find",h.object({items:h.array(h.any),as:h.string,condition:h.any}),h.any,async({items:e,as:t,condition:n},r)=>{let s=x(e,r);if(!Array.isArray(s))throw new Error("find: items is not an array");for(let 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}),is=I("push",h.object({list:h.array(h.any),item:h.any}),h.array(h.any),async({list:e,item:t},n)=>{let r=x(e,n),s=x(t,n);return Array.isArray(r)&&r.push(s),r},{docs:"Push to Array",cost:1}),as=I("len",h.object({list:h.any}),h.number,async({list:e},t)=>{let n=x(e,t);return Array.isArray(n)||typeof n=="string"?n.length:0},{docs:"Length",cost:1}),os=I("split",h.object({str:h.string,sep:h.string}),h.array(h.string),async({str:e,sep:t},n)=>x(e,n).split(x(t,n)),{docs:"Split String",cost:1}),ls=I("join",h.object({list:h.array(h.string),sep:h.string}),h.string,async({list:e,sep:t},n)=>x(e,n).join(x(t,n)),{docs:"Join String",cost:1}),us=I("template",h.object({tmpl:h.string,vars:h.record(h.any)}),h.string,async({tmpl:e,vars:t},n)=>x(e,n).replace(/\{\{(\w+)\}\}/g,(s,a)=>String(x(t[a],n)??"")),{docs:"String Template",cost:1}),cs=I("regexMatch",h.object({pattern:h.string,value:h.any}),h.boolean,async({pattern:e,value:t},n)=>{if(Lr(e))throw new Error(`Suspicious regex pattern rejected (potential ReDoS): ${e}`);let r=x(t,n);return new RegExp(e).test(r)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),ps=I("pick",h.object({obj:h.record(h.any),keys:h.array(h.string)}),h.record(h.any),async({obj:e,keys:t},n)=>{let r=x(e,n),s=x(t,n),a={};return r&&Array.isArray(s)&&s.forEach(i=>a[i]=r[i]),a},{docs:"Pick Keys",cost:1}),fs=I("omit",h.object({obj:h.record(h.any),keys:h.array(h.string)}),h.record(h.any),async({obj:e,keys:t},n)=>{let r=x(e,n),s=new Set(x(t,n)),a={};return r&&Object.keys(r).forEach(i=>{s.has(i)||(a[i]=r[i])}),a},{docs:"Omit Keys",cost:1}),hs=I("merge",h.object({a:h.record(h.any),b:h.record(h.any)}),h.record(h.any),async({a:e,b:t},n)=>({...x(e,n),...x(t,n)}),{docs:"Merge Objects",cost:1}),ds=I("keys",h.object({obj:h.record(h.any)}),h.array(h.string),async({obj:e},t)=>Object.keys(x(e,t)??{}),{docs:"Object Keys",cost:1}),Dt=10,Ft="X-Agent-Depth";function ms(e,t){try{let r=new URL(e).hostname.toLowerCase();for(let s of t){let 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 gs=I("httpFetch",h.object({url:h.string,method:h.string.optional,headers:h.record(h.string).optional,body:h.any.optional,responseType:h.string.optional}),h.any,async(e,t)=>{let n=x(e.url,t),r=x(e.method,t),s=x(e.headers,t)||{},a=x(e.body,t),i=x(e.responseType,t),o=t.context?.requestDepth??0;if(o>=Dt)throw new Error(`Agent request depth exceeded (max ${Dt}). This prevents recursive agent loops.`);if(t.capabilities.fetch)return t.capabilities.fetch(n,{method:r,headers:{...s,[Ft]:String(o+1)},body:a,signal:t.signal,responseType:i});let l=t.context?.allowedFetchDomains;if(l){if(!ms(n,l))throw new Error(`Fetch blocked: domain not in allowlist. Allowed: ${l.join(", ")}`)}else{if(Vr(n))throw new Error("Blocked URL: private/internal addresses not allowed in default fetch");try{let p=new URL(n).hostname.toLowerCase();if(p!=="localhost"&&p!=="127.0.0.1"&&p!=="[::1]")throw new Error("Fetch blocked: no allowedFetchDomains configured. Set ctx.context.allowedFetchDomains or provide a custom fetch capability.")}catch(u){throw u.message.includes("allowedFetchDomains")?u:new Error(`Invalid URL: ${n}`)}}if(typeof globalThis.fetch=="function"){let u=await globalThis.fetch(n,{method:r,headers:{...s,[Ft]: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 y=0;y<f.length;y++)m+=String.fromCharCode(f[y]);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}),ys=I("storeGet",h.object({key:h.string}),h.any,async({key:e},t)=>{let n=x(e,t);return t.capabilities.store?.get(n)},{docs:"Store Get",cost:5}),bs=I("storeSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{let r=x(e,n),s=x(t,n);return n.capabilities.store?.set(r,s)},{docs:"Store Set",cost:5}),xs=I("storeQuery",h.object({query:h.any}),h.array(h.any),async({query:e},t)=>t.capabilities.store?.query?.(x(e,t))??[],{docs:"Store Query",cost:5}),vs=I("storeVectorSearch",h.object({collection:h.string.optional,vector:h.array(h.number),k:h.number.optional}),h.array(h.any),async({collection:e,vector:t,k:n},r)=>r.capabilities.store?.vectorSearch?.(x(e,r),x(t,r),x(n,r))??[],{docs:"Vector Search",cost:(e,t)=>5+(x(e.k,t)??5)}),ws=I("llmPredict",h.object({prompt:h.string,options:h.any.optional}),h.string,async({prompt:e,options:t},n)=>{if(!n.capabilities.llm?.predict)throw new Error("Capability 'llm.predict' missing");return n.capabilities.llm.predict(x(e,n),x(t,n))},{docs:"LLM Predict",timeoutMs:12e4,cost:100}),Ss=I("agentRun",h.object({agentId:h.any,input:h.any}),h.any,async({agentId:e,input:t},n)=>{let r=x(e,n),s=x(t,n),a=s;if(s&&typeof s=="object"&&!Array.isArray(s)){a={};for(let o in s)a[o]=x(s[o],n)}if(mt(r)){let o=gt(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}),Es=I("transpileCode",h.object({code:h.string}),h.any,async({code:e},t)=>{if(!t.capabilities.code?.transpile)throw new Error("Capability 'code.transpile' missing. Enable code transpilation by providing the code capability.");let n=x(e,t);try{return t.capabilities.code.transpile(n)}catch(r){throw new Error(`Code transpilation failed: ${r.message}`)}},{docs:"Transpile AsyncJS code to AST",cost:1}),Ut=10,Cs=I("runCode",h.object({code:h.string,args:h.record(h.any).optional}),h.any,async({code:e,args:t},n)=>{let r=n.runCodeDepth??0;if(r>=Ut)throw new Error(`runCode recursion limit exceeded (max ${Ut}). This prevents infinite loops from dynamically generated code calling runCode.`);if(!n.capabilities.code?.transpile)throw new Error("Capability 'code.transpile' missing. Enable dynamic code execution by providing the code capability.");let s=x(e,n),a=t?x(t,n):{},i;try{i=n.capabilities.code.transpile(s)}catch(l){throw new Error(`Code transpilation failed: ${l.message}`)}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 ee.exec(i,o),o.error){n.error=o.error;return}return o.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),ks=I("jsonParse",h.object({str:h.string}),h.any,async({str:e},t)=>JSON.parse(x(e,t)),{docs:"Parse JSON",cost:1}),As=I("jsonStringify",h.object({value:h.any}),h.string,async({value:e},t)=>JSON.stringify(x(e,t)),{docs:"Stringify JSON",cost:1}),_s=I("xmlParse",h.object({str:h.string}),h.any,async({str:e},t)=>{if(!t.capabilities.xml?.parse)throw new Error("Capability 'xml.parse' missing");return t.capabilities.xml.parse(x(e,t))},{docs:"Parse XML",cost:1}),Ts=I("memoize",h.object({key:h.string.optional,steps:h.array(h.any)}),h.any,async({key:e,steps:t},n)=>{n.memo||(n.memo=new Map);let r=x(e,n)??await yt.exec({value:t,algorithm:"SHA-256"},n);if(n.memo.has(r))return n.memo.get(r);let s=xe(n);await ee.exec({op:"seq",steps:t},s);let a=s.output??s.state.result;return n.memo.set(r,a),a},{docs:"Memoize steps result in memory",cost:1}),Is=I("cache",h.object({key:h.string.optional,steps:h.array(h.any),ttlMs:h.number.optional}),h.any,async({key:e,steps:t,ttlMs:n},r)=>{if(!r.capabilities.store)throw new Error("Capability 'store' missing for caching");let a=`cache:${x(e,r)??await yt.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 ee.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}),Ps=I("random",h.object({min:h.number.optional,max:h.number.optional,format:h.string.optional,length:h.number.optional}),h.any,async({min:e,max:t,format:n,length:r},s)=>{let a=x(n,s)??"float",i=x(r,s)??10,o=x(e,s)??0,l=x(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 v=0;v<i;v++)m+=f[g[v]%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}),Ns=I("uuid",void 0,h.string,async()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})},{docs:"Generate UUID",cost:1}),yt=I("hash",h.object({value:h.any,algorithm:h.string.optional}),h.string,async({value:e,algorithm:t},n)=>{let r=typeof e=="string"?e:JSON.stringify(x(e,n)),s=x(t,n)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let o=new TextEncoder().encode(r),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}),Rs=I("consoleLog",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t);t.trace&&t.trace.push({op:"console.log",input:{message:n},stateDiff:{},result:n,fuelBefore:t.fuel.current,fuelAfter:t.fuel.current,timestamp:new Date().toISOString()})},{docs:"Log to trace",cost:.1}),Ms=I("consoleWarn",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.warnings||(t.warnings=[]),t.warnings.push(r),t.trace&&t.trace.push({op:"console.warn",input:{message:n},stateDiff:{},result:n,fuelBefore:t.fuel.current,fuelAfter:t.fuel.current,timestamp:new Date().toISOString()})},{docs:"Add warning",cost:.1}),$s=I("consoleError",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=x(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.error=new K(r,"console.error")},{docs:"Emit error and stop",cost:.1}),Bs=I("storeProcedure",h.object({ast:h.any,ttl:h.number.optional,maxSize:h.number.optional}),h.string,async({ast:e,ttl:t,maxSize:n},r)=>{let s=x(e,r),a=t?x(t,r):$r,i=n?x(n,r):Br;if(!s||typeof s!="object"||!s.op)throw new Error('Invalid AST: must be an object with an "op" property');let o=JSON.stringify(s);if(o.length>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=jr(),u=Date.now();return Te.set(l,{ast:s,createdAt:u,expiresAt:u+a}),l},{docs:"Store an AST and return a token for later execution",cost:1}),js=I("releaseProcedure",h.object({token:h.string}),h.boolean,async({token:e},t)=>{let n=x(e,t);return Te.delete(n)},{docs:"Release a stored procedure by token",cost:.1}),Os=I("clearExpiredProcedures",void 0,h.number,async()=>{let e=Date.now(),t=0;for(let[n,r]of Te)e>r.expiresAt&&(Te.delete(n),t++);return t},{docs:"Clear all expired procedures and return count",cost:.5}),zt={seq:ee,if:qr,while:Wr,return:zr,try:Gr,Error:Hr,varSet:Jr,constSet:Kr,varGet:Zr,varsImport:Qr,varsLet:Yr,varsExport:Xr,scope:es,map:ts,filter:ns,reduce:rs,find:ss,push:is,len:as,split:os,join:ls,template:us,regexMatch:cs,pick:ps,omit:fs,merge:hs,keys:ds,httpFetch:gs,storeGet:ys,storeSet:bs,storeQuery:xs,storeVectorSearch:vs,llmPredict:ws,agentRun:Ss,transpileCode:Es,runCode:Cs,jsonParse:ks,jsonStringify:As,xmlParse:_s,memoize:Ts,cache:Is,random:Ps,uuid:Ns,hash:yt,consoleLog:Rs,consoleWarn:Ms,consoleError:$s,storeProcedure:Bs,releaseProcedure:js,clearExpiredProcedures:Os};var Vs=new Set(["true","false","null","undefined","and","or","not"]);function Ls(e,t){let n=e.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),r=[],s=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,a;for(;(a=s.exec(n))!==null;)r.push(a[1]);let o=[...new Set(r)].filter(l=>!Vs.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 He(e,t){Ls(e,t);let n=Ds(e),r=Zt(n,0,t);if(r.pos<n.length){let s=n.slice(r.pos).join(" ");throw new Error(`Unsupported condition syntax near '${s}' in: ${e}
2
- Supported: comparisons, &&, ||, !, arithmetic, member access (a.b), literals`)}return r.node}function Ds(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]==='"'||e[n]==="'"){let r=e[n++],s="";for(;n<e.length&&e[n]!==r;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n++];n++,t.push(JSON.stringify(s));continue}if(e.slice(n,n+2).match(/^(&&|\|\||==|!=|>=|<=)$/)){t.push(e.slice(n,n+2)),n+=2;continue}if("+-*/%><!().?:[]".includes(e[n])){t.push(e[n]),n++;continue}if(/\d/.test(e[n])){let r="";for(;n<e.length&&/[\d.]/.test(e[n]);)r+=e[n++];t.push(r);continue}if(/[a-zA-Z_]/.test(e[n])){let r="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)r+=e[n++];t.push(r);continue}n++}return t}function Zt(e,t,n){return Fs(e,t,n)}function Fs(e,t,n){let{node:r,pos:s}=Gt(e,t,n);for(;e[s]==="||";){s++;let{node:a,pos:i}=Gt(e,s,n);r={$expr:"logical",op:"||",left:r,right:a},s=i}return{node:r,pos:s}}function Gt(e,t,n){let{node:r,pos:s}=Ht(e,t,n);for(;e[s]==="&&";){s++;let{node:a,pos:i}=Ht(e,s,n);r={$expr:"logical",op:"&&",left:r,right:a},s=i}return{node:r,pos:s}}function Ht(e,t,n){let{node:r,pos:s}=Jt(e,t,n),a=["==","!=",">","<",">=","<="];for(;a.includes(e[s]);){let i=e[s++],{node:o,pos:l}=Jt(e,s,n);r={$expr:"binary",op:i,left:r,right:o},s=l}return{node:r,pos:s}}function Jt(e,t,n){let{node:r,pos:s}=Kt(e,t,n);for(;e[s]==="+"||e[s]==="-";){let a=e[s++],{node:i,pos:o}=Kt(e,s,n);r={$expr:"binary",op:a,left:r,right:i},s=o}return{node:r,pos:s}}function Kt(e,t,n){let{node:r,pos:s}=bt(e,t,n);for(;e[s]==="*"||e[s]==="/"||e[s]==="%";){let 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 Us(e,t,n)}function Us(e,t,n){let r=e[t];if(r==="("){let{node:s,pos:a}=Zt(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 Me=class e{steps=[];atoms;proxy;constructor(t){return this.atoms=t,this.proxy=new Proxy(this,{get:(n,r,s)=>{if(r in n)return n[r];if(typeof r=="string"&&r in n.atoms)return 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=He(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=He(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=He(r,s),i=this.atoms.filter;return this.add(i.create({items:t,as:n,condition:a}))}find(t,n,r,s={}){let a=He(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 sa}from"tosijs-schema";var qs=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],nn=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Ws="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",rn="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",xt={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},vt="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",zs={5:vt,"5module":vt+" export import",6:vt+" const class extends export import super"},Gs=/^in(stanceof)?$/,Hs=new RegExp("["+rn+"]"),Js=new RegExp("["+rn+Ws+"]");function St(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function le(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Hs.test(String.fromCharCode(e)):t===!1?!1:St(e,nn)}function we(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Js.test(String.fromCharCode(e)):t===!1?!1:St(e,nn)||St(e,qs)}var O=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function te(e,t){return new O(e,{beforeExpr:!0,binop:t})}var ne={beforeExpr:!0},Y={startsExpr:!0},At={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,At[e]=new O(e,t)}var c={num:new O("num",Y),regexp:new O("regexp",Y),string:new O("string",Y),name:new O("name",Y),privateId:new O("privateId",Y),eof:new O("eof"),bracketL:new O("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new O("]"),braceL:new O("{",{beforeExpr:!0,startsExpr:!0}),braceR:new O("}"),parenL:new O("(",{beforeExpr:!0,startsExpr:!0}),parenR:new O(")"),comma:new O(",",ne),semi:new O(";",ne),colon:new O(":",ne),dot:new O("."),question:new O("?",ne),questionDot:new O("?."),arrow:new O("=>",ne),template:new O("template"),invalidTemplate:new O("invalidTemplate"),ellipsis:new O("...",ne),backQuote:new O("`",Y),dollarBraceL:new O("${",{beforeExpr:!0,startsExpr:!0}),eq:new O("=",{beforeExpr:!0,isAssign:!0}),assign:new O("_=",{beforeExpr:!0,isAssign:!0}),incDec:new O("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new O("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:te("||",1),logicalAND:te("&&",2),bitwiseOR:te("|",3),bitwiseXOR:te("^",4),bitwiseAND:te("&",5),equality:te("==/!=/===/!==",6),relational:te("</>/<=/>=",7),bitShift:te("<</>>/>>>",8),plusMin:new O("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:te("%",10),star:te("*",10),slash:te("/",10),starstar:new O("**",{beforeExpr:!0}),coalesce:te("??",1),_break:B("break"),_case:B("case",ne),_catch:B("catch"),_continue:B("continue"),_debugger:B("debugger"),_default:B("default",ne),_do:B("do",{isLoop:!0,beforeExpr:!0}),_else:B("else",ne),_finally:B("finally"),_for:B("for",{isLoop:!0}),_function:B("function",Y),_if:B("if"),_return:B("return",ne),_switch:B("switch"),_throw:B("throw",ne),_try:B("try"),_var:B("var"),_const:B("const"),_while:B("while",{isLoop:!0}),_with:B("with"),_new:B("new",{beforeExpr:!0,startsExpr:!0}),_this:B("this",Y),_super:B("super",Y),_class:B("class",Y),_extends:B("extends",ne),_export:B("export"),_import:B("import",Y),_null:B("null",Y),_true:B("true",Y),_false:B("false",Y),_in:B("in",{beforeExpr:!0,binop:7}),_instanceof:B("instanceof",{beforeExpr:!0,binop:7}),_typeof:B("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},X=/\r\n?|\n|\u2028|\u2029/,Ks=new RegExp(X.source,"g");function Ie(e){return e===10||e===13||e===8232||e===8233}function sn(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(Ie(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var an=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,H=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,on=Object.prototype,Zs=on.hasOwnProperty,Qs=on.toString,Pe=Object.hasOwn||(function(e,t){return Zs.call(e,t)}),Qt=Array.isArray||(function(e){return Qs.call(e)==="[object Array]"}),Yt=Object.create(null);function ve(e){return Yt[e]||(Yt[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function de(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Ys=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Be=function(t,n){this.line=t,this.column=n};Be.prototype.offset=function(t){return new Be(this.line,this.column+t)};var Xe=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ln(e,t){for(var n=1,r=0;;){var s=sn(e,r,t);if(s<0)return new Be(n,t-r);++n,r=s}}var Et={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Xt=!1;function Xs(e){var t={};for(var n in Et)t[n]=e&&Pe(e,n)?e[n]:Et[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Xt&&typeof console=="object"&&console.warn&&(Xt=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
3
- Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Qt(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return Qt(t.onComment)&&(t.onComment=ei(t,t.onComment)),t}function ei(e,t){return function(n,r,s,a,i,o){var l={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(l.loc=new Xe(this,i,o)),e.ranges&&(l.range=[s,a]),t.push(l)}}var je=1,Ne=2,_t=4,un=8,Tt=16,cn=32,et=64,pn=128,ke=256,Oe=512,tt=je|Ne|ke;function It(e,t){return Ne|(e?_t:0)|(t?un:0)}var Ke=0,Pt=1,ge=2,fn=3,hn=4,dn=5,z=function(t,n,r){this.options=t=Xs(t),this.sourceFile=t.sourceFile,this.keywords=ve(zs[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=xt[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=ve(s);var 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(X).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=c.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(je),this.regexpState=null,this.privateNameStack=[]},ue={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};z.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};ue.inFunction.get=function(){return(this.currentVarScope().flags&Ne)>0};ue.inGenerator.get=function(){return(this.currentVarScope().flags&un)>0};ue.inAsync.get=function(){return(this.currentVarScope().flags&_t)>0};ue.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Oe))return!1;if(n&Ne)return(n&_t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};ue.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&et)>0||this.options.allowSuperOutsideMethod};ue.allowDirectSuper.get=function(){return(this.currentThisScope().flags&pn)>0};ue.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};ue.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(ke|Oe)||n&Ne&&!(n&Tt))return!0}return!1};ue.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ke)>0};z.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};z.parse=function(t,n){return new this(n,t).parse()};z.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};z.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(z.prototype,ue);var Z=z.prototype,ti=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Z.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){H.lastIndex=e,e+=H.exec(this.input)[0].length;var t=ti.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){H.lastIndex=e+t[0].length;var n=H.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||X.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,H.lastIndex=e,e+=H.exec(this.input)[0].length,this.input[e]===";"&&e++}};Z.eat=function(e){return this.type===e?(this.next(),!0):!1};Z.isContextual=function(e){return this.type===c.name&&this.value===e&&!this.containsEsc};Z.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};Z.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};Z.canInsertSemicolon=function(){return this.type===c.eof||this.type===c.braceR||X.test(this.input.slice(this.lastTokEnd,this.start))};Z.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};Z.semicolon=function(){!this.eat(c.semi)&&!this.insertSemicolon()&&this.unexpected()};Z.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};Z.expect=function(e){this.eat(e)||this.unexpected()};Z.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var nt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Z.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};Z.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};Z.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};Z.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var _=z.prototype;_.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"},ni={kind:"switch"};_.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;H.lastIndex=this.pos;var t=H.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(le(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(!Gs.test(a))return!0}return!1};_.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;H.lastIndex=this.pos;var e=H.exec(this.input),t=this.pos+e[0].length,n;return!X.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(we(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};_.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;H.lastIndex=this.pos;var n=H.exec(this.input),r=this.pos+n[0].length;if(X.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||we(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;H.lastIndex=s;var i=H.exec(this.input);if(i&&X.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 le(u,!0)||u===92};_.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};_.isUsing=function(e){return this.isUsingKeyword(!1,e)};_.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){H.lastIndex=this.pos;var i=H.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)}};_.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")};_.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};_.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")};_.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 nt,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))};_.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))};_.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,$e|(n?0:Ct),!1,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")};_.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")};_.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(ni),this.enterScope(0);for(var t,n=!1;this.type!==c.braceR;)if(this.type===c._case||this.type===c._default){var r=this.type===c._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(c.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};_.parseThrowStatement=function(e){return this.next(),X.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var ri=[];_.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?cn:0),this.checkLValPattern(e,t?hn:ge),this.expect(c.parenR),e};_.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")};_.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};_.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")};_.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")};_.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};_.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")};_.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};_.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")};_.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")};_.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")};_.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};_.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Pt:ge,!1)};var $e=1,Ct=2,mn=4;_.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===c.star&&t&Ct&&this.unexpected(),e.generator=this.eat(c.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&$e&&(e.id=t&mn&&this.type!==c.name?null:this.parseIdent(),e.id&&!(t&Ct)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Pt:ge:fn));var 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&$e||(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&$e?"FunctionDeclaration":"FunctionExpression")};_.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};_.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"&&si(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")};_.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&&Ze(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};_.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};_.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)};_.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Ze(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var 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")};_.parseClassField=function(e){return Ze(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Ze(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(c.eq)?(this.enterScope(Oe|et),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};_.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ke|et);this.type!==c.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};_.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)};_.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};_.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};_.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];Pe(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function si(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Ze(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}_.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")};_.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")};_.parseExportDeclaration=function(e){return this.parseStatement(null)};_.parseExportDefaultDeclaration=function(){var e;if(this.type===c._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,$e|mn,!1,e)}else if(this.type===c._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};_.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Pe(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};_.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)};_.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)}};_.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};_.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")};_.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};_.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=ri,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===c.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};_.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")};_.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportDefaultSpecifier")};_.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")};_.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};_.parseWithClause=function(){var e=[];if(!this.eat(c._with))return e;this.expect(c.braceL);for(var t={},n=!0;!this.eat(c.braceR);){if(n)n=!1;else if(this.expect(c.comma),this.afterTrailingComma(c.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;Pe(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};_.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")};_.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return Ys.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};_.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)};_.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var se=z.prototype;se.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var 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};se.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};se.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};se.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==c.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};se.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case c.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(c.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case c.braceL:return this.parseObj(!0)}return this.parseIdent()};se.parseBindingList=function(e,t,n,r){for(var s=[],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};se.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};se.parseBindingListItem=function(e){return e};se.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(c.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};se.checkLValSimple=function(e,t,n){t===void 0&&(t=Ke);var r=t!==Ke;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===ge&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(Pe(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==dn&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};se.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ke),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var 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)}};se.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ke),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ae=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},U={b_stat:new ae("{",!1),b_expr:new ae("{",!0),b_tmpl:new ae("${",!1),p_stat:new ae("(",!1),p_expr:new ae("(",!0),q_tmpl:new ae("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ae("function",!1),f_expr:new ae("function",!0),f_expr_gen:new ae("function",!0,!1,null,!0),f_gen:new ae("function",!1,!1,null,!0)},Re=z.prototype;Re.initialContext=function(){return[U.b_stat]};Re.curContext=function(){return this.context[this.context.length-1]};Re.braceIsBlock=function(e){var t=this.curContext();return t===U.f_expr||t===U.f_stat?!0:e===c.colon&&(t===U.b_stat||t===U.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?X.test(this.input.slice(this.lastTokEnd,this.start)):e===c._else||e===c.semi||e===c.eof||e===c.parenR||e===c.arrow?!0:e===c.braceL?t===U.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Re.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};Re.updateContext=function(e){var t,n=this.type;n.keyword&&e===c.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};Re.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};c.parenR.updateContext=c.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===U.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};c.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?U.b_stat:U.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(U.b_tmpl),this.exprAllowed=!0};c.parenL.updateContext=function(e){var t=e===c._if||e===c._for||e===c._with||e===c._while;this.context.push(t?U.p_stat:U.p_expr),this.exprAllowed=!0};c.incDec.updateContext=function(){};c._function.updateContext=c._class.updateContext=function(e){e.beforeExpr&&e!==c._else&&!(e===c.semi&&this.curContext()!==U.p_stat)&&!(e===c._return&&X.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===U.b_stat)?this.context.push(U.f_expr):this.context.push(U.f_stat),this.exprAllowed=!1};c.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};c.backQuote.updateContext=function(){this.curContext()===U.q_tmpl?this.context.pop():this.context.push(U.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===U.f_expr?this.context[t]=U.f_expr_gen:this.context[t]=U.f_gen}this.exprAllowed=!0};c.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==c.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var R=z.prototype;R.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var 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}};R.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};R.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new nt,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};R.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(c.question)){var 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};R.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};R.parseExprOp=function(e,t,n,r,s){var 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};R.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")};R.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"&&gn(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&kt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,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 gn(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&gn(e.expression)}function kt(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&kt(e.expression)||e.type==="ParenthesizedExpression"&&kt(e.expression)}R.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var 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};R.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}};R.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};R.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};R.parseSubscript=function(e,t,n,r,s,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 nt,f=this.yieldPos,m=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var v=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,d);if(s&&!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,v,i);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var y=this.startNodeAt(t,n);y.callee=e,y.arguments=v,o&&(y.optional=l),e=this.finishNode(y,"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 w=this.startNodeAt(t,n);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};R.parseExprAtom=function(e,t,n){this.type===c.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case c._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===c.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==c.dot&&this.type!==c.bracketL&&this.type!==c.parenL&&this.unexpected(),this.finishNode(r,"Super");case c._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case c.name:var 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(U.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(U.b_expr),this.parseObj(!1,e);case c._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case c._class:return this.parseClass(this.startNode(),!1);case c._new:return this.parseNew();case c.backQuote:return this.parseTemplate();case c._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};R.parseExprAtomDefault=function(){this.unexpected()};R.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===c.parenL&&!e)return this.parseDynamicImport(t);if(this.type===c.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};R.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(c.parenR)?e.options=null:(this.expect(c.comma),this.afterTrailingComma(c.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(c.parenR)||(this.expect(c.comma),this.afterTrailingComma(c.parenR)||this.unexpected())));else if(!this.eat(c.parenR)){var t=this.start;this.eat(c.comma)&&this.eat(c.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};R.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};R.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};R.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};R.shouldParseArrow=function(e){return!this.canInsertSemicolon()};R.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,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 nt,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 v=this.lastTokEnd,y=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",v,y)):s=l[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(n,r);return w.expression=s,this.finishNode(w,"ParenthesizedExpression")}else return s};R.parseParenItem=function(e){return e};R.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var ii=[];R.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===c.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(c.parenL)?e.arguments=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ii,this.finishNode(e,"NewExpression")};R.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===c.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
1
+ import{s as h,validate as dt,filter as Wt}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((i,a)=>He(i,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(i=>He(e[i],t[i]))}var Z=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 $r(e){return e instanceof Z||e&&e.$error===!0}var Ie=new Map,jr=3600*1e3,Br=100*1024,mt="proc_";function gt(e){return typeof e=="string"&&e.startsWith(mt)}function yt(e){let t=Ie.get(e);if(!t)throw new Error(`Procedure not found: ${e}`);if(Date.now()>t.expiresAt)throw Ie.delete(e),new Error(`Procedure expired: ${e}`);return t.ast}function Or(){return typeof crypto<"u"&&crypto.randomUUID?mt+crypto.randomUUID():mt+Math.random().toString(36).slice(2)+Date.now().toString(36)}var zt=new Set(["__proto__","constructor","prototype"]);function Vt(e){if(zt.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 Lr(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 Dr(e){return!!(/\([^)]*[+*][^)]*\)[+*]/.test(e)||/\(([^|)]+)\|\1\)[+*]/.test(e)||/\(\.\*\)\+/.test(e)||/\(\.\+\)\+/.test(e)||/\(\[.*\]\+\)\+/.test(e))}function xe(e){return{...e,state:Object.create(e.state)}}function Fr(e,t){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let a=e[i],s=t[i];s!==a&&(n[i]=s)}return n}function v(e,t){if(e&&typeof e=="object"&&e.$kind==="arg")return t.args[e.path];if(e&&typeof e=="object"&&e.$expr)return q(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 i of n)if(zt.has(i))throw new Error(`Security Error: Access to '${i}' is forbidden`);let r=t.state[n[0]];if(r!==void 0){for(let i=1;i<n.length;i++)r=r?.[n[i]];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]=v(e[r],t);return n}return Array.isArray(e)?e.map(n=>v(n,t)):e}function Ce(e,t,n){return new Proxy(t,{get(r,i){if(i in r)return r[i];let a=n?.[i];throw a?new Error(`${e}.${i} is not available. ${a}`):new Error(`${e}.${i} is not supported in AsyncJS. Check docs for available ${e} methods.`)}})}function Te(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:Te(e[0])};if(t==="object"){let n={},r=[];for(let[i,a]of Object.entries(e))n[i]=Te(a),r.push(i);return{type:"object",properties:n,required:r}}return{}}var he={Math:Ce("Math",{PI:Math.PI,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,SQRT2:Math.SQRT2,SQRT1_2:Math.SQRT1_2,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc,sign:Math.sign,sqrt:Math.sqrt,cbrt:Math.cbrt,pow:Math.pow,exp:Math.exp,expm1:Math.expm1,log:Math.log,log2:Math.log2,log10:Math.log10,log1p:Math.log1p,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,asinh:Math.asinh,acosh:Math.acosh,atanh:Math.atanh,hypot:Math.hypot,min:Math.min,max:Math.max,clz32:Math.clz32,imul:Math.imul,fround:Math.fround,random:()=>{if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]/4294967296}return Math.random()}}),JSON:Ce("JSON",{parse:e=>JSON.parse(e),stringify:(e,t,n)=>JSON.stringify(e,t,n)}),console:Ce("console",{log:(...e)=>{},warn:(...e)=>{},error:(...e)=>{},info:(...e)=>{}},{table:"Use console.log with JSON.stringify for structured data.",dir:"Use console.log instead.",trace:"Stack traces are not available in AsyncJS."}),Array:Ce("Array",{isArray:e=>Array.isArray(e),from:(e,t,n)=>Array.from(e,t,n),of:(...e)=>Array.of(...e)},{prototype:"Prototype access is not allowed."}),Object:Ce("Object",{keys:e=>Object.keys(e),values:e=>Object.values(e),entries:e=>Object.entries(e),fromEntries:e=>Object.fromEntries(e),assign:(e,...t)=>Object.assign({},e,...t),hasOwn:(e,t)=>Object.hasOwn(e,t)},{prototype:"Prototype access is not allowed.",create:"Use object literals instead.",defineProperty:"Property descriptors are not supported.",getPrototypeOf:"Prototype access is not allowed.",setPrototypeOf:"Prototype modification is not allowed."}),String:Ce("String",{fromCharCode:(...e)=>String.fromCharCode(...e),fromCodePoint:(...e)=>String.fromCodePoint(...e)}),Number:Ce("Number",{isNaN:Number.isNaN,isFinite:Number.isFinite,isInteger:Number.isInteger,isSafeInteger:Number.isSafeInteger,parseFloat,parseInt,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,NaN:Number.NaN,EPSILON:Number.EPSILON}),parseInt,parseFloat,isNaN,isFinite,encodeURI,decodeURI,encodeURIComponent,decodeURIComponent,undefined:void 0,null:null,NaN:NaN,Infinity:1/0,filter:(e,t)=>{let n=Te(t),r=Wt(e,n);if(r instanceof Error)throw r;return r},Schema:{...h,response:(e,t)=>{let n=t?.schema!=null?t.schema:Te(t);return{type:"json_schema",json_schema:{name:e,strict:!0,schema:n}}},fromExample:e=>Te(e),isValid:(e,t)=>t?.schema!=null?dt(e,t):dt(e,Te(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(i=>r.includes(i)))},diff(n){let r=n?.toArray?.()??n??[];return he.Set(t.filter(i=>!r.includes(i)))},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:i=0,days:a=0,hours:s=0,minutes:o=0,seconds:l=0,ms:u=0}={}){let p=new globalThis.Date(n.getTime());return r&&p.setFullYear(p.getFullYear()+r),i&&p.setMonth(p.getMonth()+i),a&&p.setDate(p.getDate()+a),s&&p.setHours(p.getHours()+s),o&&p.setMinutes(p.getMinutes()+o),l&&p.setSeconds(p.getSeconds()+l),u&&p.setMilliseconds(p.getMilliseconds()+u),e(p)},diff(r,i="ms"){let a=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime(),s=n.getTime()-a;switch(i){case"seconds":return s/1e3;case"minutes":return s/6e4;case"hours":return s/36e5;case"days":return s/864e5;default:return s}},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 i=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime();return n.getTime()<i},isAfter(r){let i=typeof r=="object"&&r.timestamp?r.timestamp:new globalThis.Date(r).getTime();return n.getTime()>i},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."},Ur=.01,Lt=1e-4,Dt=.001,qr=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 q(e,t){if(e==null||typeof e!="object"||!("$expr"in e))return e;if(t.fuel&&(t.fuel.current-=Ur,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=q(e.object,t);if(e.optional&&n==null)return;let r=typeof e.property=="object"&&e.property!==null?q(e.property,t):e.property;return Vt(String(r)),n?.[r]}case"binary":{let n=q(e.left,t),r=q(e.right,t);switch(e.op){case"+":{let i=n+r;if(typeof i=="string"&&t.fuel&&(t.fuel.current-=i.length*Lt,t.fuel.current<=0)){t.error=new Z("Out of Fuel","expr.concat");return}return i}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=q(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=q(e.left,t);return e.op==="&&"?n&&q(e.right,t):e.op==="??"?n??q(e.right,t):n||q(e.right,t)}case"conditional":{let n=q(e.test,t);return q(n?e.consequent:e.alternate,t)}case"array":return e.elements.map(n=>q(n,t));case"object":{let n={};for(let r of e.properties)n[r.key]=q(r.value,t);return n}case"call":{if(e.callee==="Error"){let r=e.arguments.map(a=>q(a,t)),i=typeof r[0]=="string"?r[0]:"Error";t.error=new Z(i,"Error");return}if(e.callee in he){let r=he[e.callee];if(typeof r=="function"){let i=e.arguments.map(a=>q(a,t));return r(...i)}}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=q(e.object,t);if(e.optional&&n==null)return;let r=e.method;if(Vt(r),n==null)throw new Error(`Cannot call method '${r}' on ${n}`);let i=n[r];if(typeof i!="function")throw new Error(`'${r}' is not a function`);let a=e.arguments.map(o=>q(o,t)),s=i.apply(n,a);if(t.fuel&&qr.has(r)){let o=0;if(typeof s=="string"?o=s.length*Lt:Array.isArray(s)?o=s.length*Dt:typeof s=="object"&&s!==null&&(o=Object.keys(s).length*Dt),t.fuel.current-=o,t.fuel.current<=0){t.error=new Z("Out of Fuel",`expr.${r}`);return}}return s}default:throw new Error(`Unknown expression type: ${e.$expr}`)}}function T(e,t,n,r,i={}){let{docs:a="",timeoutMs:s=1e3,cost:o=1}=typeof i=="string"?{docs:i}:i;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,x=p.fuel.current,y,w;try{let k=p.costOverrides?.[e],b=k!==void 0?k:o,C=typeof b=="function"?b(m,p):b;if((p.fuel.current-=C)<=0){p.error=new Z("Out of Fuel",e);return}let I,E=async()=>r(u,p);if(y=s>0?await Promise.race([E(),new Promise((S,P)=>{I=setTimeout(()=>P(new Error(`Atom '${e}' timed out`)),s)})]).finally(()=>clearTimeout(I)):await E(),u.result){if(p.consts.has(u.result))throw new Error(`Cannot reassign const variable '${u.result}'`);if(y!==void 0&&n&&!dt(y,n)){p.error=new Z(`Output validation failed for '${e}'`,e);return}p.state[u.result]=y,u.resultConst&&p.consts.add(u.result)}}catch(k){w=k.message||String(k),p.error=new Z(w,e,k)}finally{if(p.trace&&g){let k=Fr(g,p.state);p.trace.push({op:e,input:m,stateDiff:k,result:y,error:w,fuelBefore:x,fuelAfter:p.fuel.current,timestamp:new Date().toISOString()})}}},docs:a,timeoutMs:s,cost:o,create:u=>({op:e,...u})}}var te=T("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}),Wr=T("if",h.object({condition:h.any,then:h.array(h.any),else:h.array(h.any).optional}),void 0,async(e,t)=>{q(e.condition,t)?await te.exec({op:"seq",steps:e.then},t):e.else&&await te.exec({op:"seq",steps:e.else},t)},{docs:"If/Else",timeoutMs:0,cost:.1}),zr=T("while",h.object({condition:h.any,body:h.array(h.any)}),void 0,async(e,t)=>{for(;q(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 te.exec({op:"seq",steps:e.body},t),t.output!==void 0||t.error)return}},{docs:"While Loop",timeoutMs:0,cost:.1}),Gr=T("return",void 0,h.any,async(e,t)=>{if(t.error)return t.output=t.error,t.error;if("value"in e){let r=v(e.value,t);if(r!=null&&!$r(r)&&(typeof r!="object"||Array.isArray(r))){let i=new Z(`Agent must return an object, got ${Array.isArray(r)?"array":typeof r}`,"return");return t.error=i,t.output=i,i}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=Wt(n,e.schema);r instanceof Error||(n=r)}}return t.output=n,n},{docs:"Return",cost:.1}),Hr=T("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 te.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 te.exec({op:"seq",steps:e.catch},t)}},{docs:"Try/Catch",timeoutMs:0,cost:.1}),Jr=T("Error",h.object({args:h.array(h.any).optional}),void 0,async(e,t)=>{let n=e.args?.[0]??"Error";t.error=new Z(String(n),"Error")},{docs:"Trigger error flow",cost:.1}),Kr=T("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]=v(t,n)},{docs:"Set Variable",cost:.1}),Zr=T("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]=v(t,n),n.consts.add(e)},{docs:"Set Const Variable (immutable)",cost:.1}),Qr=T("varGet",h.object({key:h.string}),h.any,async({key:e},t)=>v(e,t),{docs:"Get Variable",cost:.1}),Yr=T("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]=v({$kind:"arg",path:n},t);else for(let[n,r]of Object.entries(e))t.state[n]=v({$kind:"arg",path:r},t)},{docs:"Import variables from args into the current scope, with optional renaming.",cost:.2}),Xr=T("varsLet",h.record(h.any),void 0,async(e,t)=>{for(let n of Object.keys(e))n==="op"||n==="result"||(t.state[n]=v(e[n],t))},{docs:"Initialize a set of variables in the current scope from the step object properties.",cost:.1}),ei=T("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]=v(r,t);else for(let[r,i]of Object.entries(e))n[r]=v(i,t);return n},{docs:"Export variables from the current scope, with optional renaming.",cost:.2}),ti=T("scope",h.object({steps:h.array(h.any)}),void 0,async({steps:e},t)=>{let n=xe(t);await te.exec({op:"seq",steps:e},n),n.output!==void 0&&(t.output=n.output)},{docs:"Create new scope",timeoutMs:0,cost:.1}),ni=T("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 i=[],a=v(e,r);if(!Array.isArray(a))throw new Error("map: items is not an array");for(let s of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=s,await te.exec({op:"seq",steps:n},o),i.push(o.state.result??null)}return i},{docs:"Map Array",timeoutMs:0,cost:1}),ri=T("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 i=[],a=v(e,r);if(!Array.isArray(a))throw new Error("filter: items is not an array");for(let s of a){if(r.signal?.aborted)throw new Error("Execution aborted");let o=xe(r);o.state[t]=s,q(n,o)&&i.push(s)}return i},{docs:"Filter Array",timeoutMs:0,cost:1}),ii=T("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:i},a)=>{let s=v(e,a),o=v(r,a);if(!Array.isArray(s))throw new Error("reduce: items is not an array");let l=o;for(let u of s){if(a.signal?.aborted)throw new Error("Execution aborted");let p=xe(a);p.state[t]=u,p.state[n]=l,await te.exec({op:"seq",steps:i},p),l=p.state.result??l}return l},{docs:"Reduce Array",timeoutMs:0,cost:1}),si=T("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 i=v(e,r);if(!Array.isArray(i))throw new Error("find: items is not an array");for(let a of i){if(r.signal?.aborted)throw new Error("Execution aborted");let s=xe(r);if(s.state[t]=a,q(n,s))return a}return null},{docs:"Find in Array",timeoutMs:0,cost:1}),ai=T("push",h.object({list:h.array(h.any),item:h.any}),h.array(h.any),async({list:e,item:t},n)=>{let r=v(e,n),i=v(t,n);return Array.isArray(r)&&r.push(i),r},{docs:"Push to Array",cost:1}),oi=T("len",h.object({list:h.any}),h.number,async({list:e},t)=>{let n=v(e,t);return Array.isArray(n)||typeof n=="string"?n.length:0},{docs:"Length",cost:1}),li=T("split",h.object({str:h.string,sep:h.string}),h.array(h.string),async({str:e,sep:t},n)=>v(e,n).split(v(t,n)),{docs:"Split String",cost:1}),ui=T("join",h.object({list:h.array(h.string),sep:h.string}),h.string,async({list:e,sep:t},n)=>v(e,n).join(v(t,n)),{docs:"Join String",cost:1}),ci=T("template",h.object({tmpl:h.string,vars:h.record(h.any)}),h.string,async({tmpl:e,vars:t},n)=>v(e,n).replace(/\{\{(\w+)\}\}/g,(i,a)=>String(v(t[a],n)??"")),{docs:"String Template",cost:1}),pi=T("regexMatch",h.object({pattern:h.string,value:h.any}),h.boolean,async({pattern:e,value:t},n)=>{if(Dr(e))throw new Error(`Suspicious regex pattern rejected (potential ReDoS): ${e}`);let r=v(t,n);return new RegExp(e).test(r)},{docs:"Returns true if the value matches the regex pattern.",cost:2}),fi=T("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=v(e,n),i=v(t,n),a={};return r&&Array.isArray(i)&&i.forEach(s=>a[s]=r[s]),a},{docs:"Pick Keys",cost:1}),hi=T("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=v(e,n),i=new Set(v(t,n)),a={};return r&&Object.keys(r).forEach(s=>{i.has(s)||(a[s]=r[s])}),a},{docs:"Omit Keys",cost:1}),di=T("merge",h.object({a:h.record(h.any),b:h.record(h.any)}),h.record(h.any),async({a:e,b:t},n)=>({...v(e,n),...v(t,n)}),{docs:"Merge Objects",cost:1}),mi=T("keys",h.object({obj:h.record(h.any)}),h.array(h.string),async({obj:e},t)=>Object.keys(v(e,t)??{}),{docs:"Object Keys",cost:1}),Ft=10,Ut="X-Agent-Depth";function gi(e,t){try{let r=new URL(e).hostname.toLowerCase();for(let i of t){let a=i.toLowerCase();if(a.startsWith("*.")){let s=a.slice(1);if(r.endsWith(s)||r===a.slice(2))return!0}else if(r===a)return!0}return!1}catch{return!1}}var yi=T("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=v(e.url,t),r=v(e.method,t),i=v(e.headers,t)||{},a=v(e.body,t),s=v(e.responseType,t),o=t.context?.requestDepth??0;if(o>=Ft)throw new Error(`Agent request depth exceeded (max ${Ft}). This prevents recursive agent loops.`);if(t.capabilities.fetch)return t.capabilities.fetch(n,{method:r,headers:{...i,[Ut]:String(o+1)},body:a,signal:t.signal,responseType:s});let l=t.context?.allowedFetchDomains;if(l){if(!gi(n,l))throw new Error(`Fetch blocked: domain not in allowlist. Allowed: ${l.join(", ")}`)}else{if(Lr(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}`)}}if(typeof globalThis.fetch=="function"){let u=await globalThis.fetch(n,{method:r,headers:{...i,[Ut]:String(o+1)},body:a?JSON.stringify(a):void 0,signal:t.signal});if(s==="dataUrl"){let d=await u.arrayBuffer(),f=new Uint8Array(d),m="";for(let y=0;y<f.length;y++)m+=String.fromCharCode(f[y]);let g=btoa(m);return`data:${u.headers.get("content-type")||"application/octet-stream"};base64,${g}`}let p=u.headers.get("content-type");return s==="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}),bi=T("storeGet",h.object({key:h.string}),h.any,async({key:e},t)=>{let n=v(e,t);return t.capabilities.store?.get(n)},{docs:"Store Get",cost:5}),xi=T("storeSet",h.object({key:h.string,value:h.any}),void 0,async({key:e,value:t},n)=>{let r=v(e,n),i=v(t,n);return n.capabilities.store?.set(r,i)},{docs:"Store Set",cost:5}),vi=T("storeQuery",h.object({query:h.any}),h.array(h.any),async({query:e},t)=>t.capabilities.store?.query?.(v(e,t))??[],{docs:"Store Query",cost:5}),wi=T("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?.(v(e,r),v(t,r),v(n,r))??[],{docs:"Vector Search",cost:(e,t)=>5+(v(e.k,t)??5)}),Si=T("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(v(e,n),v(t,n))},{docs:"LLM Predict",timeoutMs:12e4,cost:100}),Ei=T("agentRun",h.object({agentId:h.any,input:h.any}),h.any,async({agentId:e,input:t},n)=>{let r=v(e,n),i=v(t,n),a=i;if(i&&typeof i=="object"&&!Array.isArray(i)){a={};for(let o in i)a[o]=v(i[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 s=await n.capabilities.agent.run(r,a);if(s&&typeof s=="object"&&"fuelUsed"in s&&typeof s.fuelUsed=="number"){if(s.error)throw new Error(s.error.message||"Sub-agent failed");return s.result}return s},{docs:"Run Sub-Agent (accepts procedure token, AST, or agent ID)",cost:1}),ki=T("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=v(e,t);try{return t.capabilities.code.transpile(n)}catch(r){throw new Error(`Code transpilation failed: ${r.message}`)}},{docs:"Transpile AsyncJS code to AST",cost:1}),qt=10,Ci=T("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>=qt)throw new Error(`runCode recursion limit exceeded (max ${qt}). 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 i=v(e,n),a=t?v(t,n):{},s;try{s=n.capabilities.code.transpile(i)}catch(l){throw new Error(`Code transpilation failed: ${l.message}`)}if(s.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 te.exec(s,o),o.error){n.error=o.error;return}return o.output},{docs:"Run dynamically generated AsyncJS code",cost:1}),Ai=T("jsonParse",h.object({str:h.string}),h.any,async({str:e},t)=>JSON.parse(v(e,t)),{docs:"Parse JSON",cost:1}),_i=T("jsonStringify",h.object({value:h.any}),h.string,async({value:e},t)=>JSON.stringify(v(e,t)),{docs:"Stringify JSON",cost:1}),Ti=T("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(v(e,t))},{docs:"Parse XML",cost:1}),Ii=T("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=v(e,n)??await bt.exec({value:t,algorithm:"SHA-256"},n);if(n.memo.has(r))return n.memo.get(r);let i=xe(n);await te.exec({op:"seq",steps:t},i);let a=i.output??i.state.result;return n.memo.set(r,a),a},{docs:"Memoize steps result in memory",cost:1}),Pi=T("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:${v(e,r)??await bt.exec({value:t,algorithm:"SHA-256"},r)}`,s=await r.capabilities.store.get(a);if(s)if(typeof s=="object"&&s._exp){if(Date.now()<s._exp)return s.val}else return s;let o=xe(r);await te.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}),Ni=T("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},i)=>{let a=v(n,i)??"float",s=v(r,i)??10,o=v(e,i)??0,l=v(t,i)??1;if(a==="base36"){let f="0123456789abcdefghijklmnopqrstuvwxyz",m="";if(typeof crypto<"u"&&crypto.getRandomValues){let g=new Uint8Array(s);crypto.getRandomValues(g);for(let x=0;x<s;x++)m+=f[g[x]%36]}else for(let g=0;g<s;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}),Ri=T("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=T("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(v(e,n)),i=v(t,n)||"SHA-256";if(typeof crypto<"u"&&crypto.subtle){let o=new TextEncoder().encode(r),l=await crypto.subtle.digest(i,o);return Array.from(new Uint8Array(l)).map(p=>p.toString(16).padStart(2,"0")).join("")}let a=0;for(let s=0;s<r.length;s++){let o=r.charCodeAt(s);a=(a<<5)-a+o,a|=0}return String(a)},{docs:"Hash a value",cost:1}),Mi=T("consoleLog",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=v(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}),$i=T("consoleWarn",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=v(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}),ji=T("consoleError",h.object({message:h.any}),void 0,async({message:e},t)=>{let n=v(e,t),r=typeof n=="string"?n:JSON.stringify(n);t.error=new Z(r,"console.error")},{docs:"Emit error and stop",cost:.1}),Bi=T("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 i=v(e,r),a=t?v(t,r):jr,s=n?v(n,r):Br;if(!i||typeof i!="object"||!i.op)throw new Error('Invalid AST: must be an object with an "op" property');let o=JSON.stringify(i);if(o.length>s)throw new Error(`AST too large: ${o.length} bytes exceeds limit of ${s} bytes. Consider reducing AST size or using a shorter TTL.`);let l=Or(),u=Date.now();return Ie.set(l,{ast:i,createdAt:u,expiresAt:u+a}),l},{docs:"Store an AST and return a token for later execution",cost:1}),Oi=T("releaseProcedure",h.object({token:h.string}),h.boolean,async({token:e},t)=>{let n=v(e,t);return Ie.delete(n)},{docs:"Release a stored procedure by token",cost:.1}),Vi=T("clearExpiredProcedures",void 0,h.number,async()=>{let e=Date.now(),t=0;for(let[n,r]of Ie)e>r.expiresAt&&(Ie.delete(n),t++);return t},{docs:"Clear all expired procedures and return count",cost:.5}),Gt={seq:te,if:Wr,while:zr,return:Gr,try:Hr,Error:Jr,varSet:Kr,constSet:Zr,varGet:Qr,varsImport:Yr,varsLet:Xr,varsExport:ei,scope:ti,map:ni,filter:ri,reduce:ii,find:si,push:ai,len:oi,split:li,join:ui,template:ci,regexMatch:pi,pick:fi,omit:hi,merge:di,keys:mi,httpFetch:yi,storeGet:bi,storeSet:xi,storeQuery:vi,storeVectorSearch:wi,llmPredict:Si,agentRun:Ei,transpileCode:ki,runCode:Ci,jsonParse:Ai,jsonStringify:_i,xmlParse:Ti,memoize:Ii,cache:Pi,random:Ni,uuid:Ri,hash:bt,consoleLog:Mi,consoleWarn:$i,consoleError:ji,storeProcedure:Bi,releaseProcedure:Oi,clearExpiredProcedures:Vi};var Li=new Set(["true","false","null","undefined","and","or","not"]);function Di(e,t){let n=e.replace(/"[^"]*"/g,'""').replace(/'[^']*'/g,"''"),r=[],i=/(?<![.])\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,a;for(;(a=i.exec(n))!==null;)r.push(a[1]);let o=[...new Set(r)].filter(l=>!Li.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){Di(e,t);let n=Fi(e),r=Qt(n,0,t);if(r.pos<n.length){let i=n.slice(r.pos).join(" ");throw new Error(`Unsupported condition syntax near '${i}' in: ${e}
2
+ Supported: comparisons, &&, ||, !, arithmetic, member access (a.b), literals`)}return r.node}function Fi(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++],i="";for(;n<e.length&&e[n]!==r;)e[n]==="\\"&&n+1<e.length&&n++,i+=e[n++];n++,t.push(JSON.stringify(i));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 Qt(e,t,n){return Ui(e,t,n)}function Ui(e,t,n){let{node:r,pos:i}=Ht(e,t,n);for(;e[i]==="||";){i++;let{node:a,pos:s}=Ht(e,i,n);r={$expr:"logical",op:"||",left:r,right:a},i=s}return{node:r,pos:i}}function Ht(e,t,n){let{node:r,pos:i}=Jt(e,t,n);for(;e[i]==="&&";){i++;let{node:a,pos:s}=Jt(e,i,n);r={$expr:"logical",op:"&&",left:r,right:a},i=s}return{node:r,pos:i}}function Jt(e,t,n){let{node:r,pos:i}=Kt(e,t,n),a=["==","!=",">","<",">=","<="];for(;a.includes(e[i]);){let s=e[i++],{node:o,pos:l}=Kt(e,i,n);r={$expr:"binary",op:s,left:r,right:o},i=l}return{node:r,pos:i}}function Kt(e,t,n){let{node:r,pos:i}=Zt(e,t,n);for(;e[i]==="+"||e[i]==="-";){let a=e[i++],{node:s,pos:o}=Zt(e,i,n);r={$expr:"binary",op:a,left:r,right:s},i=o}return{node:r,pos:i}}function Zt(e,t,n){let{node:r,pos:i}=xt(e,t,n);for(;e[i]==="*"||e[i]==="/"||e[i]==="%";){let a=e[i++],{node:s,pos:o}=xt(e,i,n);r={$expr:"binary",op:a,left:r,right:s},i=o}return{node:r,pos:i}}function xt(e,t,n){if(e[t]==="!"||e[t]==="-"){let r=e[t++],{node:i,pos:a}=xt(e,t,n);return{node:{$expr:"unary",op:r,argument:i},pos:a}}return qi(e,t,n)}function qi(e,t,n){let r=e[t];if(r==="("){let{node:i,pos:a}=Qt(e,t+1,n);return{node:i,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 i={$expr:"ident",name:r},a=t+1;for(;e[a]===".";){a++;let s=e[a++];i={$expr:"member",object:i,property:s}}return{node:i,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,i)=>{if(r in n)return n[r];if(typeof r=="string"&&r in n.atoms)return a=>{let s=n.atoms[r];return n.add(s.create(a)),i}}}),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,i){let a=new e(this.atoms);r(a);let s;if(i){let u=new e(this.atoms);i(u),s=u.steps}let o=Je(t,n),l=this.atoms.if;return this.add(l.create({condition:o,then:a.steps,else:s}))}while(t,n,r){let i=new e(this.atoms);r(i);let a=Je(t,n),s=this.atoms.while;return this.add(s.create({condition:a,body:i.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 i=new e(this.atoms);r(i);let a=this.atoms.map;return this.add(a.create({items:t,as:n,steps:i.steps}))}filter(t,n,r,i={}){let a=Je(r,i),s=this.atoms.filter;return this.add(s.create({items:t,as:n,condition:a}))}find(t,n,r,i={}){let a=Je(r,i),s=this.atoms.find;return this.add(s.create({items:t,as:n,condition:a}))}reduce(t,n,r,i,a){let s=new e(this.atoms);a(s);let o=this.atoms.reduce;return this.add(o.create({items:t,as:n,accumulator:r,initial:i,steps:s.steps}))}memoize(t,n){let r=new e(this.atoms);t(r);let i=this.atoms.memoize;return this.add(i.create({key:n,steps:r.steps}))}cache(t,n,r){let i=new e(this.atoms);t(i);let a=this.atoms.cache;return this.add(a.create({key:n,steps:i.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 i=this.atoms.try;return this.add(i.create({try:n.steps,catch:r}))}};import{validate as oa}from"tosijs-schema";var Wi=[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],rn=[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],zi="\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",sn="\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",Gi={5:wt,"5module":wt+" export import",6:wt+" const class extends export import super"},Hi=/^in(stanceof)?$/,Ji=new RegExp("["+sn+"]"),Ki=new RegExp("["+sn+zi+"]");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 le(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Ji.test(String.fromCharCode(e)):t===!1?!1:Et(e,rn)}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&&Ki.test(String.fromCharCode(e)):t===!1?!1:Et(e,rn)||Et(e,Wi)}var V=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 V(e,{beforeExpr:!0,binop:t})}var re={beforeExpr:!0},Y={startsExpr:!0},_t={};function B(e,t){return t===void 0&&(t={}),t.keyword=e,_t[e]=new V(e,t)}var c={num:new V("num",Y),regexp:new V("regexp",Y),string:new V("string",Y),name:new V("name",Y),privateId:new V("privateId",Y),eof:new V("eof"),bracketL:new V("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new V("]"),braceL:new V("{",{beforeExpr:!0,startsExpr:!0}),braceR:new V("}"),parenL:new V("(",{beforeExpr:!0,startsExpr:!0}),parenR:new V(")"),comma:new V(",",re),semi:new V(";",re),colon:new V(":",re),dot:new V("."),question:new V("?",re),questionDot:new V("?."),arrow:new V("=>",re),template:new V("template"),invalidTemplate:new V("invalidTemplate"),ellipsis:new V("...",re),backQuote:new V("`",Y),dollarBraceL:new V("${",{beforeExpr:!0,startsExpr:!0}),eq:new V("=",{beforeExpr:!0,isAssign:!0}),assign:new V("_=",{beforeExpr:!0,isAssign:!0}),incDec:new V("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new V("!/~",{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 V("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ne("%",10),star:ne("*",10),slash:ne("/",10),starstar:new V("**",{beforeExpr:!0}),coalesce:ne("??",1),_break:B("break"),_case:B("case",re),_catch:B("catch"),_continue:B("continue"),_debugger:B("debugger"),_default:B("default",re),_do:B("do",{isLoop:!0,beforeExpr:!0}),_else:B("else",re),_finally:B("finally"),_for:B("for",{isLoop:!0}),_function:B("function",Y),_if:B("if"),_return:B("return",re),_switch:B("switch"),_throw:B("throw",re),_try:B("try"),_var:B("var"),_const:B("const"),_while:B("while",{isLoop:!0}),_with:B("with"),_new:B("new",{beforeExpr:!0,startsExpr:!0}),_this:B("this",Y),_super:B("super",Y),_class:B("class",Y),_extends:B("extends",re),_export:B("export"),_import:B("import",Y),_null:B("null",Y),_true:B("true",Y),_false:B("false",Y),_in:B("in",{beforeExpr:!0,binop:7}),_instanceof:B("instanceof",{beforeExpr:!0,binop:7}),_typeof:B("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:B("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:B("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},X=/\r\n?|\n|\u2028|\u2029/,Zi=new RegExp(X.source,"g");function Pe(e){return e===10||e===13||e===8232||e===8233}function an(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(Pe(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var on=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ln=Object.prototype,Qi=ln.hasOwnProperty,Yi=ln.toString,Ne=Object.hasOwn||(function(e,t){return Qi.call(e,t)}),Yt=Array.isArray||(function(e){return Yi.call(e)==="[object Array]"}),Xt=Object.create(null);function ve(e){return Xt[e]||(Xt[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 Xi=/(?:[\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 un(e,t){for(var n=1,r=0;;){var i=an(e,r,t);if(i<0)return new Oe(n,t-r);++n,r=i}}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},en=!1;function es(e){var t={};for(var n in kt)t[n]=e&&Ne(e,n)?e[n]:kt[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!en&&typeof console=="object"&&console.warn&&(en=!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),Yt(t.onToken)){var r=t.onToken;t.onToken=function(i){return r.push(i)}}return Yt(t.onComment)&&(t.onComment=ts(t,t.onComment)),t}function ts(e,t){return function(n,r,i,a,s,o){var l={type:n?"Block":"Line",value:r,start:i,end:a};e.locations&&(l.loc=new et(this,s,o)),e.ranges&&(l.range=[i,a]),t.push(l)}}var Ve=1,Re=2,Tt=4,cn=8,It=16,pn=32,tt=64,fn=128,Ae=256,Le=512,nt=Ve|Re|Ae;function Pt(e,t){return Re|(e?Tt:0)|(t?cn:0)}var Ze=0,Nt=1,ge=2,hn=3,dn=4,mn=5,G=function(t,n,r){this.options=t=es(t),this.sourceFile=t.sourceFile,this.keywords=ve(Gi[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var i="";t.allowReserved!==!0&&(i=vt[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(i+=" await")),this.reservedWords=ve(i);var a=(i?i+" ":"")+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(X).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=c.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Ve),this.regexpState=null,this.privateNameStack=[]},ue={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)};ue.inFunction.get=function(){return(this.currentVarScope().flags&Re)>0};ue.inGenerator.get=function(){return(this.currentVarScope().flags&cn)>0};ue.inAsync.get=function(){return(this.currentVarScope().flags&Tt)>0};ue.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ae|Le))return!1;if(n&Re)return(n&Tt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};ue.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&tt)>0||this.options.allowSuperOutsideMethod};ue.allowDirectSuper.get=function(){return(this.currentThisScope().flags&fn)>0};ue.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};ue.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ae|Le)||n&Re&&!(n&It))return!0}return!1};ue.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ae)>0};G.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,i=0;i<t.length;i++)r=t[i](r);return r};G.parse=function(t,n){return new this(n,t).parse()};G.parseExpressionAt=function(t,n,r){var i=new this(r,t,n);return i.nextToken(),i.parseExpression()};G.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(G.prototype,ue);var Q=G.prototype,ns=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Q.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){J.lastIndex=e,e+=J.exec(this.input)[0].length;var t=ns.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){J.lastIndex=e+t[0].length;var n=J.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===";"||i==="}"||X.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,J.lastIndex=e,e+=J.exec(this.input)[0].length,this.input[e]===";"&&e++}};Q.eat=function(e){return this.type===e?(this.next(),!0):!1};Q.isContextual=function(e){return this.type===c.name&&this.value===e&&!this.containsEsc};Q.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};Q.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};Q.canInsertSemicolon=function(){return this.type===c.eof||this.type===c.braceR||X.test(this.input.slice(this.lastTokEnd,this.start))};Q.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};Q.semicolon=function(){!this.eat(c.semi)&&!this.insertSemicolon()&&this.unexpected()};Q.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};Q.expect=function(e){this.eat(e)||this.unexpected()};Q.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var rt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Q.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")}};Q.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")};Q.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")};Q.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var _=G.prototype;_.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,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[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"},rs={kind:"switch"};_.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var t=J.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(le(r,!0)){for(var i=n+1;we(r=this.input.charCodeAt(i),!0);)++i;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,i);if(!Hi.test(a))return!0}return!1};_.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var e=J.exec(this.input),t=this.pos+e[0].length,n;return!X.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(we(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};_.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;J.lastIndex=this.pos;var n=J.exec(this.input),r=this.pos+n[0].length;if(X.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!=="using"||i===this.input.length||we(a=this.input.charCodeAt(i))||a>55295&&a<56320)return!1;J.lastIndex=i;var s=J.exec(this.input);if(s&&X.test(this.input.slice(i,i+s[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 le(u,!0)||u===92};_.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};_.isUsing=function(e){return this.isUsingKeyword(!1,e)};_.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=c._var,a="let"),r){case c._break:case c._continue:return this.parseBreakContinueStatement(i,r.keyword);case c._debugger:return this.parseDebuggerStatement(i);case c._do:return this.parseDoStatement(i);case c._for:return this.parseForStatement(i);case c._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case c._class:return e&&this.unexpected(),this.parseClass(i,!0);case c._if:return this.parseIfStatement(i);case c._return:return this.parseReturnStatement(i);case c._switch:return this.parseSwitchStatement(i);case c._throw:return this.parseThrowStatement(i);case c._try:return this.parseTryStatement(i);case c._const:case c._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(i,a);case c._while:return this.parseWhileStatement(i);case c._with:return this.parseWithStatement(i);case c.braceL:return this.parseBlock(!0,i);case c.semi:return this.parseEmptyStatement(i);case c._export:case c._import:if(this.options.ecmaVersion>10&&r===c._import){J.lastIndex=this.pos;var s=J.exec(this.input),o=this.pos+s[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(i,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(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!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(i,!1,u),this.semicolon(),this.finishNode(i,"VariableDeclaration");var p=this.value,d=this.parseExpression();return r===c.name&&d.type==="Identifier"&&this.eat(c.colon)?this.parseLabeledStatement(i,p,d,e):this.parseExpressionStatement(i,d)}};_.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 i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};_.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};_.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")};_.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(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var a=this.isContextual("let"),s=!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||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===c._in&&this.unexpected(t),e.await=!0):s&&this.options.ecmaVersion>=8&&(f.start===d&&!u&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&s&&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))};_.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))};_.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Be|(n?0:Ct),!1,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")};_.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")};_.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(c.braceL),this.labels.push(rs),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")};_.parseThrowStatement=function(e){return this.next(),X.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var is=[];_.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?pn:0),this.checkLValPattern(e,t?dn:ge),this.expect(c.parenR),e};_.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")};_.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};_.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")};_.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")};_.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};_.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1){var s=a[i];s.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")};_.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};_.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")};_.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")};_.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")};_.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(c.eq)?i.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&&i.id.type!=="Identifier"&&!(t&&(this.type===c._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):i.init=null,e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(c.comma))break}return e};_.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,gn=4;_.parseFunction=function(e,t,n,r,i){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&gn&&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:hn));var a=this.yieldPos,s=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,i),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(e,t&Be?"FunctionDeclaration":"FunctionExpression")};_.parseFunctionParams=function(e){this.expect(c.parenL),e.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};_.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(c.braceL);this.type!==c.braceR;){var s=this.parseClassElement(e.superClass!==null);s&&(i.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&ss(r,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};_.parseClassElement=function(e){if(this.eat(c.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",i=!1,a=!1,s="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)&&(i=!0),!r&&!a&&!i){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=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||s!=="method"||i||a){var u=!n.static&&Qe(n,"constructor"),p=u&&e;u&&s!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=u?"constructor":s,this.parseClassMethod(n,i,a,p)}else this.parseClassField(n);return n};_.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};_.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)};_.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind==="constructor"?(t&&this.raise(i.start,"Constructor can't be a generator"),n&&this.raise(i.start,"Constructor can't be an async method")):e.static&&Qe(e,"prototype")&&this.raise(i.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")};_.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")};_.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ae|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")};_.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)};_.parseClassSuper=function(e){e.superClass=this.eat(c._extends)?this.parseExprSubscripts(null,!1):null};_.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};_.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var s=n[a];Ne(t,s.name)||(i?i.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function ss(e,t){var n=t.key.name,r=e[n],i="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(i=(t.static?"s":"i")+t.kind),r==="iget"&&i==="iset"||r==="iset"&&i==="iget"||r==="sget"&&i==="sset"||r==="sset"&&i==="sget"?(e[n]="true",!1):r?!0:(e[n]=i,!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)}_.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")};_.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 i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type==="Literal"&&this.raise(i.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")};_.parseExportDeclaration=function(e){return this.parseStatement(null)};_.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|gn,!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}};_.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),Ne(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};_.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,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var s=0,o=t.elements;s<o.length;s+=1){var l=o[s];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)};_.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}};_.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};_.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")};_.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};_.parseImport=function(e){return this.next(),this.type===c.string?(e.specifiers=is,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")};_.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")};_.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),this.finishNode(e,"ImportDefaultSpecifier")};_.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")};_.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};_.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(),i=r.key.type==="Identifier"?r.key.name:r.key.value;Ne(t,i)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(r)}return e};_.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")};_.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===c.string){var e=this.parseLiteral(this.value);return Xi.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};_.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)};_.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var se=G.prototype;se.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[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};se.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,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};se.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};se.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==c.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};se.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case c.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(c.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case c.braceL:return this.parseObj(!0)}return this.parseIdent()};se.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(c.comma),t&&this.type===c.comma)i.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===c.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),i.push(s),this.type===c.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else i.push(this.parseAssignableListItem(r))}return i};se.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};se.parseBindingListItem=function(e){return e};se.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(c.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};se.checkLValSimple=function(e,t,n){t===void 0&&(t=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&&(Ne(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==mn&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};se.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ze),e.type){case"ObjectPattern":for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var s=0,o=e.elements;s<o.length;s+=1){var l=o[s];l&&this.checkLValInnerPattern(l,t,n)}break;default:this.checkLValSimple(e,t,n)}};se.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,i,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=i,this.generator=!!a},F={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)},Me=G.prototype;Me.initialContext=function(){return[F.b_stat]};Me.curContext=function(){return this.context[this.context.length-1]};Me.braceIsBlock=function(e){var t=this.curContext();return t===F.f_expr||t===F.f_stat?!0:e===c.colon&&(t===F.b_stat||t===F.b_expr)?!t.isExpr:e===c._return||e===c.name&&this.exprAllowed?X.test(this.input.slice(this.lastTokEnd,this.start)):e===c._else||e===c.semi||e===c.eof||e===c.parenR||e===c.arrow?!0:e===c.braceL?t===F.b_stat:e===c._var||e===c._const||e===c.name?!1:!this.exprAllowed};Me.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};Me.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};Me.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===F.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)?F.b_stat:F.b_expr),this.exprAllowed=!0};c.dollarBraceL.updateContext=function(){this.context.push(F.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?F.p_stat:F.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()!==F.p_stat)&&!(e===c._return&&X.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===c.colon||e===c.braceL)&&this.curContext()===F.b_stat)?this.context.push(F.f_expr):this.context.push(F.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()===F.q_tmpl?this.context.pop():this.context.push(F.q_tmpl),this.exprAllowed=!1};c.star.updateContext=function(e){if(e===c._function){var t=this.context.length-1;this.context[t]===F.f_expr?this.context[t]=F.f_expr_gen:this.context[t]=F.f_gen}this.exprAllowed=!0};c.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==c.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var R=G.prototype;R.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case"Identifier":i=r.name;break;case"Literal":i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i==="__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}i="$"+i;var s=t[i];if(s){var o;a==="init"?o=this.strict&&s.init||s.get||s.set:o=s.init||s[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=t[i]={init:!1,get:!1,set:!1};s[a]=!0}};R.parseExpression=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===c.comma){var a=this.startNodeAt(n,r);for(a.expressions=[i];this.eat(c.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return i};R.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,s=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,s=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),s>-1&&(t.doubleProto=s),this.finishNode(p,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),u};R.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(c.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(c.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return i};R.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type==="ArrowFunctionExpression"?i:this.parseExprOp(i,n,r,-1,e)};R.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==c._in)&&a>r){var s=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,i),u,p,a,i),f=this.buildBinary(t,n,e,d,l,s||o);return(s&&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,i)}return e};R.buildBinary=function(e,t,n,r,i,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(e,t);return s.left=n,s.operator=i,s.right=r,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};R.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=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"&&yn(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,s=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===c.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==c._in&&this.unexpected();else{if(s=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(i,a);u.operator=this.value,u.prefix=!1,u.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(u,"UpdateExpression")}}if(!n&&this.eat(c.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,s,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return s};function yn(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&yn(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)}R.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return i;var a=this.parseSubscripts(i,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};R.parseSubscripts=function(e,t,n,r,i){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,s=!1;;){var o=this.parseSubscript(e,t,n,r,a,s,i);if(o.optional&&(s=!0),o===e||o.type==="ArrowFunctionExpression"){if(s){var l=this.startNodeAt(t,n);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}e=o}};R.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(c.arrow)};R.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};R.parseSubscript=function(e,t,n,r,i,a,s){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 x=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!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,x,s);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var y=this.startNodeAt(t,n);y.callee=e,y.arguments=x,o&&(y.optional=l),e=this.finishNode(y,"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 w=this.startNodeAt(t,n);w.tag=e,w.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(w,"TaggedTemplateExpression")}return e};R.parseExprAtom=function(e,t,n){this.type===c.slash&&this.readRegexp();var r,i=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,s=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(F.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(c.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[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,s),[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(i,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(F.b_expr),this.parseObj(!1,e);case c._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case c._class:return this.parseClass(this.startNode(),!1);case c._new:return this.parseNew();case c.backQuote:return this.parseTemplate();case c._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};R.parseExprAtomDefault=function(){this.unexpected()};R.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===c.parenL&&!e)return this.parseDynamicImport(t);if(this.type===c.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};R.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(c.parenR)?e.options=null:(this.expect(c.comma),this.afterTrailingComma(c.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(c.parenR)||(this.expect(c.comma),this.afterTrailingComma(c.parenR)||this.unexpected())));else if(!this.eat(c.parenR)){var t=this.start;this.eat(c.comma)&&this.eat(c.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};R.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};R.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};R.parseParenExpression=function(){this.expect(c.parenL);var e=this.parseExpression();return this.expect(c.parenR),e};R.shouldParseArrow=function(e){return!this.canInsertSemicolon()};R.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=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 x=this.lastTokEnd,y=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?(i=this.startNodeAt(s,o),i.expressions=l,this.finishNodeAt(i,"SequenceExpression",x,y)):i=l[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var w=this.startNodeAt(n,r);return w.expression=i,this.finishNode(w,"ParenthesizedExpression")}else return i};R.parseParenItem=function(e){return e};R.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var as=[];R.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===c.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),this.eat(c.parenL)?e.arguments=this.parseExprList(c.parenR,this.options.ecmaVersion>=8,!1):e.arguments=as,this.finishNode(e,"NewExpression")};R.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===c.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
5
5
  `),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
6
- `),cooked:this.value},this.next(),n.tail=this.type===c.backQuote,this.finishNode(n,"TemplateElement")};R.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===c.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(c.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(c.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};R.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===c.name||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===c.star)&&!X.test(this.input.slice(this.lastTokEnd,this.start))};R.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(c.braceR);){if(r)r=!1;else if(this.expect(c.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(c.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};R.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")};R.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};R.parsePropertyValue=function(e,t,n,r,s,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()};R.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(c.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(c.bracketR),e.key;e.computed=!1}return e.key=this.type===c.num||this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};R.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};R.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,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)|et|(n?pn:0)),this.expect(c.parenL),r.params=this.parseBindingList(c.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};R.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")};R.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,dn),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=l}this.exitScope()};R.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};R.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Pt,t?null:n)}};R.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};R.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&tt)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};R.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};R.parseIdentNode=function(){var e=this.startNode();return this.type===c.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=c.name):this.unexpected(),e};R.parsePrivateIdent=function(){var e=this.startNode();return this.type===c.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};R.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===c.semi||this.canInsertSemicolon()||this.type!==c.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(c.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};R.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Qe=z.prototype;Qe.raise=function(e,t){var n=ln(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};Qe.raiseRecoverable=Qe.raise;Qe.curPosition=function(){if(this.options.locations)return new Be(this.curLine,this.pos-this.lineStart)};var Se=z.prototype,ai=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new ai(e))};Se.exitScope=function(){this.scopeStack.pop()};Se.treatFunctionsAsVarInScope=function(e){return e.flags&Ne||!this.inModule&&e.flags&je};Se.declareName=function(e,t,n){var r=!1;if(t===ge){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&je&&delete this.undefinedExports[e]}else if(t===hn){var a=this.currentScope();a.lexical.push(e)}else if(t===fn){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&cn&&l.lexical[0]===e)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(e)>-1){r=!0;break}if(l.var.push(e),this.inModule&&l.flags&je&&delete this.undefinedExports[e],l.flags&tt)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};Se.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};Se.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Se.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tt|Oe|ke))return t}};Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tt|Oe|ke)&&!(t.flags&Tt))return t}};var rt=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new Xe(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},Ve=z.prototype;Ve.startNode=function(){return new rt(this,this.start,this.startLoc)};Ve.startNodeAt=function(e,t){return new rt(this,e,t)};function yn(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ve.finishNode=function(e,t){return yn.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Ve.finishNodeAt=function(e,t,n,r){return yn.call(this,e,t,n,r)};Ve.copyNode=function(e){var t=new rt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var oi="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",bn="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",xn=bn+" Extended_Pictographic",vn=xn,wn=vn+" EBase EComp EMod EPres ExtPict",Sn=wn,li=Sn,ui={9:bn,10:xn,11:vn,12:wn,13:Sn,14:li},ci="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",pi={9:"",10:"",11:"",12:"",13:"",14:ci},en="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",En="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Cn=En+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",kn=Cn+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",An=kn+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",_n=An+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",fi=_n+" "+oi,hi={9:En,10:Cn,11:kn,12:An,13:_n,14:fi},Tn={};function di(e){var t=Tn[e]={binary:ve(ui[e]+" "+en),binaryOfStrings:ve(pi[e]),nonBinary:{General_Category:ve(en),Script:ve(hi[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Je=0,wt=[9,10,11,12,13,14];Je<wt.length;Je+=1)tn=wt[Je],di(tn);var tn,Je,wt,A=z.prototype,Ye=function(t,n){this.parent=t,this.base=n||this};Ye.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};Ye.prototype.sibling=function(){return new Ye(this.parent,this.base)};var ce=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Tn[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ce.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,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)};ce.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};ce.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var 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};ce.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};ce.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};ce.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};ce.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};ce.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};ce.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,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};A.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 mi(e){for(var t in e)return!0;return!1}A.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&mi(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};A.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")}};A.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Ye(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};A.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};A.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};A.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};A.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};A.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};A.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};A.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)};A.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};A.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};A.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};A.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&gi(n);)t+=de(n),e.advance();return t};function gi(e){return e===105||e===109||e===115}A.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)};A.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};A.regexp_eatSyntaxCharacter=function(e){var t=e.current();return In(t)?(e.lastIntValue=t,e.advance(),!0):!1};function In(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}A.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!In(n);)e.advance();return e.pos!==t};A.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};A.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}};A.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};A.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};A.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),yi(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function yi(e){return le(e,!0)||e===36||e===95}A.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),bi(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function bi(e){return we(e,!0)||e===36||e===95||e===8204||e===8205}A.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)};A.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};A.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};A.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)};A.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};A.regexp_eatZero=function(e){return e.current()===48&&!st(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};A.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};A.regexp_eatControlLetter=function(e){var t=e.current();return Pn(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Pn(e){return e>=65&&e<=90||e>=97&&e<=122}A.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)&&xi(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function xi(e){return e>=0&&e<=1114111}A.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};A.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Nn=0,me=1,re=2;A.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(vi(t))return e.lastIntValue=-1,e.advance(),me;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===re&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Nn};function vi(e){return e===100||e===68||e===115||e===83||e===119||e===87}A.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),me}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Nn};A.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Pe(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};A.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return me;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return re;e.raise("Invalid property name")};A.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Rn(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Rn(e){return Pn(e)||e===95}A.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";wi(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function wi(e){return Rn(e)||st(e)}A.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};A.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===re&&e.raise("Negated character class may contain strings"),!0}return!1};A.regexp_classContents=function(e){return e.current()===93?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)};A.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")}}};A.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Bn(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};A.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)};A.regexp_classSetExpression=function(e){var t=me,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===re&&(t=re);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==re&&(t=me);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===re&&(t=re)}};A.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};A.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?me:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};A.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===re&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};A.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};A.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===re&&(t=re);return t};A.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?me:re};A.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Si(n)||Ei(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Si(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Ei(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}A.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ci(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ci(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}A.regexp_eatClassControlLetter=function(e){var t=e.current();return st(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};A.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};A.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;st(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function st(e){return e>=48&&e<=57}A.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Mn(n=e.current());)e.lastIntValue=16*e.lastIntValue+$n(n),e.advance();return e.pos!==t};function Mn(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function $n(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}A.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};A.regexp_eatOctalDigit=function(e){var t=e.current();return Bn(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Bn(e){return e>=48&&e<=55}A.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Mn(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+$n(s),e.advance()}return!0};var Rt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Xe(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},$=z.prototype;$.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Rt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};$.getToken=function(){return this.next(),new Rt(this)};typeof Symbol<"u"&&($[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});$.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(c.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};$.readToken=function(e){return le(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};$.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};$.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=sn(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};$.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Ie(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};$.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&an.test(String.fromCharCode(e)))++this.pos;else break e}}};$.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};$.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(c.ellipsis)):(++this.pos,this.finishToken(c.dot))};$.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(c.assign,2):this.finishOp(c.slash,1)};$.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?c.star:c.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=c.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(c.assign,n+1):this.finishOp(r,n)};$.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(c.assign,3)}return this.finishOp(e===124?c.logicalOR:c.logicalAND,2)}return t===61?this.finishOp(c.assign,2):this.finishOp(e===124?c.bitwiseOR:c.bitwiseAND,1)};$.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};$.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||X.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(c.incDec,2):t===61?this.finishOp(c.assign,2):this.finishOp(c.plusMin,1)};$.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(c.assign,n+1):this.finishOp(c.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(c.relational,n))};$.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(c.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(c.arrow)):this.finishOp(e===61?c.eq:c.prefix,1)};$.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(c.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(c.assign,3)}return this.finishOp(c.coalesce,2)}}return this.finishOp(c.question,1)};$.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),le(t,!0)||t===92))return this.finishToken(c.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+de(t)+"'")};$.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(c.parenL);case 41:return++this.pos,this.finishToken(c.parenR);case 59:return++this.pos,this.finishToken(c.semi);case 44:return++this.pos,this.finishToken(c.comma);case 91:return++this.pos,this.finishToken(c.bracketL);case 93:return++this.pos,this.finishToken(c.bracketR);case 123:return++this.pos,this.finishToken(c.braceL);case 125:return++this.pos,this.finishToken(c.braceR);case 58:return++this.pos,this.finishToken(c.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(c.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(c.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+de(e)+"'")};$.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};$.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(X.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new ce(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})};$.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 ki(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function jn(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}$.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=jn(this.input.slice(t,this.pos)),++this.pos):le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,n)};$.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=jn(this.input.slice(t,this.pos));return++this.pos,le(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")),le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=ki(this.input.slice(t,this.pos),n);return this.finishToken(c.num,a)};$.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};$.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Ie(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(c.string,t)};var On={};$.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===On)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};$.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw On;this.raise(e,t)};$.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===c.template||this.type===c.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(c.dollarBraceL)):(++this.pos,this.finishToken(c.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(c.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Ie(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
6
+ `),cooked:this.value},this.next(),n.tail=this.type===c.backQuote,this.finishNode(n,"TemplateElement")};R.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===c.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(c.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(c.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};R.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===c.name||this.type===c.num||this.type===c.string||this.type===c.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===c.star)&&!X.test(this.input.slice(this.lastTokEnd,this.start))};R.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};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,i,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};R.parseProperty=function(e,t){var n=this.startNode(),r,i,a,s;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,s=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)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(c.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,s,t,o),this.finishNode(n,"Property")};R.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};R.parsePropertyValue=function(e,t,n,r,i,a,s,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,s),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=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===c.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};R.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(c.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(c.bracketR),e.key;e.computed=!1}return e.key=this.type===c.num||this.type===c.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};R.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};R.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,s=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?fn: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=i,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(r,"FunctionExpression")};R.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,s=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=i,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(e,"ArrowFunctionExpression")};R.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==c.braceL,a=this.strict,s=!1;if(i)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)&&(s=this.strictDirective(this.end),s&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(e,!a&&!s&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,mn),e.body=this.parseBlock(!1,void 0,s&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=l}this.exitScope()};R.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};R.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Nt,t?null:n)}};R.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(c.comma),t&&this.afterTrailingComma(e))break;var s=void 0;n&&this.type===c.comma?s=null:this.type===c.ellipsis?(s=this.parseSpread(r),r&&this.type===c.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):s=this.parseMaybeAssign(!1,r),i.push(s)}return i};R.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&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 i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};R.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};R.parseIdentNode=function(){var e=this.startNode();return this.type===c.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=c.name):this.unexpected(),e};R.parsePrivateIdent=function(){var e=this.startNode();return this.type===c.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};R.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===c.semi||this.canInsertSemicolon()||this.type!==c.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(c.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};R.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Ye=G.prototype;Ye.raise=function(e,t){var n=un(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};Ye.raiseRecoverable=Ye.raise;Ye.curPosition=function(){if(this.options.locations)return new Oe(this.curLine,this.pos-this.lineStart)};var Se=G.prototype,os=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new os(e))};Se.exitScope=function(){this.scopeStack.pop()};Se.treatFunctionsAsVarInScope=function(e){return e.flags&Re||!this.inModule&&e.flags&Ve};Se.declareName=function(e,t,n){var r=!1;if(t===ge){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&Ve&&delete this.undefinedExports[e]}else if(t===dn){var a=this.currentScope();a.lexical.push(e)}else if(t===hn){var s=this.currentScope();this.treatFunctionsAsVar?r=s.lexical.indexOf(e)>-1:r=s.lexical.indexOf(e)>-1||s.var.indexOf(e)>-1,s.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&pn&&l.lexical[0]===e)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(e)>-1){r=!0;break}if(l.var.push(e),this.inModule&&l.flags&Ve&&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|Ae))return t}};Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(nt|Le|Ae)&&!(t.flags&It))return t}};var it=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])},De=G.prototype;De.startNode=function(){return new it(this,this.start,this.startLoc)};De.startNodeAt=function(e,t){return new it(this,e,t)};function bn(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}De.finishNode=function(e,t){return bn.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};De.finishNodeAt=function(e,t,n,r){return bn.call(this,e,t,n,r)};De.copyNode=function(e){var t=new it(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var ls="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",xn="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",vn=xn+" Extended_Pictographic",wn=vn,Sn=wn+" EBase EComp EMod EPres ExtPict",En=Sn,us=En,cs={9:xn,10:vn,11:wn,12:Sn,13:En,14:us},ps="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",fs={9:"",10:"",11:"",12:"",13:"",14:ps},tn="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",kn="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Cn=kn+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",An=Cn+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",_n=An+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Tn=_n+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",hs=Tn+" "+ls,ds={9:kn,10:Cn,11:An,12:_n,13:Tn,14:hs},In={};function ms(e){var t=In[e]={binary:ve(cs[e]+" "+tn),binaryOfStrings:ve(fs[e]),nonBinary:{General_Category:ve(tn),Script:ve(ds[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)nn=St[Ke],ms(nn);var nn,Ke,St,A=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 ce=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=In[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ce.prototype.reset=function(t,n,r){var i=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,i&&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)};ce.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};ce.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,i=r.length;if(t>=i)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=i)return a;var s=r.charCodeAt(t+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a};ce.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,i=r.length;if(t>=i)return i;var a=r.charCodeAt(t),s;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=i||(s=r.charCodeAt(t+1))<56320||s>57343?t+1:t+2};ce.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};ce.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};ce.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};ce.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};ce.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,i=0,a=t;i<a.length;i+=1){var s=a[i],o=this.at(r,n);if(o===-1||o!==s)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};A.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var s=n.charAt(a);t.indexOf(s)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(s,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),s==="u"&&(r=!0),s==="v"&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,"Invalid regular expression flag")};function gs(e){for(var t in e)return!0;return!1}A.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&gs(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};A.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")}};A.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")};A.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};A.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};A.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};A.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};A.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};A.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};A.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)};A.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};A.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 i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var s=this.regexp_eatModifiers(e);!n&&!s&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<s.length;o++){var l=s.charAt(o);(s.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};A.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};A.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&ys(n);)t+=de(n),e.advance();return t};function ys(e){return e===105||e===109||e===115}A.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)};A.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};A.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Pn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Pn(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}A.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Pn(n);)e.advance();return e.pos!==t};A.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};A.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,i=n;r<i.length;r+=1){var a=i[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}};A.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};A.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};A.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),bs(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function bs(e){return le(e,!0)||e===36||e===95}A.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),xs(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function xs(e){return we(e,!0)||e===36||e===95||e===8204||e===8205}A.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)};A.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};A.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};A.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)};A.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};A.regexp_eatZero=function(e){return e.current()===48&&!st(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};A.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};A.regexp_eatControlLetter=function(e){var t=e.current();return Nn(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Nn(e){return e>=65&&e<=90||e>=97&&e<=122}A.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 i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(s>=56320&&s<=57343)return e.lastIntValue=(i-55296)*1024+(s-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&vs(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function vs(e){return e>=0&&e<=1114111}A.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};A.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 Rn=0,me=1,ie=2;A.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(ws(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===ie&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Rn};function ws(e){return e===100||e===68||e===115||e===83||e===119||e===87}A.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 i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Rn};A.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Ne(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};A.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return me;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return ie;e.raise("Invalid property name")};A.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Mn(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Mn(e){return Nn(e)||e===95}A.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Ss(t=e.current());)e.lastStringValue+=de(t),e.advance();return e.lastStringValue!==""};function Ss(e){return Mn(e)||st(e)}A.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};A.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===ie&&e.raise("Negated character class may contain strings"),!0}return!1};A.regexp_classContents=function(e){return e.current()===93?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)};A.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")}}};A.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Bn(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};A.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)};A.regexp_classSetExpression=function(e){var t=me,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===ie&&(t=ie);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==ie&&(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===ie&&(t=ie)}};A.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};A.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?me:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};A.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===ie&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null};A.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};A.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===ie&&(t=ie);return t};A.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?me:ie};A.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()&&Es(n)||ks(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Es(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 ks(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}A.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Cs(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Cs(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}A.regexp_eatClassControlLetter=function(e){var t=e.current();return st(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};A.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};A.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;st(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function st(e){return e>=48&&e<=57}A.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;$n(n=e.current());)e.lastIntValue=16*e.lastIntValue+jn(n),e.advance();return e.pos!==t};function $n(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function jn(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}A.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};A.regexp_eatOctalDigit=function(e){var t=e.current();return Bn(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Bn(e){return e>=48&&e<=55}A.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!$n(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+jn(i),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])},$=G.prototype;$.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Mt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};$.getToken=function(){return this.next(),new Mt(this)};typeof Symbol<"u"&&($[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===c.eof,value:t}}}});$.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(c.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};$.readToken=function(e){return le(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};$.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};$.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=an(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};$.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Pe(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};$.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&on.test(String.fromCharCode(e)))++this.pos;else break e}}};$.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};$.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(c.ellipsis)):(++this.pos,this.finishToken(c.dot))};$.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(c.assign,2):this.finishOp(c.slash,1)};$.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?c.star:c.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=c.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(c.assign,n+1):this.finishOp(r,n)};$.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(c.assign,3)}return this.finishOp(e===124?c.logicalOR:c.logicalAND,2)}return t===61?this.finishOp(c.assign,2):this.finishOp(e===124?c.bitwiseOR:c.bitwiseAND,1)};$.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(c.assign,2):this.finishOp(c.bitwiseXOR,1)};$.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||X.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(c.incDec,2):t===61?this.finishOp(c.assign,2):this.finishOp(c.plusMin,1)};$.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(c.assign,n+1):this.finishOp(c.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(c.relational,n))};$.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(c.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(c.arrow)):this.finishOp(e===61?c.eq:c.prefix,1)};$.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(c.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(c.assign,3)}return this.finishOp(c.coalesce,2)}}return this.finishOp(c.question,1)};$.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),le(t,!0)||t===92))return this.finishToken(c.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+de(t)+"'")};$.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(c.parenL);case 41:return++this.pos,this.finishToken(c.parenR);case 59:return++this.pos,this.finishToken(c.semi);case 44:return++this.pos,this.finishToken(c.comma);case 91:return++this.pos,this.finishToken(c.bracketL);case 93:return++this.pos,this.finishToken(c.bracketR);case 123:return++this.pos,this.finishToken(c.braceL);case 125:return++this.pos,this.finishToken(c.braceR);case 58:return++this.pos,this.finishToken(c.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(c.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(c.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+de(e)+"'")};$.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};$.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(X.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new ce(this));o.reset(n,i,s),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(i,s)}catch{}return this.finishToken(c.regexp,{pattern:i,flags:s,value:l})};$.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=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){i&&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,s=s*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:s};function As(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function On(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}$.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=On(this.input.slice(t,this.pos)),++this.pos):le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,n)};$.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=On(this.input.slice(t,this.pos));return++this.pos,le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(c.num,i)}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")),le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=As(this.input.slice(t,this.pos),n);return this.finishToken(c.num,a)};$.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};$.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Pe(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(c.string,t)};var Vn={};$.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Vn)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};$.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Vn;this.raise(e,t)};$.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===c.template||this.type===c.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(c.dollarBraceL)):(++this.pos,this.finishToken(c.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(c.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Pe(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
7
  `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};$.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(c.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
8
8
  `&&++this.pos;case`
9
9
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};$.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
10
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return de(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return Ie(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};$.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};$.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(we(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var 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?le: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)};$.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=At[e]),this.finishToken(t,e)};var Ai="8.15.0";z.acorn={Parser:z,version:Ai,defaultOptions:Et,Position:Be,SourceLocation:Xe,getLineInfo:ln,Node:rt,TokenType:O,tokTypes:c,keywordTypes:At,TokContext:ae,tokContexts:U,isIdentifierChar:we,isIdentifierStart:le,Token:Rt,isNewLine:Ie,lineBreak:X,lineBreakG:Ks,nonASCIIwhitespace:an};function Vn(e,t){return z.parse(e,t)}function Ln(e,t,n){return z.parseExpressionAt(e,t,n)}var F=class extends Error{line;column;source;filename;constructor(t,n,r,s){let 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}},Q=class extends F{constructor(t,n,r,s){super(t,n,r,s),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
11
- `),r=this.line-1,s=Math.max(0,r-t),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 ie(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options}}function q(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function 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===`
13
- `&&(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 b=n.trimEnd();if(!b[b.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(b)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(b)){n+=f,r++,i="regex";continue}}break}if(f==="{"){u++,n+=f,r++;continue}if(f==="}"){u--;let b=l[l.length-1];b&&u===b.braceDepth&&l.pop(),n+=f,r++;continue}let g=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(g){let b=g[0].slice(0,-1);n+=b,r+=b.length,l.push({type:"class-body",braceDepth:u});continue}let v=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(v){let b=v[1],S=v[0].length,k=e[r+S],E=null,T=r+S;(k==="?"||k==="!")&&(E=k,T++,E==="!"?t.unsafeFunctions.add(b):t.safeFunctions.add(b)),n+=`function ${b}(`,r=T;let P=it(e,r,"(",")");if(!P){n+=e[r],r++;continue}let{content:N,endPos:j}=P;r=j;let V=$t(N,t,!0);n+=V+")";let L=r;for(;L<e.length&&/\s/.test(e[L]);)L++;if(e[L]===":"){let J=e.slice(L,L+2),ye;for(J===":?"||J===":!"?(L+=2,ye=J===":?"?"safe":"unsafe"):L+=1;L<e.length&&/\s/.test(e[L]);)L++;let Ee=Mt(e,L);Ee&&(s===void 0&&(s=Ee.type,ye&&(a=ye)),r=Ee.endPos)}continue}let y=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),w=(()=>{for(let b=n.length-1;b>=0;b--)if(!/\s/.test(n[b]))return n[b];return`
14
- `})(),C=w!=="="&&w!==","&&w!=="("&&w!=="["&&w!==">";if(y&&d()&&!C){let b=y[1].length;n+=e.slice(r,r+b),r+=b;continue}if(y&&d()&&C){let b=y[1],S=y[0].length,k=r+S;n+=b+"(",r=k;let E=it(e,r,"(",")");if(!E){n+=e[r],r++;continue}let{content:T,endPos:P}=E;r=P;let N=$t(T,t,!0);n+=N+")";let j=r;for(;j<e.length&&/\s/.test(e[j]);)j++;if(e[j]===":"){let V=e.slice(j,j+2);for(V===":?"||V===":!"?j+=2:j++;j<e.length&&/\s/.test(e[j]);)j++;let L=Mt(e,j);L&&(r=L.endPos)}continue}if(e[r]==="("){let b=it(e,r+1,"(",")");if(!b){n+=e[r],r++;continue}let S=b.content,k=b.endPos,E=k;for(;E<e.length&&/\s/.test(e[E]);)E++;let T;if(e[E]===":"){let P=e.slice(E,E+2);for(P===":?"||P===":!"?E+=2:E++;E<e.length&&/\s/.test(e[E]);)E++;let N=Mt(e,E);if(N)for(T=N.type,E=N.endPos;E<e.length&&/\s/.test(e[E]);)E++}if(e.slice(E,E+2)==="=>"){let P=null,N=S,j=S.trimStart();j.startsWith("?")&&(j.length===1||/\s/.test(j[1]))?(P="?",N=j.slice(1)):j.startsWith("!")&&(j.length===1||/\s/.test(j[1]))&&(P="!",N=j.slice(1));let V=$t(N,t,!1);for(n+=`(${P==="?"?"/* safe */ ":P==="!"?"/* unsafe */ ":""}${V})`,r=k;r<E&&/\s/.test(e[r]);)n+=e[r],r++;T&&(r=E)}else{let P=lt(S,t);n+=`(${P.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 Un(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,s=e[n];if(s==="{"||s==="["){let 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 Le(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function Mt(e,t){let n=t,r=0,s=!1,a="",i=!1,o=l=>({type:Le(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:Le(e.slice(t,u).trim()),endPos:u};if(e[n]!=="|"&&e[n]!=="&")return{type:Le(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:Le(e.slice(t,d).trim()),endPos:u}}if(e[n]!=="|"&&e[n]!=="&")return{type:Le(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===`
15
- `){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 $t(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`{ ${Dn(m,t)} }`}if(n&&p.startsWith("[")&&p.endsWith("]")){let m=p.slice(1,-1);return`[ ${Dn(m,t)} ]`}if(p.startsWith("...")){let m=Fn(p);return m!==-1?p.slice(0,m).trim():u}let d=p.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(d){let[,m,g]=d;return o(m),a=!0,`${m} = ${g}`}if(!Ti(p)){let m=p.match(/^(\w+)\s*=/);return m&&o(m[1]),a=!0,u}let f=Fn(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 Dn(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 Ti(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 Fn(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 Ii(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 Hn(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 Jn(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 E=e[u];E==="{"?l++:E==="}"&&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 E=u+m[0].length;l=1;let T=E;for(;T<e.length&&l>0;){let P=e[T];P==="{"?l++:P==="}"&&l--,T++}l===0&&(d=e.slice(E,T-1),f=T)}let v=Ni(p).map(E=>{let T=Ri(e,i,E);return T?`${E}: ${T}`:E}),y={id:`__tjs_wasm_${s}`,body:p,fallback:d,captures:v,start:i,end:f};t.push(y);let w=d??p,C=v.map(E=>E.split(":")[0].trim()),b=C.length>0?C.join(", "):"",S=C.length>0?`globalThis.${y.id}(${b})`:`globalThis.${y.id}()`,k=`(globalThis.${y.id} ? ${S} : (() => {${w}})())`;n+=k,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Pi(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Ni(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s;for(;(s=r.exec(t))!==null;)n.add(s[1]);let 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"),v=t.match(m)?.length||0,y=t.match(g)?.length||0;v<=y&&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)&&!Pi(f)&&d.push(f);return d.sort()}function Ri(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,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?qn(o[1],n):void 0}return qn(a[1],n)}function qn(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let s=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(s)return s[1];let a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function Kn(e){let t=`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,n=new RegExp(t+"\\s+IsNot\\s+"+t,"g");e=e.replace(n,"IsNot($1, $2)");let r=new RegExp(t+"\\s+Is\\s+"+t,"g");return e=e.replace(r,"Is($1, $2)"),e}function Zn(e){let t=/^[\s]*[([`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,s=e.split(`
16
- `),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]:"",v=l.slice(g.length);a.push(g+";"+v);continue}}a.push(l)}return a.join(`
17
- `)}function Mi(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==="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 Qn(e){e=Mi(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===`
19
- `&&(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=$i(a,o),d=Bi(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),v=a.slice(d),w=/[a-zA-Z0-9_$]$/.test(g)?" ":"";a=`${g}${w}${u}(${f}, ${m})${v}`}}return a}function $i(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 Bi(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 Yn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(r){let s=r[1],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 v=l[0].trim(),y=l[0].slice(v.length);t+=`const ${s} = Type('${s}', ${v})${y}`,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 v=e.slice(f,g-1).trim(),y=g,w=v.match(/description\s*:\s*(['"`])([^]*?)\1/);w&&!o&&(i=w[2]);let C,b=v.match(/example\s*:\s*/);if(b){let k=b.index+b[0].length,E=Un(v,k);E&&(C=E.value.trim())}let S=v.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(S&&C){let k=S[1].trim(),E=S[2].trim(),T=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { if (!globalThis.__tjs?.validate(${k}, globalThis.__tjs?.infer(${C}))) return false; ${E} }, ${C}${T})`}else if(S){let k=S[1].trim(),E=S[2].trim(),T=u?`, undefined, ${u}`:"";t+=`const ${s} = Type('${i}', (${k}) => { ${E} }${T})`}else if(C){let k=u?`, ${u}`:"";t+=`const ${s} = Type('${i}', undefined, ${C}${k})`}else u?t+=`const ${s} = Type('${i}', ${u})`:t+=`const ${s} = Type('${i}')`;n=y;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 Xn(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(r){let s=r[1],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=Ii(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 v=m?m[2]:s;if(a){let y=a.split(",").map(C=>{let b=C.trim().split("=").map(S=>S.trim());if(b.length===2){let S=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${S}]`}return`'${b[0]}'`}),w=a.split(",").map(C=>C.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${v}', [${y.join(", ")}], (${w.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${v}', { ${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 er(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(r){let s=r[1],a=r[2],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let C=e[u];C==="{"?l++:C==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=a.split(",").map(C=>{let b=C.trim().split("=").map(S=>S.trim());if(b.length===2){let S=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${S}]`}return`'${b[0]}'`}),m=p,g=m.search(/\bdeclaration\s*\{/);if(g!==-1){let C=m.indexOf("{",g),b=1,S=C+1;for(;S<m.length&&b>0;)m[S]==="{"?b++:m[S]==="}"&&b--,S++;m=m.slice(0,g)+m.slice(S)}let v=m.match(/description\s*:\s*(['"`])([^]*?)\1/),y=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),w=v?v[2]:s;if(y){let C=y[1].trim().split(",").map(T=>T.trim()),b=y[2].trim(),S=C[0]||"x",k=C.slice(1),E=k.map(T=>`check${T}`);k.forEach((T,P)=>{b=b.replace(new RegExp(`\\b${T}\\s*\\(`,"g"),`${E[P]}(`)}),t+=`const ${s} = Generic([${f.join(", ")}], (${S}, ${E.join(", ")}) => { ${b} }, '${w}')`}else t+=`const ${s} = Generic([${f.join(", ")}], () => true, '${w}')`;n=d;continue}t+=e[n],n++}return t}function tr(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(r){let s=r[1],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=Wn(p);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=d;continue}else{let o=e.indexOf(`
20
- `,i);o===-1&&(o=e.length);let l=e.slice(i,o).trim();if(l){let u=Wn(l);t+=`const ${s} = Union('${a}', [${u.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Wn(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function nr(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(r){let s=r[1],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=ji(p).map(([g,v])=>`${g}: ${v}`).join(", ");t+=`const ${s} = Enum('${a}', { ${m} })`,n=d;continue}t+=e[n],n++}return t}function ji(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 rr(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]===`
21
- `||e[r-1]===";"||e[r-1]==="}"){let b=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 b=m.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!b){f++;continue}let S=b[1],k=!!b[2],E=b[3],T=f+b[0].length-1,P=1,N=T+1;for(;N<m.length&&P>0;)m[N]==="("&&P++,m[N]===")"&&P--,N++;let j=m.slice(T+1,N-1),V=N;for(;V<m.length&&/\s/.test(m[V]);)V++;if(m[V]==="="&&m[V+1]===">"){let be=De(e,l+1+f);throw new Q(`Arrow functions are not allowed in extend blocks (method '${E}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,be)}if(m[V]!=="{"){f++;continue}let L=Fe(m,V),J=m.slice(f,L).trim(),ye=j.split(",").map(be=>be.trim()).filter(be=>be.length>0).map(be=>{let ft=be.match(/^(\w+)\s*:\s*(.+)$/);return ft?`${ft[1]} = ${ft[2]}`:be}).join(", "),Ee=k?"async ":"",Rr=m.slice(V+1,L-1);d.push({name:E,isAsync:k,fullText:`${E}: ${Ee}function(${ye}) {${Rr}}`}),f=L}let g=!t.has(o);g&&t.set(o,new Set);let v=t.get(o);for(let C of d)v.add(C.name);let y=d.map(C=>` ${C.fullText}`).join(`,
22
- `),w;g?w=`${i}const __ext_${o} = {
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],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=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(i)}return Pe(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};$.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};$.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(we(i,r))this.pos+=i<=65535?1:2;else if(i===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 s=this.readCodePoint();(t?le:we)(s,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=de(s),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};$.readWord=function(){var e=this.readWord1(),t=c.name;return this.keywords.test(e)&&(t=_t[e]),this.finishToken(t,e)};var _s="8.15.0";G.acorn={Parser:G,version:_s,defaultOptions:kt,Position:Oe,SourceLocation:et,getLineInfo:un,Node:it,TokenType:V,tokTypes:c,keywordTypes:_t,TokContext:oe,tokContexts:F,isIdentifierChar:we,isIdentifierStart:le,Token:Mt,isNewLine:Pe,lineBreak:X,lineBreakG:Zi,nonASCIIwhitespace:on};function Ln(e,t){return G.parse(e,t)}function Dn(e,t,n){return G.parseExpressionAt(e,t,n)}var U=class extends Error{line;column;source;filename;constructor(t,n,r,i){let a=`${i||"<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=i}},H=class extends U{constructor(t,n,r,i){super(t,n,r,i),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
11
+ `),r=this.line-1,i=Math.max(0,r-t),a=Math.min(n.length-1,r+t),s=[],o=String(a+1).length;for(let l=i;l<=a;l++){let u=String(l+1).padStart(o),p=l===r?">":" ";if(s.push(`${p} ${u} | ${n[l]}`),l===r){let d=" ".repeat(o+4+this.column);s.push(`${d}^ ${this.message.split(" at ")[0]}`)}}return s.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}}function W(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Is(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,i=1,a=r+1;for(;a<e.length&&i>0;)e[a]==="{"?i++:e[a]==="}"&&i--,a++;if(i!==0)return null;let s=e.slice(r,a),o=[n[0].slice(0,-1)+s,s];return o.index=n.index,o}function zn(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,s=1,o=a;for(;o<e.length&&s>0;){let u=e[o];u==="{"?s++:u==="}"&&s--,o++}if(s!==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 Gn(e){let t=[],n="",r=0,i=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let s=r,o=r+a[0].length,l=1,u=o;for(;u<e.length&&l>0;){let E=e[u];E==="{"?l++:E==="}"&&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 E=u+m[0].length;l=1;let S=E;for(;S<e.length&&l>0;){let P=e[S];P==="{"?l++:P==="}"&&l--,S++}l===0&&(d=e.slice(E,S-1),f=S)}let x=Ns(p).map(E=>{let S=Rs(e,s,E);return S?`${E}: ${S}`:E}),y={id:`__tjs_wasm_${i}`,body:p,fallback:d,captures:x,start:s,end:f};t.push(y);let w=d??p,k=x.map(E=>E.split(":")[0].trim()),b=k.length>0?k.join(", "):"",C=k.length>0?`globalThis.${y.id}(${b})`:`globalThis.${y.id}()`,I=`(globalThis.${y.id} ? ${C} : (() => {${w}})())`;n+=I,r=f,i++}else n+=e[r],r++}return{source:n,blocks:t}}function Ps(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Ns(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i;for(;(i=r.exec(t))!==null;)n.add(i[1]);let a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s=new Set;for(;(i=a.exec(t))!==null;)s.add(i[1]);for(let f of n){if(!s.has(f))continue;let m=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),g=new RegExp(`\\.${f}\\b`,"g"),x=t.match(m)?.length||0,y=t.match(g)?.length||0;x<=y&&s.delete(f)}let o=new Set,l=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(i=l.exec(t))!==null;)o.add(i[1]);let u=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(i=u.exec(t))!==null;)o.add(i[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 s)!o.has(f)&&!p.has(f)&&!Ps(f)&&d.push(f);return d.sort()}function Rs(e,t,n){let r=e.slice(0,t),i=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(i);if(!a){let s=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(s);return o?Fn(o[1],n):void 0}return Fn(a[1],n)}function Fn(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let i=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(i)return i[1];let a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function Hn(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 Jn(e){let t=/^[\s]*[([`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,i=e.split(`
13
+ `),a=[],s=!1;for(let o=0;o<i.length;o++){let l=i[o],u=o>0?i[o-1]:"";if(s){a.push(l),l.includes("*/")&&(s=!1);continue}let p=l.indexOf("/*"),d=l.indexOf("*/");if(p!==-1&&(d===-1||d<p)){s=!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]:"",x=l.slice(g.length);a.push(g+";"+x);continue}}a.push(l)}return a.join(`
14
+ `)}function Ms(e){let t=[],n=0,r="normal",i=[];for(;n<e.length;){let s=e[n],o=e[n+1];switch(r){case"single-string":if(s==="\\"&&n+1<e.length){n+=2;continue}s==="'"&&(r="normal"),n++;continue;case"double-string":if(s==="\\"&&n+1<e.length){n+=2;continue}s==='"'&&(r="normal"),n++;continue;case"template-string":if(s==="\\"&&n+1<e.length){n+=2;continue}if(s==="$"&&o==="{"){n+=2,i.push(1),r="normal";continue}s==="`"&&(r="normal"),n++;continue;case"line-comment":s===`
15
+ `&&(r="normal"),n++;continue;case"block-comment":if(s==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(s==="\\"&&n+1<e.length){n+=2;continue}if(s==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(s==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(i.length>0){if(s==="{")i[i.length-1]++;else if(s==="}"&&(i[i.length-1]--,i[i.length-1]===0)){i.pop(),n++,r="template-string";continue}}if(s==="'"){n++,r="single-string";continue}if(s==='"'){n++,r="double-string";continue}if(s==="`"){n++,r="template-string";continue}if(s==="/"&&o==="/"){n+=2,r="line-comment";continue}if(s==="/"&&o==="*"){n+=2,r="block-comment";continue}if(s==="/"){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(s==="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 s=t.length-1;s>=0;s--){let o=t[s];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Kn(e){e=Ms(e);let t=[],n=0,r="normal",i=[];for(;n<e.length;){let s=e[n],o=e[n+1];switch(r){case"single-string":if(s==="\\"&&n+1<e.length){n+=2;continue}s==="'"&&(r="normal"),n++;continue;case"double-string":if(s==="\\"&&n+1<e.length){n+=2;continue}s==='"'&&(r="normal"),n++;continue;case"template-string":if(s==="\\"&&n+1<e.length){n+=2;continue}if(s==="$"&&o==="{"){n+=2,i.push(1),r="normal";continue}s==="`"&&(r="normal"),n++;continue;case"line-comment":s===`
16
+ `&&(r="normal"),n++;continue;case"block-comment":if(s==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(s==="\\"&&n+1<e.length){n+=2;continue}if(s==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(s==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(i.length>0){if(s==="{")i[i.length-1]++;else if(s==="}"&&(i[i.length-1]--,i[i.length-1]===0)){i.pop(),n++,r="template-string";continue}}if(s==="'"){n++,r="single-string";continue}if(s==='"'){n++,r="double-string";continue}if(s==="`"){n++,r="template-string";continue}if(s==="/"&&o==="/"){n+=2,r="line-comment";continue}if(s==="/"&&o==="*"){n+=2,r="block-comment";continue}if(s==="/"){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(s==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(s==="!"&&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 s=t.length-1;s>=0;s--){let{pos:o,op:l}=t[s],u=l==="=="?"Eq":"NotEq",p=$s(a,o),d=js(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),x=a.slice(d),w=/[a-zA-Z0-9_$]$/.test(g)?" ":"";a=`${g}${w}${u}(${f}, ${m})${x}`}}return a}function $s(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,i=!1,a="";for(;n>=0;){let s=e[n],o=n>0?e[n-1]:"";if(i){s===a&&o!=="\\"&&(i=!1),n--;continue}if((s==='"'||s==="'"||s==="`")&&o!=="\\"){i=!0,a=s,n--;continue}if(s===")"||s==="]"||s==="}"){r++,n--;continue}if(s==="("||s==="["){if(r>0){r--,n--;continue}return n+1}if(s==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(s===";")return n+1;if(/[a-z]/.test(s)){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(s===">"&&o==="="||s==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||s==="&"&&o==="&"||s==="|"&&o==="|"||s==="?"||s===":"||s===",")return n+1;n--}return 0}function js(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return e.length;let r=0,i=!1,a="";for(;n<e.length;){let s=e[n],o=n+1<e.length?e[n+1]:"";if(i){s===a&&e[n-1]!=="\\"&&(i=!1),n++;continue}if((s==='"'||s==="'"||s==="`")&&e[n-1]!=="\\"){i=!0,a=s,n++;continue}if(s==="("||s==="["||s==="{"){r++,n++;continue}if(s===")"||s==="]"||s==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(s===";"||s==="&"&&o==="&"||s==="|"&&o==="|"||s==="?"||s===":"||s===","||(s==="="||s==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function Zn(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 i=r[1],a=n+r[0].length,s=i,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==="{")s=l[2],o=!0,a=f;else if(g){let x=l[0].trim(),y=l[0].slice(x.length);t+=`const ${i} = Type('${i}', ${x})${y}`,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 I=e[g];I==="{"?m++:I==="}"&&m--,g++}if(m!==0){t+=e[n],n++;continue}let x=e.slice(f,g-1).trim(),y=g,w=x.match(/description\s*:\s*(['"`])([^]*?)\1/);w&&!o&&(s=w[2]);let k,b=x.match(/example\s*:\s*/);if(b){let I=b.index+b[0].length,E=mr(x,I);E&&(k=E.value.trim())}let C=x.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(C&&k){let I=C[1].trim(),E=C[2].trim(),S=u?`, ${u}`:"";t+=`const ${i} = Type('${s}', (${I}) => { if (!globalThis.__tjs?.validate(${I}, globalThis.__tjs?.infer(${k}))) return false; ${E} }, ${k}${S})`}else if(C){let I=C[1].trim(),E=C[2].trim(),S=u?`, undefined, ${u}`:"";t+=`const ${i} = Type('${s}', (${I}) => { ${E} }${S})`}else if(k){let I=u?`, ${u}`:"";t+=`const ${i} = Type('${s}', undefined, ${k}${I})`}else u?t+=`const ${i} = Type('${s}', ${u})`:t+=`const ${i} = Type('${s}')`;n=y;continue}else if(u){t+=`const ${i} = Type('${s}', ${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 ${i} = Type('${i}', ${m})`,n=a+f[0].length;continue}}}t+=e[n],n++}return t}function Qn(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 i=r[1],a=r[2],s=n+r[0].length;if(e[s]==="{"){let o=1,l=s+1;for(;l<e.length&&o>0;)e[l]==="{"?o++:e[l]==="}"&&o--,l++;if(o===0){let u=e.slice(s+1,l-1).trim(),p=Is(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 x=m?m[2]:i;if(a){let y=a.split(",").map(k=>{let b=k.trim().split("=").map(C=>C.trim());if(b.length===2){let C=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${C}]`}return`'${b[0]}'`}),w=a.split(",").map(k=>k.trim().split("=")[0].trim());t+=`const ${i} = FunctionPredicate('${x}', [${y.join(", ")}], (${w.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${i} = FunctionPredicate('${x}', { ${g.join(", ")} })`;n=l;continue}}if(e[s]==="("){let o=1,l=s+1;for(;l<e.length&&o>0;)e[l]==="("?o++:e[l]===")"&&o--,l++;if(o===0){let u=e.slice(s+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 ${i} = FunctionPredicate(${f}, ${d})`}else t+=`const ${i} = FunctionPredicate('${i}', ${u})`;n=l;continue}}}t+=e[n],n++}return t}function Yn(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 i=r[1],a=r[2],o=n+r[0].length-1+1,l=1,u=o;for(;u<e.length&&l>0;){let k=e[u];k==="{"?l++:k==="}"&&l--,u++}if(l!==0){t+=e[n],n++;continue}let p=e.slice(o,u-1).trim(),d=u,f=a.split(",").map(k=>{let b=k.trim().split("=").map(C=>C.trim());if(b.length===2){let C=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${C}]`}return`'${b[0]}'`}),m=p,g=m.search(/\bdeclaration\s*\{/);if(g!==-1){let k=m.indexOf("{",g),b=1,C=k+1;for(;C<m.length&&b>0;)m[C]==="{"?b++:m[C]==="}"&&b--,C++;m=m.slice(0,g)+m.slice(C)}let x=m.match(/description\s*:\s*(['"`])([^]*?)\1/),y=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),w=x?x[2]:i;if(y){let k=y[1].trim().split(",").map(S=>S.trim()),b=y[2].trim(),C=k[0]||"x",I=k.slice(1),E=I.map(S=>`check${S}`);I.forEach((S,P)=>{b=b.replace(new RegExp(`\\b${S}\\s*\\(`,"g"),`${E[P]}(`)}),t+=`const ${i} = Generic([${f.join(", ")}], (${C}, ${E.join(", ")}) => { ${b} }, '${w}')`}else t+=`const ${i} = Generic([${f.join(", ")}], () => true, '${w}')`;n=d;continue}t+=e[n],n++}return t}function Xn(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 i=r[1],a=r[3],s=n+r[0].length;if(e[s]==="{"){let o=s+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=Un(p);t+=`const ${i} = Union('${a}', [${f.join(", ")}])`,n=d;continue}else{let o=e.indexOf(`
17
+ `,s);o===-1&&(o=e.length);let l=e.slice(s,o).trim();if(l){let u=Un(l);t+=`const ${i} = Union('${a}', [${u.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Un(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function er(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 i=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=Bs(p).map(([g,x])=>`${g}: ${x}`).join(", ");t+=`const ${i} = Enum('${a}', { ${m} })`,n=d;continue}t+=e[n],n++}return t}function Bs(e){let t=[],n=0,r=e.split(/[\n,]/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("//"));for(let i of r){let a=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let s=a[1],o=a[2]?.trim();if(o!==void 0){t.push([s,o]);let l=Number(o);isNaN(l)||(n=l+1)}else t.push([s,String(n)]),n++}}return t}function tr(e){let t=new Map,n="",r=0;for(;r<e.length;){let i=e.slice(r),a=i.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){if(r===0||e[r-1]===`
18
+ `||e[r-1]===";"||e[r-1]==="}"){let b=i.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}n+=e[r],r++;continue}let s=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 b=m.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!b){f++;continue}let C=b[1],I=!!b[2],E=b[3],S=f+b[0].length-1,P=1,N=S+1;for(;N<m.length&&P>0;)m[N]==="("&&P++,m[N]===")"&&P--,N++;let O=m.slice(S+1,N-1),j=N;for(;j<m.length&&/\s/.test(m[j]);)j++;if(m[j]==="="&&m[j+1]===">"){let be=Ee(e,l+1+f);throw new H(`Arrow functions are not allowed in extend blocks (method '${E}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,be)}if(m[j]!=="{"){f++;continue}let D=Fe(m,j),z=m.slice(f,D).trim(),ye=O.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(", "),ke=I?"async ":"",$e=m.slice(j+1,D-1);d.push({name:E,isAsync:I,fullText:`${E}: ${ke}function(${ye}) {${$e}}`}),f=D}let g=!t.has(o);g&&t.set(o,new Set);let x=t.get(o);for(let k of d)x.add(k.name);let y=d.map(k=>` ${k.fullText}`).join(`,
19
+ `),w;g?w=`${s}const __ext_${o} = {
23
20
  ${y}
24
- ${i}}
25
- `:w=`${i}Object.assign(__ext_${o}, {
21
+ ${s}}
22
+ `:w=`${s}Object.assign(__ext_${o}, {
26
23
  ${y}
27
- ${i}})
28
- `;for(let C of d)w+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${C.name}', __ext_${o}.${C.name}) }
29
- `;n+=w,r=u}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function sr(e,t){if(t.size===0)return e;let n=new Map;for(let[s,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 De(e,t){let n=1,r=0;for(let s=0;s<t&&s<e.length;s++)e[s]===`
30
- `?(n++,r=0):r++;return{line:n,column:r}}function ir(e,t){let n=t.trim();return/^['"`]/.test(n)?`typeof ${e} === 'string'`:n==="true"||n==="false"?`typeof ${e} === 'boolean'`:n==="null"?`${e} === null`:n==="undefined"?`${e} === undefined`:n.startsWith("[")?`Array.isArray(${e})`:n.startsWith("{")?`(typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e}))`:/^\+\d+/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}) && ${e} >= 0)`:/^-?\d+\.\d+/.test(n)?`typeof ${e} === 'number'`:/^-?\d+$/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}))`:"true"}function ct(e){let t=e.trim();return/^['"`]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":t.startsWith("[")?"array":t.startsWith("{")?"object":/^\+\d+/.test(t)?"non-negative-integer":/^-?\d+\.\d+/.test(t)?"number":/^-?\d+$/.test(t)?"integer":"any"}function Bt(e,t){let n=[],r=0,s="",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=zn(s.trim(),t);u&&n.push(u),s="";continue}s+=l}let i=s.trim();if(i){let o=zn(i,t);o&&n.push(o)}return n}function zn(e,t){let n=e.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(n.startsWith("..."))return null;let r=n.indexOf("=");if(r===-1)return{name:n.trim(),defaultValue:"",required:!0};let s=n.slice(0,r).trim(),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===`
31
- `&&(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 ar(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,v=g,w=a[0].indexOf("function");w>=0&&(v=g+w),i.push({name:m,fullMatchStart:g,funcKeywordStart:v,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 v=g-1,y=e.slice(f+1,v),w=g;for(;w<e.length&&e[w]!=="{";)w++;if(w>=e.length)continue;let C=Fe(e,w),b=d.fullMatchStart;for(;b>0&&e[b-1]===" ";)b--;let S=s.get(d.name),k=Bt(y,t);if(y.includes("...")){let T=De(e,d.funcKeywordStart);throw new Q(`Rest parameters are not supported in polymorphic function '${d.name}'. Use separate function names instead.`,T)}S.push({index:S.length+1,start:b,end:C,text:e.slice(b,C),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=De(e,f[0].start);throw new Q(`Polymorphic function '${d}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let v=g+1;v<f.length;v++){let y=f[g],w=f[v];if(y.params.length!==w.params.length)continue;let C=!0;for(let b=0;b<y.params.length;b++){let S=y.params[b].defaultValue?ct(y.params[b].defaultValue):"any",k=w.params[b].defaultValue?ct(w.params[b].defaultValue):"any";if(S!==k){C=!1;break}}if(C){let b=De(e,w.start);throw new Q(`Polymorphic function '${d}': variants ${g+1} and ${v+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,b)}}}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(S=>S.exported),v=m?"async ":"",y=g?"export ":"",w=[...f].sort((S,k)=>{if(S.params.length!==k.params.length)return 0;let E=0,T=0;for(let P of S.params){let N=P.defaultValue?ct(P.defaultValue):"any";N==="non-negative-integer"?E+=3:N==="integer"?E+=2:N!=="any"&&(E+=1)}for(let P of k.params){let N=P.defaultValue?ct(P.defaultValue):"any";N==="non-negative-integer"?T+=3:N==="integer"?T+=2:N!=="any"&&(T+=1)}return T-E}),C=[];for(let S of w){let k=[`__args.length === ${S.params.length}`],E=[];for(let T=0;T<S.params.length;T++){let P=S.params[T];if(E.push(`__args[${T}]`),P.defaultValue){let N=ir(`__args[${T}]`,P.defaultValue);N!=="true"&&k.push(N)}}C.push(` if (${k.join(" && ")}) return ${d}$${S.index}(${E.join(", ")})`)}let b=`
32
- ${y}${v}function ${d}(...__args) {
33
- ${C.join(`
24
+ ${s}})
25
+ `;for(let k of d)w+=`${s}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${k.name}', __ext_${o}.${k.name}) }
26
+ `;n+=w,r=u}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function nr(e,t){if(t.size===0)return e;let n=new Map;for(let[i,a]of t)for(let s of a)n.has(s)||n.set(s,[]),n.get(s).push(i);let r=e;for(let[i,a]of n){if(!a.includes("String"))continue;let s=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${i})\\((\\))?`,"g");r=r.replace(s,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${i})\\((\\))?`,"g");r=r.replace(o,(u,p,d,f)=>f?`__ext_String.${d}.call(${p})`:`__ext_String.${d}.call(${p}, `);let l=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+i+"\\((\\))?","g");r=r.replace(l,(u,p,d)=>d?`__ext_String.${i}.call(${p})`:`__ext_String.${i}.call(${p}, `)}for(let[i,a]of n){if(!a.includes("Array"))continue;let s=`].${i}(`,o=0,l;for(;(l=r.indexOf(s,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+s.length);g[0]===")"?r=`${m}__ext_Array.${i}.call(${f})${g.slice(1)}`:r=`${m}__ext_Array.${i}.call(${f}, ${g}`}o=l+1}}for(let[i,a]of n){if(!a.includes("Number"))continue;let s=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${i})\\((\\))?`,"g");r=r.replace(s,(o,l,u,p)=>p?`__ext_Number.${u}.call(${l})`:`__ext_Number.${u}.call(${l}, `)}return r}function Ee(e,t){let n=1,r=0;for(let i=0;i<t&&i<e.length;i++)e[i]===`
27
+ `?(n++,r=0):r++;return{line:n,column:r}}function rr(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,i="",a=!1;for(let o=0;o<e.length;o++){let l=e[o];if(!a&&(l==="'"||l==='"'||l==="`")){a=l,i+=l;continue}if(a){if(i+=l,l==="\\"){o++,o<e.length&&(i+=e[o]);continue}l===a&&(a=!1);continue}if(l==="("||l==="["||l==="{"){r++,i+=l;continue}if(l===")"||l==="]"||l==="}"){r--,i+=l;continue}if(l===","&&r===0){let u=qn(i.trim(),t);u&&n.push(u),i="";continue}i+=l}let s=i.trim();if(s){let o=qn(s,t);o&&n.push(o)}return n}function qn(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 i=n.slice(0,r).trim(),a=n.slice(r+1).trim();return{name:i,defaultValue:a,required:t.has(i)}}function Fe(e,t){let n=1,r=t+1,i=!1,a=!1,s=!1;for(;r<e.length&&n>0;){let o=e[r],l=r+1<e.length?e[r+1]:"";if(a){o===`
28
+ `&&(a=!1),r++;continue}if(s){if(o==="*"&&l==="/"){s=!1,r+=2;continue}r++;continue}if(i){if(o==="\\"){r+=2;continue}o===i&&(i=!1),r++;continue}if(o==="/"&&l==="/"){a=!0,r+=2;continue}if(o==="/"&&l==="*"){s=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){i=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function ir(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,i=new Map,a,s=[];for(;(a=r.exec(e))!==null;){let d=!!a[1],f=!!a[2],m=a[3],g=a.index,x=g,w=a[0].indexOf("function");w>=0&&(x=g+w),s.push({name:m,fullMatchStart:g,funcKeywordStart:x,exported:d,isAsync:f})}for(let d of s)i.has(d.name)||i.set(d.name,[]);let o=new Map;for(let d of s)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 s){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 x=g-1,y=e.slice(f+1,x),w=g;for(;w<e.length&&e[w]!=="{";)w++;if(w>=e.length)continue;let k=Fe(e,w),b=d.fullMatchStart;for(;b>0&&e[b-1]===" ";)b--;let C=i.get(d.name),I=$t(y,t);if(y.includes("...")){let S=Ee(e,d.funcKeywordStart);throw new H(`Rest parameters are not supported in polymorphic function '${d.name}'. Use separate function names instead.`,S)}C.push({index:C.length+1,start:b,end:k,text:e.slice(b,k),exported:d.exported,isAsync:d.isAsync,params:I})}for(let[d,f]of i){if(f.length<2)continue;let m=f.filter(g=>g.isAsync).length;if(m>0&&m<f.length){let g=Ee(e,f[0].start);throw new H(`Polymorphic function '${d}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let x=g+1;x<f.length;x++){let y=f[g],w=f[x];if(y.params.length!==w.params.length)continue;let k=!0;for(let b=0;b<y.params.length;b++){let C=y.params[b].defaultValue?at(y.params[b].defaultValue):"any",I=w.params[b].defaultValue?at(w.params[b].defaultValue):"any";if(C!==I){k=!1;break}}if(k){let b=Ee(e,w.start);throw new H(`Polymorphic function '${d}': variants ${g+1} and ${x+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,b)}}}let u=[];for(let[d,f]of i)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 i){if(f.length<2)continue;n.add(d);let m=f[0].isAsync,g=f.some(C=>C.exported),x=m?"async ":"",y=g?"export ":"",w=[...f].sort((C,I)=>{if(C.params.length!==I.params.length)return 0;let E=0,S=0;for(let P of C.params){let N=P.defaultValue?at(P.defaultValue):"any";N==="non-negative-integer"?E+=3:N==="integer"?E+=2:N!=="any"&&(E+=1)}for(let P of I.params){let N=P.defaultValue?at(P.defaultValue):"any";N==="non-negative-integer"?S+=3:N==="integer"?S+=2:N!=="any"&&(S+=1)}return S-E}),k=[];for(let C of w){let I=[`__args.length === ${C.params.length}`],E=[];for(let S=0;S<C.params.length;S++){let P=C.params[S];if(E.push(`__args[${S}]`),P.defaultValue){let N=rr(`__args[${S}]`,P.defaultValue);N!=="true"&&I.push(N)}}k.push(` if (${I.join(" && ")}) return ${d}$${C.index}(${E.join(", ")})`)}let b=`
29
+ ${y}${x}function ${d}(...__args) {
30
+ ${k.join(`
34
31
  `)}
35
32
  return __tjs.typeError('${d}', 'no matching overload', __args)
36
33
  }
37
- `;p+=b}return{source:p,polymorphicNames:n}}function or(e){return e.replace(/(?<=^|[;\n{])\s*([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(t,n)=>t.replace(n,`const ${n}`))}function lr(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,v=!1;for(;m<e.length&&f>0;){let y=e[m];if(v){v=!1,m++;continue}if(y==="\\"&&g){v=!0,m++;continue}if(g){y===g&&(g=null),m++;continue}if(y==="/"&&e[m+1]==="/"){let w=e.indexOf(`
38
- `,m);m=w===-1?e.length:w+1;continue}if(y==="/"&&e[m+1]==="*"){let w=e.indexOf("*/",m+2);m=w===-1?e.length:w+2;continue}if(y==="'"||y==='"'||y==="`"){g=y,m++;continue}y==="{"?f++:y==="}"&&f--,m++}if(f===0){let y=e.slice(d,m-1).trim(),w=m,C=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:u,body:y,start:o,end:w,line:C}),!t)try{new Function(y)()}catch(k){let E=u||`test at line ${C}`;r.push(`Test failed: ${E} (line ${C})
39
- ${k.message||k}`)}let S=(e.slice(o,w).match(/\n/g)||[]).length;s+=`
40
- `.repeat(S),a=w;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function ur(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,v=[];for(;(g=m.exec(f))!==null;)v.push(g.index);if(v.length<2)continue;n.add(l);let y=[];for(let T=0;T<v.length;T++){let P=v[T],N=f.indexOf("(",P),j=1,V=N+1;for(;V<f.length&&j>0;)f[V]==="("&&j++,f[V]===")"&&j--,V++;let L=f.slice(N+1,V-1),J=V;for(;J<f.length&&f[J]!=="{";)J++;let ye=Fe(f,J),Ee=f.slice(J+1,ye-1);y.push({index:T+1,paramStr:L,bodyText:Ee,fullStart:P,fullEnd:ye})}let w=f.slice(0,y[0].fullEnd),C=y[y.length-1].fullEnd;w+=f.slice(C);let b=f;for(let T=y.length-1;T>=1;T--){let P=y[T],N=P.fullStart;for(;N>0&&b[N-1]===" ";)N--;N>0&&b[N-1]===`
41
- `&&N--,b=b.slice(0,N)+b.slice(P.fullEnd)}let S="";for(let T=1;T<y.length;T++){let P=y[T],N=Bt(P.paramStr,t);if(P.paramStr.includes("...")){let V=De(e,p+P.fullStart);throw new Q(`Rest parameters are not supported in polymorphic constructors for '${l}'.`,V)}S+=`
42
- function ${l}$ctor$${P.index}(${P.paramStr}) {`,S+=`
43
- const __obj = Object.create(${l}.prototype)`,S+=`
44
- ;(function() {${P.bodyText}}).call(__obj)`,S+=`
45
- return __obj`,S+=`
34
+ `;p+=b}return{source:p,polymorphicNames:n}}function sr(e){return e.replace(/(?<=^|[;\n{])\s*([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(t,n)=>t.replace(n,`const ${n}`))}function ar(e,t=!1){let n=[],r=[],i="",a=0;for(;a<e.length;){let s=e.slice(a).match(/^\btest\s+/);if(s){let o=a,l=a+s[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,x=!1;for(;m<e.length&&f>0;){let y=e[m];if(x){x=!1,m++;continue}if(y==="\\"&&g){x=!0,m++;continue}if(g){y===g&&(g=null),m++;continue}if(y==="/"&&e[m+1]==="/"){let w=e.indexOf(`
35
+ `,m);m=w===-1?e.length:w+1;continue}if(y==="/"&&e[m+1]==="*"){let w=e.indexOf("*/",m+2);m=w===-1?e.length:w+2;continue}if(y==="'"||y==='"'||y==="`"){g=y,m++;continue}y==="{"?f++:y==="}"&&f--,m++}if(f===0){let y=e.slice(d,m-1).trim(),w=m,k=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:u,body:y,start:o,end:w,line:k}),!t)try{new Function(y)()}catch(I){let E=u||`test at line ${k}`;r.push(`Test failed: ${E} (line ${k})
36
+ ${I.message||I}`)}let C=(e.slice(o,w).match(/\n/g)||[]).length;i+=`
37
+ `.repeat(C),a=w;continue}}}i+=e[a],a++}return{source:i,tests:n,errors:r}}function or(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,i,a=[];for(;(i=r.exec(e))!==null;){let o=i[1],l=i[2]?.trim()||"",u=i.index+i[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 s=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,x=[];for(;(g=m.exec(f))!==null;)x.push(g.index);if(x.length<2)continue;n.add(l);let y=[];for(let S=0;S<x.length;S++){let P=x[S],N=f.indexOf("(",P),O=1,j=N+1;for(;j<f.length&&O>0;)f[j]==="("&&O++,f[j]===")"&&O--,j++;let D=f.slice(N+1,j-1),z=j;for(;z<f.length&&f[z]!=="{";)z++;let ye=Fe(f,z),ke=f.slice(z+1,ye-1);y.push({index:S+1,paramStr:D,bodyText:ke,fullStart:P,fullEnd:ye})}let w=f.slice(0,y[0].fullEnd),k=y[y.length-1].fullEnd;w+=f.slice(k);let b=f;for(let S=y.length-1;S>=1;S--){let P=y[S],N=P.fullStart;for(;N>0&&b[N-1]===" ";)N--;N>0&&b[N-1]===`
38
+ `&&N--,b=b.slice(0,N)+b.slice(P.fullEnd)}let C="";for(let S=1;S<y.length;S++){let P=y[S],N=$t(P.paramStr,t);if(P.paramStr.includes("...")){let j=Ee(e,p+P.fullStart);throw new H(`Rest parameters are not supported in polymorphic constructors for '${l}'.`,j)}C+=`
39
+ function ${l}$ctor$${P.index}(${P.paramStr}) {`,C+=`
40
+ const __obj = Object.create(${l}.prototype)`,C+=`
41
+ ;(function() {${P.bodyText}}).call(__obj)`,C+=`
42
+ return __obj`,C+=`
46
43
  }
47
- `}let k=[];for(let T=0;T<y.length;T++){let P=y[T],N=Bt(P.paramStr,t),j=[`a.length === ${N.length}`];for(let V=0;V<N.length;V++){let L=N[V];if(L.defaultValue){let J=ir(`a[${V}]`,L.defaultValue);J!=="true"&&j.push(J)}}if(T===0)k.push(` if (${j.join(" && ")}) return Reflect.construct(t, a)`);else{let V=N.map((L,J)=>`a[${J}]`).join(", ");k.push(` if (${j.join(" && ")}) return ${l}$ctor$${P.index}(${V})`)}}S+=`
44
+ `}let I=[];for(let S=0;S<y.length;S++){let P=y[S],N=$t(P.paramStr,t),O=[`a.length === ${N.length}`];for(let j=0;j<N.length;j++){let D=N[j];if(D.defaultValue){let z=rr(`a[${j}]`,D.defaultValue);z!=="true"&&O.push(z)}}if(S===0)I.push(` if (${O.join(" && ")}) return Reflect.construct(t, a)`);else{let j=N.map((D,z)=>`a[${z}]`).join(", ");I.push(` if (${O.join(" && ")}) return ${l}$ctor$${P.index}(${j})`)}}C+=`
48
45
  function ${l}$dispatch(t, a) {
49
- `,S+=k.join(`
46
+ `,C+=I.join(`
50
47
  `)+`
51
- `,S+=` return __tjs.typeError('${l}', 'no matching constructor', a)
52
- `,S+=`}
53
- `,i=i.slice(0,p)+b+i.slice(d);let E=p+b.length;i=i.slice(0,E)+S+i.slice(E)}return{source:i,polyCtorClasses:n}}function cr(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 pr(e){let t=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now() or Timestamp.from()"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now()"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:n,message:r}of t)if(n.test(e))throw new Error(r);return e}function fr(e){let t=new Set,n=/\bconst!\s+(\w+)\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);if(t.size===0)return e;e=e.replace(/\bconst!\s+/g,"const ");let s=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let 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 hr(e){if(/(?<![a-zA-Z_$])\bvar\s+/.test(e))throw new Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return e}function dr(e){if(/(?<![A-Za-z_$])\beval\s*\(/.test(e))throw new Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(e))throw new Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return e}function mr(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let 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=Oi(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===`
54
- `&&(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 Oi(e){let t=e.length-1;for(;t>=0&&/\s/.test(e[t]);)t--;if(t<0)return e.length;for(;t>=0;){let n=e[t];if(/[\w$]/.test(n)){for(;t>=0&&/[\w$]/.test(e[t]);)t--;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n===")"){if(t=Gn(e,t,"(",")"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n==="]"){if(t=Gn(e,t,"[","]"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else return t+1}return 0}function Gn(e,t,n,r){let s=1;for(t--;t>=0&&s>0;)e[t]===r?s++:e[t]===n&&s--,s>0&&t--;return t}function Vi(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(`
55
- `,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function Li(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,l=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e)||t.vmTarget,u=l?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0};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)\b/,f;for(;f=e.match(d);){let k=f[2];k==="TjsStrict"?(u.tjsEquals=!0,u.tjsClass=!0,u.tjsDate=!0,u.tjsNoeval=!0,u.tjsNoVar=!0,u.tjsStandard=!0):k==="TjsCompat"?(u.tjsEquals=!1,u.tjsClass=!1,u.tjsDate=!1,u.tjsNoeval=!1,u.tjsNoVar=!1,u.tjsStandard=!1,u.tjsSafeEval=!1):k==="TjsEquals"?u.tjsEquals=!0:k==="TjsClass"?u.tjsClass=!0:k==="TjsDate"?u.tjsDate=!0:k==="TjsNoeval"?u.tjsNoeval=!0:k==="TjsNoVar"?u.tjsNoVar=!0:k==="TjsStandard"?u.tjsStandard=!0:k==="TjsSafeEval"&&(u.tjsSafeEval=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${k}\\s*`),"$1")}e=Vi(e),u.tjsStandard&&(e=Zn(e)),e=fr(e),e=mr(e),e=Kn(e),u.tjsEquals&&!t.vmTarget&&(e=Qn(e)),e=Yn(e),e=er(e),e=Xn(e),e=tr(e),e=nr(e),e=or(e);let{source:m,returnType:g,returnSafety:v}=lt(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=m;let y=rr(e);e=y.source,e=Hn(e);let w=ar(e,s);e=w.source;let C=Jn(e);e=C.source;let b=lr(e,t.dangerouslySkipTests);e=b.source;let S=ur(e,s);e=S.source;for(let k of S.polyCtorClasses)a.add(`${k}$dispatch`);return u.tjsClass&&(e=cr(e,S.polyCtorClasses)),u.tjsDate&&(e=pr(e)),u.tjsNoeval&&(e=dr(e)),u.tjsNoVar&&(e=hr(e)),e=sr(e,y.extensions),{source:e,returnType:g,returnSafety:v,moduleSafety:r,tjsModes:u,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:C.blocks,tests:b.tests,testErrors:b.errors,polymorphicNames:w.polymorphicNames,extensions:y.extensions}}function gr(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1}=t,{source:a,returnType:i,returnSafety:o,moduleSafety:l,originalSource:u,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:v}=r?Li(e,{vmTarget:s}):{source:e,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:e,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[]};try{return{ast:Vn(a,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:i,returnSafety:o,moduleSafety:l,originalSource:u,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:v}}catch(y){let w=y.loc||{line:1,column:0};throw new Q(y.message.replace(/\s*\(\d+:\d+\)$/,""),w,u,n)}}function yr(e,t){for(let r of e.body){if(r.type==="ImportDeclaration")throw new Q("Imports are not supported. All atoms must be registered with the VM.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration")throw new Q("Exports are not supported. The function is automatically exported.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ClassDeclaration")throw new Q("Classes are not supported. Agent99 uses functional composition.",r.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(r=>r.type==="FunctionDeclaration");if(n.length===0)throw new Q("Source must contain a function declaration",{line:1,column:0},void 0,t);if(n.length>1){let r=n[1];throw new Q("Only a single function per agent is allowed",r.loc?.start||{line:1,column:0},void 0,t)}return n[0]}function br(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),s=[...r.matchAll(/\/\*#([\s\S]*?)\*\//g)];if(s.length>0){let p=s[s.length-1],d=r.substring(p.index+p[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(d)){let f=p[1],m=f.split(`
56
- `),g=m.filter(v=>v.trim().length>0).reduce((v,y)=>{let w=y.match(/^(\s*)/)?.[1].length||0;return Math.min(v,w)},1/0);return g>0&&g<1/0&&(f=m.map(v=>v.slice(g)).join(`
57
- `)),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 oe(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(i=>i!=null).map(i=>oe(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]=oe(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?oe(n):t==="&&"||t==="??"?oe(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=oe(n),a=oe(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"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function jt(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new F("Only simple parameter names are supported",q(e));let s=n.name,a=t?.has(s)??!1,i=oe(r),o=pe(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=jt(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}`,q(e))}function pe(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?pe(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=pe(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=pe(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=pe(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?pe(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?pe(n)??pe(r):void 0}default:return}}function xr(e){try{let t=Ln(e,0,{ecmaVersion:2022});return oe(t)}catch{return{kind:"any"}}}function pt(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?pt(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=pt(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(pt)}:{};default:return{}}}function Di(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=pt(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function wr(e,t,n,r={},s){let a=br(t,e),i=new Map;for(let y of e.params){let w=jt(y,s);if(w.name==="__destructured__"&&w.type.kind==="object"&&w.type.destructuredParams)for(let[C,b]of Object.entries(w.type.destructuredParams))i.set(C,{...b,description:a.params[C]});else w.description=a.params[w.name],i.set(w.name,w)}let o;n&&(o=xr(n));let l={depth:0,locals:new Map,parameters:i,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r},u=fe(e.body,l),p=[],d=[],f=[];for(let[y,w]of i.entries())w.required?d.push(y):w.default!==void 0?f.push({name:y,defaultValue:w.default}):d.push(y);d.length>0&&p.push({op:"varsImport",keys:d});for(let{name:y,defaultValue:w}of f)p.push({op:"varsImport",keys:[y]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:y},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:y,value:w}]});p.push(...u);let m=Object.fromEntries(i),g={name:e.id?.name||"anonymous",description:a.description,parameters:m,returns:o},v=Di(m);return{ast:{op:"seq",steps:p,inputSchema:v},signature:g,warnings:l.warnings}}function fe(e,t){let n=[];for(let r of e.body){let s=Ue(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Ue(e,t){switch(e.type){case"VariableDeclaration":return Fi(e,t);case"ExpressionStatement":return Ui(e,t);case"IfStatement":return Wi(e,t);case"WhileStatement":return zi(e,t);case"ForOfStatement":return Gi(e,t);case"TryStatement":return Hi(e,t);case"ReturnStatement":return Ji(e,t);case"ThrowStatement":throw new F("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",q(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:fe(e,ie(t))};case"EmptyStatement":return null;default:throw new F(`Unsupported statement type: ${e.type}`,q(e),t.source,t.filename)}}function Fi(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",q(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:l}=Ae(a.init,t,i,r);o?n.push(o):l!==i&&n.push({op:s,key:i,value:l});let u=oe(a.init);t.locals.set(i,u)}else{if(r)throw new F("const declarations must be initialized",q(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function Ui(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return qi(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=Ae(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:q(e).line,column:q(e).column}),null}function qi(e,t){if(e.left.type!=="Identifier")throw new F("Only simple variable assignment is supported",q(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=Ae(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function Wi(e,t){let n=D(e.test,t),r=e.consequent.type==="BlockStatement"?fe(e.consequent,ie(t)):[Ue(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?fe(e.alternate,ie(t)):[Ue(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function zi(e,t){let n=D(e.test,t),r=e.body.type==="BlockStatement"?fe(e.body,ie(t)):[Ue(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Gi(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",q(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",q(e.left),t.source,t.filename);let r=G(e.right,t),s=ie(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?fe(e.body,s):[Ue(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function Hi(e,t){let n=fe(e.block,ie(t)),r,s;if(e.handler){let a=ie(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=fe(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function Ji(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=Ae(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:G(e.argument,t)}}var Sr=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Ki=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),qe=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),Zi=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 Qi(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Ki.has(t)||qe.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Sr.has(n)||qe.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Zi.has(n))return!0}}return!1}function Yi(e){if(e.object.type==="Identifier"){let t=e.object.name;return Sr.has(t)||qe.has(t)}return!1}var vr={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function Xi(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(qe.has(t))return vr[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(qe.has(n))return vr[n]||`${n} is not available in AsyncJS.`}}return null}function Er(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function Ae(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return Ae(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let l=Er(o);throw new F(`The 'new' keyword is not supported in AsyncJS.${l}`,q(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=Xi(e);if(i)throw new F(i,q(e),t.source,t.filename)}if(e.type==="CallExpression"&&Qi(e)){let i=D(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&Yi(e)){let i=D(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return ea(e,t,n,r);if(e.type==="TemplateLiteral")return na(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=D(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:G(e,t)}}function ea(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=G(l.object,t);else throw new F("Computed method names are not supported",q(e),t.source,t.filename)}else throw new F("Only named function calls are supported",q(e),t.source,t.filename);if(a)return ta(s,i,e.arguments,t,n,r);s==="console"&&e.callee.type;let o=ra(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function ta(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=ie(r);u.locals.set(l,{kind:"any"});let p;if(i.body.type==="BlockStatement")p=fe(i.body,u);else{let{step:d,resultVar:f}=Ae(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=ie(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",q(n[0]),r.source,r.filename);return p=D(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=ie(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",q(n[0]),r.source,r.filename);return p=D(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=ie(r);d.locals.set(u,{kind:"any"}),d.locals.set(p,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=fe(i.body,d);else{let{step:g,resultVar:v}=Ae(i.body,d,"result");f=g?[g]:[{op:"varSet",key:"result",value:v}]}let m=G(n[1],r);return{step:{op:"reduce",items:t,as:p,accumulator: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:G(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?G(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?G(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=>G(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function na(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]=G(o,t),s+=`{{${l}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function D(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=D(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;if(i.type==="Literal")return{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}};throw new F("Computed member access with variables not yet supported",q(e),t.source,t.filename)}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return D(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:D(n.left,t),right:D(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:D(n.left,t),right:D(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:D(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:D(n.test,t),consequent:D(n.consequent,t),alternate:D(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>D(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:D(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:D(r.object,t),method:s,arguments:n.arguments.map(i=>D(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier")return{$expr:"call",callee:n.callee.name,arguments:n.arguments.map(s=>D(s,t))};throw new F("Complex function calls in expressions should be lifted to statements",q(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=Er(r);throw new F(`The 'new' keyword is not supported in AsyncJS.${s}`,q(e),t.source,t.filename)}case"TemplateLiteral":throw new F("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",q(e),t.source,t.filename);default:throw new F(`Unsupported expression type in condition: ${e.type}`,q(e),t.source,t.filename)}}function G(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return D(e,t);let s=G(n.object,t);if(s&&typeof s=="object"&&s.$expr){let 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`${s}[${G(n.property,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 G(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?G(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=G(r.value,t)}return n}case"TemplateLiteral":return D(e,t);case"CallExpression":return D(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return D(e,t);default:return null}}function ra(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]=G(s.value,t)}return r}return{args:e.arguments.map(n=>G(n,t))}}function Cr(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=gr(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),i=yr(n,t.filename),{ast:o,signature:l,warnings:u}=wr(i,s,r,t,a);return{ast:o,signature:l,warnings:u}}var ia=10,kr=class{atoms;constructor(t={}){this.atoms={...zt,...t}}get builder(){return new Me(this.atoms)}get Agent(){return new Me(this.atoms)}get A99(){return this.Agent}resolve(t){return this.atoms[t]}getTools(t="all"){let n=Object.values(this.atoms);if(Array.isArray(t))n=n.filter(r=>t.includes(r.op));else if(t==="flow"){let r=["seq","if","while","return","try","varSet","varGet","scope"];n=n.filter(s=>r.includes(s.op))}return n.map(r=>({type:"function",function:{name:r.op,description:r.docs,parameters:r.inputSchema?.schema??{}}}))}async run(t,n={},r={}){let s;if(typeof t=="string")if(mt(t))s=gt(t);else try{s=Cr(t).ast}catch(g){throw new Error(`AJS transpilation failed: ${g.message}`)}else s=t;let a=r.fuel??1e3,i=r.timeoutMs??a*ia,o=r.capabilities??{},l=[];if(!o.store){let g=new Map,v=!1;o.store={get:async y=>(v||(v=!0,l.push("Using default in-memory store (not suitable for production)")),g.get(y)),set:async(y,w)=>{v||(v=!0,l.push("Using default in-memory store (not suitable for production)")),g.set(y,w)}}}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,context:r.context,warnings:l};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&&!sa(n,f)){let g=new K("Input validation failed: args do not match expected schema","vm.run");return{result:g,error:g,fuelUsed:0,trace:d.trace,warnings:l.length>0?l:void 0}}try{await Promise.race([this.resolve("seq")?.exec(s,d),new Promise((g,v)=>{u.signal.addEventListener("abort",()=>{v(new Error(`Execution timeout after ${i}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`))}),u.signal.aborted&&v(new Error(`Execution timeout after ${i}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`))})])}catch(g){if(g.message?.includes("timeout")||g.message?.includes("aborted")||u.signal.aborted)d.error=new K(`Execution timeout after ${i}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`,"vm.run");else throw g}finally{clearTimeout(p)}d.error&&d.output===void 0&&(d.output=d.error);let m=[...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 M}from"tosijs-schema";var Ar=I("storeVectorize",M.object({text:M.string,model:M.string.optional}),M.array(M.number),async({text:e},t)=>{let n=t.capabilities.vector;if(!n)throw new Error("Capability 'vector' missing. Ensure vector battery is loaded.");let r=x(e,t);return n.embed(r)},{docs:"Generate embeddings using vector battery",cost:20}),_r=I("storeCreateCollection",M.object({collection:M.string,dimension:M.number.optional}),void 0,async({collection:e,dimension:t},n)=>{let r=n.capabilities.store;if(!r?.createCollection)throw new Error("Capability 'store' missing or does not support createCollection.");let s=x(e,n),a=x(t,n);return r.createCollection(s,void 0,a)},{docs:"Create a vector store collection",cost:5}),Tr=I("storeVectorAdd",M.object({collection:M.string,doc:M.any}),void 0,async({collection:e,doc:t},n)=>{let r=n.capabilities.store;if(!r?.vectorAdd)throw new Error("Capability 'store' missing or does not support vectorAdd.");let s=x(e,n),a=x(t,n);return r.vectorAdd(s,a)},{docs:"Add a document to a vector store collection",cost:5}),Ir=I("storeSearch",M.object({collection:M.string,queryVector:M.array(M.number),k:M.number.optional,filter:M.record(M.any).optional}),M.array(M.any),async({collection:e,queryVector:t,k:n,filter:r},s)=>{let a=s.capabilities.store;if(!a?.vectorSearch)throw new Error("Capability 'store' missing or does not support vectorSearch.");let i=x(e,s),o=x(t,s),l=x(n,s)??5,u=x(r,s);return a.vectorSearch(i,o,l,u)},{docs:"Search vector store",cost:(e,t)=>5+(x(e.k,t)??5)}),Pr=I("llmPredictBattery",M.object({system:M.string.optional,user:M.string,tools:M.array(M.any).optional,responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,user:t,tools:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=x(e,s)??"You are a helpful agent.",o=x(t,s),l=x(n,s),u=x(r,s);return a.predict(i,o,l,u)},{docs:"Generate completion using LLM battery",cost:100}),Nr=I("llmVision",M.object({system:M.string.optional,prompt:M.string,images:M.array(M.string),responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,prompt:t,images:n,responseFormat:r},s)=>{let a=s.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let i=x(e,s)??"You analyze images accurately and concisely.",o=x(t,s),l=x(n,s)??[],u=x(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 Va={storeCreateCollection:_r,storeSearch:Ir,storeVectorAdd:Tr,storeVectorize:Ar,llmPredictBattery:Pr,llmVision:Nr};export{K as AgentError,kr as AgentVM,Br as DEFAULT_MAX_AST_SIZE,$r as DEFAULT_PROCEDURE_TTL,dt as PROCEDURE_TOKEN_PREFIX,Ss as agentRun,Va as batteryAtoms,he as builtins,Is as cache,Os as clearExpiredProcedures,$s as consoleError,Rs as consoleLog,Ms as consoleWarn,Kr as constSet,zt as coreAtoms,xe as createChildScope,I as defineAtom,Hr as errorAtom,W as evaluateExpr,gs as fetch,ns as filter,ss as find,yt as hash,qr as iff,Mr as isAgentError,mt as isProcedureToken,ls as join,ks as jsonParse,As as jsonStringify,ds as keys,as as len,ws as llmPredict,ts as map,Ts as memoize,hs as merge,fs as omit,ps as pick,Te as procedureStore,is as push,Ps as random,rs as reduce,cs as regexMatch,js as releaseProcedure,gt as resolveProcedureToken,x as resolveValue,zr as ret,Cs as runCode,es as scope,ee as seq,os as split,ys as storeGet,Bs as storeProcedure,xs as storeQuery,bs as storeSet,us as template,Es as transpileCode,Gr as tryCatch,Ns as uuid,Zr as varGet,Jr as varSet,Xr as varsExport,Qr as varsImport,Yr as varsLet,vs as vectorSearch,Wr as whileLoop,_s as xmlParse};
48
+ `,C+=` return __tjs.typeError('${l}', 'no matching constructor', a)
49
+ `,C+=`}
50
+ `,s=s.slice(0,p)+b+s.slice(d);let E=p+b.length;s=s.slice(0,E)+C+s.slice(E)}return{source:s,polyCtorClasses:n}}function lr(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",i=0,a;for(;(a=n.exec(e))!==null;){let s=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(i,l),r+=`let ${s} = class ${s}${o} ${m}; `,t.has(s)?r+=`${s} = new Proxy(${s}, { apply(t, _, a) { return ${s}$dispatch(t, a) }, construct(t, a) { return ${s}$dispatch(t, a) } });`:r+=`${s} = new Proxy(${s}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,i=f}}return r+=e.slice(i),r}function ur(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 cr(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 i=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(i))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(i))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(i))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(i))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function pr(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 fr(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 hr(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",i=0;for(;n<e.length;){let a=e[n],s=e[n+1];if(r==="normal"){if(a==="/"&&s==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&s==="*"){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",i++,t+=a,n++;continue}if(a==="!"&&s==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,l=Os(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===`
51
+ `&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&s==="/"?(t+=s,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=s||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=s||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=s||"",n+=2):a==="`"?(i--,r=i>0?"string-template":"normal",n++):a==="$"&&s==="{"?(t+=s,n+=2,r="normal"):n++):(t+=a,n++)}return t}function Os(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=Wn(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=Wn(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 Wn(e,t,n,r){let i=1;for(t--;t>=0&&i>0;)e[t]===r?i++:e[t]===n&&i--,i>0&&t--;return t}function dr(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,i="normal",a=[];for(;r<e.length;){let o=e[r],l=e[r+1];switch(i){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(i="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(i="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&l==="{"){r+=2,a.push(1),i="normal";continue}o==="`"&&(i="normal"),r++;continue;case"line-comment":o===`
52
+ `&&(i="normal"),r++;continue;case"block-comment":if(o==="*"&&l==="/"){r+=2,i="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++;i="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++,i="template-string";continue}}if(o==="'"){r++,i="single-string";continue}if(o==='"'){r++,i="double-string";continue}if(o==="`"){r++,i="template-string";continue}if(o==="/"&&l==="/"){r+=2,i="line-comment";continue}if(o==="/"&&l==="*"){r+=2,i="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++,i="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 x=m+1;for(;x<e.length&&/[ \t]/.test(e[x]);)x++;let y=Vs(e,x);if(y>x){let w=e.slice(x,y).trim();t.set(f,w),n.push({start:d,end:y,replacement:""}),r=y;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let s=e;for(let o=n.length-1;o>=0;o--){let l=n[o];s=s.slice(0,l.start)+l.replacement+s.slice(l.end)}return{source:s,annotations:t}}function Vs(e,t){let n=t,r=0,i=0,a=0,s="normal",o=[];for(;n<e.length;){let l=e[n];if(s==="sq"){if(l==="\\"){n+=2;continue}l==="'"&&(s="normal"),n++;continue}if(s==="dq"){if(l==="\\"){n+=2;continue}l==='"'&&(s="normal"),n++;continue}if(s==="tpl"){if(l==="\\"){n+=2;continue}if(l==="$"&&e[n+1]==="{"){o.push(1),s="normal",n+=2;continue}l==="`"&&(s="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(),s="tpl",n++;continue}}if(l==="'"){s="sq",n++;continue}if(l==='"'){s="dq",n++;continue}if(l==="`"){s="tpl",n++;continue}if(l==="("?r++:l===")"?r--:l==="{"?i++:l==="}"?i--:l==="["?a++:l==="]"&&a--,r===0&&i===0&&a===0&&(l==="="||l===","||l===";"||l===`
53
+ `))return n;n++}return n}function ct(e,t){let n="",r=0,i,a,s="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(s){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==="'"&&(s="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=m,r+=2;continue}f==='"'&&(s="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),s="normal";continue}f==="`"&&(s="normal"),r++;continue;case"line-comment":n+=f,f===`
54
+ `&&(s="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&m==="/"){n+=m,r+=2,s="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++;s="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++,s="template-string";continue}}if(f==="'"){n+=f,r++,s="single-string";continue}if(f==='"'){n+=f,r++,s="double-string";continue}if(f==="`"){n+=f,r++,s="template-string";continue}if(f==="/"&&m==="/"){n+=f+m,r+=2,s="line-comment";continue}if(f==="/"&&m==="*"){n+=f+m,r+=2,s="block-comment";continue}if(f==="/"){let b=n.trimEnd();if(!b[b.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(b)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(b)){n+=f,r++,s="regex";continue}}break}if(f==="{"){u++,n+=f,r++;continue}if(f==="}"){u--;let b=l[l.length-1];b&&u===b.braceDepth&&l.pop(),n+=f,r++;continue}let g=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(g){let b=g[0].slice(0,-1);n+=b,r+=b.length,l.push({type:"class-body",braceDepth:u});continue}let x=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(x){let b=x[1],C=x[0].length,I=e[r+C],E=null,S=r+C;(I==="?"||I==="!")&&(E=I,S++,E==="!"?t.unsafeFunctions.add(b):t.safeFunctions.add(b)),n+=`function ${b}(`,r=S;let P=ot(e,r,"(",")");if(!P){n+=e[r],r++;continue}let{content:N,endPos:O}=P;r=O;let j=Bt(N,t,!0);n+=j+")";let D=r;for(;D<e.length&&/\s/.test(e[D]);)D++;if(e[D]===":"){let ye=e.slice(D,D+2),ke;for(ye===":?"||ye===":!"?(D+=2,ke=ye===":?"?"safe":"unsafe"):D+=1;D<e.length&&/\s/.test(e[D]);)D++;let $e=jt(e,D);$e&&(i===void 0&&(i=$e.type,ke&&(a=ke)),r=$e.endPos)}let z=r;for(;z<e.length&&/\s/.test(e[z]);)z++;if(e[z]==="="&&e[z+1]===">")throw new H("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",Ee(t.originalSource,z),t.originalSource);continue}let y=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),w=(()=>{for(let b=n.length-1;b>=0;b--)if(!/\s/.test(n[b]))return n[b];return`
55
+ `})(),k=w!=="="&&w!==","&&w!=="("&&w!=="["&&w!==">";if(y&&d()&&!k){let b=y[1].length;n+=e.slice(r,r+b),r+=b;continue}if(y&&d()&&k){let b=y[1],C=y[0].length,I=r+C;n+=b+"(",r=I;let E=ot(e,r,"(",")");if(!E){n+=e[r],r++;continue}let{content:S,endPos:P}=E;r=P;let N=Bt(S,t,!0);n+=N+")";let O=r;for(;O<e.length&&/\s/.test(e[O]);)O++;if(e[O]===":"){let D=e.slice(O,O+2);for(D===":?"||D===":!"?O+=2:O++;O<e.length&&/\s/.test(e[O]);)O++;let z=jt(e,O);z&&(r=z.endPos)}let j=r;for(;j<e.length&&/\s/.test(e[j]);)j++;if(e[j]==="="&&e[j+1]===">")throw new H("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",Ee(t.originalSource,j),t.originalSource);continue}if(e[r]==="("){let b=ot(e,r+1,"(",")");if(!b){n+=e[r],r++;continue}let C=b.content,I=b.endPos,E=I;for(;E<e.length&&/\s/.test(e[E]);)E++;let S;if(e[E]===":"){let P=e.slice(E,E+2);for(P===":?"||P===":!"?E+=2:E++;E<e.length&&/\s/.test(e[E]);)E++;let N=jt(e,E);if(N)for(S=N.type,E=N.endPos;E<e.length&&/\s/.test(e[E]);)E++}if(e.slice(E,E+2)==="=>"){let P=null,N=C,O=C.trimStart();O.startsWith("?")&&(O.length===1||/\s/.test(O[1]))?(P="?",N=O.slice(1)):O.startsWith("!")&&(O.length===1||/\s/.test(O[1]))&&(P="!",N=O.slice(1));let j=Bt(N,t,!1);for(n+=`(${P==="?"?"/* safe */ ":P==="!"?"/* unsafe */ ":""}${j})`,r=I;r<E&&/\s/.test(e[r]);)n+=e[r],r++;S&&(r=E)}else{let P=ct(C,t);n+=`(${P.source})`,r=I}continue}n+=e[r],r++}return{source:n,returnType:i,returnSafety:a}}function ot(e,t,n,r){let i=1,a=t,s=!1,o="";for(;a<e.length&&i>0;){let l=e[a];!s&&(l==="'"||l==='"'||l==="`")?(s=!0,o=l):s&&l===o&&e[a-1]!=="\\"?s=!1:s||(l===n?i++:l===r&&i--),a++}return i!==0?null:{content:e.slice(t,a-1),endPos:a}}function mr(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,i=e[n];if(i==="{"||i==="["){let s=i==="{"?"}":"]",o=ot(e,n+1,i,s);return o?{value:e.slice(r,o.endPos),endPos:o.endPos}:null}if(i==="'"||i==='"'||i==="`"){for(n++;n<e.length;){if(e[n]===i&&e[n-1]!=="\\")return n++,{value:e.slice(r,n),endPos:n};n++}return null}if(/[-+\d]/.test(i)){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,i=!1,a="",s=!1,o=l=>({type:Ue(e.slice(t,l).trim()),endPos:l});for(;n<e.length;){let l=e[n];if(!i&&(l==="'"||l==='"'||l==="`")){i=!0,a=l,s=!0,n++;continue}if(i){if(l===a&&e[n-1]!=="\\"){if(i=!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++,s=!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(s)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,s=!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(s=!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(s=!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 s?o(n):null}function pt(e){let t=[],n="",r=0,i=!1,a=!1,s=0;for(;s<e.length;){let o=e[s],l=e[s+1];if(!a&&o==="/"&&l==="/"){i=!0,n+="//",s+=2;continue}if(!i&&o==="/"&&l==="*"){a=!0,n+="/*",s+=2;continue}if(i&&o===`
56
+ `){i=!1,n+=o,s++;continue}if(a&&o==="*"&&l==="/"){a=!1,n+="*/",s+=2;continue}if(i||a){n+=o,s++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,s++}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,i=pt(r),a=!1,s=new Set,o=u=>{if(n&&/^\w+$/.test(u)){if(s.has(u))throw new Error(`Duplicate parameter name '${u}'`);s.add(u)}};return i.map(u=>{let p=u.trim();if(!p)return u;if(n&&p.startsWith("{")&&p.endsWith("}")){let m=p.slice(1,-1);return`{ ${gr(m,t)} }`}if(n&&p.startsWith("[")&&p.endsWith("]")){let m=p.slice(1,-1);return`[ ${gr(m,t)} ]`}if(p.startsWith("...")){let m=yr(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(!Ls(p)){let m=p.match(/^(\w+)\s*=/);return m&&o(m[1]),a=!0,u}let f=yr(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 gr(e,t){return pt(e).map(i=>{let a=i.trim();if(!a)return i;let s=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(s){let[,u,p]=s;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 i}).join(", ")}function lt(e){let t=e.slice(1,-1).trim();return`{ ${pt(t).map(i=>{let a=i.trim();if(!a)return i;let s=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(s){let[,d,f]=s;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 i}).join(", ")} }`}function ut(e){let t=e.slice(1,-1).trim();return`[ ${pt(t).map(i=>{let a=i.trim();return a?a.startsWith("{")&&a.endsWith("}")?lt(a):a.startsWith("[")&&a.endsWith("]")?ut(a):i:i}).join(", ")} ]`}function Ls(e){let t=0,n=!1,r=!1,i=!1,a="";for(let s=0;s<e.length;s++){let o=e[s];if(!i&&(o==="'"||o==='"'||o==="`")){i=!0,a=o;continue}if(i){o===a&&e[s-1]!=="\\"&&(i=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[s+1]!==">"&&(r=!0))}return n&&!r}function yr(e){let t=0,n=!1,r="";for(let i=0;i<e.length;i++){let a=e[i];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[i-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return i}return-1}function Ds(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let i=r;for(t+=r,n++;n<e.length&&e[n]!==i;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let i=e.indexOf("*/",n+2),a=i===-1?e.slice(n):e.slice(n,i+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let i=e.indexOf(`
57
+ `,n),a=i===-1?e.length:i;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function Fs(e,t={}){let n=e,r,i=new Set,a=new Set,s=new Set,l=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e)||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 S=f[2];S==="TjsStrict"?(u.tjsEquals=!0,u.tjsClass=!0,u.tjsDate=!0,u.tjsNoeval=!0,u.tjsNoVar=!0,u.tjsStandard=!0,u.tjsSafeAssign=!0):S==="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):S==="TjsEquals"?u.tjsEquals=!0:S==="TjsClass"?u.tjsClass=!0:S==="TjsDate"?u.tjsDate=!0:S==="TjsNoeval"?u.tjsNoeval=!0:S==="TjsNoVar"?u.tjsNoVar=!0:S==="TjsStandard"?u.tjsStandard=!0:S==="TjsSafeEval"?u.tjsSafeEval=!0:S==="TjsSafeAssign"&&(u.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${S}\\s*`),"$1")}e=Ds(e),u.tjsStandard&&(e=Jn(e)),e=cr(e),e=hr(e);let m=dr(e);e=m.source;let g=m.annotations;e=Hn(e),u.tjsEquals&&!t.vmTarget&&(e=Kn(e)),e=Zn(e),e=Yn(e),e=Qn(e),e=Xn(e),e=er(e),e=sr(e);let{source:x,returnType:y,returnSafety:w}=ct(e,{originalSource:n,requiredParams:i,unsafeFunctions:a,safeFunctions:s});e=x;let k=tr(e);e=k.source,e=zn(e);let b=ir(e,i);e=b.source;let C=Gn(e);e=C.source;let I=ar(e,t.dangerouslySkipTests);e=I.source;let E=or(e,i);e=E.source;for(let S of E.polyCtorClasses)a.add(`${S}$dispatch`);return u.tjsClass&&(e=lr(e,E.polyCtorClasses)),u.tjsDate&&(e=ur(e)),u.tjsNoeval&&(e=fr(e)),u.tjsNoVar&&(e=pr(e)),e=nr(e,k.extensions),{source:e,returnType:y,returnSafety:w,moduleSafety:r,tjsModes:u,originalSource:n,requiredParams:i,unsafeFunctions:a,safeFunctions:s,wasmBlocks:C.blocks,tests:I.tests,testErrors:I.errors,polymorphicNames:b.polymorphicNames,extensions:k.extensions,letAnnotations:g}}function br(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:i=!1}=t,{source:a,returnType:s,returnSafety:o,moduleSafety:l,originalSource:u,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:x,letAnnotations:y,tjsModes:w}=r?Fs(e,{vmTarget:i}):{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:Ln(a,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:s,returnSafety:o,moduleSafety:l,originalSource:u,requiredParams:p,unsafeFunctions:d,safeFunctions:f,wasmBlocks:m,tests:g,testErrors:x,letAnnotations:y,tjsModes:w}}catch(k){let b=k.loc||{line:1,column:0};throw new H(k.message.replace(/\s*\(\d+:\d+\)$/,""),b,u,n)}}function xr(e,t){for(let r of e.body){if(r.type==="ImportDeclaration")throw new H("Imports are not supported. All atoms must be registered with the VM.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration")throw new H("Exports are not supported. The function is automatically exported.",r.loc?.start||{line:1,column:0},void 0,t);if(r.type==="ClassDeclaration")throw new H("Classes are not supported. Agent99 uses functional composition.",r.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(r=>r.type==="FunctionDeclaration");if(n.length===0)throw new H("Source must contain a function declaration",{line:1,column:0},void 0,t);if(n.length>1){let r=n[1];throw new H("Only a single function per agent is allowed",r.loc?.start||{line:1,column:0},void 0,t)}return n[0]}function vr(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),i=[...r.matchAll(/\/\*#([\s\S]*?)\*\//g)];if(i.length>0){let p=i[i.length-1],d=r.substring(p.index+p[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(d)){let f=p[1],m=f.split(`
58
+ `),g=m.filter(x=>x.trim().length>0).reduce((x,y)=>{let w=y.match(/^(\s*)/)?.[1].length||0;return Math.min(x,w)},1/0);return g>0&&g<1/0&&(f=m.map(x=>x.slice(g)).join(`
59
+ `)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let s=a[0],o=s.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(s))!==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(s=>s!=null).map(s=>ee(s));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let s of n){let o=JSON.stringify(s);r.has(o)||r.set(o,s)}let i=[...r.values()];return{kind:"array",items:i.length===1?i[0]:{kind:"union",members:i}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let i=r.key.name;n[i]=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 i=ee(n),a=ee(r);return a.kind==="null"?{...i,nullable:!0}:i.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[i,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(i=>Us(i)),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 i=n.raw;return i&&i.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function Us(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 U("Only simple parameter names are supported",W(e));let i=n.name,a=t?.has(i)??!1,s=ee(r),o=pe(r);return{name:i,type:s,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},i={};for(let a of n)if(a.type==="Property"){let s=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[s]={kind:"any"},i[s]={name:s,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ot(a.value,t),l=t?.has(s)??!1;r[s]=o.type,i[s]={name:s,type:o.type,required:l,default:l?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:i},required:!0}}throw new U(`Unsupported parameter pattern: ${e.type}`,W(e))}function pe(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?pe(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=pe(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=pe(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=pe(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?pe(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?pe(n)??pe(r):void 0}default:return}}function wr(e){try{let t=Dn(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 qs(e){let t={},n=[];for(let[r,i]of Object.entries(e))t[r]=ft(i.type),i.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function Er(e,t,n,r={},i){let a=vr(t,e),s=new Map;for(let y of e.params){let w=Ot(y,i);if(w.name==="__destructured__"&&w.type.kind==="object"&&w.type.destructuredParams)for(let[k,b]of Object.entries(w.type.destructuredParams))s.set(k,{...b,description:a.params[k]});else w.description=a.params[w.name],s.set(w.name,w)}let o;n&&(o=wr(n));let l={depth:0,locals:new Map,parameters:s,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r},u=fe(e.body,l),p=[],d=[],f=[];for(let[y,w]of s.entries())w.required?d.push(y):w.default!==void 0?f.push({name:y,defaultValue:w.default}):d.push(y);d.length>0&&p.push({op:"varsImport",keys:d});for(let{name:y,defaultValue:w}of f)p.push({op:"varsImport",keys:[y]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:y},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:y,value:w}]});p.push(...u);let m=Object.fromEntries(s),g={name:e.id?.name||"anonymous",description:a.description,parameters:m,returns:o},x=qs(m);return{ast:{op:"seq",steps:p,inputSchema:x},signature:g,warnings:l.warnings}}function fe(e,t){let n=[];for(let r of e.body){let i=qe(r,t);i&&(Array.isArray(i)?n.push(...i):n.push(i))}return n}function qe(e,t){switch(e.type){case"VariableDeclaration":return Ws(e,t);case"ExpressionStatement":return zs(e,t);case"IfStatement":return Hs(e,t);case"WhileStatement":return Js(e,t);case"ForOfStatement":return Ks(e,t);case"TryStatement":return Zs(e,t);case"ReturnStatement":return Qs(e,t);case"ThrowStatement":throw new U("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",W(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:fe(e,ae(t))};case"EmptyStatement":return null;default:throw new U(`Unsupported statement type: ${e.type}`,W(e),t.source,t.filename)}}function Ws(e,t){let n=[],r=e.kind==="const",i=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new U("Only simple variable names are supported",W(a),t.source,t.filename);let s=a.id.name;if(a.init){let{step:o,resultVar:l}=_e(a.init,t,s,r);o?n.push(o):l!==s&&n.push({op:i,key:s,value:l});let u=ee(a.init);t.locals.set(s,u)}else{if(r)throw new U("const declarations must be initialized",W(a),t.source,t.filename);n.push({op:"varSet",key:s,value:null}),t.locals.set(s,{kind:"any",nullable:!0})}}return n}function zs(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Gs(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:i}=_e(n,t);return r||(i?{op:"varSet",key:"_",value:i}:null)}return t.warnings.push({message:"Expression statement has no effect",line:W(e).line,column:W(e).column}),null}function Gs(e,t){if(e.left.type!=="Identifier")throw new U("Only simple variable assignment is supported",W(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:i}=_e(e.right,t,n);return r||{op:"varSet",key:n,value:i}}function Hs(e,t){let n=L(e.test,t),r=e.consequent.type==="BlockStatement"?fe(e.consequent,ae(t)):[qe(e.consequent,t)].filter(Boolean),i;return e.alternate&&(i=e.alternate.type==="BlockStatement"?fe(e.alternate,ae(t)):[qe(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...i&&{else:i}}}function Js(e,t){let n=L(e.test,t),r=e.body.type==="BlockStatement"?fe(e.body,ae(t)):[qe(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Ks(e,t){let n;if(e.left.type==="VariableDeclaration"){let s=e.left.declarations[0];if(s.id.type!=="Identifier")throw new U("Only simple variable names are supported in for...of",W(e.left),t.source,t.filename);n=s.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new U("Unsupported for...of left-hand side",W(e.left),t.source,t.filename);let r=K(e.right,t),i=ae(t);i.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?fe(e.body,i):[qe(e.body,i)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function Zs(e,t){let n=fe(e.block,ae(t)),r,i;if(e.handler){let a=ae(t);e.handler.param?.type==="Identifier"&&(i=e.handler.param.name,a.locals.set(i,{kind:"any"})),r=fe(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...i&&{catchParam:i}}}function Qs(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=_e(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:K(e.argument,t)}}var kr=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Ys=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"]),Xs=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 ea(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Ys.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(kr.has(n)||We.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Xs.has(n))return!0}}return!1}function ta(e){if(e.object.type==="Identifier"){let t=e.object.name;return kr.has(t)||We.has(t)}return!1}var Sr={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 na(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(We.has(t))return Sr[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 Sr[n]||`${n} is not available in AsyncJS.`}}return null}function Cr(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 _e(e,t,n,r){let i=r?"constSet":"varSet";if(e.type==="ChainExpression")return _e(e.expression,t,n,r);if(e.type==="NewExpression"){let s=e,o="constructor";s.callee.type==="Identifier"&&(o=s.callee.name);let l=Cr(o);throw new U(`The 'new' keyword is not supported in AsyncJS.${l}`,W(e),t.source,t.filename)}if(e.type==="CallExpression"){let s=na(e);if(s)throw new U(s,W(e),t.source,t.filename)}if(e.type==="CallExpression"&&ea(e)){let s=L(e,t);return n?{step:{op:i,key:n,value:s},resultVar:n}:{step:null,resultVar:s}}if(e.type==="MemberExpression"&&ta(e)){let s=L(e,t);return n?{step:{op:i,key:n,value:s},resultVar:n}:{step:null,resultVar:s}}if(e.type==="CallExpression")return ra(e,t,n,r);if(e.type==="TemplateLiteral")return sa(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let s=L(e,t);return n?{step:{op:i,key:n,value:s},resultVar:n}:{step:null,resultVar:s}}return{step:null,resultVar:K(e,t)}}function ra(e,t,n,r){let i,a=!1,s;if(e.callee.type==="Identifier")i=e.callee.name;else if(e.callee.type==="MemberExpression"){let l=e.callee;if(l.property.type==="Identifier")i=l.property.name,a=!0,s=K(l.object,t);else throw new U("Computed method names are not supported",W(e),t.source,t.filename)}else throw new U("Only named function calls are supported",W(e),t.source,t.filename);if(a)return ia(i,s,e.arguments,t,n,r);i==="console"&&e.callee.type;let o=aa(e,t);return{step:{op:i,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function ia(e,t,n,r,i,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let s=n[0],o=s.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(s.body.type==="BlockStatement")p=fe(s.body,u);else{let{step:d,resultVar:f}=_e(s.body,u,"result");p=d?[d]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:l,steps:p,...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let s=n[0],o=s.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(s.body.type==="BlockStatement")throw new U("filter callback must be an expression, not a block",W(n[0]),r.source,r.filename);return p=L(s.body,u),{step:{op:"filter",items:t,as:l,condition:p,...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let s=n[0],o=s.params[0],l=o?.type==="Identifier"?o.name:"item",u=ae(r);u.locals.set(l,{kind:"any"});let p;if(s.body.type==="BlockStatement")throw new U("find callback must be an expression, not a block",W(n[0]),r.source,r.filename);return p=L(s.body,u),{step:{op:"find",items:t,as:l,condition:p,...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let s=n[0],o=s.params[0],l=s.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(s.body.type==="BlockStatement")f=fe(s.body,d);else{let{step:g,resultVar:x}=_e(s.body,d,"result");f=g?[g]:[{op:"varSet",key:"result",value:x}]}let m=K(n[1],r);return{step:{op:"reduce",items:t,as:p,accumulator:u,initial:m,steps:f,...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:K(n[0],r),...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i};case"join":return{step:{op:"join",list:t,sep:n.length>0?K(n[0],r):"",...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i};case"split":return{step:{op:"split",str:t,sep:n.length>0?K(n[0],r):"",...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(s=>K(s,r)),...i&&{result:i},...i&&a&&{resultConst:!0}},resultVar:i}}function sa(e,t,n,r){let i="",a={};for(let s=0;s<e.quasis.length;s++)if(i+=e.quasis[s].value.cooked||e.quasis[s].value.raw,s<e.expressions.length){let o=e.expressions[s],l=`_${s}`;a[l]=K(o,t),i+=`{{${l}}}`}return{step:{op:"template",tmpl:i,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),i=n.optional===!0;if(n.computed){let s=n.property;return s.type==="Literal"?{$expr:"member",object:r,property:String(s.value),computed:!0,...i&&{optional:!0}}:{$expr:"member",object:r,property:L(s,t),computed:!0,...i&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...i&&{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 i of n.properties)if(i.type==="Property"){let a=i.key.type==="Identifier"?i.key.name:String(i.key.value);r.push({key:a,value:L(i.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,i=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:i,arguments:n.arguments.map(s=>L(s,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier")return{$expr:"call",callee:n.callee.name,arguments:n.arguments.map(i=>L(i,t))};throw new U("Complex function calls in expressions should be lifted to statements",W(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let i=Cr(r);throw new U(`The 'new' keyword is not supported in AsyncJS.${i}`,W(e),t.source,t.filename)}case"TemplateLiteral":throw new U("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",W(e),t.source,t.filename);default:throw new U(`Unsupported expression type in condition: ${e.type}`,W(e),t.source,t.filename)}}function K(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 i=K(n.object,t);if(i&&typeof i=="object"&&i.$expr){let s=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:i,property:s,...n.computed&&{computed:!0}}}if(n.computed)return L(e,t);let a=n.property.name;return typeof i=="string"?`${i}.${a}`:i&&i.$kind==="arg"?{$kind:"arg",path:`${i.path}.${a}`}:`${i}.${a}`}case"ChainExpression":return K(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?K(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let i=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[i]=K(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 aa(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let i of n.properties)if(i.type==="Property"){let a=i.key.type==="Identifier"?i.key.name:String(i.key.value);r[a]=K(i.value,t)}return r}return{args:e.arguments.map(n=>K(n,t))}}function Ar(e,t={}){let{ast:n,returnType:r,originalSource:i,requiredParams:a}=br(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),s=xr(n,t.filename),{ast:o,signature:l,warnings:u}=Er(s,i,r,t,a);return{ast:o,signature:l,warnings:u}}var la=10,_r=class{atoms;constructor(t={}){this.atoms={...Gt,...t}}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(i=>r.includes(i.op))}return n.map(r=>({type:"function",function:{name:r.op,description:r.docs,parameters:r.inputSchema?.schema??{}}}))}async run(t,n={},r={}){let i;if(typeof t=="string")if(gt(t))i=yt(t);else try{i=Ar(t).ast}catch(g){throw new Error(`AJS transpilation failed: ${g.message}`)}else i=t;let a=r.fuel??1e3,s=r.timeoutMs??a*la,o=r.capabilities??{},l=[];if(!o.store){let g=new Map,x=!1;o.store={get:async y=>(x||(x=!0,l.push("Using default in-memory store (not suitable for production)")),g.get(y)),set:async(y,w)=>{x||(x=!0,l.push("Using default in-memory store (not suitable for production)")),g.set(y,w)}}}let u=new AbortController,p=setTimeout(()=>u.abort(),s);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,context:r.context,warnings:l};if(r.trace&&(d.trace=[]),i.op!=="seq")throw new Error("Root AST must be 'seq'. Ensure you're passing a transpiled agent (use ajs`...` or transpile()).");let f=i.inputSchema;if(f&&!oa(n,f)){let g=new Z("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(i,d),new Promise((g,x)=>{u.signal.addEventListener("abort",()=>{x(new Error(`Execution timeout after ${s}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`))}),u.signal.aborted&&x(new Error(`Execution timeout after ${s}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`))})])}catch(g){if(g.message?.includes("timeout")||g.message?.includes("aborted")||u.signal.aborted)d.error=new Z(`Execution timeout after ${s}ms (fuel: ${a}). Consider increasing fuel or optimizing your agent.`,"vm.run");else throw g}finally{clearTimeout(p)}d.error&&d.output===void 0&&(d.output=d.error);let m=[...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 M}from"tosijs-schema";var Tr=T("storeVectorize",M.object({text:M.string,model:M.string.optional}),M.array(M.number),async({text:e},t)=>{let n=t.capabilities.vector;if(!n)throw new Error("Capability 'vector' missing. Ensure vector battery is loaded.");let r=v(e,t);return n.embed(r)},{docs:"Generate embeddings using vector battery",cost:20}),Ir=T("storeCreateCollection",M.object({collection:M.string,dimension:M.number.optional}),void 0,async({collection:e,dimension:t},n)=>{let r=n.capabilities.store;if(!r?.createCollection)throw new Error("Capability 'store' missing or does not support createCollection.");let i=v(e,n),a=v(t,n);return r.createCollection(i,void 0,a)},{docs:"Create a vector store collection",cost:5}),Pr=T("storeVectorAdd",M.object({collection:M.string,doc:M.any}),void 0,async({collection:e,doc:t},n)=>{let r=n.capabilities.store;if(!r?.vectorAdd)throw new Error("Capability 'store' missing or does not support vectorAdd.");let i=v(e,n),a=v(t,n);return r.vectorAdd(i,a)},{docs:"Add a document to a vector store collection",cost:5}),Nr=T("storeSearch",M.object({collection:M.string,queryVector:M.array(M.number),k:M.number.optional,filter:M.record(M.any).optional}),M.array(M.any),async({collection:e,queryVector:t,k:n,filter:r},i)=>{let a=i.capabilities.store;if(!a?.vectorSearch)throw new Error("Capability 'store' missing or does not support vectorSearch.");let s=v(e,i),o=v(t,i),l=v(n,i)??5,u=v(r,i);return a.vectorSearch(s,o,l,u)},{docs:"Search vector store",cost:(e,t)=>5+(v(e.k,t)??5)}),Rr=T("llmPredictBattery",M.object({system:M.string.optional,user:M.union([M.string,M.array(M.any)]),tools:M.array(M.any).optional,responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,user:t,tools:n,responseFormat:r},i)=>{let a=i.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let s=v(e,i)??"You are a helpful agent.",o=v(t,i),l=v(n,i),u=v(r,i);return a.predict(s,o,l,u)},{docs:"Generate completion using LLM battery",cost:100}),Mr=T("llmVision",M.object({system:M.string.optional,prompt:M.string,images:M.array(M.string),responseFormat:M.any.optional}),M.object({role:M.string.optional,content:M.string.optional,tool_calls:M.array(M.any).optional}),async({system:e,prompt:t,images:n,responseFormat:r},i)=>{let a=i.capabilities.llmBattery;if(!a?.predict)throw new Error("Capability 'llmBattery' missing or invalid.");let s=v(e,i)??"You analyze images accurately and concisely.",o=v(t,i),l=v(n,i)??[],u=v(r,i);return a.predict(s,{text:o,images:l},void 0,u)},{docs:"Analyze images using a vision model",timeoutMs:12e4,cost:150});var qa={storeCreateCollection:Ir,storeSearch:Nr,storeVectorAdd:Pr,storeVectorize:Tr,llmPredictBattery:Rr,llmVision:Mr};export{Z as AgentError,_r as AgentVM,Br as DEFAULT_MAX_AST_SIZE,jr as DEFAULT_PROCEDURE_TTL,mt as PROCEDURE_TOKEN_PREFIX,Ei as agentRun,qa as batteryAtoms,he as builtins,Pi as cache,Vi as clearExpiredProcedures,ji as consoleError,Mi as consoleLog,$i as consoleWarn,Zr as constSet,Gt as coreAtoms,xe as createChildScope,T as defineAtom,Jr as errorAtom,q as evaluateExpr,yi as fetch,ri as filter,si as find,bt as hash,Wr as iff,$r as isAgentError,gt as isProcedureToken,ui as join,Ai as jsonParse,_i as jsonStringify,mi as keys,oi as len,Si as llmPredict,ni as map,Ii as memoize,di as merge,hi as omit,fi as pick,Ie as procedureStore,ai as push,Ni as random,ii as reduce,pi as regexMatch,Oi as releaseProcedure,yt as resolveProcedureToken,v as resolveValue,Gr as ret,Ci as runCode,ti as scope,te as seq,li as split,bi as storeGet,Bi as storeProcedure,vi as storeQuery,xi as storeSet,ci as template,ki as transpileCode,Hr as tryCatch,Ri as uuid,Qr as varGet,Kr as varSet,ei as varsExport,Yr as varsImport,Xr as varsLet,wi as vectorSearch,zr as whileLoop,Ti as xmlParse};
58
60
  //# sourceMappingURL=tjs-vm.js.map