subscript 10.0.2 → 10.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -138,10 +138,17 @@ codegen(['+', ['*', 'min', [,60]], [,'sec']])
138
138
  Bundle imports into a single file:
139
139
 
140
140
  ```js
141
- import { bundle } from 'subscript/util/bundle.js'
141
+ // Node.js
142
+ import { bundleFile } from 'subscript/util/bundle.js'
143
+ console.log(await bundleFile('jessie.js'))
142
144
 
143
- const code = await bundle('subscript/jessie.js')
144
- // self-contained ES module
145
+ // Browser / custom sources
146
+ import { bundle } from 'subscript/util/bundle.js'
147
+ console.log(await bundle('main.js', {
148
+ 'main.js': `import { x } from './lib.js'; export default x * 2`,
149
+ 'lib.js': `export const x = 21`
150
+ }))
151
+ // → "const x = 21;\nexport { x as default }"
145
152
  ```
146
153
 
147
154
 
@@ -5,7 +5,7 @@
5
5
  * { get x() { body } } → ['{}', ['get', 'x', body]]
6
6
  * { set x(v) { body } } → ['{}', ['set', 'x', 'v', body]]
7
7
  */
8
- import { token, expr, skip, space, err, next, parse, cur, idx, operator, compile } from '../parse.js';
8
+ import { token, expr, skip, space, next, parse, cur, idx, operator, compile } from '../parse.js';
9
9
 
10
10
  // Accessor marker for object property definitions
11
11
  export const ACC = Symbol('accessor');
@@ -33,6 +33,19 @@ const accessor = (kind) => a => {
33
33
  token('get', ASSIGN - 1, accessor('get'));
34
34
  token('set', ASSIGN - 1, accessor('set'));
35
35
 
36
+ // Method shorthand: { foo() {} } → [':', 'foo', ['=>', ['()', params], body]]
37
+ // Uses token() infix handler - returns undefined to fall through to function call
38
+ token('(', ASSIGN - 1, a => {
39
+ // Only handle infix position with plain identifier in low-precedence context (object literal)
40
+ if (!a || typeof a !== 'string') return;
41
+ const params = expr(0, CPAREN) || null;
42
+ space();
43
+ // Not followed by { - not method shorthand, fall through
44
+ if (cur.charCodeAt(idx) !== OBRACE) return;
45
+ skip();
46
+ return [':', a, ['=>', ['()', params], expr(0, CBRACE) || null]];
47
+ });
48
+
36
49
  // Compile
37
50
  operator('get', (name, body) => {
38
51
  body = body ? compile(body) : () => {};
package/feature/class.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Class declarations and expressions
2
2
  // class A extends B { ... }
3
- import { binary, unary, token, expr, space, next, parse, literal, word, operator, compile } from '../parse.js';
3
+ import { binary, unary, token, expr, space, next, parse, literal, word, operator, compile, skip } from '../parse.js';
4
4
  import { keyword, block } from './block.js';
5
5
 
6
6
  const TOKEN = 200, PREFIX = 140, COMP = 90;
@@ -27,12 +27,15 @@ keyword('class', TOKEN, () => {
27
27
  space();
28
28
  let name = next(parse.id) || null;
29
29
  // 'extends' parsed as name? → anonymous class
30
- if (name === 'extends') name = null;
31
- else {
30
+ if (name === 'extends') {
31
+ name = null;
32
+ space();
33
+ } else {
32
34
  space();
33
35
  if (!word('extends')) return ['class', name, null, block()];
36
+ skip(7); // skip 'extends'
37
+ space();
34
38
  }
35
- space();
36
39
  return ['class', name, expr(TOKEN), block()];
37
40
  });
38
41
 
@@ -5,20 +5,29 @@
5
5
  */
6
6
  import { compile } from '../parse.js';
7
7
 
8
+ // Flatten comma into array: [',', a, b, c] → [a, b, c]
9
+ const flatten = items => items[0]?.[0] === ',' ? items[0].slice(1) : items;
10
+
8
11
  // Destructure value into context
9
12
  export const destructure = (pattern, value, ctx) => {
10
13
  if (typeof pattern === 'string') { ctx[pattern] = value; return; }
11
- const [op, ...items] = pattern;
14
+ const [op, ...raw] = pattern;
15
+ const items = flatten(raw);
12
16
  if (op === '{}') {
13
17
  for (const item of items) {
14
18
  let key, binding, def;
15
- if (item[0] === '=') [, [, key, binding], def] = item;
16
- else [, key, binding] = item;
19
+ // Shorthand: {x} → item is 'x'
20
+ // With default: {x = 1} → ['=', 'x', default]
21
+ // Rename: {x: y} → [':', 'x', 'y']
22
+ if (typeof item === 'string') { key = binding = item }
23
+ else if (item[0] === '=') { typeof item[1] === 'string' ? (key = binding = item[1]) : ([, key, binding] = item[1]); def = item[2] }
24
+ else { [, key, binding] = item }
17
25
  let val = value[key];
18
26
  if (val === undefined && def) val = compile(def)(ctx);
19
27
  destructure(binding, val, ctx);
20
28
  }
21
- } else if (op === '[]') {
29
+ }
30
+ else if (op === '[]') {
22
31
  let i = 0;
23
32
  for (const item of items) {
24
33
  if (item === null) { i++; continue; }
@@ -1,5 +1,5 @@
1
1
  // Function declarations and expressions
2
- import { space, next, parse, parens, expr, operator, compile } from '../parse.js';
2
+ import { space, next, parse, parens, expr, operator, compile, cur, idx, skip } from '../parse.js';
3
3
  import { RETURN } from './control.js';
4
4
  import { keyword, block } from './block.js';
5
5
 
@@ -7,9 +7,17 @@ const TOKEN = 200;
7
7
 
8
8
  keyword('function', TOKEN, () => {
9
9
  space();
10
+ // Check for generator: function*
11
+ let generator = false;
12
+ if (cur[idx] === '*') {
13
+ generator = true;
14
+ skip();
15
+ space();
16
+ }
10
17
  const name = next(parse.id);
11
18
  name && space();
12
- return ['function', name, parens() || null, block()];
19
+ const node = generator ? ['function*', name, parens() || null, block()] : ['function', name, parens() || null, block()];
20
+ return node;
13
21
  });
14
22
 
15
23
  // Compile
@@ -42,3 +50,8 @@ operator('function', (name, params, body) => {
42
50
  return fn;
43
51
  };
44
52
  });
53
+
54
+ // Generator function (parse only, no implementation)
55
+ operator('function*', (name, params, body) => {
56
+ throw Error('Generator functions are not supported in evaluation');
57
+ });
package/feature/module.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * export { a } from './x' → ['export', ['from', ['{}', ...], path]]
10
10
  * export const x = 1 → ['export', decl]
11
11
  */
12
- import { token, expr, space, lookup, skip } from '../parse.js';
12
+ import { token, expr, space, lookup, skip, word } from '../parse.js';
13
13
  import { keyword } from './block.js';
14
14
 
15
15
  const STATEMENT = 5, SEQ = 10, STAR = 42;
@@ -25,13 +25,16 @@ token('from', SEQ + 1, a => !a ? false : a[0] !== '=' && a[0] !== ',' && (space(
25
25
  token('as', SEQ + 2, a => !a ? false : (space(), ['as', a, expr(SEQ + 2)]));
26
26
 
27
27
  // import: prefix that parses specifiers + from + path
28
- keyword('import', STATEMENT, () => (space(), ['import', expr(SEQ)]));
28
+ // import.meta returns ['import.meta']
29
+ keyword('import', STATEMENT, () => (
30
+ word('.meta') ? (skip(5), ['import.meta']) : ['import', expr(SEQ)]
31
+ ));
29
32
 
30
33
  // export: prefix for declarations or re-exports (use STATEMENT to capture const/let/function)
31
34
  keyword('export', STATEMENT, () => (space(), ['export', expr(STATEMENT)]));
32
35
 
33
- // default: prefix for export default
34
- keyword('default', SEQ + 1, () => (space(), ['default', expr(SEQ)]));
36
+ // default: prefix for export default (NOT switch default: which has colon)
37
+ keyword('default', SEQ + 1, () => space() !== 58 && (space(), ['default', expr(SEQ)]));
35
38
 
36
39
  // Compile stubs - import/export are parse-only (no runtime semantics)
37
40
  import { operator, compile } from '../parse.js';
package/feature/number.js CHANGED
@@ -5,24 +5,32 @@
5
5
  */
6
6
  import { parse, lookup, next, err, skip, idx, cur } from '../parse.js';
7
7
 
8
- const PERIOD = 46, _0 = 48, _9 = 57, _E = 69, _e = 101, PLUS = 43, MINUS = 45;
8
+ const PERIOD = 46, _0 = 48, _9 = 57, _E = 69, _e = 101, PLUS = 43, MINUS = 45, UNDERSCORE = 95, _n = 110;
9
9
  const _a = 97, _f = 102, _A = 65, _F = 70;
10
10
 
11
+ // Strip underscores only if present (avoid allocation for common case)
12
+ const strip = s => s.indexOf('_') < 0 ? s : s.replaceAll('_', '');
13
+
11
14
  // Decimal number - check for .. range operator (don't consume . if followed by .)
12
- const num = a => [, (
13
- a = +next(c =>
15
+ // Supports numeric separators: 1_000_000 and BigInt suffix: 123n
16
+ const num = a => {
17
+ let str = strip(next(c =>
14
18
  // . is decimal only if NOT followed by another . (range operator)
15
19
  (c === PERIOD && cur.charCodeAt(idx + 1) !== PERIOD) ||
16
20
  (c >= _0 && c <= _9) ||
21
+ c === UNDERSCORE ||
17
22
  ((c === _E || c === _e) && ((c = cur.charCodeAt(idx + 1)) >= _0 && c <= _9 || c === PLUS || c === MINUS) ? 2 : 0)
18
- )
19
- ) != a ? err() : a];
23
+ ));
24
+ // BigInt suffix
25
+ if (cur.charCodeAt(idx) === _n) { skip(); return [, BigInt(str)]; }
26
+ return (a = +str) != a ? err() : [, a];
27
+ };
20
28
 
21
- // Char test for prefix base
29
+ // Char test for prefix base (with underscore support)
22
30
  const charTest = {
23
- 2: c => c === 48 || c === 49,
24
- 8: c => c >= 48 && c <= 55,
25
- 16: c => (c >= _0 && c <= _9) || (c >= _a && c <= _f) || (c >= _A && c <= _F)
31
+ 2: c => c === 48 || c === 49 || c === UNDERSCORE,
32
+ 8: c => (c >= 48 && c <= 55) || c === UNDERSCORE,
33
+ 16: c => (c >= _0 && c <= _9) || (c >= _a && c <= _f) || (c >= _A && c <= _F) || c === UNDERSCORE
26
34
  };
27
35
 
28
36
  // Default: no prefixes
@@ -40,7 +48,7 @@ lookup[_0] = a => {
40
48
  for (const [pre, base] of Object.entries(cfg)) {
41
49
  if (pre[0] === '0' && cur[idx + 1]?.toLowerCase() === pre[1]) {
42
50
  skip(2);
43
- return [, parseInt(next(charTest[base]), base)];
51
+ return [, parseInt(strip(next(charTest[base])), base)];
44
52
  }
45
53
  }
46
54
  }
@@ -8,14 +8,17 @@
8
8
  *
9
9
  * JS-specific keywords
10
10
  */
11
- import { unary, operator, compile } from '../../parse.js';
11
+ import { unary, operator, compile, token, space, skip, expr, word } from '../../parse.js';
12
12
 
13
13
  const PREFIX = 140;
14
14
 
15
15
  unary('typeof', PREFIX);
16
16
  unary('void', PREFIX);
17
17
  unary('delete', PREFIX);
18
- unary('new', PREFIX);
18
+ // new X() or new.target - can't use two unary() because both start with 'n' (lookup collision)
19
+ token('new', PREFIX, a => !a && (
20
+ word('.target') ? (skip(7), ['new.target']) : ['new', expr(PREFIX)]
21
+ ));
19
22
 
20
23
  // Compile
21
24
  operator('typeof', a => (a = compile(a), ctx => typeof a(ctx)));
package/feature/switch.js CHANGED
@@ -1,48 +1,71 @@
1
1
  // Switch/case/default
2
- // AST: ['switch', val, [';', ['case', test], stmts..., ['default'], stmts...]]
3
- import { expr, skip, space, parens, operator, compile } from '../parse.js';
4
- import { keyword, block } from './block.js';
2
+ // AST: ['switch', val, ['case', test, body], ['default', body], ...]
3
+ import { expr, skip, space, parens, operator, compile, idx, err, seek, parse, lookup, word } from '../parse.js';
4
+ import { keyword } from './block.js';
5
5
  import { BREAK } from './control.js';
6
6
 
7
- const STATEMENT = 5, ASSIGN = 20, COLON = 58;
7
+ const STATEMENT = 5, ASSIGN = 20, COLON = 58, SEMI = 59, CBRACE = 125;
8
8
 
9
- keyword('switch', STATEMENT + 1, () => (space(), ['switch', parens(), block()]));
10
- keyword('case', STATEMENT + 1, () => (space(), (c => (space() === COLON && skip(), ['case', c]))(expr(ASSIGN))));
11
- keyword('default', STATEMENT + 1, () => (space() === COLON && skip(), ['default']));
9
+ // Reserve 'case' and 'default' as keywords that fail outside switch body
10
+ // This prevents them becoming identifiers for colon operator
11
+ const reserve = (w, c = w.charCodeAt(0), prev = lookup[c]) =>
12
+ lookup[c] = (a, prec, op) => (word(w) && !a && (parse.reserved = 1)) || prev?.(a, prec, op);
13
+ reserve('case');
14
+ reserve('default');
15
+
16
+ // caseBody() - parse statements until next case/default/}
17
+ const caseBody = (c) => {
18
+ const stmts = [];
19
+ while ((c = space()) !== CBRACE && !word('case') && !word('default')) {
20
+ if (c === SEMI) { skip(); continue; }
21
+ stmts.push(expr(STATEMENT - .5)) || err();
22
+ }
23
+ return stmts.length > 1 ? [';', ...stmts] : stmts[0] || null;
24
+ };
25
+
26
+ // switchBody() - parse case/default statements
27
+ const switchBody = () => {
28
+ space() === 123 || err('Expected {'); skip();
29
+ const cases = [];
30
+ while (space() !== CBRACE) {
31
+ if (word('case')) {
32
+ seek(idx + 4); space();
33
+ const test = expr(ASSIGN - .5);
34
+ space() === COLON && skip();
35
+ cases.push(['case', test, caseBody()]);
36
+ } else if (word('default')) {
37
+ seek(idx + 7); space() === COLON && skip();
38
+ cases.push(['default', caseBody()]);
39
+ } else err('Expected case or default');
40
+ }
41
+ skip();
42
+ return cases;
43
+ };
44
+
45
+ // switch (x) { ... }
46
+ keyword('switch', STATEMENT + 1, () => (space(), ['switch', parens(), ...switchBody()]));
12
47
 
13
48
  // Compile
14
- operator('switch', (val, cases) => {
49
+ operator('switch', (val, ...cases) => {
15
50
  val = compile(val);
16
- // Parse cases body: [';', ['case', test], stmts..., ['default'], stmts...]
17
- if (!cases) return ctx => val(ctx);
18
- const parsed = [];
19
- const items = cases[0] === ';' ? cases.slice(1) : [cases];
20
- let current = null;
21
- for (const item of items) {
22
- if (Array.isArray(item) && (item[0] === 'case' || item[0] === 'default')) {
23
- if (current) parsed.push(current);
24
- current = [item[0] === 'case' ? compile(item[1]) : null, []];
25
- } else if (current) {
26
- current[1].push(compile(item));
27
- }
28
- }
29
- if (current) parsed.push(current);
51
+ if (!cases.length) return ctx => val(ctx);
52
+
53
+ cases = cases.map(c => [
54
+ c[0] === 'case' ? compile(c[1]) : null,
55
+ (c[0] === 'case' ? c[2] : c[1])?.[0] === ';'
56
+ ? (c[0] === 'case' ? c[2] : c[1]).slice(1).map(compile)
57
+ : (c[0] === 'case' ? c[2] : c[1]) ? [compile(c[0] === 'case' ? c[2] : c[1])] : []
58
+ ]);
30
59
 
31
60
  return ctx => {
32
61
  const v = val(ctx);
33
- let matched = false, result;
34
- for (const [test, stmts] of parsed) {
35
- if (matched || test === null || test(ctx) === v) {
36
- matched = true;
37
- for (const stmt of stmts) {
38
- try { result = stmt(ctx); }
39
- catch (e) {
40
- if (e?.type === BREAK) return e.value !== undefined ? e.value : result;
41
- throw e;
42
- }
43
- }
44
- }
45
- }
46
- return result;
62
+ let matched = false, r;
63
+ for (const [test, stmts] of cases)
64
+ if (matched || test === null || test(ctx) === v)
65
+ for (matched = true, i = 0; i < stmts.length; i++)
66
+ try { r = stmts[i](ctx); }
67
+ catch (e) { if (e?.type === BREAK) return e.value ?? r; throw e; }
68
+ var i;
69
+ return r;
47
70
  };
48
71
  });
package/jessie.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var u,c,m=r=>(u=0,c=r,m.newline=!1,r=A(),c[u]?I():r||""),I=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
2
- `),o=t.pop(),n=c.slice(Math.max(0,e-40),e),s="\u032D",f=(c[e]||"\u2205")+s,l=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
- ${(c[e-41]!==`
4
- `?"...":"")+n}${f}${l}`)},V=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},g=(r=1)=>c[u+=r],G=r=>u=r,A=(r=0,e)=>{let t,o,n,s,f=m.reserved,l;for(e&&m.asi&&(m.newline=!1),m.reserved=0;(t=m.space())&&(l=m.newline,1)&&t!==e&&(n=((s=w[t])&&s(o,r))??(m.asi&&o&&l&&(n=m.asi(o,r,A)))??(!o&&!m.reserved&&k(m.id)));)o=n,m.reserved=0;return m.reserved=f,e&&(t==e?u++:I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},y=m.space=(r,e=u)=>{for(;(r=c.charCodeAt(u))<=32;)m.asi&&r===10&&(m.newline=!0),u++;return r},mt=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,X=(r,e=r.length)=>c.substr(u,e)===r&&!m.id(c.charCodeAt(u+e)),N=()=>(g(),A(0,41)),w=[],S=(r,e=32,t,o=r.charCodeAt(0),n=r.length,s=w[o],f=r.toUpperCase()!==r,l,h)=>w[o]=(E,T,F,C=u)=>(l=F,(F?r==F:(n<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(n<3||c.substr(u,n)==r))&&(!f||!m.id(c.charCodeAt(u+n)))&&(l=F=r))&&T<e&&(u+=n,(h=t(E))?V(h,C):(u=C,l=0,f&&h!==!1&&(m.reserved=1),!f&&!s&&I()),h)||s?.(E,T,l)),d=(r,e,t=!1)=>S(r,e,(o,n)=>o&&(n=A(e-(t?.5:0)))&&[r,o,n]),v=(r,e,t)=>S(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),P=(r,e)=>S(r,200,t=>!t&&[,e]),sr=(r,e,t)=>{S(r,e,(o,n)=>(n=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o))},H=(r,e)=>S(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),pr=(r,e)=>S(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),ir={},p=(r,e,t=ir[r])=>ir[r]=(...o)=>e(...o)||t?.(...o),i=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):ir[r[0]]?.(...r.slice(1))??I(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var Y=46,j=48,Z=57,br=69,re=101,ee=43,te=45,oe=97,ne=102,ie=65,se=70,fr=r=>[,(r=+k(e=>e===Y&&c.charCodeAt(u+1)!==Y||e>=j&&e<=Z||((e===br||e===re)&&((e=c.charCodeAt(u+1))>=j&&e<=Z||e===ee||e===te)?2:0)))!=r?I():r],pe={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=j&&r<=Z||r>=oe&&r<=ne||r>=ie&&r<=se};m.number=null;w[Y]=r=>!r&&c.charCodeAt(u+1)!==Y&&fr();for(let r=j;r<=Z;r++)w[r]=e=>e?void 0:fr();w[j]=r=>{if(r)return;let e=m.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1])return g(2),[,parseInt(k(pe[o]),o)]}return fr()};var fe=92,vr=34,Tr=39,le={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ir=r=>(e,t,o="")=>{if(!(e||!m.string?.[String.fromCharCode(r)]))return g(),k(n=>n-r&&(n===fe?(o+=le[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?g():I("Bad string"),[,o]};w[vr]=Ir(vr);w[Tr]=Ir(Tr);m.string={'"':!0};var ue=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>d(r,ue,!0));var Rr=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?Rr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),Nr={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in Nr)p(r,(e,t)=>(t=i(t),Rr(e,(o,n,s)=>Nr[r](o,n,t(s)))));var me=30,ce=40,_r=140;d("!",_r);v("!",_r);d("||",me);d("&&",ce);p("!",r=>(r=i(r),e=>!r(e)));p("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var de=50,Ae=60,ye=70,Or=100,he=140;d("|",de);d("&",ye);d("^",Ae);d(">>",Or);d("<<",Or);v("~",he);p("~",r=>(r=i(r),e=>~r(e)));p("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var q=90;d("<",q);d(">",q);d("<=",q);d(">=",q);p(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var Pr=80;d("==",Pr);d("!=",Pr);p("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Mr=110,lr=120,Ur=140;d("+",Mr);d("-",Mr);d("*",lr);d("/",lr);d("%",lr);v("+",Ur);v("-",Ur);p("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));p("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var x=150;S("++",x,r=>r?["++",r,null]:["++",A(x-1)]);S("--",x,r=>r?["--",r,null]:["--",A(x-1)]);var ur=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?ur(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>ur(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>ur(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var ge=5,Ee=10,ae=170;H("()",ae);sr(",",Ee);sr(";",ge,!0);var Lr=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});p(",",Lr);p(";",Lr);var M=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",mr=170;pr("[]",mr);d(".",mr);pr("()",mr);var b=r=>{throw Error(r)};p("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=i(t[1]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&b("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return M(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],M(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?b("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&b("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return cr(r,(n,s,f)=>n[s](...o(f)))});var O=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&O(r[1])||r[0]==="{}"),cr=(r,e,t,o)=>r==null?b("Empty ()"):r[0]==="()"&&r.length==2?cr(r[1],e):typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="?."?(t=i(r[1]),o=r[2],n=>{let s=t(n);return s==null?void 0:e(s,o,n)}):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="?.[]"?(t=i(r[1]),o=i(r[2]),n=>{let s=t(n);return s==null?void 0:e(s,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),U=cr;var Fr=new WeakMap,Se=(r,...e)=>typeof r=="string"?i(m(r)):Fr.get(r)||Fr.set(r,Ce(r,e)).get(r),Gr=57344,Ce=(r,e)=>{let t=r.reduce((s,f,l)=>s+(l?String.fromCharCode(Gr+l-1):"")+f,""),o=m(t),n=s=>{if(typeof s=="string"&&s.length===1){let f=s.charCodeAt(0)-Gr,l;if(f>=0&&f<e.length)return l=e[f],we(l)?l:[,l]}return Array.isArray(s)?s.map(n):s};return i(n(o))},we=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Xr=Se;var ke=32,ve=m.space;m.comment??={"//":`
6
- `,"/*":"*/"};var dr;m.space=()=>{dr||(dr=Object.entries(m.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r=ve();){for(var e=0,t;t=dr[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
7
- `)for(;c.charCodeAt(o)>=ke;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}G(o),r=0;break}if(r)return r}return r};var Kr=80;d("===",Kr);d("!==",Kr);p("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var Te=30;d("??",Te);p("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Ie=130,Ne=20;d("**",Ie,!0);d("**=",Ne,!0);p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var Re=r=>{throw Error(r)};p("**=",(r,e)=>(O(r)||Re("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]**=e(n))));var Dr=90;d("in",Dr);d("of",Dr);p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var _e=20,Oe=100,Pe=r=>{throw Error(r)};d(">>>",Oe);d(">>>=",_e,!0);p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(O(r)||Pe("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]>>>=e(n))));var L=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r;if(o==="{}")for(let s of n){let f,l,h;s[0]==="="?[,[,f,l],h]=s:[,f,l]=s;let E=e[f];E===void 0&&h&&(E=i(h)(t)),L(l,E,t)}else if(o==="[]"){let s=0;for(let f of n){if(f===null){s++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(s);break}let l=f,h;Array.isArray(f)&&f[0]==="="&&([,l,h]=f);let E=e[s++];E===void 0&&h&&(E=i(h)(t)),L(l,E,t)}}};var Ar=20,rr=r=>{throw Error(r)};d("||=",Ar,!0);d("&&=",Ar,!0);d("??=",Ar,!0);p("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=i(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>L(t,e(o),o)}return O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]??=e(n))));P("true",!0);P("false",!1);P("null",null);P("undefined",void 0);P("NaN",NaN);P("Infinity",1/0);var yr=20;S("?",yr,(r,e,t)=>r&&(e=A(yr-1))&&k(o=>o===58)&&(t=A(yr-1),["?",r,e,t]));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var Me=20;d("=>",Me,!0);p("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=i(e[0]==="{}"?e[1]:e),(n=null)=>(n=Object.create(n),(...s)=>(r.forEach((f,l)=>n[f]=s[l]),o&&(n[o]=s.slice(t)),e(n)))});var Ue=140;v("...",Ue);p("...",r=>(r=i(r),e=>Object.entries(r(e))));var Br=170;S("?.",Br,(r,e)=>{if(!r)return;let t=y();return t===40?(g(),["?.()",r,A(0,41)||null]):t===91?(g(),["?.[]",r,A(0,93)]):(e=A(Br),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=i(r),M(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return M(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return M(s)?()=>{}:f=>n(f)?.[s]?.(...t(f))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return f=>{let l=n(f),h=s(f);return M(h)?void 0:l?.[h]?.(...t(f))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return M(s)?()=>{}:f=>n(f)?.[s]?.(...t(f))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return f=>{let l=n(f),h=s(f);return M(h)?void 0:l?.[h]?.(...t(f))}}let o=i(r);return n=>o(n)?.(...t(n))});var er=140;v("typeof",er);v("void",er);v("delete",er);v("new",er);p("typeof",r=>(r=i(r),e=>typeof r(e)));p("void",r=>(r=i(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=i(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(f=>f(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var tr=Symbol("accessor"),Qr=20,Le=40,Fe=41,Ge=123,Xe=125,$r=r=>e=>{if(e)return;y();let t=k(m.id);if(!t||(y(),c.charCodeAt(u)!==Le))return!1;g();let o=A(0,Fe);return y(),c.charCodeAt(u)!==Ge?!1:(g(),[r,t,o,A(0,Xe)])};S("get",Qr-1,$r("get"));S("set",Qr-1,$r("set"));p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[tr,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[tr,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var Ke=20,Hr=200;H("[]",Hr);H("{}",Hr);d(":",Ke-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let f of t.flatMap(l=>l(o)))if(f[0]===tr){let[,l,h]=f;s[l]={...s[l],...h,configurable:!0,enumerable:!0}}else n[f[0]]=f[1];for(let f in s)Object.defineProperty(n,f,s[f]);return n}});p(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var De=170,or=96,Be=36,Qe=123,$e=92,He={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},jr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==or;)t?t===$e?(g(),e+=He[c[u]]||c[u],g()):t===Be&&c.charCodeAt(u+1)===Qe?(e&&r.push([,e]),e="",g(2),r.push(A(0,125))):(e+=c[u],g(),t=c.charCodeAt(u),t===or&&e&&r.push([,e])):I("Unterminated template");return g(),r},je=w[or];w[or]=(r,e)=>r&&e<De?m.asi&&m.newline?void 0:(g(),["``",r,...jr()]):r?je?.(r,e):(g(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(jr()));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(f=>f(s)))});m.string["'"]=!0;m.number={"0x":16,"0b":2,"0o":8};var hr=5,Wr=123,zr=125,a=(r,e,t,o=r.charCodeAt(0),n=r.length,s=w[o],f)=>w[o]=(l,h,E,T=u)=>!l&&(E?r==E:(n<2||c.substr(u,n)==r)&&(E=r))&&h<e&&!m.id(c.charCodeAt(u+n))&&(G(u+n),(f=t())?V(f,T):(G(T),!s&&I()),f)||s?.(l,h,E),gr=(r,e,t,o=r.charCodeAt(0),n=r.length,s=w[o],f)=>w[o]=(l,h,E,T=u)=>l&&(E?r==E:(n<2||c.substr(u,n)==r)&&(E=r))&&h<e&&!m.id(c.charCodeAt(u+n))&&(G(u+n),V(f=t(l),T),f)||s?.(l,h,E),_=()=>(y()===Wr||I("Expected {"),g(),A(hr-.5,zr)||null),K=()=>y()!==Wr?A(hr+.5):(g(),A(hr-.5,zr)||null);var Er=5,We=10,ze=20,Jr=r=>{let e=A(We-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};S("let",Er+1,r=>!r&&Jr("let"));S("const",Er+1,r=>!r&&Jr("const"));a("var",Er,()=>(y(),["var",A(ze)]));var Vr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,n=i(o);return typeof t=="string"?s=>{s[t]=n(s)}:s=>L(t,n(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",Vr);p("const",Vr);p("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var D=Symbol("break"),W=Symbol("continue"),B=Symbol("return");var Je=200;a("function",Je,()=>{y();let r=k(m.id);return r&&y(),["function",r,N()||null,_()]});p("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,s=-1,f=o[o.length-1];return Array.isArray(f)&&f[0]==="..."&&(s=o.length-1,n=f[1],o.length--),l=>{let h=(...E)=>{let T={};o.forEach((C,R)=>T[C]=E[R]),n&&(T[n]=E.slice(s));let F=new Proxy(T,{get:(C,R)=>R in C?C[R]:l[R],set:(C,R,xr)=>((R in C?C:l)[R]=xr,!0),has:(C,R)=>R in C||R in l});try{return t(F)}catch(C){if(C?.type===B)return C.value;throw C}};return r&&(l[r]=h),h}});var nr=140,ar=20;v("await",nr);a("yield",nr,()=>(y(),c[u]==="*"?(g(),y(),["yield*",A(ar)]):["yield",A(ar)]));a("async",nr,()=>{if(y(),X("function"))return["async",A(nr)];let r=A(ar-.5);return r&&["async",r]});p("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});p("await",r=>(r=i(r),async e=>await r(e)));p("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));p("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var Sr=200,Ve=140,Ye=90,Ze=Symbol("static");P("super",Symbol.for("super"));v("static",Ve);d("instanceof",Ye);S("#",Sr,r=>{if(r)return;let e=k(m.id);return e?"#"+e:void 0});a("class",Sr,()=>{y();let r=k(m.id)||null;if(r==="extends")r=null;else if(y(),!X("extends"))return["class",r,null,_()];return y(),["class",r,A(Sr),_()]});var qe=r=>{throw Error(r)};p("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));p("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,o=>{let n=e?e(o):Object,s=function(...f){if(!(this instanceof s))return qe("Class constructor must be called with new");let l=e?Reflect.construct(n,f,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(l,f),l};if(Object.setPrototypeOf(s.prototype,n.prototype),Object.setPrototypeOf(s,n),t){let f=Object.create(o);f.super=n;let l=t(f),h=Array.isArray(l)&&typeof l[0]?.[0]=="string"?l:[];for(let[E,T]of h)E==="constructor"?s.prototype.__constructor__=T:s.prototype[E]=T}return r&&(o[r]=s),s}));p("static",r=>(r=i(r),e=>[[Ze,r(e)]]));var xe=140,Cr=47,be=92,rt=r=>r===be?2:r&&r!==Cr,et=r=>r===103||r===105||r===109||r===115||r===117||r===121;S("/",xe,r=>{if(r)return;let e=c.charCodeAt(u);if(e===Cr||e===42||e===43||e===63||e===61)return;let t=k(rt);c.charCodeAt(u)===Cr||I("Unterminated regex"),g();try{return[,new RegExp(t,k(et))]}catch(o){I("Invalid regex: "+o.message)}});var tt=5,ot=59,nt=()=>{let r=u;return y()===ot&&g(),y(),X("else")?(g(4),!0):(G(r),!1)};a("if",tt+1,()=>{y();let r=["if",N(),K()];return nt()&&r.push(K()),r});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,o=>r(o)?e(o):t?.(o)));var z=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===D)return{b:1};if(t?.type===W)return{c:1};if(t?.type===B)return{r:1,v:t.value};throw t}},Q=5,it=125,st=59;a("while",Q+1,()=>(y(),["while",N(),K()]));a("do",Q+1,()=>(r=>(y(),g(5),y(),["do",r,N()]))(K()));a("for",Q+1,()=>(y(),X("await")?(g(5),y(),["for await",N(),K()]):["for",N(),K()]));a("break",Q+1,()=>["break"]);a("continue",Q+1,()=>["continue"]);a("return",Q+1,()=>{m.asi&&(m.newline=!1),y();let r=c.charCodeAt(u);return!r||r===it||r===st||m.newline?["return"]:["return",A(Q)]});p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;for(;r(t)&&!(o=z(e,t)).b;){if(o.r)return o.v;o.c||(n=o.v)}return n}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;do{if((o=z(r,t)).b)break;if(o.r)return o.v;o.c||(n=o.v)}while(e(t));return n}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let f,l;for(t?.(s);o(s)&&!(f=z(e,s)).b;n?.(s)){if(f.r)return f.v;f.c||(l=f.v)}return l}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return ft(o,n,e);if(t==="of")return pt(o,n,e)}});var pt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,f,l=o?null:n[r];for(let h of e(n)){if(o?L(r,h,n):n[r]=h,(s=z(t,n)).b)break;if(s.r)return s.v;s.c||(f=s.v)}return o||(n[r]=l),f}},ft=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,f,l=o?null:n[r];for(let h in e(n)){if(o?L(r,h,n):n[r]=h,(s=z(t,n)).b)break;if(s.r)return s.v;s.c||(f=s.v)}return o||(n[r]=l),f}};p("break",()=>()=>{throw{type:D}});p("continue",()=>()=>{throw{type:W}});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw{type:B,value:r?.(e)}}));var J=5;a("try",J+1,()=>["try",_()]);gr("catch",J+1,r=>(y(),["catch",r,N(),_()]));gr("finally",J+1,r=>["finally",r,_()]);a("throw",J+1,()=>{if(m.asi&&(m.newline=!1),y(),m.newline)throw SyntaxError("Unexpected newline after throw");return["throw",A(J)]});p("try",r=>(r=r?i(r):null,e=>r?.(e)));p("catch",(r,e,t)=>{let o=r?.[1]?i(r[1]):null;return t=t?i(t):null,n=>{let s;try{s=o?.(n)}catch(f){if(f?.type===D||f?.type===W||f?.type===B)throw f;if(e!==null&&t){let l=e in n,h=n[e];n[e]=f;try{s=t(n)}finally{l?n[e]=h:delete n[e]}}else if(e===null)throw f}return s}});p("finally",(r,e)=>(r=r?i(r):null,e=e?i(e):null,t=>{let o;try{o=r?.(t)}finally{e?.(t)}return o}));p("throw",r=>(r=i(r),e=>{throw r(e)}));var wr=5,lt=20,Yr=58;a("switch",wr+1,()=>(y(),["switch",N(),_()]));a("case",wr+1,()=>(y(),(r=>(y()===Yr&&g(),["case",r]))(A(lt))));a("default",wr+1,()=>(y()===Yr&&g(),["default"]));p("switch",(r,e)=>{if(r=i(r),!e)return s=>r(s);let t=[],o=e[0]===";"?e.slice(1):[e],n=null;for(let s of o)Array.isArray(s)&&(s[0]==="case"||s[0]==="default")?(n&&t.push(n),n=[s[0]==="case"?i(s[1]):null,[]]):n&&n[1].push(i(s));return n&&t.push(n),s=>{let f=r(s),l=!1,h;for(let[E,T]of t)if(l||E===null||E(s)===f){l=!0;for(let F of T)try{h=F(s)}catch(C){if(C?.type===D)return C.value!==void 0?C.value:h;throw C}}return h}});var kr=5,$=10,Zr=42,ut=w[Zr];w[Zr]=(r,e)=>r?ut?.(r,e):(g(),"*");S("from",$+1,r=>r?r[0]!=="="&&r[0]!==","&&(y(),["from",r,A($+1)]):!1);S("as",$+2,r=>r?(y(),["as",r,A($+2)]):!1);a("import",kr,()=>(y(),["import",A($)]));a("export",kr,()=>(y(),["export",A(kr)]));a("default",$+1,()=>(y(),["default",A($)]));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var qr=5;m.asi=(r,e,t)=>{if(e>=qr)return;let o=t(qr-.5);if(o)return r?.[0]!==";"?[";",r,o]:(r.push(o),r)};export{pr as access,d as binary,i as compile,c as cur,Xr as default,I as err,A as expr,H as group,mt as id,u as idx,P as literal,V as loc,w as lookup,sr as nary,k as next,p as operator,ir as operators,N as parens,m as parse,G as seek,g as skip,y as space,S as token,v as unary,X as word};
1
+ var u,c,m=r=>(u=0,c=r,m.newline=!1,r=d(),c[u]?k():r||""),k=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
2
+ `),o=t.pop(),i=c.slice(Math.max(0,e-40),e),s="\u032D",l=(c[e]||" ")+s,f=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${c[e-41]!==`
4
+ `,""+i}${l}${f}`)},Y=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),v=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},y=(r=1)=>c[u+=r],O=r=>u=r,d=(r=0,e)=>{let t,o,i,s,l=m.reserved,f;for(e&&m.asi&&(m.newline=!1),m.reserved=0;(t=m.space())&&(f=m.newline,1)&&t!==e&&(i=((s=C[t])&&s(o,r))??(m.asi&&o&&f&&(i=m.asi(o,r,d)))??(!o&&!m.reserved&&v(m.id)));)o=i,m.reserved=0;return m.reserved=l,e&&(t==e?u++:k("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},A=m.space=(r,e=u)=>{for(;(r=c.charCodeAt(u))<=32;)m.asi&&r===10&&(m.newline=!0),u++;return r},wt=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,T=(r,e=r.length)=>c.substr(u,e)===r&&!m.id(c.charCodeAt(u+e)),N=()=>(y(),d(0,41)),C=[],E=(r,e=32,t,o=r.charCodeAt(0),i=r.length,s=C[o],l=r.toUpperCase()!==r,f,a)=>C[o]=(g,S,$,R=u)=>(f=$,($?r==$:(i<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(i<3||c.substr(u,i)==r))&&(!l||!m.id(c.charCodeAt(u+i)))&&(f=$=r))&&S<e&&(u+=i,(a=t(g))?Y(a,R):(u=R,f=0,l&&a!==!1&&(m.reserved=1),!l&&!s&&k()),a)||s?.(g,S,f)),h=(r,e,t=!1)=>E(r,e,(o,i)=>o&&(i=d(e-(t?.5:0)))&&[r,o,i]),I=(r,e,t)=>E(r,e,o=>t?o&&[r,o]:!o&&(o=d(e-.5))&&[r,o]),U=(r,e)=>E(r,200,t=>!t&&[,e]),pr=(r,e,t)=>{E(r,e,(o,i)=>(i=d(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},H=(r,e)=>E(r[0],e,t=>!t&&[r,d(0,r.charCodeAt(1))||null]),lr=(r,e)=>E(r[0],e,t=>t&&[r,t,d(0,r.charCodeAt(1))||null]),sr={},p=(r,e,t=sr[r])=>sr[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):sr[r[0]]?.(...r.slice(1))??k(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var q=46,j=48,x=57,pe=69,le=101,fe=43,ue=45,Z=95,me=110,ce=97,de=102,Ae=65,he=70,Tr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),fr=r=>{let e=Tr(v(t=>t===q&&c.charCodeAt(u+1)!==q||t>=j&&t<=x||t===Z||((t===pe||t===le)&&((t=c.charCodeAt(u+1))>=j&&t<=x||t===fe||t===ue)?2:0)));return c.charCodeAt(u)===me?(y(),[,BigInt(e)]):(r=+e)!=r?k():[,r]},ye={2:r=>r===48||r===49||r===Z,8:r=>r>=48&&r<=55||r===Z,16:r=>r>=j&&r<=x||r>=ce&&r<=de||r>=Ae&&r<=he||r===Z};m.number=null;C[q]=r=>!r&&c.charCodeAt(u+1)!==q&&fr();for(let r=j;r<=x;r++)C[r]=e=>e?void 0:fr();C[j]=r=>{if(r)return;let e=m.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1])return y(2),[,parseInt(Tr(v(ye[o])),o)]}return fr()};var ae=92,Ir=34,Rr=39,ge={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Nr=r=>(e,t,o="")=>{if(!(e||!m.string?.[String.fromCharCode(r)]))return y(),v(i=>i-r&&(i===ae?(o+=ge[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?y():k("Bad string"),[,o]};C[Ir]=Nr(Ir);C[Rr]=Nr(Rr);m.string={'"':!0};var Ee=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>h(r,Ee,!0));var Or=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?Or(r[1],e):(()=>{throw Error("Invalid assignment target")})(),_r={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in _r)p(r,(e,t)=>(t=n(t),Or(e,(o,i,s)=>_r[r](o,i,t(s)))));var we=30,Ce=40,Pr=140;h("!",Pr);I("!",Pr);h("||",we);h("&&",Ce);p("!",r=>(r=n(r),e=>!r(e)));p("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var Se=50,ke=60,ve=70,Mr=100,Te=140;h("|",Se);h("&",ve);h("^",ke);h(">>",Mr);h("<<",Mr);I("~",Te);p("~",r=>(r=n(r),e=>~r(e)));p("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var b=90;h("<",b);h(">",b);h("<=",b);h(">=",b);p(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var Ur=80;h("==",Ur);h("!=",Ur);p("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var Lr=110,ur=120,Fr=140;h("+",Lr);h("-",Lr);h("*",ur);h("/",ur);h("%",ur);I("+",Fr);I("-",Fr);p("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));p("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var rr=150;E("++",rr,r=>r?["++",r,null]:["++",d(rr-1)]);E("--",rr,r=>r?["--",r,null]:["--",d(rr-1)]);var mr=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?mr(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>mr(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>mr(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Ie=5,Re=10,Ne=170;H("()",Ne);pr(",",Re);pr(";",Ie,!0);var Gr=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});p(",",Gr);p(";",Gr);var L=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",cr=170;lr("[]",cr);h(".",cr);lr("()",cr);var er=r=>{throw Error(r)};p("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&er("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return L(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],L(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?er("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(s=>s==null||t(s));t(e)&&er("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(s=>s(i))):(e=n(e),i=>[e(i)]):()=>[];return dr(r,(i,s,l)=>i[s](...o(l)))});var P=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&P(r[1])||r[0]==="{}"),dr=(r,e,t,o)=>r==null?er("Empty ()"):r[0]==="()"&&r.length==2?dr(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let s=t(i);return s==null?void 0:e(s,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let s=t(i);return s==null?void 0:e(s,o(i),i)}):(r=n(r),i=>e([r(i)],0,i)),F=dr;var Br=new WeakMap,_e=(r,...e)=>typeof r=="string"?n(m(r)):Br.get(r)||Br.set(r,Oe(r,e)).get(r),Xr=57344,Oe=(r,e)=>{let t=r.reduce((s,l,f)=>s+(f?String.fromCharCode(Xr+f-1):"")+l,""),o=m(t),i=s=>{if(typeof s=="string"&&s.length===1){let l=s.charCodeAt(0)-Xr,f;if(l>=0&&l<e.length)return f=e[l],Pe(f)?f:[,f]}return Array.isArray(s)?s.map(i):s};return n(i(o))},Pe=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Dr=_e;var Me=32,Ue=m.space;m.comment??={"//":`
6
+ `,"/*":"*/"};var Ar;m.space=()=>{Ar||(Ar=Object.entries(m.comment).map(([i,s])=>[i,s,i.charCodeAt(0)]));for(var r;r=Ue();){for(var e=0,t;t=Ar[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
7
+ `)for(;c.charCodeAt(o)>=Me;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}O(o),r=0;break}if(r)return r}return r};var Kr=80;h("===",Kr);h("!==",Kr);p("===",(r,e)=>(r=n(r),e=n(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=n(r),e=n(e),t=>r(t)!==e(t)));var Le=30;h("??",Le);p("??",(r,e)=>(r=n(r),e=n(e),t=>r(t)??e(t)));var Fe=130,Ge=20;h("**",Fe,!0);h("**=",Ge,!0);p("**",(r,e)=>(r=n(r),e=n(e),t=>r(t)**e(t)));var Be=r=>{throw Error(r)};p("**=",(r,e)=>(P(r)||Be("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]**=e(i))));var Qr=90;h("in",Qr);h("of",Qr);p("in",(r,e)=>(r=n(r),e=n(e),t=>r(t)in e(t)));var Xe=20,De=100,Ke=r=>{throw Error(r)};h(">>>",De);h(">>>=",Xe,!0);p(">>>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(P(r)||Ke("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]>>>=e(i))));var Qe=r=>r[0]?.[0]===","?r[0].slice(1):r,G=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...i]=r,s=Qe(i);if(o==="{}")for(let l of s){let f,a,g;typeof l=="string"?f=a=l:l[0]==="="?(typeof l[1]=="string"?f=a=l[1]:[,f,a]=l[1],g=l[2]):[,f,a]=l;let S=e[f];S===void 0&&g&&(S=n(g)(t)),G(a,S,t)}else if(o==="[]"){let l=0;for(let f of s){if(f===null){l++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(l);break}let a=f,g;Array.isArray(f)&&f[0]==="="&&([,a,g]=f);let S=e[l++];S===void 0&&g&&(S=n(g)(t)),G(a,S,t)}}};var hr=20,tr=r=>{throw Error(r)};h("||=",hr,!0);h("&&=",hr,!0);h("??=",hr,!0);p("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=n(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>G(t,e(o),o)}return P(r)||tr("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]=e(i))});p("||=",(r,e)=>(P(r)||tr("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]||=e(i))));p("&&=",(r,e)=>(P(r)||tr("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]&&=e(i))));p("??=",(r,e)=>(P(r)||tr("Invalid assignment target"),e=n(e),F(r,(t,o,i)=>t[o]??=e(i))));U("true",!0);U("false",!1);U("null",null);U("undefined",void 0);U("NaN",NaN);U("Infinity",1/0);var yr=20;E("?",yr,(r,e,t)=>r&&(e=d(yr-1))&&v(o=>o===58)&&(t=d(yr-1),["?",r,e,t]));p("?",(r,e,t)=>(r=n(r),e=n(e),t=n(t),o=>r(o)?e(o):t(o)));var $e=20;h("=>",$e,!0);p("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=n(e[0]==="{}"?e[1]:e),(i=null)=>(i=Object.create(i),(...s)=>(r.forEach((l,f)=>i[l]=s[f]),o&&(i[o]=s.slice(t)),e(i)))});var He=140;I("...",He);p("...",r=>(r=n(r),e=>Object.entries(r(e))));var $r=170;E("?.",$r,(r,e)=>{if(!r)return;let t=A();return t===40?(y(),["?.()",r,d(0,41)||null]):t===91?(y(),["?.[]",r,d(0,93)]):(e=d($r),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=n(r),L(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=n(r),e=n(e),t=>{let o=e(t);return L(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(s=>s(i))):(e=n(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=n(r[1]),s=r[2];return L(s)?()=>{}:l=>i(l)?.[s]?.(...t(l))}if(r[0]==="?.[]"){let i=n(r[1]),s=n(r[2]);return l=>{let f=i(l),a=s(l);return L(a)?void 0:f?.[a]?.(...t(l))}}if(r[0]==="."){let i=n(r[1]),s=r[2];return L(s)?()=>{}:l=>i(l)?.[s]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),s=n(r[2]);return l=>{let f=i(l),a=s(l);return L(a)?void 0:f?.[a]?.(...t(l))}}let o=n(r);return i=>o(i)?.(...t(i))});var W=140;I("typeof",W);I("void",W);I("delete",W);E("new",W,r=>!r&&(T(".target")?(y(7),["new.target"]):["new",d(W)]));p("typeof",r=>(r=n(r),e=>typeof r(e)));p("void",r=>(r=n(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=n(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=n(r[1]),t=n(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=n(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(i=>s=>i.map(l=>l(s)))(t.slice(1).map(n)):(i=>s=>[i(s)])(n(t)):()=>[];return i=>new(e(i))(...o(i))});var or=Symbol("accessor"),ar=20,je=40,Hr=41,jr=123,Wr=125,zr=r=>e=>{if(e)return;A();let t=v(m.id);if(!t||(A(),c.charCodeAt(u)!==je))return!1;y();let o=d(0,Hr);return A(),c.charCodeAt(u)!==jr?!1:(y(),[r,t,o,d(0,Wr)])};E("get",ar-1,zr("get"));E("set",ar-1,zr("set"));E("(",ar-1,r=>{if(!r||typeof r!="string")return;let e=d(0,Hr)||null;if(A(),c.charCodeAt(u)===jr)return y(),[":",r,["=>",["()",e],d(0,Wr)||null]]});p("get",(r,e)=>(e=e?n(e):()=>{},t=>[[or,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?n(t):()=>{},o=>[[or,r,{set:function(i){let s=Object.create(o||{});s.this=this,s[e]=i,t(s)}}]]));var We=20,Jr=200;H("[]",Jr);H("{}",Jr);h(":",We-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},s={};for(let l of t.flatMap(f=>f(o)))if(l[0]===or){let[,f,a]=l;s[f]={...s[f],...a,configurable:!0,enumerable:!0}}else i[l[0]]=l[1];for(let l in s)Object.defineProperty(i,l,s[l]);return i}});p(":",(r,e)=>(e=n(e),Array.isArray(r)?(r=n(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var ze=170,nr=96,Je=36,Ve=123,Ye=92,Ze={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Vr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==nr;)t?t===Ye?(y(),e+=Ze[c[u]]||c[u],y()):t===Je&&c.charCodeAt(u+1)===Ve?(e&&r.push([,e]),e="",y(2),r.push(d(0,125))):(e+=c[u],y(),t=c.charCodeAt(u),t===nr&&e&&r.push([,e])):k("Unterminated template");return y(),r},qe=C[nr];C[nr]=(r,e)=>r&&e<ze?m.asi&&m.newline?void 0:(y(),["``",r,...Vr()]):r?qe?.(r,e):(y(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Vr()));p("`",(...r)=>(r=r.map(n),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=n(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(n(s));let i=Object.assign([...t],{raw:t});return s=>r(s)(i,...o.map(l=>l(s)))});m.string["'"]=!0;m.number={"0x":16,"0b":2,"0o":8};var gr=5,Yr=123,Zr=125,w=(r,e,t,o=r.charCodeAt(0),i=r.length,s=C[o],l)=>C[o]=(f,a,g,S=u)=>!f&&(g?r==g:(i<2||c.substr(u,i)==r)&&(g=r))&&a<e&&!m.id(c.charCodeAt(u+i))&&(O(u+i),(l=t())?Y(l,S):(O(S),!s&&k()),l)||s?.(f,a,g),Er=(r,e,t,o=r.charCodeAt(0),i=r.length,s=C[o],l)=>C[o]=(f,a,g,S=u)=>f&&(g?r==g:(i<2||c.substr(u,i)==r)&&(g=r))&&a<e&&!m.id(c.charCodeAt(u+i))&&(O(u+i),Y(l=t(f),S),l)||s?.(f,a,g),M=()=>(A()===Yr||k("Expected {"),y(),d(gr-.5,Zr)||null),B=()=>A()!==Yr?d(gr+.5):(y(),d(gr-.5,Zr)||null);var wr=5,xe=10,be=20,qr=r=>{let e=d(xe-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};E("let",wr+1,r=>!r&&qr("let"));E("const",wr+1,r=>!r&&qr("const"));w("var",wr,()=>(A(),["var",d(be)]));var xr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,i=n(o);return typeof t=="string"?s=>{s[t]=i(s)}:s=>G(t,i(s),s)}return n(e)}),e=>{for(let t of r)t(e)});p("let",xr);p("const",xr);p("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var X=Symbol("break"),z=Symbol("continue"),D=Symbol("return");var rt=200;w("function",rt,()=>{A();let r=!1;c[u]==="*"&&(r=!0,y(),A());let e=v(m.id);return e&&A(),r?["function*",e,N()||null,M()]:["function",e,N()||null,M()]});p("function",(r,e,t)=>{t=t?n(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],i=null,s=-1,l=o[o.length-1];return Array.isArray(l)&&l[0]==="..."&&(s=o.length-1,i=l[1],o.length--),f=>{let a=(...g)=>{let S={};o.forEach((R,_)=>S[R]=g[_]),i&&(S[i]=g.slice(s));let $=new Proxy(S,{get:(R,_)=>_ in R?R[_]:f[_],set:(R,_,se)=>((_ in R?R:f)[_]=se,!0),has:(R,_)=>_ in R||_ in f});try{return t($)}catch(R){if(R?.type===D)return R.value;throw R}};return r&&(f[r]=a),a}});p("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});var ir=140,Cr=20;I("await",ir);w("yield",ir,()=>(A(),c[u]==="*"?(y(),A(),["yield*",d(Cr)]):["yield",d(Cr)]));w("async",ir,()=>{if(A(),T("function"))return["async",d(ir)];let r=d(Cr-.5);return r&&["async",r]});p("async",r=>{let e=n(r);return t=>{let o=e(t);return async function(...i){return o(...i)}}});p("await",r=>(r=n(r),async e=>await r(e)));p("yield",r=>(r=r?n(r):null,e=>{throw{__yield__:r?r(e):void 0}}));p("yield*",r=>(r=n(r),e=>{throw{__yield_all__:r(e)}}));var Sr=200,et=140,tt=90,ot=Symbol("static");U("super",Symbol.for("super"));I("static",et);h("instanceof",tt);E("#",Sr,r=>{if(r)return;let e=v(m.id);return e?"#"+e:void 0});w("class",Sr,()=>{A();let r=v(m.id)||null;if(r==="extends")r=null,A();else{if(A(),!T("extends"))return["class",r,null,M()];y(7),A()}return["class",r,d(Sr),M()]});var nt=r=>{throw Error(r)};p("instanceof",(r,e)=>(r=n(r),e=n(e),t=>r(t)instanceof e(t)));p("class",(r,e,t)=>(e=e?n(e):null,t=t?n(t):null,o=>{let i=e?e(o):Object,s=function(...l){if(!(this instanceof s))return nt("Class constructor must be called with new");let f=e?Reflect.construct(i,l,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(f,l),f};if(Object.setPrototypeOf(s.prototype,i.prototype),Object.setPrototypeOf(s,i),t){let l=Object.create(o);l.super=i;let f=t(l),a=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,S]of a)g==="constructor"?s.prototype.__constructor__=S:s.prototype[g]=S}return r&&(o[r]=s),s}));p("static",r=>(r=n(r),e=>[[ot,r(e)]]));var it=140,kr=47,st=92,pt=r=>r===st?2:r&&r!==kr,lt=r=>r===103||r===105||r===109||r===115||r===117||r===121;E("/",it,r=>{if(r)return;let e=c.charCodeAt(u);if(e===kr||e===42||e===43||e===63||e===61)return;let t=v(pt);c.charCodeAt(u)===kr||k("Unterminated regex"),y();try{return[,new RegExp(t,v(lt))]}catch(o){k("Invalid regex: "+o.message)}});var ft=5,ut=59,mt=()=>{let r=u;return A()===ut&&y(),A(),T("else")?(y(4),!0):(O(r),!1)};w("if",ft+1,()=>{A();let r=["if",N(),B()];return mt()&&r.push(B()),r});p("if",(r,e,t)=>(r=n(r),e=n(e),t=t!==void 0?n(t):null,o=>r(o)?e(o):t?.(o)));var J=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===X)return{b:1};if(t?.type===z)return{c:1};if(t?.type===D)return{r:1,v:t.value};throw t}},K=5,ct=125,dt=59;w("while",K+1,()=>(A(),["while",N(),B()]));w("do",K+1,()=>(r=>(A(),y(5),A(),["do",r,N()]))(B()));w("for",K+1,()=>(A(),T("await")?(y(5),A(),["for await",N(),B()]):["for",N(),B()]));w("break",K+1,()=>["break"]);w("continue",K+1,()=>["continue"]);w("return",K+1,()=>{m.asi&&(m.newline=!1),A();let r=c.charCodeAt(u);return!r||r===ct||r===dt||m.newline?["return"]:["return",d(K)]});p("while",(r,e)=>(r=n(r),e=n(e),t=>{let o,i;for(;r(t)&&!(o=J(e,t)).b;){if(o.r)return o.v;o.c||(i=o.v)}return i}));p("do",(r,e)=>(r=n(r),e=n(e),t=>{let o,i;do{if((o=J(r,t)).b)break;if(o.r)return o.v;o.c||(i=o.v)}while(e(t));return i}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,i]=r;return t=t?n(t):null,o=o?n(o):()=>!0,i=i?n(i):null,e=n(e),s=>{let l,f;for(t?.(s);o(s)&&!(l=J(e,s)).b;i?.(s)){if(l.r)return l.v;l.c||(f=l.v)}return f}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,i]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return ht(o,i,e);if(t==="of")return At(o,i,e)}});var At=(r,e,t)=>{e=n(e),t=n(t);let o=Array.isArray(r);return i=>{let s,l,f=o?null:i[r];for(let a of e(i)){if(o?G(r,a,i):i[r]=a,(s=J(t,i)).b)break;if(s.r)return s.v;s.c||(l=s.v)}return o||(i[r]=f),l}},ht=(r,e,t)=>{e=n(e),t=n(t);let o=Array.isArray(r);return i=>{let s,l,f=o?null:i[r];for(let a in e(i)){if(o?G(r,a,i):i[r]=a,(s=J(t,i)).b)break;if(s.r)return s.v;s.c||(l=s.v)}return o||(i[r]=f),l}};p("break",()=>()=>{throw{type:X}});p("continue",()=>()=>{throw{type:z}});p("return",r=>(r=r!==void 0?n(r):null,e=>{throw{type:D,value:r?.(e)}}));var V=5;w("try",V+1,()=>["try",M()]);Er("catch",V+1,r=>(A(),["catch",r,N(),M()]));Er("finally",V+1,r=>["finally",r,M()]);w("throw",V+1,()=>{if(m.asi&&(m.newline=!1),A(),m.newline)throw SyntaxError("Unexpected newline after throw");return["throw",d(V)]});p("try",r=>(r=r?n(r):null,e=>r?.(e)));p("catch",(r,e,t)=>{let o=r?.[1]?n(r[1]):null;return t=t?n(t):null,i=>{let s;try{s=o?.(i)}catch(l){if(l?.type===X||l?.type===z||l?.type===D)throw l;if(e!==null&&t){let f=e in i,a=i[e];i[e]=l;try{s=t(i)}finally{f?i[e]=a:delete i[e]}}else if(e===null)throw l}return s}});p("finally",(r,e)=>(r=r?n(r):null,e=e?n(e):null,t=>{let o;try{o=r?.(t)}finally{e?.(t)}return o}));p("throw",r=>(r=n(r),e=>{throw r(e)}));var ee=5,yt=20,br=58,at=59,te=125,oe=(r,e=r.charCodeAt(0),t=C[e])=>C[e]=(o,i,s)=>T(r)&&!o&&(m.reserved=1)||t?.(o,i,s);oe("case");oe("default");var re=r=>{let e=[];for(;(r=A())!==te&&!T("case")&&!T("default");){if(r===at){y();continue}e.push(d(ee-.5))||k()}return e.length>1?[";",...e]:e[0]||null},gt=()=>{A()===123||k("Expected {"),y();let r=[];for(;A()!==te;)if(T("case")){O(u+4),A();let e=d(yt-.5);A()===br&&y(),r.push(["case",e,re()])}else T("default")?(O(u+7),A()===br&&y(),r.push(["default",re()])):k("Expected case or default");return y(),r};w("switch",ee+1,()=>(A(),["switch",N(),...gt()]));p("switch",(r,...e)=>(r=n(r),e.length?(e=e.map(t=>[t[0]==="case"?n(t[1]):null,(t[0]==="case"?t[2]:t[1])?.[0]===";"?(t[0]==="case"?t[2]:t[1]).slice(1).map(n):(t[0]==="case"?t[2]:t[1])?[n(t[0]==="case"?t[2]:t[1])]:[]]),t=>{let o=r(t),i=!1,s;for(let[f,a]of e)if(i||f===null||f(t)===o)for(i=!0,l=0;l<a.length;l++)try{s=a[l](t)}catch(g){if(g?.type===X)return g.value??s;throw g}var l;return s}):t=>r(t)));var vr=5,Q=10,ne=42,Et=C[ne];C[ne]=(r,e)=>r?Et?.(r,e):(y(),"*");E("from",Q+1,r=>r?r[0]!=="="&&r[0]!==","&&(A(),["from",r,d(Q+1)]):!1);E("as",Q+2,r=>r?(A(),["as",r,d(Q+2)]):!1);w("import",vr,()=>T(".meta")?(y(5),["import.meta"]):["import",d(Q)]);w("export",vr,()=>(A(),["export",d(vr)]));w("default",Q+1,()=>A()!==58&&(A(),["default",d(Q)]));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>n(r));var ie=5;m.asi=(r,e,t)=>{if(e>=ie)return;let o=t(ie-.5);if(o)return r?.[0]!==";"?[";",r,o]:(r.push(o),r)};export{lr as access,h as binary,n as compile,c as cur,Dr as default,k as err,d as expr,H as group,wt as id,u as idx,U as literal,Y as loc,C as lookup,pr as nary,v as next,p as operator,sr as operators,N as parens,m as parse,O as seek,y as skip,A as space,E as token,I as unary,T as word};
package/justin.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var u,c,f=r=>(u=0,c=r,f.newline=!1,r=A(),c[u]?I():r||""),I=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
2
- `),o=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",m=(c[e]||"\u2205")+p,d=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
- ${(c[e-41]!==`
4
- `?"...":"")+i}${m}${d}`)},Ir=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),v=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},h=(r=1)=>c[u+=r],rr=r=>u=r,A=(r=0,e)=>{let t,o,i,p,m=f.reserved,d;for(e&&f.asi&&(f.newline=!1),f.reserved=0;(t=f.space())&&(d=f.newline,1)&&t!==e&&(i=((p=S[t])&&p(o,r))??(f.asi&&o&&d&&(i=f.asi(o,r,A)))??(!o&&!f.reserved&&v(f.id)));)o=i,f.reserved=0;return f.reserved=m,e&&(t==e?u++:I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},P=f.space=(r,e=u)=>{for(;(r=c.charCodeAt(u))<=32;)f.asi&&r===10&&(f.newline=!0),u++;return r},ge=f.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,he=(r,e=r.length)=>c.substr(u,e)===r&&!f.id(c.charCodeAt(u+e)),ye=()=>(h(),A(0,41)),S=[],y=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=S[o],m=r.toUpperCase()!==r,d,g)=>S[o]=(E,x,T,b=u)=>(d=T,(T?r==T:(i<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(i<3||c.substr(u,i)==r))&&(!m||!f.id(c.charCodeAt(u+i)))&&(d=T=r))&&x<e&&(u+=i,(g=t(E))?Ir(g,b):(u=b,d=0,m&&g!==!1&&(f.reserved=1),!m&&!p&&I()),g)||p?.(E,x,d)),l=(r,e,t=!1)=>y(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),C=(r,e,t)=>y(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),k=(r,e)=>y(r,200,t=>!t&&[,e]),K=(r,e,t)=>{y(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},R=(r,e)=>y(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),j=(r,e)=>y(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),H={},s=(r,e,t=H[r])=>H[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):H[r[0]]?.(...r.slice(1))??I(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var U=46,L=48,_=57,vr=69,wr=101,Nr=43,Or=45,kr=97,Pr=102,Rr=65,Lr=70,W=r=>[,(r=+v(e=>e===U&&c.charCodeAt(u+1)!==U||e>=L&&e<=_||((e===vr||e===wr)&&((e=c.charCodeAt(u+1))>=L&&e<=_||e===Nr||e===Or)?2:0)))!=r?I():r],Tr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=L&&r<=_||r>=kr&&r<=Pr||r>=Rr&&r<=Lr};f.number=null;S[U]=r=>!r&&c.charCodeAt(u+1)!==U&&W();for(let r=L;r<=_;r++)S[r]=e=>e?void 0:W();S[L]=r=>{if(r)return;let e=f.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1])return h(2),[,parseInt(v(Tr[o]),o)]}return W()};var Ur=92,er=34,tr=39,_r={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},or=r=>(e,t,o="")=>{if(!(e||!f.string?.[String.fromCharCode(r)]))return h(),v(i=>i-r&&(i===Ur?(o+=_r[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?h():I("Bad string"),[,o]};S[er]=or(er);S[tr]=or(tr);f.string={'"':!0};var Mr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>l(r,Mr,!0));var ir=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?ir(r[1],e):(()=>{throw Error("Invalid assignment target")})(),nr={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in nr)s(r,(e,t)=>(t=n(t),ir(e,(o,i,p)=>nr[r](o,i,t(p)))));var Fr=30,Br=40,sr=140;l("!",sr);C("!",sr);l("||",Fr);l("&&",Br);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var Dr=50,Gr=60,Xr=70,pr=100,$r=140;l("|",Dr);l("&",Xr);l("^",Gr);l(">>",pr);l("<<",pr);C("~",$r);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var M=90;l("<",M);l(">",M);l("<=",M);l(">=",M);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var mr=80;l("==",mr);l("!=",mr);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var lr=110,z=120,ur=140;l("+",lr);l("-",lr);l("*",z);l("/",z);l("%",z);C("+",ur);C("-",ur);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var F=150;y("++",F,r=>r?["++",r,null]:["++",A(F-1)]);y("--",F,r=>r?["--",r,null]:["--",A(F-1)]);var J=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?J(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>J(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>J(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Qr=5,Hr=10,Kr=170;R("()",Kr);K(",",Hr);K(";",Qr,!0);var fr=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",fr);s(";",fr);var N=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",V=170;j("[]",V);l(".",V);j("()",V);var B=r=>{throw Error(r)};s("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&B("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],N(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?B("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&B("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return Y(r,(i,p,m)=>i[p](...o(m)))});var w=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&w(r[1])||r[0]==="{}"),Y=(r,e,t,o)=>r==null?B("Empty ()"):r[0]==="()"&&r.length==2?Y(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i)),O=Y;var cr=new WeakMap,jr=(r,...e)=>typeof r=="string"?n(f(r)):cr.get(r)||cr.set(r,Wr(r,e)).get(r),dr=57344,Wr=(r,e)=>{let t=r.reduce((p,m,d)=>p+(d?String.fromCharCode(dr+d-1):"")+m,""),o=f(t),i=p=>{if(typeof p=="string"&&p.length===1){let m=p.charCodeAt(0)-dr,d;if(m>=0&&m<e.length)return d=e[m],zr(d)?d:[,d]}return Array.isArray(p)?p.map(i):p};return n(i(o))},zr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Jr=jr;var Vr=32,Yr=f.space;f.comment??={"//":`
6
- `,"/*":"*/"};var Z;f.space=()=>{Z||(Z=Object.entries(f.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=Yr();){for(var e=0,t;t=Z[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
7
- `)for(;c.charCodeAt(o)>=Vr;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}rr(o),r=0;break}if(r)return r}return r};var Ar=80;l("===",Ar);l("!==",Ar);s("===",(r,e)=>(r=n(r),e=n(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=n(r),e=n(e),t=>r(t)!==e(t)));var Zr=30;l("??",Zr);s("??",(r,e)=>(r=n(r),e=n(e),t=>r(t)??e(t)));var qr=130,ar=20;l("**",qr,!0);l("**=",ar,!0);s("**",(r,e)=>(r=n(r),e=n(e),t=>r(t)**e(t)));var xr=r=>{throw Error(r)};s("**=",(r,e)=>(w(r)||xr("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]**=e(i))));var gr=90;l("in",gr);l("of",gr);s("in",(r,e)=>(r=n(r),e=n(e),t=>r(t)in e(t)));var br=20,re=100,ee=r=>{throw Error(r)};l(">>>",re);l(">>>=",br,!0);s(">>>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(w(r)||ee("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]>>>=e(i))));var D=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...i]=r;if(o==="{}")for(let p of i){let m,d,g;p[0]==="="?[,[,m,d],g]=p:[,m,d]=p;let E=e[m];E===void 0&&g&&(E=n(g)(t)),D(d,E,t)}else if(o==="[]"){let p=0;for(let m of i){if(m===null){p++;continue}if(Array.isArray(m)&&m[0]==="..."){t[m[1]]=e.slice(p);break}let d=m,g;Array.isArray(m)&&m[0]==="="&&([,d,g]=m);let E=e[p++];E===void 0&&g&&(E=n(g)(t)),D(d,E,t)}}};var q=20,G=r=>{throw Error(r)};l("||=",q,!0);l("&&=",q,!0);l("??=",q,!0);s("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=n(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>D(t,e(o),o)}return w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]=e(i))});s("||=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]||=e(i))));s("&&=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]&&=e(i))));s("??=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]??=e(i))));k("true",!0);k("false",!1);k("null",null);k("undefined",void 0);k("NaN",NaN);k("Infinity",1/0);var a=20;y("?",a,(r,e,t)=>r&&(e=A(a-1))&&v(o=>o===58)&&(t=A(a-1),["?",r,e,t]));s("?",(r,e,t)=>(r=n(r),e=n(e),t=n(t),o=>r(o)?e(o):t(o)));var te=20;l("=>",te,!0);s("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=n(e[0]==="{}"?e[1]:e),(i=null)=>(i=Object.create(i),(...p)=>(r.forEach((m,d)=>i[m]=p[d]),o&&(i[o]=p.slice(t)),e(i)))});var oe=140;C("...",oe);s("...",r=>(r=n(r),e=>Object.entries(r(e))));var hr=170;y("?.",hr,(r,e)=>{if(!r)return;let t=P();return t===40?(h(),["?.()",r,A(0,41)||null]):t===91?(h(),["?.[]",r,A(0,93)]):(e=A(hr),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=n(r),N(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)?.[o]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:m=>i(m)?.[p]?.(...t(m))}if(r[0]==="?.[]"){let i=n(r[1]),p=n(r[2]);return m=>{let d=i(m),g=p(m);return N(g)?void 0:d?.[g]?.(...t(m))}}if(r[0]==="."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:m=>i(m)?.[p]?.(...t(m))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),p=n(r[2]);return m=>{let d=i(m),g=p(m);return N(g)?void 0:d?.[g]?.(...t(m))}}let o=n(r);return i=>o(i)?.(...t(i))});var X=140;C("typeof",X);C("void",X);C("delete",X);C("new",X);s("typeof",r=>(r=n(r),e=>typeof r(e)));s("void",r=>(r=n(r),e=>(r(e),void 0)));s("delete",r=>{if(r[0]==="."){let e=n(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=n(r[1]),t=n(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});s("new",r=>{let e=n(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(i=>p=>i.map(m=>m(p)))(t.slice(1).map(n)):(i=>p=>[i(p)])(n(t)):()=>[];return i=>new(e(i))(...o(i))});var $=Symbol("accessor"),yr=20,ne=40,ie=41,se=123,pe=125,Cr=r=>e=>{if(e)return;P();let t=v(f.id);if(!t||(P(),c.charCodeAt(u)!==ne))return!1;h();let o=A(0,ie);return P(),c.charCodeAt(u)!==se?!1:(h(),[r,t,o,A(0,pe)])};y("get",yr-1,Cr("get"));y("set",yr-1,Cr("set"));s("get",(r,e)=>(e=e?n(e):()=>{},t=>[[$,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));s("set",(r,e,t)=>(t=t?n(t):()=>{},o=>[[$,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[e]=i,t(p)}}]]));var me=20,Sr=200;R("[]",Sr);R("{}",Sr);l(":",me-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},p={};for(let m of t.flatMap(d=>d(o)))if(m[0]===$){let[,d,g]=m;p[d]={...p[d],...g,configurable:!0,enumerable:!0}}else i[m[0]]=m[1];for(let m in p)Object.defineProperty(i,m,p[m]);return i}});s(":",(r,e)=>(e=n(e),Array.isArray(r)?(r=n(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var le=170,Q=96,ue=36,fe=123,ce=92,de={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Er=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==Q;)t?t===ce?(h(),e+=de[c[u]]||c[u],h()):t===ue&&c.charCodeAt(u+1)===fe?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[u],h(),t=c.charCodeAt(u),t===Q&&e&&r.push([,e])):I("Unterminated template");return h(),r},Ae=S[Q];S[Q]=(r,e)=>r&&e<le?f.asi&&f.newline?void 0:(h(),["``",r,...Er()]):r?Ae?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Er()));s("`",(...r)=>(r=r.map(n),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=n(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(n(p));let i=Object.assign([...t],{raw:t});return p=>r(p)(i,...o.map(m=>m(p)))});f.string["'"]=!0;f.number={"0x":16,"0b":2,"0o":8};export{j as access,l as binary,n as compile,c as cur,Jr as default,I as err,A as expr,R as group,ge as id,u as idx,k as literal,Ir as loc,S as lookup,K as nary,v as next,s as operator,H as operators,ye as parens,f as parse,rr as seek,h as skip,P as space,y as token,C as unary,he as word};
1
+ var m,c,d=r=>(m=0,c=r,d.newline=!1,r=A(),c[m]?v():r||""),v=(r="Unexpected token",e=m,t=c.slice(0,e).split(`
2
+ `),o=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",l=(c[e]||" ")+p,u=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${c[e-41]!==`
4
+ `,""+i}${l}${u}`)},Rr=(r,e=m)=>(Array.isArray(r)&&(r.loc=e),r),w=(r,e=m,t)=>{for(;t=r(c.charCodeAt(m));)m+=t;return c.slice(e,m)},g=(r=1)=>c[m+=r],tr=r=>m=r,A=(r=0,e)=>{let t,o,i,p,l=d.reserved,u;for(e&&d.asi&&(d.newline=!1),d.reserved=0;(t=d.space())&&(u=d.newline,1)&&t!==e&&(i=((p=C[t])&&p(o,r))??(d.asi&&o&&u&&(i=d.asi(o,r,A)))??(!o&&!d.reserved&&w(d.id)));)o=i,d.reserved=0;return d.reserved=l,e&&(t==e?m++:v("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},R=d.space=(r,e=m)=>{for(;(r=c.charCodeAt(m))<=32;)d.asi&&r===10&&(d.newline=!0),m++;return r},Ee=d.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,or=(r,e=r.length)=>c.substr(m,e)===r&&!d.id(c.charCodeAt(m+e)),Ie=()=>(g(),A(0,41)),C=[],y=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=C[o],l=r.toUpperCase()!==r,u,h)=>C[o]=(E,I,U,er=m)=>(u=U,(U?r==U:(i<2||r.charCodeAt(1)===c.charCodeAt(m+1)&&(i<3||c.substr(m,i)==r))&&(!l||!d.id(c.charCodeAt(m+i)))&&(u=U=r))&&I<e&&(m+=i,(h=t(E))?Rr(h,er):(m=er,u=0,l&&h!==!1&&(d.reserved=1),!l&&!p&&v()),h)||p?.(E,I,u)),f=(r,e,t=!1)=>y(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),S=(r,e,t)=>y(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),P=(r,e)=>y(r,200,t=>!t&&[,e]),j=(r,e,t)=>{y(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},L=(r,e)=>y(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),W=(r,e)=>y(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),a={},s=(r,e,t=a[r])=>a[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):a[r[0]]?.(...r.slice(1))??v(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var B=46,T=48,D=57,Pr=69,Lr=101,Tr=43,_r=45,M=95,Ur=110,Mr=97,Br=102,Dr=65,Fr=70,nr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),z=r=>{let e=nr(w(t=>t===B&&c.charCodeAt(m+1)!==B||t>=T&&t<=D||t===M||((t===Pr||t===Lr)&&((t=c.charCodeAt(m+1))>=T&&t<=D||t===Tr||t===_r)?2:0)));return c.charCodeAt(m)===Ur?(g(),[,BigInt(e)]):(r=+e)!=r?v():[,r]},Gr={2:r=>r===48||r===49||r===M,8:r=>r>=48&&r<=55||r===M,16:r=>r>=T&&r<=D||r>=Mr&&r<=Br||r>=Dr&&r<=Fr||r===M};d.number=null;C[B]=r=>!r&&c.charCodeAt(m+1)!==B&&z();for(let r=T;r<=D;r++)C[r]=e=>e?void 0:z();C[T]=r=>{if(r)return;let e=d.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[m+1]?.toLowerCase()===t[1])return g(2),[,parseInt(nr(w(Gr[o])),o)]}return z()};var Xr=92,ir=34,sr=39,$r={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},pr=r=>(e,t,o="")=>{if(!(e||!d.string?.[String.fromCharCode(r)]))return g(),w(i=>i-r&&(i===Xr?(o+=$r[c[m+1]]||c[m+1],2):(o+=c[m],1))),c[m]===String.fromCharCode(r)?g():v("Bad string"),[,o]};C[ir]=pr(ir);C[sr]=pr(sr);d.string={'"':!0};var Qr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>f(r,Qr,!0));var fr=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?fr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),lr={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in lr)s(r,(e,t)=>(t=n(t),fr(e,(o,i,p)=>lr[r](o,i,t(p)))));var Hr=30,Kr=40,mr=140;f("!",mr);S("!",mr);f("||",Hr);f("&&",Kr);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var ar=50,jr=60,Wr=70,ur=100,zr=140;f("|",ar);f("&",Wr);f("^",jr);f(">>",ur);f("<<",ur);S("~",zr);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var F=90;f("<",F);f(">",F);f("<=",F);f(">=",F);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var cr=80;f("==",cr);f("!=",cr);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var dr=110,J=120,Ar=140;f("+",dr);f("-",dr);f("*",J);f("/",J);f("%",J);S("+",Ar);S("-",Ar);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var G=150;y("++",G,r=>r?["++",r,null]:["++",A(G-1)]);y("--",G,r=>r?["--",r,null]:["--",A(G-1)]);var V=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?V(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>V(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>V(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Jr=5,Vr=10,Yr=170;L("()",Yr);j(",",Vr);j(";",Jr,!0);var gr=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",gr);s(";",gr);var O=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",Y=170;W("[]",Y);f(".",Y);W("()",Y);var X=r=>{throw Error(r)};s("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&X("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return O(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],O(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?X("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&X("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return Z(r,(i,p,l)=>i[p](...o(l)))});var N=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&N(r[1])||r[0]==="{}"),Z=(r,e,t,o)=>r==null?X("Empty ()"):r[0]==="()"&&r.length==2?Z(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i)),k=Z;var hr=new WeakMap,Zr=(r,...e)=>typeof r=="string"?n(d(r)):hr.get(r)||hr.set(r,qr(r,e)).get(r),yr=57344,qr=(r,e)=>{let t=r.reduce((p,l,u)=>p+(u?String.fromCharCode(yr+u-1):"")+l,""),o=d(t),i=p=>{if(typeof p=="string"&&p.length===1){let l=p.charCodeAt(0)-yr,u;if(l>=0&&l<e.length)return u=e[l],xr(u)?u:[,u]}return Array.isArray(p)?p.map(i):p};return n(i(o))},xr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),br=Zr;var re=32,ee=d.space;d.comment??={"//":`
6
+ `,"/*":"*/"};var q;d.space=()=>{q||(q=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=ee();){for(var e=0,t;t=q[e++];)if(r===t[2]&&c.substr(m,t[0].length)===t[0]){var o=m+t[0].length;if(t[1]===`
7
+ `)for(;c.charCodeAt(o)>=re;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}tr(o),r=0;break}if(r)return r}return r};var Cr=80;f("===",Cr);f("!==",Cr);s("===",(r,e)=>(r=n(r),e=n(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=n(r),e=n(e),t=>r(t)!==e(t)));var te=30;f("??",te);s("??",(r,e)=>(r=n(r),e=n(e),t=>r(t)??e(t)));var oe=130,ne=20;f("**",oe,!0);f("**=",ne,!0);s("**",(r,e)=>(r=n(r),e=n(e),t=>r(t)**e(t)));var ie=r=>{throw Error(r)};s("**=",(r,e)=>(N(r)||ie("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]**=e(i))));var Sr=90;f("in",Sr);f("of",Sr);s("in",(r,e)=>(r=n(r),e=n(e),t=>r(t)in e(t)));var se=20,pe=100,le=r=>{throw Error(r)};f(">>>",pe);f(">>>=",se,!0);s(">>>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(N(r)||le("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]>>>=e(i))));var fe=r=>r[0]?.[0]===","?r[0].slice(1):r,$=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...i]=r,p=fe(i);if(o==="{}")for(let l of p){let u,h,E;typeof l=="string"?u=h=l:l[0]==="="?(typeof l[1]=="string"?u=h=l[1]:[,u,h]=l[1],E=l[2]):[,u,h]=l;let I=e[u];I===void 0&&E&&(I=n(E)(t)),$(h,I,t)}else if(o==="[]"){let l=0;for(let u of p){if(u===null){l++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(l);break}let h=u,E;Array.isArray(u)&&u[0]==="="&&([,h,E]=u);let I=e[l++];I===void 0&&E&&(I=n(E)(t)),$(h,I,t)}}};var x=20,Q=r=>{throw Error(r)};f("||=",x,!0);f("&&=",x,!0);f("??=",x,!0);s("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=n(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>$(t,e(o),o)}return N(r)||Q("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]=e(i))});s("||=",(r,e)=>(N(r)||Q("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]||=e(i))));s("&&=",(r,e)=>(N(r)||Q("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]&&=e(i))));s("??=",(r,e)=>(N(r)||Q("Invalid assignment target"),e=n(e),k(r,(t,o,i)=>t[o]??=e(i))));P("true",!0);P("false",!1);P("null",null);P("undefined",void 0);P("NaN",NaN);P("Infinity",1/0);var b=20;y("?",b,(r,e,t)=>r&&(e=A(b-1))&&w(o=>o===58)&&(t=A(b-1),["?",r,e,t]));s("?",(r,e,t)=>(r=n(r),e=n(e),t=n(t),o=>r(o)?e(o):t(o)));var me=20;f("=>",me,!0);s("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=n(e[0]==="{}"?e[1]:e),(i=null)=>(i=Object.create(i),(...p)=>(r.forEach((l,u)=>i[l]=p[u]),o&&(i[o]=p.slice(t)),e(i)))});var ue=140;S("...",ue);s("...",r=>(r=n(r),e=>Object.entries(r(e))));var Er=170;y("?.",Er,(r,e)=>{if(!r)return;let t=R();return t===40?(g(),["?.()",r,A(0,41)||null]):t===91?(g(),["?.[]",r,A(0,93)]):(e=A(Er),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=n(r),O(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=n(r),e=n(e),t=>{let o=e(t);return O(o)?void 0:r(t)?.[o]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=n(r[1]),p=r[2];return O(p)?()=>{}:l=>i(l)?.[p]?.(...t(l))}if(r[0]==="?.[]"){let i=n(r[1]),p=n(r[2]);return l=>{let u=i(l),h=p(l);return O(h)?void 0:u?.[h]?.(...t(l))}}if(r[0]==="."){let i=n(r[1]),p=r[2];return O(p)?()=>{}:l=>i(l)?.[p]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),p=n(r[2]);return l=>{let u=i(l),h=p(l);return O(h)?void 0:u?.[h]?.(...t(l))}}let o=n(r);return i=>o(i)?.(...t(i))});var _=140;S("typeof",_);S("void",_);S("delete",_);y("new",_,r=>!r&&(or(".target")?(g(7),["new.target"]):["new",A(_)]));s("typeof",r=>(r=n(r),e=>typeof r(e)));s("void",r=>(r=n(r),e=>(r(e),void 0)));s("delete",r=>{if(r[0]==="."){let e=n(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=n(r[1]),t=n(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});s("new",r=>{let e=n(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(i=>p=>i.map(l=>l(p)))(t.slice(1).map(n)):(i=>p=>[i(p)])(n(t)):()=>[];return i=>new(e(i))(...o(i))});var H=Symbol("accessor"),rr=20,ce=40,Ir=41,vr=123,wr=125,Nr=r=>e=>{if(e)return;R();let t=w(d.id);if(!t||(R(),c.charCodeAt(m)!==ce))return!1;g();let o=A(0,Ir);return R(),c.charCodeAt(m)!==vr?!1:(g(),[r,t,o,A(0,wr)])};y("get",rr-1,Nr("get"));y("set",rr-1,Nr("set"));y("(",rr-1,r=>{if(!r||typeof r!="string")return;let e=A(0,Ir)||null;if(R(),c.charCodeAt(m)===vr)return g(),[":",r,["=>",["()",e],A(0,wr)||null]]});s("get",(r,e)=>(e=e?n(e):()=>{},t=>[[H,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));s("set",(r,e,t)=>(t=t?n(t):()=>{},o=>[[H,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[e]=i,t(p)}}]]));var de=20,Or=200;L("[]",Or);L("{}",Or);f(":",de-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},p={};for(let l of t.flatMap(u=>u(o)))if(l[0]===H){let[,u,h]=l;p[u]={...p[u],...h,configurable:!0,enumerable:!0}}else i[l[0]]=l[1];for(let l in p)Object.defineProperty(i,l,p[l]);return i}});s(":",(r,e)=>(e=n(e),Array.isArray(r)?(r=n(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var Ae=170,K=96,ge=36,he=123,ye=92,Ce={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},kr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(m))!==K;)t?t===ye?(g(),e+=Ce[c[m]]||c[m],g()):t===ge&&c.charCodeAt(m+1)===he?(e&&r.push([,e]),e="",g(2),r.push(A(0,125))):(e+=c[m],g(),t=c.charCodeAt(m),t===K&&e&&r.push([,e])):v("Unterminated template");return g(),r},Se=C[K];C[K]=(r,e)=>r&&e<Ae?d.asi&&d.newline?void 0:(g(),["``",r,...kr()]):r?Se?.(r,e):(g(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(kr()));s("`",(...r)=>(r=r.map(n),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=n(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(n(p));let i=Object.assign([...t],{raw:t});return p=>r(p)(i,...o.map(l=>l(p)))});d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};export{W as access,f as binary,n as compile,c as cur,br as default,v as err,A as expr,L as group,Ee as id,m as idx,P as literal,Rr as loc,C as lookup,j as nary,w as next,s as operator,a as operators,Ie as parens,d as parse,tr as seek,g as skip,R as space,y as token,S as unary,or as word};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subscript",
3
- "version": "10.0.2",
3
+ "version": "10.0.4",
4
4
  "description": "Tiny expression parser & evaluator",
5
5
  "main": "subscript.js",
6
6
  "module": "subscript.js",
@@ -76,7 +76,6 @@
76
76
  "devDependencies": {
77
77
  "@playwright/test": "^1.57.0",
78
78
  "esbuild": "^0.27.2",
79
- "jsep": "^1.4.0",
80
79
  "terser": "^5.44.1",
81
80
  "tst": "^9.2.0"
82
81
  }
package/parse.js CHANGED
@@ -14,10 +14,10 @@ export let idx, cur,
14
14
  last = lines.pop(),
15
15
  before = cur.slice(Math.max(0, at - 40), at),
16
16
  ptr = '\u032D',
17
- chr = (cur[at] || '') + ptr,
17
+ chr = (cur[at] || ' ') + ptr,
18
18
  after = cur.slice(at + 1, at + 20)
19
19
  ) => {
20
- throw SyntaxError(`${msg} at ${lines.length + 1}:${last.length + 1}\n${(cur[at-41]!=='\n' ? '...' : '') +before}${chr}${after}`)
20
+ throw SyntaxError(`${msg} at ${lines.length + 1}:${last.length + 1}\n${(cur[at-41]!=='\n' ? '' : '') +before}${chr}${after}`)
21
21
  },
22
22
 
23
23
  // attach location to node (returns node for chaining)
package/subscript.min.js CHANGED
@@ -1,5 +1,5 @@
1
- var l,f,u=r=>(l=0,f=r,u.newline=!1,r=A(),f[l]?y():r||""),y=(r="Unexpected token",e=l,t=f.slice(0,e).split(`
2
- `),o=t.pop(),i=f.slice(Math.max(0,e-40),e),p="\u032D",c=(f[e]||"\u2205")+p,d=f.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
- ${(f[e-41]!==`
4
- `?"...":"")+i}${c}${d}`)},er=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),S=(r,e=l,t)=>{for(;t=r(f.charCodeAt(l));)l+=t;return f.slice(e,l)},E=(r=1)=>f[l+=r],Pr=r=>l=r,A=(r=0,e)=>{let t,o,i,p,c=u.reserved,d;for(e&&u.asi&&(u.newline=!1),u.reserved=0;(t=u.space())&&(d=u.newline,1)&&t!==e&&(i=((p=g[t])&&p(o,r))??(u.asi&&o&&d&&(i=u.asi(o,r,A)))??(!o&&!u.reserved&&S(u.id)));)o=i,u.reserved=0;return u.reserved=c,e&&(t==e?l++:y("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},Ur=u.space=(r,e=l)=>{for(;(r=f.charCodeAt(l))<=32;)u.asi&&r===10&&(u.newline=!0),l++;return r},Mr=u.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,Rr=(r,e=r.length)=>f.substr(l,e)===r&&!u.id(f.charCodeAt(l+e)),Dr=()=>(E(),A(0,41)),g=[],h=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=g[o],c=r.toUpperCase()!==r,d,I)=>g[o]=(k,X,T,Q=l)=>(d=T,(T?r==T:(i<2||r.charCodeAt(1)===f.charCodeAt(l+1)&&(i<3||f.substr(l,i)==r))&&(!c||!u.id(f.charCodeAt(l+i)))&&(d=T=r))&&X<e&&(l+=i,(I=t(k))?er(I,Q):(l=Q,d=0,c&&I!==!1&&(u.reserved=1),!c&&!p&&y()),I)||p?.(k,X,d)),m=(r,e,t=!1)=>h(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),C=(r,e,t)=>h(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),Lr=(r,e)=>h(r,200,t=>!t&&[,e]),D=(r,e,t)=>{h(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},B=(r,e)=>h(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),L=(r,e)=>h(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),R={},s=(r,e,t=R[r])=>R[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):R[r[0]]?.(...r.slice(1))??y(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var _=46,w=48,v=57,tr=69,or=101,nr=43,ir=45,sr=97,lr=102,pr=65,ur=70,$=r=>[,(r=+S(e=>e===_&&f.charCodeAt(l+1)!==_||e>=w&&e<=v||((e===tr||e===or)&&((e=f.charCodeAt(l+1))>=w&&e<=v||e===nr||e===ir)?2:0)))!=r?y():r],mr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=w&&r<=v||r>=sr&&r<=lr||r>=pr&&r<=ur};u.number=null;g[_]=r=>!r&&f.charCodeAt(l+1)!==_&&$();for(let r=w;r<=v;r++)g[r]=e=>e?void 0:$();g[w]=r=>{if(r)return;let e=u.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&f[l+1]?.toLowerCase()===t[1])return E(2),[,parseInt(S(mr[o]),o)]}return $()};var fr=92,H=34,G=39,dr={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},W=r=>(e,t,o="")=>{if(!(e||!u.string?.[String.fromCharCode(r)]))return E(),S(i=>i-r&&(i===fr?(o+=dr[f[l+1]]||f[l+1],2):(o+=f[l],1))),f[l]===String.fromCharCode(r)?E():y("Bad string"),[,o]};g[H]=W(H);g[G]=W(G);u.string={'"':!0};var cr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>m(r,cr,!0));var J=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?J(r[1],e):(()=>{throw Error("Invalid assignment target")})(),z={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in z)s(r,(e,t)=>(t=n(t),J(e,(o,i,p)=>z[r](o,i,t(p)))));var Ar=30,gr=40,K=140;m("!",K);C("!",K);m("||",Ar);m("&&",gr);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var hr=50,yr=60,Cr=70,V=100,Sr=140;m("|",hr);m("&",Cr);m("^",yr);m(">>",V);m("<<",V);C("~",Sr);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var P=90;m("<",P);m(">",P);m("<=",P);m(">=",P);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var Y=80;m("==",Y);m("!=",Y);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var Z=110,F=120,q=140;m("+",Z);m("-",Z);m("*",F);m("/",F);m("%",F);C("+",q);C("-",q);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var U=150;h("++",U,r=>r?["++",r,null]:["++",A(U-1)]);h("--",U,r=>r?["--",r,null]:["--",A(U-1)]);var N=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?N(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>N(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>N(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Er=5,wr=10,Ir=170;B("()",Ir);D(",",wr);D(";",Er,!0);var x=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",x);s(";",x);var j=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",O=170;L("[]",O);m(".",O);L("()",O);var M=r=>{throw Error(r)};s("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&M("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return j(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],j(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?M("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&M("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return a(r,(i,p,c)=>i[p](...o(c)))});var a=(r,e,t,o)=>r==null?M("Empty ()"):r[0]==="()"&&r.length==2?a(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i));var b=new WeakMap,Tr=(r,...e)=>typeof r=="string"?n(u(r)):b.get(r)||b.set(r,_r(r,e)).get(r),rr=57344,_r=(r,e)=>{let t=r.reduce((p,c,d)=>p+(d?String.fromCharCode(rr+d-1):"")+c,""),o=u(t),i=p=>{if(typeof p=="string"&&p.length===1){let c=p.charCodeAt(0)-rr,d;if(c>=0&&c<e.length)return d=e[c],vr(d)?d:[,d]}return Array.isArray(p)?p.map(i):p};return n(i(o))},vr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),ne=Tr;export{L as access,m as binary,n as compile,f as cur,ne as default,y as err,A as expr,B as group,Mr as id,l as idx,Lr as literal,er as loc,g as lookup,D as nary,S as next,s as operator,R as operators,Dr as parens,u as parse,Pr as seek,E as skip,Ur as space,h as token,C as unary,Rr as word};
1
+ var l,f,u=r=>(l=0,f=r,u.newline=!1,r=c(),f[l]?C():r||""),C=(r="Unexpected token",e=l,t=f.slice(0,e).split(`
2
+ `),o=t.pop(),i=f.slice(Math.max(0,e-40),e),p="\u032D",A=(f[e]||" ")+p,d=f.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${f[e-41]!==`
4
+ `,""+i}${A}${d}`)},or=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),E=(r,e=l,t)=>{for(;t=r(f.charCodeAt(l));)l+=t;return f.slice(e,l)},y=(r=1)=>f[l+=r],Dr=r=>l=r,c=(r=0,e)=>{let t,o,i,p,A=u.reserved,d;for(e&&u.asi&&(u.newline=!1),u.reserved=0;(t=u.space())&&(d=u.newline,1)&&t!==e&&(i=((p=g[t])&&p(o,r))??(u.asi&&o&&d&&(i=u.asi(o,r,c)))??(!o&&!u.reserved&&E(u.id)));)o=i,u.reserved=0;return u.reserved=A,e&&(t==e?l++:C("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},Mr=u.space=(r,e=l)=>{for(;(r=f.charCodeAt(l))<=32;)u.asi&&r===10&&(u.newline=!0),l++;return r},Or=u.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,Lr=(r,e=r.length)=>f.substr(l,e)===r&&!u.id(f.charCodeAt(l+e)),Nr=()=>(y(),c(0,41)),g=[],h=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=g[o],A=r.toUpperCase()!==r,d,w)=>g[o]=(X,Q,I,B=l)=>(d=I,(I?r==I:(i<2||r.charCodeAt(1)===f.charCodeAt(l+1)&&(i<3||f.substr(l,i)==r))&&(!A||!u.id(f.charCodeAt(l+i)))&&(d=I=r))&&Q<e&&(l+=i,(w=t(X))?or(w,B):(l=B,d=0,A&&w!==!1&&(u.reserved=1),!A&&!p&&C()),w)||p?.(X,Q,d)),m=(r,e,t=!1)=>h(r,e,(o,i)=>o&&(i=c(e-(t?.5:0)))&&[r,o,i]),S=(r,e,t)=>h(r,e,o=>t?o&&[r,o]:!o&&(o=c(e-.5))&&[r,o]),$r=(r,e)=>h(r,200,t=>!t&&[,e]),O=(r,e,t)=>{h(r,e,(o,i)=>(i=c(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},H=(r,e)=>h(r[0],e,t=>!t&&[r,c(0,r.charCodeAt(1))||null]),L=(r,e)=>h(r[0],e,t=>t&&[r,t,c(0,r.charCodeAt(1))||null]),M={},s=(r,e,t=M[r])=>M[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):M[r[0]]?.(...r.slice(1))??C(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var U=46,_=48,v=57,nr=69,ir=101,sr=43,lr=45,T=95,pr=110,ur=97,mr=102,fr=65,dr=70,G=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),N=r=>{let e=G(E(t=>t===U&&f.charCodeAt(l+1)!==U||t>=_&&t<=v||t===T||((t===nr||t===ir)&&((t=f.charCodeAt(l+1))>=_&&t<=v||t===sr||t===lr)?2:0)));return f.charCodeAt(l)===pr?(y(),[,BigInt(e)]):(r=+e)!=r?C():[,r]},Ar={2:r=>r===48||r===49||r===T,8:r=>r>=48&&r<=55||r===T,16:r=>r>=_&&r<=v||r>=ur&&r<=mr||r>=fr&&r<=dr||r===T};u.number=null;g[U]=r=>!r&&f.charCodeAt(l+1)!==U&&N();for(let r=_;r<=v;r++)g[r]=e=>e?void 0:N();g[_]=r=>{if(r)return;let e=u.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&f[l+1]?.toLowerCase()===t[1])return y(2),[,parseInt(G(E(Ar[o])),o)]}return N()};var cr=92,W=34,z=39,gr={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},J=r=>(e,t,o="")=>{if(!(e||!u.string?.[String.fromCharCode(r)]))return y(),E(i=>i-r&&(i===cr?(o+=gr[f[l+1]]||f[l+1],2):(o+=f[l],1))),f[l]===String.fromCharCode(r)?y():C("Bad string"),[,o]};g[W]=J(W);g[z]=J(z);u.string={'"':!0};var hr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>m(r,hr,!0));var V=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?V(r[1],e):(()=>{throw Error("Invalid assignment target")})(),K={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in K)s(r,(e,t)=>(t=n(t),V(e,(o,i,p)=>K[r](o,i,t(p)))));var Cr=30,yr=40,Y=140;m("!",Y);S("!",Y);m("||",Cr);m("&&",yr);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var Sr=50,Er=60,_r=70,Z=100,wr=140;m("|",Sr);m("&",_r);m("^",Er);m(">>",Z);m("<<",Z);S("~",wr);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var P=90;m("<",P);m(">",P);m("<=",P);m(">=",P);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var q=80;m("==",q);m("!=",q);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var x=110,$=120,j=140;m("+",x);m("-",x);m("*",$);m("/",$);m("%",$);S("+",j);S("-",j);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var R=150;h("++",R,r=>r?["++",r,null]:["++",c(R-1)]);h("--",R,r=>r?["--",r,null]:["--",c(R-1)]);var F=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?F(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>F(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>F(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Ir=5,Tr=10,Ur=170;H("()",Ur);O(",",Tr);O(";",Ir,!0);var a=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",a);s(";",a);var b=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",k=170;L("[]",k);m(".",k);L("()",k);var D=r=>{throw Error(r)};s("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&D("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return b(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],b(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?D("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&D("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return rr(r,(i,p,A)=>i[p](...o(A)))});var rr=(r,e,t,o)=>r==null?D("Empty ()"):r[0]==="()"&&r.length==2?rr(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i));var er=new WeakMap,vr=(r,...e)=>typeof r=="string"?n(u(r)):er.get(r)||er.set(r,Pr(r,e)).get(r),tr=57344,Pr=(r,e)=>{let t=r.reduce((p,A,d)=>p+(d?String.fromCharCode(tr+d-1):"")+A,""),o=u(t),i=p=>{if(typeof p=="string"&&p.length===1){let A=p.charCodeAt(0)-tr,d;if(A>=0&&A<e.length)return d=e[A],Rr(d)?d:[,d]}return Array.isArray(p)?p.map(i):p};return n(i(o))},Rr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),le=vr;export{L as access,m as binary,n as compile,f as cur,le as default,C as err,c as expr,H as group,Or as id,l as idx,$r as literal,or as loc,g as lookup,O as nary,E as next,s as operator,M as operators,Nr as parens,u as parse,Dr as seek,y as skip,Mr as space,h as token,S as unary,Lr as word};
package/util/bundle.js CHANGED
@@ -6,8 +6,6 @@
6
6
  */
7
7
  import { parse } from '../jessie.js';
8
8
  import { codegen } from './stringify.js';
9
- import { readFile } from 'fs/promises';
10
- import { resolve } from 'path';
11
9
 
12
10
  // === AST Utilities ===
13
11
 
@@ -294,9 +292,17 @@ const resolvePath = (from, to) => {
294
292
  /**
295
293
  * Bundle ES modules into single file
296
294
  * @param {string} entry - Entry file path
297
- * @param {(path: string) => string|Promise<string>} read - File reader
295
+ * @param {Object|Function} read - Source map {path: code} or reader function
298
296
  */
299
297
  export async function bundle(entry, read) {
298
+ // Accept object as source map
299
+ if (typeof read === 'object') {
300
+ const sources = read;
301
+ read = path => {
302
+ if (!(path in sources)) throw Error(`Module not found: ${path}`);
303
+ return sources[path];
304
+ };
305
+ }
300
306
  const modules = new Map();
301
307
  const order = [];
302
308
 
@@ -487,10 +493,17 @@ export async function bundle(entry, read) {
487
493
  return result;
488
494
  }
489
495
 
490
- /** Bundle with Node.js fs */
491
- export const bundleFile = (entry) => bundle(resolve(entry), path => readFile(path, 'utf-8'));
496
+ /**
497
+ * Bundle with Node.js fs (only available in Node.js environment)
498
+ * Dynamically imports fs/path to avoid browser errors
499
+ */
500
+ export async function bundleFile(entry) {
501
+ const { readFile } = await import('fs/promises');
502
+ const { resolve } = await import('path');
503
+ return bundle(resolve(entry), path => readFile(path, 'utf-8'));
504
+ }
492
505
 
493
- // CLI
506
+ // CLI (Node.js only)
494
507
  if (typeof process !== 'undefined' && process.argv[1]?.includes('bundle')) {
495
508
  const entry = process.argv[2];
496
509
  if (!entry) {