@dbml/parse 3.7.1 → 3.7.2

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.
@@ -1,6 +1,6 @@
1
- import I, { findLastIndex as jt, last as it } from "lodash";
2
- var l = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(l || {});
3
- function Yt(t) {
1
+ import I, { partition as jt, findLastIndex as Yt, last as it } from "lodash";
2
+ var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
3
+ function zt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -45,13 +45,13 @@ class F {
45
45
  }
46
46
  }
47
47
  function bt(t) {
48
- return t.trailingTrivia.find(({ kind: e }) => e === l.NEWLINE) !== void 0;
48
+ return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
49
49
  }
50
50
  function ot(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === l.NEWLINE) !== void 0 || bt(t);
51
+ return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
52
52
  }
53
53
  function Ce(t) {
54
- return t.trailingTrivia.find(({ kind: e }) => e === l.SPACE) !== void 0;
54
+ return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
55
55
  }
56
56
  function It(t) {
57
57
  return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
@@ -59,12 +59,12 @@ function It(t) {
59
59
  function Lt(t) {
60
60
  return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
61
61
  }
62
- function zt(t) {
63
- return [l.SINGLE_LINE_COMMENT, l.MULTILINE_COMMENT].includes(
62
+ function Qt(t) {
63
+ return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
66
66
  }
67
- class Qt {
67
+ class qt {
68
68
  constructor() {
69
69
  this.id = 0;
70
70
  }
@@ -94,13 +94,13 @@ class x {
94
94
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
95
95
  }
96
96
  }
97
- var Ee = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(Ee || {});
98
- class G extends x {
97
+ var Ne = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(Ne || {});
98
+ class X extends x {
99
99
  constructor({ body: e = [], eof: n }, s) {
100
100
  super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
101
101
  }
102
102
  }
103
- class A extends x {
103
+ class v extends x {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -108,7 +108,7 @@ class A extends x {
108
108
  alias: i,
109
109
  attributeList: r,
110
110
  bodyColon: a,
111
- body: u
111
+ body: l
112
112
  }, p) {
113
113
  if (super(p, "<element-declaration>", [
114
114
  e,
@@ -117,13 +117,13 @@ class A extends x {
117
117
  i,
118
118
  r,
119
119
  a,
120
- u
121
- ]), u && a && !(u instanceof y || u instanceof A))
120
+ l
121
+ ]), l && a && !(l instanceof w || l instanceof v))
122
122
  throw new Error("If an element has a simple body, it must be a function application node");
123
- this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = u;
123
+ this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
124
124
  }
125
125
  }
126
- class $ extends x {
126
+ class Y extends x {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
@@ -156,17 +156,17 @@ class Ue extends x {
156
156
  super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
157
157
  }
158
158
  }
159
- class te extends x {
159
+ class ne extends x {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class y extends x {
164
+ class w extends x {
165
165
  constructor({ callee: e, args: n = [] }, s) {
166
166
  super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
167
167
  }
168
168
  }
169
- class ne extends x {
169
+ class J extends x {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class ne extends x {
175
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
- class D extends x {
178
+ class R extends x {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -189,7 +189,7 @@ class D extends x {
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
- class J extends x {
192
+ class Z extends x {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -203,7 +203,7 @@ class J extends x {
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
205
205
  }
206
- class We extends J {
206
+ class We extends Z {
207
207
  constructor({
208
208
  groupOpenParen: e,
209
209
  expression: n,
@@ -233,7 +233,7 @@ class be extends x {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class Z extends x {
236
+ class K extends x {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
@@ -245,11 +245,11 @@ class U extends x {
245
245
  }
246
246
  class xe extends x {
247
247
  constructor({ pre: e }, n) {
248
- const s = F.create(l.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class ue extends x {
252
+ class he extends x {
253
253
  constructor({ expression: e, indexer: n }, s) {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
@@ -264,12 +264,12 @@ function gt(t, e) {
264
264
  (i) => i !== null
265
265
  );
266
266
  }
267
- function ls(t, e = !1) {
267
+ function us(t, e = !1) {
268
268
  return JSON.stringify(
269
269
  t,
270
270
  function(n, s) {
271
271
  var i;
272
- return !(this instanceof G) && n === "symbol" ? s == null ? void 0 : s.id : (
272
+ return !(this instanceof X) && n === "symbol" ? s == null ? void 0 : s.id : (
273
273
  /* this instanceof SyntaxNode && */
274
274
  n === "symbol" ? {
275
275
  symbolTable: s == null ? void 0 : s.symbolTable,
@@ -312,7 +312,7 @@ class S {
312
312
  return !0;
313
313
  }
314
314
  }
315
- class w {
315
+ class y {
316
316
  // eslint-disable-next-line class-methods-use-this
317
317
  unwrap() {
318
318
  throw new Error("Trying to unwrap a None value");
@@ -323,11 +323,11 @@ class w {
323
323
  }
324
324
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
325
325
  and_then(e) {
326
- return new w();
326
+ return new y();
327
327
  }
328
328
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
329
329
  map(e) {
330
- return new w();
330
+ return new y();
331
331
  }
332
332
  // eslint-disable-next-line class-methods-use-this
333
333
  isOk() {
@@ -356,7 +356,7 @@ function qe(t) {
356
356
  function He(t) {
357
357
  return `TableGroup field:${t}`;
358
358
  }
359
- function qt(t) {
359
+ function Ht(t) {
360
360
  return `Note:${t}`;
361
361
  }
362
362
  function Ve(t, e) {
@@ -384,16 +384,16 @@ function ie(t) {
384
384
  return Object.values(T).includes(e) ? new S({
385
385
  name: n,
386
386
  kind: e
387
- }) : new w();
387
+ }) : new y();
388
388
  }
389
- function Ht(t) {
389
+ function Jt(t) {
390
390
  const e = ie(t).unwrap_or(void 0);
391
391
  if (!e)
392
392
  return !1;
393
393
  const { kind: n, name: s } = e;
394
394
  return n === "Schema" && s === "public";
395
395
  }
396
- function Jt(t) {
396
+ function Zt(t) {
397
397
  return [
398
398
  je,
399
399
  Oe,
@@ -407,16 +407,16 @@ function Jt(t) {
407
407
  function Me(t) {
408
408
  return !!t.match(/(\p{L}|_|\p{M})/gu);
409
409
  }
410
- function Re(t) {
410
+ function De(t) {
411
411
  const [e] = t;
412
412
  return e >= "0" && e <= "9";
413
413
  }
414
- function Zt(t) {
414
+ function Kt(t) {
415
415
  const [e] = t;
416
- return Re(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
416
+ return De(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
417
417
  }
418
- function de(t) {
419
- return Me(t) || Re(t);
418
+ function Ee(t) {
419
+ return Me(t) || De(t);
420
420
  }
421
421
  function ct(t, e) {
422
422
  const n = [], s = Math.min(t.length, e.length);
@@ -427,7 +427,7 @@ function ct(t, e) {
427
427
  function ge(t, e) {
428
428
  return t >= e.start && t < e.end;
429
429
  }
430
- class Kt {
430
+ class en {
431
431
  constructor() {
432
432
  this.id = 0;
433
433
  }
@@ -443,12 +443,12 @@ class _t {
443
443
  this.references = [], this.id = n, this.symbolTable = e;
444
444
  }
445
445
  }
446
- class en {
446
+ class tn {
447
447
  constructor({ symbolTable: e, declaration: n }, s) {
448
448
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
449
449
  }
450
450
  }
451
- class tn {
451
+ class nn {
452
452
  constructor({ declaration: e }, n) {
453
453
  this.references = [], this.id = n, this.declaration = e;
454
454
  }
@@ -458,17 +458,17 @@ class At {
458
458
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
459
459
  }
460
460
  }
461
- class nn {
461
+ class sn {
462
462
  constructor({ declaration: e }, n) {
463
463
  this.references = [], this.id = n, this.declaration = e;
464
464
  }
465
465
  }
466
- class sn {
466
+ class rn {
467
467
  constructor({ symbolTable: e, declaration: n }, s) {
468
468
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
469
469
  }
470
470
  }
471
- class rn {
471
+ class an {
472
472
  constructor({ declaration: e }, n) {
473
473
  this.references = [], this.id = n, this.declaration = e;
474
474
  }
@@ -479,7 +479,7 @@ class c extends Error {
479
479
  super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
480
480
  }
481
481
  }
482
- class B {
482
+ class V {
483
483
  constructor(e, n) {
484
484
  this.value = e, this.errors = n === void 0 ? [] : n;
485
485
  }
@@ -491,21 +491,21 @@ class B {
491
491
  }
492
492
  chain(e) {
493
493
  const n = e(this.value), s = [...this.errors, ...n.errors];
494
- return new B(n.value, s);
494
+ return new V(n.value, s);
495
495
  }
496
496
  map(e) {
497
- return new B(e(this.value), this.errors);
497
+ return new V(e(this.value), this.errors);
498
498
  }
499
499
  }
500
- function an(t, e, n) {
500
+ function on(t, e, n) {
501
501
  if (!t || !me(t) || e.length === 0)
502
- return new w();
502
+ return new y();
503
503
  const s = [...e], i = Ge(t).unwrap(), r = s.pop();
504
- if (!(r instanceof ne))
505
- return new w();
506
- const a = I.last(s) instanceof D ? s.pop() : void 0;
504
+ if (!(r instanceof J))
505
+ return new y();
506
+ const a = I.last(s) instanceof R ? s.pop() : void 0;
507
507
  return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
508
- n.create(A, {
508
+ n.create(v, {
509
509
  type: i,
510
510
  name: s[0],
511
511
  as: Ge(s[1]).unwrap(),
@@ -514,33 +514,33 @@ function an(t, e, n) {
514
514
  body: r
515
515
  })
516
516
  ) : s.length === 1 ? new S(
517
- n.create(A, {
517
+ n.create(v, {
518
518
  type: i,
519
519
  name: s[0],
520
520
  attributeList: a,
521
521
  body: r
522
522
  })
523
523
  ) : s.length === 0 ? new S(
524
- n.create(A, {
524
+ n.create(v, {
525
525
  type: i,
526
526
  attributeList: a,
527
527
  body: r
528
528
  })
529
- ) : new w();
529
+ ) : new y();
530
530
  }
531
531
  function lt(t) {
532
- return t.kind === l.IDENTIFIER && t.value === "as";
532
+ return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function N(t) {
535
- t && (t instanceof F ? on(t) : cn(t));
536
- }
537
- function on(t) {
538
- t.kind !== l.EOF && (t.isInvalid = !0);
535
+ t && (t instanceof F ? cn(t) : ln(t));
539
536
  }
540
537
  function cn(t) {
541
- if (t instanceof A)
538
+ t.kind !== u.EOF && (t.isInvalid = !0);
539
+ }
540
+ function ln(t) {
541
+ if (t instanceof v)
542
542
  N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
543
- else if (t instanceof $)
543
+ else if (t instanceof Y)
544
544
  t.identifiers.forEach(N);
545
545
  else if (t instanceof se)
546
546
  N(t.name), N(t.colon), N(t.value);
@@ -550,21 +550,21 @@ function cn(t) {
550
550
  N(t.leftExpression), N(t.op), N(t.rightExpression);
551
551
  else if (t instanceof Ue)
552
552
  N(t.op), N(t.expression);
553
- else if (t instanceof ne)
553
+ else if (t instanceof J)
554
554
  N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
555
- else if (t instanceof D)
555
+ else if (t instanceof R)
556
556
  N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
557
- else if (t instanceof J)
557
+ else if (t instanceof Z)
558
558
  N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
559
559
  else if (t instanceof H)
560
560
  N(t.callee), N(t.argumentList);
561
- else if (t instanceof y)
561
+ else if (t instanceof w)
562
562
  N(t.callee), t.args.forEach(N);
563
563
  else if (t instanceof U)
564
564
  N(t.expression);
565
- else if (t instanceof te)
565
+ else if (t instanceof ne)
566
566
  N(t.value);
567
- else if (t instanceof Z)
567
+ else if (t instanceof K)
568
568
  N(t.variable);
569
569
  else if (t instanceof be)
570
570
  N(t.literal);
@@ -577,10 +577,10 @@ function vt(t) {
577
577
  function P(...t) {
578
578
  return t.filter((e) => e !== void 0);
579
579
  }
580
- function ln(t) {
581
- if (t instanceof G)
580
+ function un(t) {
581
+ if (t instanceof X)
582
582
  return P(...t.body, t.eof);
583
- if (t instanceof A)
583
+ if (t instanceof v)
584
584
  return P(
585
585
  t.type,
586
586
  t.name,
@@ -592,11 +592,11 @@ function ln(t) {
592
592
  );
593
593
  if (t instanceof se)
594
594
  return P(t.name, t.colon, t.value);
595
- if (t instanceof $)
595
+ if (t instanceof Y)
596
596
  return t.identifiers;
597
597
  if (t instanceof be)
598
598
  return t.literal ? [t.literal] : [];
599
- if (t instanceof Z)
599
+ if (t instanceof K)
600
600
  return P(t.variable);
601
601
  if (t instanceof Q)
602
602
  return P(t.op, t.expression);
@@ -604,19 +604,19 @@ function ln(t) {
604
604
  return P(t.leftExpression, t.op, t.rightExpression);
605
605
  if (t instanceof Ue)
606
606
  return P(t.expression, t.op);
607
- if (t instanceof te)
607
+ if (t instanceof ne)
608
608
  return P(t.value);
609
- if (t instanceof y)
609
+ if (t instanceof w)
610
610
  return P(t.callee, ...t.args);
611
- if (t instanceof ne)
611
+ if (t instanceof J)
612
612
  return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
613
- if (t instanceof D)
613
+ if (t instanceof R)
614
614
  return P(
615
615
  t.listOpenBracket,
616
616
  ...ct(t.elementList, t.commaList),
617
617
  t.listCloseBracket
618
618
  );
619
- if (t instanceof J)
619
+ if (t instanceof Z)
620
620
  return P(
621
621
  t.tupleOpenParen,
622
622
  ...ct(t.elementList, t.commaList),
@@ -626,7 +626,7 @@ function ln(t) {
626
626
  return P(t.callee, t.argumentList);
627
627
  if (t instanceof U)
628
628
  return P(t.expression);
629
- if (t instanceof ue)
629
+ if (t instanceof he)
630
630
  return P(
631
631
  t.array,
632
632
  t.indexer
@@ -634,18 +634,18 @@ function ln(t) {
634
634
  throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
635
635
  }
636
636
  function Ge(t) {
637
- return M(t) ? new S(t.expression.variable) : new w();
637
+ return M(t) ? new S(t.expression.variable) : new y();
638
638
  }
639
- function j(t) {
639
+ function $(t) {
640
640
  var e;
641
- return t instanceof U && (t.expression instanceof Z && t.expression.variable instanceof F && t.expression.variable.kind === l.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === l.STRING_LITERAL);
641
+ return t instanceof U && (t.expression instanceof K && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
642
642
  }
643
643
  function M(t) {
644
- return t instanceof U && t.expression instanceof Z && t.expression.variable instanceof F;
644
+ return t instanceof U && t.expression instanceof K && t.expression.variable instanceof F;
645
645
  }
646
646
  function me(t) {
647
647
  var e;
648
- return t instanceof U && t.expression instanceof Z && ((e = t.expression.variable) == null ? void 0 : e.kind) === l.IDENTIFIER;
648
+ return t instanceof U && t.expression instanceof K && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
649
649
  }
650
650
  function Je(t) {
651
651
  var e;
@@ -653,11 +653,11 @@ function Je(t) {
653
653
  }
654
654
  function Te(t) {
655
655
  if (t === void 0)
656
- return new w();
656
+ return new y();
657
657
  const e = t.identifiers.map((n) => n.value).join(" ");
658
- return e === "" ? new w() : new S(e);
658
+ return e === "" ? new y() : new S(e);
659
659
  }
660
- class un {
660
+ class hn {
661
661
  // list of errors during lexing
662
662
  constructor(e) {
663
663
  this.start = {
@@ -706,50 +706,50 @@ class un {
706
706
  );
707
707
  }
708
708
  lex() {
709
- return this.scanTokens(), this.tokens.push(F.create(l.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
709
+ return this.scanTokens(), this.tokens.push(F.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new V(this.tokens, this.errors);
710
710
  }
711
711
  scanTokens() {
712
712
  for (; !this.isAtEnd(); ) {
713
713
  const e = this.advance();
714
714
  switch (e) {
715
715
  case " ":
716
- this.addToken(l.SPACE);
716
+ this.addToken(u.SPACE);
717
717
  break;
718
718
  case "\r":
719
719
  break;
720
720
  case `
721
721
  `:
722
- this.addToken(l.NEWLINE);
722
+ this.addToken(u.NEWLINE);
723
723
  break;
724
724
  case " ":
725
- this.addToken(l.TAB);
725
+ this.addToken(u.TAB);
726
726
  break;
727
727
  case ",":
728
- this.addToken(l.COMMA);
728
+ this.addToken(u.COMMA);
729
729
  break;
730
730
  case "(":
731
- this.addToken(l.LPAREN);
731
+ this.addToken(u.LPAREN);
732
732
  break;
733
733
  case ")":
734
- this.addToken(l.RPAREN);
734
+ this.addToken(u.RPAREN);
735
735
  break;
736
736
  case "[":
737
- this.addToken(l.LBRACKET);
737
+ this.addToken(u.LBRACKET);
738
738
  break;
739
739
  case "]":
740
- this.addToken(l.RBRACKET);
740
+ this.addToken(u.RBRACKET);
741
741
  break;
742
742
  case "{":
743
- this.addToken(l.LBRACE);
743
+ this.addToken(u.LBRACE);
744
744
  break;
745
745
  case "}":
746
- this.addToken(l.RBRACE);
746
+ this.addToken(u.RBRACE);
747
747
  break;
748
748
  case ";":
749
- this.addToken(l.SEMICOLON);
749
+ this.addToken(u.SEMICOLON);
750
750
  break;
751
751
  case ":":
752
- this.addToken(l.COLON);
752
+ this.addToken(u.COLON);
753
753
  break;
754
754
  case "'":
755
755
  this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
@@ -775,15 +775,15 @@ class un {
775
775
  this.identifier();
776
776
  break;
777
777
  }
778
- if (Re(e)) {
778
+ if (De(e)) {
779
779
  this.numericLiteralOrIdentifier();
780
780
  break;
781
781
  }
782
- this.addToken(l.OP, !0), this.errors.push(
782
+ this.addToken(u.OP, !0), this.errors.push(
783
783
  new c(
784
784
  o.UNKNOWN_SYMBOL,
785
785
  `Unexpected token '${e}'`,
786
- this.createToken(l.OP, !0)
786
+ this.createToken(u.OP, !0)
787
787
  )
788
788
  );
789
789
  break;
@@ -795,7 +795,7 @@ class un {
795
795
  let e = !0, n = [], s;
796
796
  const i = [];
797
797
  for (const r of this.tokens)
798
- Yt(r) ? (n.push(r), r.kind === l.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
798
+ zt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
799
799
  this.tokens = i;
800
800
  }
801
801
  gatherInvalid() {
@@ -820,10 +820,10 @@ class un {
820
820
  // Whether to interpret '\' as a backlash
821
821
  consumeStopSequence: a = !0
822
822
  }) {
823
- let u = "";
823
+ let l = "";
824
824
  for (; !this.isAtEnd() && (s || !this.check(`
825
825
  `)) && !this.check(n); )
826
- this.peek() === "\\" && !r ? (this.advance(), u += this.escapedString()) : u += this.advance();
826
+ this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
827
827
  if (this.isAtEnd() && !i) {
828
828
  const p = this.createToken(e, !0);
829
829
  this.tokens.push(p), this.errors.push(
@@ -843,38 +843,38 @@ class un {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, u, !1));
846
+ a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, l, !1));
847
847
  }
848
848
  singleLineStringLiteral() {
849
- this.consumeUntil(l.STRING_LITERAL, "'", {
849
+ this.consumeUntil(u.STRING_LITERAL, "'", {
850
850
  allowNewline: !1,
851
851
  allowEof: !1,
852
852
  raw: !1
853
853
  });
854
854
  }
855
855
  multilineStringLiteral() {
856
- this.consumeUntil(l.STRING_LITERAL, "'''", {
856
+ this.consumeUntil(u.STRING_LITERAL, "'''", {
857
857
  allowNewline: !0,
858
858
  allowEof: !1,
859
859
  raw: !1
860
860
  });
861
861
  }
862
862
  functionExpression() {
863
- this.consumeUntil(l.FUNCTION_EXPRESSION, "`", {
863
+ this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
864
864
  allowNewline: !1,
865
865
  allowEof: !1,
866
866
  raw: !0
867
867
  });
868
868
  }
869
869
  quotedVariable() {
870
- this.consumeUntil(l.QUOTED_STRING, '"', {
870
+ this.consumeUntil(u.QUOTED_STRING, '"', {
871
871
  allowNewline: !1,
872
872
  allowEof: !1,
873
873
  raw: !1
874
874
  });
875
875
  }
876
876
  singleLineComment() {
877
- this.consumeUntil(l.SINGLE_LINE_COMMENT, `
877
+ this.consumeUntil(u.SINGLE_LINE_COMMENT, `
878
878
  `, {
879
879
  allowNewline: !0,
880
880
  allowEof: !0,
@@ -883,55 +883,55 @@ class un {
883
883
  });
884
884
  }
885
885
  multilineComment() {
886
- this.consumeUntil(l.MULTILINE_COMMENT, "*/", {
886
+ this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
887
887
  allowNewline: !0,
888
888
  allowEof: !1,
889
889
  raw: !0
890
890
  });
891
891
  }
892
892
  identifier() {
893
- for (; !this.isAtEnd() && de(this.peek()); )
893
+ for (; !this.isAtEnd() && Ee(this.peek()); )
894
894
  this.advance();
895
- this.addToken(l.IDENTIFIER);
895
+ this.addToken(u.IDENTIFIER);
896
896
  }
897
897
  operator() {
898
898
  for (; rt(this.peek()); )
899
899
  this.advance();
900
- this.addToken(l.OP);
900
+ this.addToken(u.OP);
901
901
  }
902
902
  // we accept identifiers starting with digits but must contain at least one char or underscore
903
903
  numericLiteralOrIdentifier() {
904
904
  let e = 0;
905
905
  if (this.isAtEnd())
906
- return this.addToken(l.NUMERIC_LITERAL);
906
+ return this.addToken(u.NUMERIC_LITERAL);
907
907
  for (; !this.isAtEnd(); ) {
908
908
  const n = this.check(".");
909
909
  if (e += n ? 1 : 0, e > 1)
910
910
  break;
911
911
  if (!n && this.current.offset === this.text.length - 1)
912
- return this.advance(), this.addToken(l.NUMERIC_LITERAL);
913
- if (!n && !de(this.peek()))
914
- return this.addToken(l.NUMERIC_LITERAL);
915
- if (!n && !Re(this.peek()))
912
+ return this.advance(), this.addToken(u.NUMERIC_LITERAL);
913
+ if (!n && !Ee(this.peek()))
914
+ return this.addToken(u.NUMERIC_LITERAL);
915
+ if (!n && !De(this.peek()))
916
916
  break;
917
917
  this.advance();
918
918
  }
919
919
  if (e > 0) {
920
- for (; !this.isAtEnd() && (this.check(".") || de(this.peek())); )
920
+ for (; !this.isAtEnd() && (this.check(".") || Ee(this.peek())); )
921
921
  this.advance();
922
- const n = this.createToken(l.NUMERIC_LITERAL, !0);
922
+ const n = this.createToken(u.NUMERIC_LITERAL, !0);
923
923
  this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
924
924
  } else {
925
- for (; !this.isAtEnd() && de(this.peek()); )
925
+ for (; !this.isAtEnd() && Ee(this.peek()); )
926
926
  this.advance();
927
- const n = this.createToken(l.IDENTIFIER, !1);
927
+ const n = this.createToken(u.IDENTIFIER, !1);
928
928
  this.tokens.push(n);
929
929
  }
930
930
  }
931
931
  colorLiteral() {
932
- for (; !this.isAtEnd() && de(this.peek()); )
932
+ for (; !this.isAtEnd() && Ee(this.peek()); )
933
933
  this.advance();
934
- this.addToken(l.COLOR_LITERAL);
934
+ this.addToken(u.COLOR_LITERAL);
935
935
  }
936
936
  escapedString() {
937
937
  const e = { column: this.current.column - 1, offset: this.current.offset - 1, line: this.current.line };
@@ -970,8 +970,8 @@ class un {
970
970
  case "u": {
971
971
  let n = "";
972
972
  for (let s = 0; s <= 3; s += 1) {
973
- if (this.isAtEnd() || !de(this.peek()))
974
- return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(l.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
973
+ if (this.isAtEnd() || !Ee(this.peek()))
974
+ return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
975
975
  n += this.advance();
976
976
  }
977
977
  return String.fromCharCode(parseInt(n, 16));
@@ -982,7 +982,7 @@ class un {
982
982
  }
983
983
  }
984
984
  var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
985
- class hn {
985
+ class fn {
986
986
  constructor() {
987
987
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
988
988
  }
@@ -1023,7 +1023,7 @@ class hn {
1023
1023
  if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
1024
1024
  for (let s = n; s < e.length - 1; s += 1)
1025
1025
  switch (e[s].kind) {
1026
- case l.COMMA:
1026
+ case u.COMMA:
1027
1027
  if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
1028
1028
  return [...this.stack].reverse().find(
1029
1029
  (r) => [
@@ -1033,22 +1033,22 @@ class hn {
1033
1033
  ].includes(r)
1034
1034
  );
1035
1035
  break;
1036
- case l.RPAREN:
1036
+ case u.RPAREN:
1037
1037
  if (this.isWithinGroupExpressionContext())
1038
1038
  return 1;
1039
1039
  break;
1040
- case l.RBRACE:
1040
+ case u.RBRACE:
1041
1041
  if (this.isWithinBlockExpressionContext())
1042
1042
  return 2;
1043
1043
  break;
1044
- case l.RBRACKET:
1044
+ case u.RBRACKET:
1045
1045
  if (this.isWithinListExpressionContext())
1046
1046
  return 0;
1047
1047
  break;
1048
1048
  }
1049
1049
  }
1050
1050
  }
1051
- class fn {
1051
+ class pn {
1052
1052
  constructor(e) {
1053
1053
  this.generator = e;
1054
1054
  }
@@ -1061,29 +1061,29 @@ class d {
1061
1061
  this.token = e, this.partialNode = n, this.handlerContext = s;
1062
1062
  }
1063
1063
  }
1064
- class pn {
1064
+ class dn {
1065
1065
  constructor(e, n) {
1066
- this.current = 0, this.errors = [], this.contextStack = new hn(), this.synchronizeProgram = () => {
1066
+ this.current = 0, this.errors = [], this.contextStack = new fn(), this.synchronizeProgram = () => {
1067
1067
  const s = this.peek();
1068
- s.kind !== l.EOF ? N(this.advance()) : (N(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1068
+ s.kind !== u.EOF ? N(this.advance()) : (N(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1069
1069
  }, this.synchronizeElementDeclarationName = () => {
1070
1070
  for (; !this.isAtEnd(); ) {
1071
1071
  const s = this.peek();
1072
- if (lt(s) || this.check(l.COLON, l.LBRACE, l.LBRACKET))
1072
+ if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1073
1073
  break;
1074
1074
  N(s), this.advance();
1075
1075
  }
1076
1076
  }, this.synchronizeElementDeclarationAlias = () => {
1077
1077
  for (; !this.isAtEnd(); ) {
1078
1078
  const s = this.peek();
1079
- if (this.check(l.COLON, l.LBRACE, l.LBRACKET))
1079
+ if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
1080
1080
  break;
1081
1081
  N(s), this.advance();
1082
1082
  }
1083
1083
  }, this.blockExpression = this.contextStack.withContextDo(Se.BlockExpression, () => {
1084
- const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
1084
+ const s = { body: [] }, i = () => this.nodeFactory.create(J, s);
1085
1085
  try {
1086
- this.consume("Expect an opening brace '{'", l.LBRACE), s.blockOpenBrace = this.previous();
1086
+ this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
1087
1087
  } catch (r) {
1088
1088
  if (!(r instanceof d))
1089
1089
  throw r;
@@ -1091,7 +1091,7 @@ class pn {
1091
1091
  throw new d(r.token, i(), r.handlerContext);
1092
1092
  this.synchronizeBlock();
1093
1093
  }
1094
- for (; !this.isAtEnd() && !this.check(l.RBRACE); )
1094
+ for (; !this.isAtEnd() && !this.check(u.RBRACE); )
1095
1095
  try {
1096
1096
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1097
1097
  } catch (r) {
@@ -1102,7 +1102,7 @@ class pn {
1102
1102
  this.synchronizeBlock();
1103
1103
  }
1104
1104
  try {
1105
- this.consume("Expect a closing brace '}'", l.RBRACE), s.blockCloseBrace = this.previous();
1105
+ this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
1106
1106
  } catch (r) {
1107
1107
  if (!(r instanceof d))
1108
1108
  throw r;
@@ -1112,10 +1112,10 @@ class pn {
1112
1112
  }
1113
1113
  return i();
1114
1114
  }), this.synchronizeBlock = () => {
1115
- if (!this.check(l.RBRACE))
1115
+ if (!this.check(u.RBRACE))
1116
1116
  for (N(this.advance()); !this.isAtEnd(); ) {
1117
1117
  const s = this.peek();
1118
- if (this.check(l.RBRACE) || ot(this.previous(), s))
1118
+ if (this.check(u.RBRACE) || ot(this.previous(), s))
1119
1119
  break;
1120
1120
  N(s), this.advance();
1121
1121
  }
@@ -1124,9 +1124,9 @@ class pn {
1124
1124
  groupOpenParen: s.tupleOpenParen,
1125
1125
  groupCloseParen: s.tupleCloseParen,
1126
1126
  expression: s.elementList[0]
1127
- }), r = () => this.nodeFactory.create(J, s);
1127
+ }), r = () => this.nodeFactory.create(Z, s);
1128
1128
  try {
1129
- this.consume("Expect an opening parenthesis '('", l.LPAREN), s.tupleOpenParen = this.previous();
1129
+ this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
1130
1130
  } catch (a) {
1131
1131
  if (!(a instanceof d))
1132
1132
  throw a;
@@ -1134,7 +1134,7 @@ class pn {
1134
1134
  throw new d(a.token, r(), a.handlerContext);
1135
1135
  this.synchronizeTuple();
1136
1136
  }
1137
- if (!this.isAtEnd() && !this.check(l.RPAREN))
1137
+ if (!this.isAtEnd() && !this.check(u.RPAREN))
1138
1138
  try {
1139
1139
  s.elementList.push(this.normalExpression());
1140
1140
  } catch (a) {
@@ -1144,9 +1144,9 @@ class pn {
1144
1144
  throw new d(a.token, i(), a.handlerContext);
1145
1145
  this.synchronizeTuple();
1146
1146
  }
1147
- for (; !this.isAtEnd() && !this.check(l.RPAREN); )
1147
+ for (; !this.isAtEnd() && !this.check(u.RPAREN); )
1148
1148
  try {
1149
- this.consume("Expect a comma ','", l.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1149
+ this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1150
1150
  } catch (a) {
1151
1151
  if (!(a instanceof d))
1152
1152
  throw a;
@@ -1155,7 +1155,7 @@ class pn {
1155
1155
  this.synchronizeTuple();
1156
1156
  }
1157
1157
  try {
1158
- this.consume("Expect a closing parenthesis ')'", l.RPAREN), s.tupleCloseParen = this.previous();
1158
+ this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
1159
1159
  } catch (a) {
1160
1160
  if (!(a instanceof d))
1161
1161
  throw a;
@@ -1167,14 +1167,14 @@ class pn {
1167
1167
  }), this.synchronizeTuple = () => {
1168
1168
  for (; !this.isAtEnd(); ) {
1169
1169
  const s = this.peek();
1170
- if (this.check(l.RPAREN, l.COMMA))
1170
+ if (this.check(u.RPAREN, u.COMMA))
1171
1171
  break;
1172
1172
  N(s), this.advance();
1173
1173
  }
1174
1174
  }, this.listExpression = this.contextStack.withContextDo(Se.ListExpression, () => {
1175
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(D, s);
1175
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
1176
1176
  try {
1177
- this.consume("Expect an opening bracket '['", l.LBRACKET), s.listOpenBracket = this.previous();
1177
+ this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1178
1178
  } catch (r) {
1179
1179
  if (!(r instanceof d))
1180
1180
  throw r;
@@ -1182,7 +1182,7 @@ class pn {
1182
1182
  throw new d(r.token, i(), r.handlerContext);
1183
1183
  this.synchronizeList();
1184
1184
  }
1185
- if (!this.isAtEnd() && !this.check(l.RBRACKET))
1185
+ if (!this.isAtEnd() && !this.check(u.RBRACKET))
1186
1186
  try {
1187
1187
  s.elementList.push(this.attribute());
1188
1188
  } catch (r) {
@@ -1192,9 +1192,9 @@ class pn {
1192
1192
  throw new d(r.token, i(), r.handlerContext);
1193
1193
  this.synchronizeList();
1194
1194
  }
1195
- for (; !this.isAtEnd() && !this.check(l.RBRACKET); )
1195
+ for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
1196
1196
  try {
1197
- this.consume("Expect a comma ','", l.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1197
+ this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1198
1198
  } catch (r) {
1199
1199
  if (!(r instanceof d))
1200
1200
  throw r;
@@ -1203,7 +1203,7 @@ class pn {
1203
1203
  this.synchronizeList();
1204
1204
  }
1205
1205
  try {
1206
- this.consume("Expect a closing bracket ']'", l.RBRACKET), s.listCloseBracket = this.previous();
1206
+ this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
1207
1207
  } catch (r) {
1208
1208
  if (!(r instanceof d))
1209
1209
  throw r;
@@ -1215,28 +1215,28 @@ class pn {
1215
1215
  }), this.synchronizeList = () => {
1216
1216
  for (; !this.isAtEnd(); ) {
1217
1217
  const s = this.peek();
1218
- if (this.check(l.COMMA, l.RBRACKET))
1218
+ if (this.check(u.COMMA, u.RBRACKET))
1219
1219
  break;
1220
1220
  N(s), this.advance();
1221
1221
  }
1222
1222
  }, this.synchronizeAttributeName = () => {
1223
1223
  for (; !this.isAtEnd(); ) {
1224
1224
  const s = this.peek();
1225
- if (this.check(l.COMMA, l.RBRACKET, l.COLON))
1225
+ if (this.check(u.COMMA, u.RBRACKET, u.COLON))
1226
1226
  break;
1227
1227
  N(s), this.advance();
1228
1228
  }
1229
1229
  }, this.synchronizeAttributeValue = () => {
1230
1230
  for (; !this.isAtEnd(); ) {
1231
1231
  const s = this.peek();
1232
- if (this.check(l.COMMA, l.RBRACKET))
1232
+ if (this.check(u.COMMA, u.RBRACKET))
1233
1233
  break;
1234
1234
  N(s), this.advance();
1235
1235
  }
1236
- }, this.tokens = e, this.nodeFactory = new fn(n);
1236
+ }, this.tokens = e, this.nodeFactory = new pn(n);
1237
1237
  }
1238
1238
  isAtEnd() {
1239
- return this.current >= this.tokens.length || this.tokens[this.current].kind === l.EOF;
1239
+ return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
1240
1240
  }
1241
1241
  advance() {
1242
1242
  return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
@@ -1289,8 +1289,8 @@ class pn {
1289
1289
  this.tokens = e;
1290
1290
  }
1291
1291
  parse() {
1292
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(G, { body: e, eof: n });
1293
- return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1292
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(X, { body: e, eof: n });
1293
+ return this.gatherInvalid(), new V({ ast: s, tokens: this.tokens }, this.errors);
1294
1294
  }
1295
1295
  /* Parsing and synchronizing ProgramNode */
1296
1296
  program() {
@@ -1308,13 +1308,13 @@ class pn {
1308
1308
  }
1309
1309
  /* Parsing and synchronizing top-level ElementDeclarationNode */
1310
1310
  elementDeclaration() {
1311
- const e = {}, n = () => this.nodeFactory.create(A, e);
1311
+ const e = {}, n = () => this.nodeFactory.create(v, e);
1312
1312
  try {
1313
- this.consume("Expect an identifier", l.IDENTIFIER), e.type = this.previous();
1313
+ this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1314
1314
  } catch (s) {
1315
1315
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1316
1316
  }
1317
- if (!this.check(l.COLON, l.LBRACE, l.LBRACKET))
1317
+ if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
1318
1318
  try {
1319
1319
  e.name = this.normalExpression();
1320
1320
  } catch (s) {
@@ -1325,7 +1325,7 @@ class pn {
1325
1325
  this.synchronizeElementDeclarationName();
1326
1326
  }
1327
1327
  if (lt(this.peek()))
1328
- if (e.as = this.advance(), this.check(l.COLON, l.LBRACE, l.LBRACKET))
1328
+ if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1329
1329
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1330
1330
  else
1331
1331
  try {
@@ -1338,27 +1338,27 @@ class pn {
1338
1338
  this.synchronizeElementDeclarationAlias();
1339
1339
  }
1340
1340
  try {
1341
- e.attributeList = this.check(l.LBRACKET) ? this.listExpression() : void 0;
1341
+ e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
1342
1342
  } catch (s) {
1343
1343
  throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1344
1344
  }
1345
1345
  if (!this.discardUntil(
1346
1346
  "Expect an opening brace '{' or a colon ':'",
1347
- l.LBRACE,
1348
- l.COLON
1347
+ u.LBRACE,
1348
+ u.COLON
1349
1349
  ))
1350
1350
  return n();
1351
1351
  try {
1352
- if (this.match(l.COLON)) {
1352
+ if (this.match(u.COLON)) {
1353
1353
  e.bodyColon = this.previous();
1354
1354
  const s = this.expression();
1355
- s instanceof A ? (N(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
1355
+ s instanceof v ? (N(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
1356
1356
  } else
1357
1357
  e.body = this.blockExpression();
1358
1358
  } catch (s) {
1359
1359
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1360
1360
  }
1361
- return this.nodeFactory.create(A, e);
1361
+ return this.nodeFactory.create(v, e);
1362
1362
  }
1363
1363
  /* Parsing nested element declarations with simple body */
1364
1364
  // e.g
@@ -1367,29 +1367,29 @@ class pn {
1367
1367
  // Note: 'This is a note' // fieldDeclaration() handles this
1368
1368
  // }
1369
1369
  fieldDeclaration() {
1370
- const e = {}, n = () => this.nodeFactory.create(A, e);
1370
+ const e = {}, n = () => this.nodeFactory.create(v, e);
1371
1371
  try {
1372
- this.consume("Expect an identifier", l.IDENTIFIER), e.type = this.previous();
1372
+ this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1373
1373
  } catch (s) {
1374
1374
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1375
1375
  }
1376
1376
  try {
1377
- this.consume("Expect a colon ':'", l.COLON), e.bodyColon = this.previous();
1377
+ this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
1378
1378
  } catch (s) {
1379
1379
  throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1380
1380
  }
1381
1381
  try {
1382
1382
  const s = this.expression();
1383
- s instanceof A ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1383
+ s instanceof v ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1384
1384
  } catch (s) {
1385
1385
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1386
1386
  }
1387
- return this.nodeFactory.create(A, e);
1387
+ return this.nodeFactory.create(v, e);
1388
1388
  }
1389
1389
  /* Parsing any ExpressionNode, including non-NormalExpression */
1390
1390
  expression() {
1391
- const e = { args: [] }, n = () => an(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
- this.nodeFactory.create(y, e)
1391
+ const e = { args: [] }, n = () => on(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
+ this.nodeFactory.create(w, e)
1393
1393
  );
1394
1394
  try {
1395
1395
  e.callee = this.normalExpression();
@@ -1413,7 +1413,7 @@ class pn {
1413
1413
  if (this.isAtEnd() || bt(this.previous()))
1414
1414
  return !0;
1415
1415
  const e = this.peek().kind;
1416
- return e === l.RBRACE || e === l.RBRACKET || e === l.RPAREN || e === l.COMMA || e === l.COLON;
1416
+ return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
1417
1417
  }
1418
1418
  normalExpression() {
1419
1419
  return this.expression_bp(0);
@@ -1423,7 +1423,7 @@ class pn {
1423
1423
  let n = this.leftExpression_bp();
1424
1424
  for (; !this.isAtEnd(); ) {
1425
1425
  const s = this.peek();
1426
- if (s.kind === l.LPAREN) {
1426
+ if (s.kind === u.LPAREN) {
1427
1427
  const { left: i } = ut(s);
1428
1428
  if (i < e || // When '(' is encountered,
1429
1429
  // consider it part of another expression if
@@ -1442,16 +1442,16 @@ class pn {
1442
1442
  argumentList: r.partialNode
1443
1443
  }), new d(r.token, n, r.handlerContext)) : r;
1444
1444
  }
1445
- } else if (s.kind === l.LBRACKET) {
1445
+ } else if (s.kind === u.LBRACKET) {
1446
1446
  if (Ce(this.previous()))
1447
1447
  break;
1448
1448
  try {
1449
- n = this.nodeFactory.create(ue, {
1449
+ n = this.nodeFactory.create(he, {
1450
1450
  expression: n,
1451
1451
  indexer: this.listExpression()
1452
1452
  });
1453
1453
  } catch (i) {
1454
- throw i instanceof d ? (n = this.nodeFactory.create(ue, {
1454
+ throw i instanceof d ? (n = this.nodeFactory.create(he, {
1455
1455
  expression: n,
1456
1456
  indexer: i.partialNode
1457
1457
  }), new d(i.token, n, i.handlerContext)) : i;
@@ -1466,7 +1466,7 @@ class pn {
1466
1466
  op: i
1467
1467
  });
1468
1468
  } else {
1469
- const a = En(i);
1469
+ const a = Nn(i);
1470
1470
  if (a.left === null || a.left <= e)
1471
1471
  break;
1472
1472
  this.advance();
@@ -1476,12 +1476,12 @@ class pn {
1476
1476
  op: i,
1477
1477
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1478
1478
  });
1479
- } catch (u) {
1480
- throw u instanceof d ? (n = this.nodeFactory.create(q, {
1479
+ } catch (l) {
1480
+ throw l instanceof d ? (n = this.nodeFactory.create(q, {
1481
1481
  leftExpression: n,
1482
1482
  op: i,
1483
- rightExpression: u.partialNode
1484
- }), new d(u.token, n, u.handlerContext)) : u;
1483
+ rightExpression: l.partialNode
1484
+ }), new d(l.token, n, l.handlerContext)) : l;
1485
1485
  }
1486
1486
  }
1487
1487
  } else
@@ -1494,7 +1494,7 @@ class pn {
1494
1494
  if (at(this.peek())) {
1495
1495
  const n = {};
1496
1496
  n.op = this.peek();
1497
- const s = mn(n.op);
1497
+ const s = Tn(n.op);
1498
1498
  if (s.right === null)
1499
1499
  throw this.logError(
1500
1500
  n.op,
@@ -1530,12 +1530,12 @@ class pn {
1530
1530
  // e.g { ... }
1531
1531
  extractOperand() {
1532
1532
  return this.check(
1533
- l.NUMERIC_LITERAL,
1534
- l.STRING_LITERAL,
1535
- l.COLOR_LITERAL,
1536
- l.QUOTED_STRING,
1537
- l.IDENTIFIER
1538
- ) ? this.primaryExpression() : this.check(l.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(l.LBRACKET) ? this.listExpression() : this.check(l.LBRACE) ? this.blockExpression() : this.check(l.LPAREN) ? this.tupleExpression() : (this.peek().kind === l.EOF ? this.logError(
1533
+ u.NUMERIC_LITERAL,
1534
+ u.STRING_LITERAL,
1535
+ u.COLOR_LITERAL,
1536
+ u.QUOTED_STRING,
1537
+ u.IDENTIFIER
1538
+ ) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
1539
1539
  this.peek(),
1540
1540
  o.UNEXPECTED_EOF,
1541
1541
  "Unexpected EOF"
@@ -1549,32 +1549,32 @@ class pn {
1549
1549
  functionExpression() {
1550
1550
  const e = {};
1551
1551
  try {
1552
- this.consume("Expect a function expression", l.FUNCTION_EXPRESSION), e.value = this.previous();
1552
+ this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
1553
1553
  } catch (n) {
1554
1554
  throw n instanceof d ? (e.value = n.partialNode, new d(
1555
1555
  n.token,
1556
- this.nodeFactory.create(te, e),
1556
+ this.nodeFactory.create(ne, e),
1557
1557
  n.handlerContext
1558
1558
  )) : n;
1559
1559
  }
1560
- return this.nodeFactory.create(te, e);
1560
+ return this.nodeFactory.create(ne, e);
1561
1561
  }
1562
1562
  canBeField() {
1563
- return this.peek().kind === l.IDENTIFIER && this.peek(1).kind === l.COLON;
1563
+ return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
1564
1564
  }
1565
1565
  /* Parsing PrimaryExpression */
1566
1566
  primaryExpression() {
1567
1567
  if (this.match(
1568
- l.COLOR_LITERAL,
1569
- l.STRING_LITERAL,
1570
- l.NUMERIC_LITERAL
1568
+ u.COLOR_LITERAL,
1569
+ u.STRING_LITERAL,
1570
+ u.NUMERIC_LITERAL
1571
1571
  ))
1572
1572
  return this.nodeFactory.create(U, {
1573
1573
  expression: this.nodeFactory.create(be, { literal: this.previous() })
1574
1574
  });
1575
- if (this.match(l.QUOTED_STRING, l.IDENTIFIER))
1575
+ if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1576
1576
  return this.nodeFactory.create(U, {
1577
- expression: this.nodeFactory.create(Z, { variable: this.previous() })
1577
+ expression: this.nodeFactory.create(K, { variable: this.previous() })
1578
1578
  });
1579
1579
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1580
1580
  this.peek(),
@@ -1584,13 +1584,13 @@ class pn {
1584
1584
  }
1585
1585
  attribute() {
1586
1586
  const e = {};
1587
- if (this.check(l.COLON, l.RBRACKET, l.COMMA)) {
1587
+ if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
1588
1588
  const n = this.peek();
1589
1589
  this.logError(
1590
1590
  n,
1591
1591
  o.EMPTY_ATTRIBUTE_NAME,
1592
1592
  "Expect a non-empty attribute name"
1593
- ), e.name = this.nodeFactory.create($, { identifiers: [] });
1593
+ ), e.name = this.nodeFactory.create(Y, { identifiers: [] });
1594
1594
  } else
1595
1595
  try {
1596
1596
  e.name = this.attributeName();
@@ -1605,12 +1605,12 @@ class pn {
1605
1605
  );
1606
1606
  this.synchronizeAttributeName();
1607
1607
  }
1608
- return this.match(l.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1608
+ return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1609
1609
  }
1610
1610
  attributeValue() {
1611
1611
  let e;
1612
1612
  try {
1613
- e = this.peek().kind === l.IDENTIFIER && this.peek(1).kind === l.IDENTIFIER ? this.attributeName() : this.normalExpression();
1613
+ e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
1614
1614
  } catch (n) {
1615
1615
  if (!(n instanceof d) || !this.canHandle(n))
1616
1616
  throw n;
@@ -1620,25 +1620,25 @@ class pn {
1620
1620
  }
1621
1621
  attributeName() {
1622
1622
  const e = [];
1623
- if (this.peek().kind !== l.IDENTIFIER)
1623
+ if (this.peek().kind !== u.IDENTIFIER)
1624
1624
  return this.primaryExpression();
1625
- for (; !this.isAtEnd() && !this.check(l.COLON, l.COMMA, l.RBRACKET); )
1625
+ for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
1626
1626
  try {
1627
- this.consume("Expect an identifier", l.IDENTIFIER), e.push(this.previous());
1627
+ this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
1628
1628
  } catch (n) {
1629
1629
  throw n instanceof d ? new d(
1630
1630
  n.token,
1631
- this.nodeFactory.create($, { identifiers: e }),
1631
+ this.nodeFactory.create(Y, { identifiers: e }),
1632
1632
  n.handlerContext
1633
1633
  ) : n;
1634
1634
  }
1635
- return this.nodeFactory.create($, { identifiers: e });
1635
+ return this.nodeFactory.create(Y, { identifiers: e });
1636
1636
  }
1637
1637
  logError(e, n, s) {
1638
1638
  this.errors.push(new c(n, s, e));
1639
1639
  }
1640
1640
  }
1641
- const dn = {
1641
+ const En = {
1642
1642
  "+": { left: 9, right: 10 },
1643
1643
  "*": { left: 11, right: 12 },
1644
1644
  "-": { left: 9, right: 10 },
@@ -1654,10 +1654,10 @@ const dn = {
1654
1654
  "!=": { left: 4, right: 5 },
1655
1655
  ".": { left: 16, right: 17 }
1656
1656
  };
1657
- function En(t) {
1658
- return dn[t.value] || { left: null, right: null };
1657
+ function Nn(t) {
1658
+ return En[t.value] || { left: null, right: null };
1659
1659
  }
1660
- const Nn = {
1660
+ const mn = {
1661
1661
  "+": { left: null, right: 15 },
1662
1662
  "-": { left: null, right: 15 },
1663
1663
  "<": { left: null, right: 15 },
@@ -1665,14 +1665,14 @@ const Nn = {
1665
1665
  "<>": { left: null, right: 15 },
1666
1666
  "!": { left: null, right: 15 }
1667
1667
  };
1668
- function mn(t) {
1669
- return Nn[t.value] || { left: null, right: null };
1668
+ function Tn(t) {
1669
+ return mn[t.value] || { left: null, right: null };
1670
1670
  }
1671
- const Tn = {
1671
+ const bn = {
1672
1672
  "(": { left: 14, right: null }
1673
1673
  };
1674
1674
  function ut(t) {
1675
- return Tn[t.value] || { left: null, right: null };
1675
+ return bn[t.value] || { left: null, right: null };
1676
1676
  }
1677
1677
  var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
1678
1678
  function ve(t) {
@@ -1688,51 +1688,51 @@ function ve(t) {
1688
1688
  case b.TableGroup:
1689
1689
  return new S(e);
1690
1690
  default:
1691
- return new w();
1691
+ return new y();
1692
1692
  }
1693
1693
  }
1694
- function fe(t) {
1694
+ function pe(t) {
1695
1695
  if (!Je(t))
1696
1696
  return new S([t]);
1697
- const e = fe(t.leftExpression).unwrap_or(void 0);
1698
- return e ? (e.push(t.rightExpression), new S(e)) : new w();
1697
+ const e = pe(t.leftExpression).unwrap_or(void 0);
1698
+ return e ? (e.push(t.rightExpression), new S(e)) : new y();
1699
1699
  }
1700
- function C(t) {
1700
+ function W(t) {
1701
1701
  if (t === void 0)
1702
- return new w();
1703
- const e = fe(t).unwrap_or(void 0);
1702
+ return new y();
1703
+ const e = pe(t).unwrap_or(void 0);
1704
1704
  if (!e)
1705
- return new w();
1705
+ return new y();
1706
1706
  const n = [];
1707
1707
  for (const s of e) {
1708
- const i = X(s).unwrap_or(void 0);
1708
+ const i = j(s).unwrap_or(void 0);
1709
1709
  if (!i)
1710
- return new w();
1710
+ return new y();
1711
1711
  n.push(i);
1712
1712
  }
1713
1713
  return new S(n);
1714
1714
  }
1715
1715
  function _e(t) {
1716
1716
  if (t === void 0)
1717
- return new w();
1718
- const e = fe(t).unwrap_or(void 0);
1717
+ return new y();
1718
+ const e = pe(t).unwrap_or(void 0);
1719
1719
  if (!e || e.length === 0)
1720
- return new w();
1720
+ return new y();
1721
1721
  const n = [];
1722
1722
  let s;
1723
1723
  if (!M(I.last(e))) {
1724
1724
  const i = e.pop();
1725
1725
  if (xt(i))
1726
1726
  s = i.elementList.map(
1727
- (r) => V(r).unwrap()
1727
+ (r) => C(r).unwrap()
1728
1728
  );
1729
1729
  else
1730
- return new w();
1730
+ return new y();
1731
1731
  }
1732
1732
  for (const i of e) {
1733
- const r = X(i).unwrap_or(void 0);
1733
+ const r = j(i).unwrap_or(void 0);
1734
1734
  if (!r)
1735
- return new w();
1735
+ return new y();
1736
1736
  n.push(r);
1737
1737
  }
1738
1738
  return new S({
@@ -1740,33 +1740,33 @@ function _e(t) {
1740
1740
  tupleElements: s
1741
1741
  });
1742
1742
  }
1743
- function X(t) {
1744
- return M(t) ? new S(t.expression.variable.value) : new w();
1743
+ function j(t) {
1744
+ return M(t) ? new S(t.expression.variable.value) : new y();
1745
1745
  }
1746
1746
  function Xe(t) {
1747
1747
  if (ht(t))
1748
- return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1749
- if (t instanceof J && t.elementList.every(ht)) {
1748
+ return t instanceof ne ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1749
+ if (t instanceof Z && t.elementList.every(ht)) {
1750
1750
  const e = t.elementList.filter(
1751
- (s) => s instanceof te
1751
+ (s) => s instanceof ne
1752
1752
  ), n = t.elementList.filter(M);
1753
1753
  return new S({ functional: e, nonFunctional: n });
1754
1754
  }
1755
- return new w();
1755
+ return new y();
1756
1756
  }
1757
- function V(t) {
1757
+ function C(t) {
1758
1758
  var n;
1759
1759
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1760
- return e === void 0 ? new w() : new S(e);
1760
+ return e === void 0 ? new y() : new S(e);
1761
1761
  }
1762
- function z(t) {
1763
- return j(t) ? t.expression instanceof Z ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new w();
1762
+ function G(t) {
1763
+ return $(t) ? t.expression instanceof K ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new y();
1764
1764
  }
1765
- function bn(t) {
1765
+ function In(t) {
1766
1766
  var e;
1767
1767
  return !(t instanceof q) || !kt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
1768
1768
  }
1769
- function In(t) {
1769
+ function Ln(t) {
1770
1770
  const e = _e(t.leftExpression), n = _e(t.rightExpression);
1771
1771
  if (!e.isOk() || !n.isOk())
1772
1772
  return !1;
@@ -1774,23 +1774,23 @@ function In(t) {
1774
1774
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1775
1775
  }
1776
1776
  function ht(t) {
1777
- return t instanceof U && t.expression instanceof Z || t instanceof te;
1777
+ return t instanceof U && t.expression instanceof K || t instanceof ne;
1778
1778
  }
1779
- function Ln(t, e) {
1780
- var i, r, a, u;
1779
+ function gn(t, e) {
1780
+ var i, r, a, l;
1781
1781
  let n = e;
1782
- const s = Ht(t);
1782
+ const s = Jt(t);
1783
1783
  for (; n; ) {
1784
1784
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1785
1785
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1786
- if (((u = n.symbol) == null ? void 0 : u.declaration) instanceof G && s)
1786
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
1787
1787
  return n.symbol;
1788
- if (n instanceof G)
1788
+ if (n instanceof X)
1789
1789
  return;
1790
1790
  n = n.parent;
1791
1791
  }
1792
1792
  }
1793
- class gn {
1793
+ class _n {
1794
1794
  constructor(e, n, s) {
1795
1795
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1796
1796
  }
@@ -1798,7 +1798,7 @@ class gn {
1798
1798
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1799
1799
  }
1800
1800
  validateContext() {
1801
- return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1801
+ return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1802
1802
  }
1803
1803
  validateName(e) {
1804
1804
  return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
@@ -1812,10 +1812,10 @@ class gn {
1812
1812
  validateBody(e) {
1813
1813
  if (!e)
1814
1814
  return [];
1815
- if (e instanceof ne)
1815
+ if (e instanceof J)
1816
1816
  return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1817
1817
  const n = [];
1818
- return j(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1818
+ return $(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1819
1819
  }
1820
1820
  }
1821
1821
  class we {
@@ -1835,7 +1835,7 @@ class we {
1835
1835
  return this.table.entries();
1836
1836
  }
1837
1837
  }
1838
- class _n {
1838
+ class An {
1839
1839
  constructor(e, n, s) {
1840
1840
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1841
1841
  }
@@ -1843,7 +1843,7 @@ class _n {
1843
1843
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
1844
1844
  }
1845
1845
  validateContext() {
1846
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1846
+ return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1847
1847
  }
1848
1848
  validateName(e) {
1849
1849
  return e ? yt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
@@ -1853,11 +1853,11 @@ class _n {
1853
1853
  }
1854
1854
  registerElement() {
1855
1855
  const e = [];
1856
- this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new we() });
1857
- const { name: n } = this.declarationNode, s = C(n);
1856
+ this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
1857
+ const { name: n } = this.declarationNode, s = W(n);
1858
1858
  if (s.isOk()) {
1859
- const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), u = ze(r);
1860
- a.has(u) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(u, this.declarationNode.symbol);
1859
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
1860
+ a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1861
1861
  }
1862
1862
  return e;
1863
1863
  }
@@ -1867,9 +1867,9 @@ class _n {
1867
1867
  validateBody(e) {
1868
1868
  if (!e)
1869
1869
  return [];
1870
- if (e instanceof y)
1870
+ if (e instanceof w)
1871
1871
  return this.validateFields([e]);
1872
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
1872
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
1873
1873
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1874
1874
  }
1875
1875
  validateFields(e) {
@@ -1877,21 +1877,21 @@ class _n {
1877
1877
  const s = [];
1878
1878
  n.callee && !M(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1879
1879
  const i = [...n.args];
1880
- return I.last(i) instanceof D ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof D && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1880
+ return I.last(i) instanceof R ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof R && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1881
1881
  });
1882
1882
  }
1883
1883
  validateFieldSettings(e) {
1884
- const n = W(e), s = n.getErrors(), i = n.getValue();
1884
+ const n = B(e), s = n.getErrors(), i = n.getValue();
1885
1885
  for (const r in i) {
1886
1886
  const a = i[r];
1887
1887
  switch (r) {
1888
1888
  case "note":
1889
- a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", u))), a.forEach((u) => {
1890
- j(u.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", u));
1889
+ a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1890
+ $(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1891
1891
  });
1892
1892
  break;
1893
1893
  default:
1894
- a.forEach((u) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, u)));
1894
+ a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1895
1895
  }
1896
1896
  }
1897
1897
  return s;
@@ -1900,13 +1900,13 @@ class _n {
1900
1900
  return e.flatMap((n) => {
1901
1901
  if (n.parent = this.declarationNode, !n.type)
1902
1902
  return [];
1903
- const s = re(n);
1903
+ const s = ae(n);
1904
1904
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1905
1905
  });
1906
1906
  }
1907
1907
  registerField(e) {
1908
1908
  if (e.callee && M(e.callee)) {
1909
- const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
1909
+ const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(nn, { declaration: e });
1910
1910
  e.symbol = i;
1911
1911
  const r = this.declarationNode.symbol.symbolTable;
1912
1912
  if (r.has(s)) {
@@ -1921,7 +1921,7 @@ class _n {
1921
1921
  return [];
1922
1922
  }
1923
1923
  }
1924
- class An {
1924
+ class vn {
1925
1925
  constructor(e, n, s) {
1926
1926
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1927
1927
  }
@@ -1929,7 +1929,7 @@ class An {
1929
1929
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1930
1930
  }
1931
1931
  validateContext() {
1932
- return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1932
+ return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1933
1933
  }
1934
1934
  validateName(e) {
1935
1935
  return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
@@ -1943,9 +1943,9 @@ class An {
1943
1943
  validateBody(e) {
1944
1944
  if (!e)
1945
1945
  return [];
1946
- if (e instanceof y)
1946
+ if (e instanceof w)
1947
1947
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1948
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
1948
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
1949
1949
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1950
1950
  }
1951
1951
  validateFields(e) {
@@ -1953,7 +1953,7 @@ class An {
1953
1953
  if (!n.callee)
1954
1954
  return [];
1955
1955
  const s = [], i = [n.callee, ...n.args];
1956
- return I.last(i) instanceof D && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1956
+ return I.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1957
1957
  for (; r instanceof H; )
1958
1958
  r.argumentList && !Xe(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
1959
1959
  Xe(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
@@ -1961,29 +1961,29 @@ class An {
1961
1961
  });
1962
1962
  }
1963
1963
  validateFieldSetting(e) {
1964
- const n = W(e), s = n.getErrors(), i = n.getValue();
1964
+ const n = B(e), s = n.getErrors(), i = n.getValue();
1965
1965
  for (const r in i) {
1966
1966
  const a = i[r];
1967
1967
  switch (r) {
1968
1968
  case "note":
1969
1969
  case "name":
1970
- a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
1971
- j(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, u));
1970
+ a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1971
+ $(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1972
1972
  });
1973
1973
  break;
1974
1974
  case "unique":
1975
1975
  case "pk":
1976
- a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
1977
- le(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, u));
1976
+ a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1977
+ ue(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1978
1978
  });
1979
1979
  break;
1980
1980
  case "type":
1981
- a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", u))), a.forEach((u) => {
1982
- M(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, u));
1981
+ a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1982
+ M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1983
1983
  });
1984
1984
  break;
1985
1985
  default:
1986
- a.forEach((u) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, u)));
1986
+ a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1987
1987
  }
1988
1988
  }
1989
1989
  return s;
@@ -1992,30 +1992,44 @@ class An {
1992
1992
  return e.flatMap((n) => {
1993
1993
  if (n.parent = this.declarationNode, !n.type)
1994
1994
  return [];
1995
- const s = re(n);
1995
+ const s = ae(n);
1996
1996
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1997
1997
  });
1998
1998
  }
1999
1999
  }
2000
- class vn {
2000
+ class wn {
2001
2001
  constructor(e, n, s) {
2002
2002
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2003
2003
  }
2004
2004
  validate() {
2005
- return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2005
+ return [
2006
+ ...this.validateContext(),
2007
+ ...this.validateName(this.declarationNode.name),
2008
+ ...this.validateAlias(this.declarationNode.alias),
2009
+ ...this.validateSettingList(this.declarationNode.attributeList),
2010
+ ...this.validateBody(this.declarationNode.body)
2011
+ ];
2006
2012
  }
2007
2013
  validateContext() {
2008
- return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
2014
+ return !(this.declarationNode.parent instanceof X) && ![
2015
+ b.Table,
2016
+ b.TableGroup,
2017
+ b.Project
2018
+ ].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(
2019
+ o.INVALID_NOTE_CONTEXT,
2020
+ "A Note can only appear inside a Table, a Table Group or a Project. Sticky note can only appear at the global scope.",
2021
+ this.declarationNode
2022
+ )] : [];
2009
2023
  }
2010
2024
  validateName(e) {
2011
- if (!(this.declarationNode.parent instanceof G))
2025
+ if (!(this.declarationNode.parent instanceof X))
2012
2026
  return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2013
2027
  if (!e)
2014
2028
  return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2015
- const n = C(e);
2029
+ const n = W(e);
2016
2030
  if (!n.isOk())
2017
2031
  return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2018
- const i = n.unwrap().join("."), r = qt(i);
2032
+ const i = n.unwrap().join("."), r = Ht(i);
2019
2033
  return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
2020
2034
  }
2021
2035
  validateAlias(e) {
@@ -2027,25 +2041,25 @@ class vn {
2027
2041
  validateBody(e) {
2028
2042
  if (!e)
2029
2043
  return [];
2030
- if (e instanceof y)
2044
+ if (e instanceof w)
2031
2045
  return this.validateFields([e]);
2032
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
2046
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
2033
2047
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2034
2048
  }
2035
2049
  validateFields(e) {
2036
2050
  const n = [];
2037
- return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), j(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2051
+ return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2038
2052
  }
2039
2053
  validateSubElements(e) {
2040
2054
  return e.flatMap((n) => {
2041
2055
  if (n.parent = this.declarationNode, !n.type)
2042
2056
  return [];
2043
- const s = re(n);
2057
+ const s = ae(n);
2044
2058
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2045
2059
  });
2046
2060
  }
2047
2061
  }
2048
- class wn {
2062
+ class yn {
2049
2063
  constructor(e, n, s) {
2050
2064
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2051
2065
  }
@@ -2053,7 +2067,7 @@ class wn {
2053
2067
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2054
2068
  }
2055
2069
  validateContext() {
2056
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2070
+ return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2057
2071
  }
2058
2072
  validateName(e) {
2059
2073
  return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
@@ -2067,9 +2081,9 @@ class wn {
2067
2081
  validateBody(e) {
2068
2082
  if (!e)
2069
2083
  return [];
2070
- if (e instanceof y)
2084
+ if (e instanceof w)
2071
2085
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2072
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
2086
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
2073
2087
  return [
2074
2088
  ...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2075
2089
  ...this.validateSubElements(s)
@@ -2079,12 +2093,12 @@ class wn {
2079
2093
  return e.flatMap((n) => {
2080
2094
  if (n.parent = this.declarationNode, !n.type)
2081
2095
  return [];
2082
- const s = re(n);
2096
+ const s = ae(n);
2083
2097
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2084
2098
  });
2085
2099
  }
2086
2100
  }
2087
- class yn {
2101
+ class kn {
2088
2102
  constructor(e, n, s) {
2089
2103
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2090
2104
  }
@@ -2092,7 +2106,7 @@ class yn {
2092
2106
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2093
2107
  }
2094
2108
  validateContext() {
2095
- return this.declarationNode.parent instanceof G ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2109
+ return this.declarationNode.parent instanceof X ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2096
2110
  }
2097
2111
  validateName(e) {
2098
2112
  return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
@@ -2106,9 +2120,9 @@ class yn {
2106
2120
  validateBody(e) {
2107
2121
  if (!e)
2108
2122
  return [];
2109
- if (e instanceof y)
2123
+ if (e instanceof w)
2110
2124
  return this.validateFields([e]);
2111
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
2125
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
2112
2126
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2113
2127
  }
2114
2128
  validateFields(e) {
@@ -2116,24 +2130,24 @@ class yn {
2116
2130
  return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2117
2131
  const n = [];
2118
2132
  return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2119
- s.callee && !bn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !In(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2133
+ s.callee && !In(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Ln(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2120
2134
  const i = [...s.args];
2121
- I.last(i) instanceof D ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof D && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2135
+ I.last(i) instanceof R ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof R && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2122
2136
  }), n;
2123
2137
  }
2124
2138
  validateFieldSettings(e) {
2125
- const n = W(e), s = n.getErrors(), i = n.getValue();
2139
+ const n = B(e), s = n.getErrors(), i = n.getValue();
2126
2140
  for (const r in i) {
2127
2141
  const a = i[r];
2128
2142
  switch (r) {
2129
2143
  case "delete":
2130
2144
  case "update":
2131
- a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
2132
- kn(u.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, u));
2145
+ a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2146
+ xn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2133
2147
  });
2134
2148
  break;
2135
2149
  default:
2136
- a.forEach((u) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, u)));
2150
+ a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2137
2151
  }
2138
2152
  }
2139
2153
  return s;
@@ -2142,16 +2156,16 @@ class yn {
2142
2156
  return e.flatMap((n) => {
2143
2157
  if (n.parent = this.declarationNode, !n.type)
2144
2158
  return [];
2145
- const s = re(n);
2159
+ const s = ae(n);
2146
2160
  return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2147
2161
  });
2148
2162
  }
2149
2163
  }
2150
- function kn(t) {
2151
- if (!(M(t) && t.expression.variable.kind !== l.QUOTED_STRING) && !(t instanceof $))
2164
+ function xn(t) {
2165
+ if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof Y))
2152
2166
  return !1;
2153
2167
  let e;
2154
- if (t instanceof $ ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
2168
+ if (t instanceof Y ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
2155
2169
  switch (e.toLowerCase()) {
2156
2170
  case "cascade":
2157
2171
  case "no action":
@@ -2164,7 +2178,7 @@ function kn(t) {
2164
2178
  }
2165
2179
  return !1;
2166
2180
  }
2167
- class xn {
2181
+ class Sn {
2168
2182
  constructor(e, n, s) {
2169
2183
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2170
2184
  }
@@ -2172,31 +2186,31 @@ class xn {
2172
2186
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
2173
2187
  }
2174
2188
  validateContext() {
2175
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2189
+ return this.declarationNode.parent instanceof v ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2176
2190
  }
2177
2191
  validateName(e) {
2178
- return e ? e instanceof ue ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : yt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2192
+ return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : yt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2179
2193
  }
2180
2194
  validateAlias(e) {
2181
- return e ? Dn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2195
+ return e ? Pn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2182
2196
  }
2183
2197
  validateSettingList(e) {
2184
- const n = W(e), s = n.getErrors(), i = n.getValue();
2198
+ const n = B(e), s = n.getErrors(), i = n.getValue();
2185
2199
  for (const r in i) {
2186
2200
  const a = i[r];
2187
2201
  switch (r) {
2188
2202
  case "headercolor":
2189
- a.length > 1 && s.push(...a.map((u) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", u))), a.forEach((u) => {
2190
- Pn(u.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", u.value || u.name));
2203
+ a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2204
+ Un(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2191
2205
  });
2192
2206
  break;
2193
2207
  case "note":
2194
- a.length > 1 && s.push(...a.map((u) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", u))), a.forEach((u) => {
2195
- j(u.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", u.value || u.name));
2208
+ a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2209
+ $(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2196
2210
  });
2197
2211
  break;
2198
2212
  default:
2199
- s.push(...a.map((u) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, u)));
2213
+ s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2200
2214
  }
2201
2215
  }
2202
2216
  return s;
@@ -2204,13 +2218,13 @@ class xn {
2204
2218
  registerElement() {
2205
2219
  const e = [];
2206
2220
  this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
2207
- const { name: n, alias: s } = this.declarationNode, i = C(n);
2221
+ const { name: n, alias: s } = this.declarationNode, i = W(n);
2208
2222
  if (i.isOk()) {
2209
- const r = [...i.unwrap()], a = r.pop(), u = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2210
- u.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), u.set(p, this.declarationNode.symbol);
2223
+ const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2224
+ l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2211
2225
  }
2212
- if (s && ye(s) && !On(s.expression.variable.value, i.unwrap_or([]))) {
2213
- const r = V(s).unwrap(), a = Oe(r);
2226
+ if (s && ye(s) && !Dn(s.expression.variable.value, i.unwrap_or([]))) {
2227
+ const r = C(s).unwrap(), a = Oe(r);
2214
2228
  this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2215
2229
  }
2216
2230
  return e;
@@ -2218,9 +2232,9 @@ class xn {
2218
2232
  validateBody(e) {
2219
2233
  if (!e)
2220
2234
  return [];
2221
- if (e instanceof y)
2235
+ if (e instanceof w)
2222
2236
  return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2223
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
2237
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
2224
2238
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2225
2239
  }
2226
2240
  validateFields(e) {
@@ -2228,14 +2242,14 @@ class xn {
2228
2242
  if (!n.callee)
2229
2243
  return [];
2230
2244
  const s = [];
2231
- n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Sn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2245
+ n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !On(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2232
2246
  const i = n.args.slice(1);
2233
2247
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2234
2248
  });
2235
2249
  }
2236
2250
  registerField(e) {
2237
2251
  if (e.callee && M(e.callee)) {
2238
- const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(nn, { declaration: e });
2252
+ const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(sn, { declaration: e });
2239
2253
  e.symbol = i;
2240
2254
  const r = this.declarationNode.symbol.symbolTable;
2241
2255
  if (r.has(s)) {
@@ -2251,71 +2265,71 @@ class xn {
2251
2265
  }
2252
2266
  // This is needed to support legacy inline settings
2253
2267
  validateFieldSetting(e) {
2254
- if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
2268
+ if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof R))
2255
2269
  return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2256
2270
  if (e.length === 0)
2257
2271
  return [];
2258
2272
  let n;
2259
- I.last(e) instanceof D && (n = e.pop());
2260
- const s = W(n), i = s.getErrors(), r = s.getValue();
2273
+ I.last(e) instanceof R && (n = e.pop());
2274
+ const s = B(n), i = s.getErrors(), r = s.getValue();
2261
2275
  for (const p of e) {
2262
- const f = V(p).unwrap_or("").toLowerCase();
2276
+ const f = C(p).unwrap_or("").toLowerCase();
2263
2277
  if (f !== "pk" && f !== "unique") {
2264
2278
  i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2265
2279
  continue;
2266
2280
  }
2267
2281
  r[f] === void 0 ? r[f] = [p] : r[f].push(p);
2268
2282
  }
2269
- const a = r.pk || [], u = r["primary key"] || [];
2270
- a.length >= 1 && u.length >= 1 && i.push(...[...a, ...u].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2283
+ const a = r.pk || [], l = r["primary key"] || [];
2284
+ a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2271
2285
  for (const p in r) {
2272
2286
  const f = r[p];
2273
2287
  switch (p) {
2274
2288
  case "note":
2275
2289
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
2276
- j(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2290
+ $(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2277
2291
  });
2278
2292
  break;
2279
2293
  case "ref":
2280
2294
  f.forEach((h) => {
2281
- Mn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
2295
+ Fn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
2282
2296
  });
2283
2297
  break;
2284
2298
  case "primary key":
2285
2299
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
2286
- le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
2300
+ ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
2287
2301
  });
2288
2302
  break;
2289
2303
  case "pk":
2290
2304
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
2291
- h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
2305
+ h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
2292
2306
  });
2293
2307
  break;
2294
2308
  case "not null":
2295
2309
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
2296
2310
  const E = r.null || [];
2297
2311
  f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", h))), f.forEach((h) => {
2298
- le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
2312
+ ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
2299
2313
  });
2300
2314
  break;
2301
2315
  case "null":
2302
2316
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
2303
- le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
2317
+ ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
2304
2318
  });
2305
2319
  break;
2306
2320
  case "unique":
2307
2321
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
2308
- h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
2322
+ h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
2309
2323
  });
2310
2324
  break;
2311
2325
  case "increment":
2312
2326
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
2313
- h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
2327
+ h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
2314
2328
  });
2315
2329
  break;
2316
2330
  case "default":
2317
2331
  f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
2318
- Un(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
2332
+ Mn(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
2319
2333
  });
2320
2334
  break;
2321
2335
  default:
@@ -2328,32 +2342,32 @@ class xn {
2328
2342
  const n = e.flatMap((i) => {
2329
2343
  if (i.parent = this.declarationNode, !i.type)
2330
2344
  return [];
2331
- const r = re(i);
2345
+ const r = ae(i);
2332
2346
  return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
2333
2347
  }), s = e.filter((i) => {
2334
2348
  var r;
2335
2349
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2336
2350
  });
2337
- return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2351
+ return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2338
2352
  }
2339
2353
  }
2340
- function Sn(t) {
2341
- if (!(t instanceof H || Je(t) || t instanceof U || t instanceof ue))
2354
+ function On(t) {
2355
+ if (!(t instanceof H || Je(t) || t instanceof U || t instanceof he))
2342
2356
  return !1;
2343
2357
  if (t instanceof H) {
2344
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => he(n) || j(n) || me(n)))
2358
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || $(n) || me(n)))
2345
2359
  return !1;
2346
2360
  t = t.callee;
2347
2361
  }
2348
- for (; t instanceof ue; ) {
2349
- if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && he(n.name)))
2362
+ for (; t instanceof he; ) {
2363
+ if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && fe(n.name)))
2350
2364
  return !1;
2351
2365
  t = t.array;
2352
2366
  }
2353
- const e = C(t).unwrap_or(void 0);
2367
+ const e = W(t).unwrap_or(void 0);
2354
2368
  return e !== void 0 && e.length > 0;
2355
2369
  }
2356
- function On(t, e) {
2370
+ function Dn(t, e) {
2357
2371
  return e.length === 1 && t === e[0];
2358
2372
  }
2359
2373
  class Rn {
@@ -2361,21 +2375,44 @@ class Rn {
2361
2375
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2362
2376
  }
2363
2377
  validate() {
2364
- return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
2378
+ return [
2379
+ ...this.validateContext(),
2380
+ ...this.validateName(this.declarationNode.name),
2381
+ ...this.validateAlias(this.declarationNode.alias),
2382
+ ...this.validateSettingList(this.declarationNode.attributeList),
2383
+ ...this.registerElement(),
2384
+ ...this.validateBody(this.declarationNode.body)
2385
+ ];
2365
2386
  }
2366
2387
  validateContext() {
2367
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2388
+ return this.declarationNode.parent instanceof v ? [new c(
2389
+ o.INVALID_TABLEGROUP_CONTEXT,
2390
+ "TableGroup must appear top-level",
2391
+ this.declarationNode
2392
+ )] : [];
2368
2393
  }
2369
2394
  validateName(e) {
2370
- return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be a single identifier", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2395
+ return e ? ye(e) ? [] : [new c(
2396
+ o.INVALID_NAME,
2397
+ "A TableGroup name must be a single identifier",
2398
+ e
2399
+ )] : [new c(
2400
+ o.NAME_NOT_FOUND,
2401
+ "A TableGroup must have a name",
2402
+ this.declarationNode
2403
+ )];
2371
2404
  }
2372
2405
  validateAlias(e) {
2373
- return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2406
+ return e ? [new c(
2407
+ o.UNEXPECTED_ALIAS,
2408
+ "A TableGroup shouldn't have an alias",
2409
+ e
2410
+ )] : [];
2374
2411
  }
2375
2412
  registerElement() {
2376
2413
  const { name: e } = this.declarationNode;
2377
- this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new we() });
2378
- const n = C(e);
2414
+ this.declarationNode.symbol = this.symbolFactory.create(rn, { declaration: this.declarationNode, symbolTable: new we() });
2415
+ const n = W(e);
2379
2416
  if (n.isOk()) {
2380
2417
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
2381
2418
  if (r.has(a))
@@ -2385,33 +2422,75 @@ class Rn {
2385
2422
  return [];
2386
2423
  }
2387
2424
  validateSettingList(e) {
2388
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2425
+ const n = B(e), s = n.getErrors(), i = n.getValue();
2426
+ return I.forIn(i, (r, a) => {
2427
+ switch (a) {
2428
+ case "headercolor":
2429
+ s.push(...r.map((l) => new c(
2430
+ o.INVALID_TABLE_SETTING,
2431
+ "'headercolor' is not supported",
2432
+ l
2433
+ )));
2434
+ break;
2435
+ case "note":
2436
+ r.length > 1 && s.push(...r.map((l) => new c(
2437
+ o.DUPLICATE_TABLE_SETTING,
2438
+ "'note' can only appear once",
2439
+ l
2440
+ ))), r.filter((l) => !$(l.value)).forEach((l) => {
2441
+ s.push(new c(
2442
+ o.INVALID_TABLE_SETTING,
2443
+ "'note' must be a string literal",
2444
+ l.value || l.name
2445
+ ));
2446
+ });
2447
+ break;
2448
+ default:
2449
+ s.push(...r.map((l) => new c(
2450
+ o.INVALID_TABLE_SETTING,
2451
+ `Unknown '${a}' setting`,
2452
+ l
2453
+ )));
2454
+ break;
2455
+ }
2456
+ }), s;
2389
2457
  }
2390
2458
  validateBody(e) {
2391
2459
  if (!e)
2392
2460
  return [];
2393
- if (e instanceof y)
2394
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2395
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
2396
- return [...this.validateFields(n), ...this.validateSubElements(s)];
2461
+ if (e instanceof w)
2462
+ return [new c(
2463
+ o.UNEXPECTED_SIMPLE_BODY,
2464
+ "A TableGroup's body must be a block",
2465
+ e
2466
+ )];
2467
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
2468
+ return [
2469
+ ...this.validateFields(n),
2470
+ ...this.validateSubElements(s)
2471
+ ];
2397
2472
  }
2398
2473
  validateFields(e) {
2399
2474
  return e.flatMap((n) => {
2400
2475
  const s = [];
2401
- return n.callee && !C(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2476
+ return n.callee && !W(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2402
2477
  });
2403
2478
  }
2404
2479
  validateSubElements(e) {
2405
- return e.flatMap((n) => {
2406
- if (n.parent = this.declarationNode, !n.type)
2480
+ const n = e.flatMap((i) => {
2481
+ if (i.parent = this.declarationNode, !i.type)
2407
2482
  return [];
2408
- const s = re(n);
2409
- return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2483
+ const r = ae(i);
2484
+ return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
2485
+ }), s = e.filter((i) => {
2486
+ var r;
2487
+ return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2410
2488
  });
2489
+ return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2411
2490
  }
2412
2491
  registerField(e) {
2413
2492
  if (e.callee && M(e.callee)) {
2414
- const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(rn, { declaration: e });
2493
+ const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(an, { declaration: e });
2415
2494
  e.symbol = i;
2416
2495
  const r = this.declarationNode.symbol.symbolTable;
2417
2496
  if (r.has(s)) {
@@ -2427,34 +2506,34 @@ class Rn {
2427
2506
  }
2428
2507
  }
2429
2508
  const wt = ["-", "+"];
2430
- function re(t) {
2509
+ function ae(t) {
2431
2510
  switch (t.type.value.toLowerCase()) {
2432
2511
  case b.Enum:
2433
- return _n;
2512
+ return An;
2434
2513
  case b.Table:
2435
- return xn;
2514
+ return Sn;
2436
2515
  case b.TableGroup:
2437
2516
  return Rn;
2438
2517
  case b.Project:
2439
- return wn;
2440
- case b.Ref:
2441
2518
  return yn;
2519
+ case b.Ref:
2520
+ return kn;
2442
2521
  case b.Note:
2443
- return vn;
2522
+ return wn;
2444
2523
  case b.Indexes:
2445
- return An;
2524
+ return vn;
2446
2525
  default:
2447
- return gn;
2526
+ return _n;
2448
2527
  }
2449
2528
  }
2450
2529
  function yt(t) {
2451
- return !!C(t).unwrap_or(!1);
2530
+ return !!W(t).unwrap_or(!1);
2452
2531
  }
2453
- function Dn(t) {
2532
+ function Pn(t) {
2454
2533
  return ye(t);
2455
2534
  }
2456
2535
  function ye(t) {
2457
- return t instanceof U && t.expression instanceof Z;
2536
+ return t instanceof U && t.expression instanceof K;
2458
2537
  }
2459
2538
  function Ze(t, e, n) {
2460
2539
  var i;
@@ -2462,14 +2541,14 @@ function Ze(t, e, n) {
2462
2541
  let s = e;
2463
2542
  for (const r of t) {
2464
2543
  let a;
2465
- const u = je(r);
2466
- if (s.has(u)) {
2467
- if (a = (i = s.get(u)) == null ? void 0 : i.symbolTable, !a)
2544
+ const l = je(r);
2545
+ if (s.has(l)) {
2546
+ if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2468
2547
  throw new Error("Expect a symbol table in a schema symbol");
2469
2548
  } else {
2470
2549
  a = new we();
2471
2550
  const p = n.create(_t, { symbolTable: a });
2472
- s.set(u, p);
2551
+ s.set(l, p);
2473
2552
  }
2474
2553
  s = a;
2475
2554
  }
@@ -2478,44 +2557,44 @@ function Ze(t, e, n) {
2478
2557
  function kt(t) {
2479
2558
  return t === "-" || t === "<>" || t === ">" || t === "<";
2480
2559
  }
2481
- function Pn(t) {
2560
+ function Un(t) {
2482
2561
  var n;
2483
- if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== l.COLOR_LITERAL)
2562
+ if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2484
2563
  return !1;
2485
2564
  const e = t.expression.literal.value;
2486
2565
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2487
2566
  return !1;
2488
2567
  for (let s = 1; s < e.length; s += 1)
2489
- if (!Zt(e[s]))
2568
+ if (!Kt(e[s]))
2490
2569
  return !1;
2491
2570
  return !0;
2492
2571
  }
2493
- function le(t) {
2572
+ function ue(t) {
2494
2573
  return t === void 0;
2495
2574
  }
2496
- function Un(t) {
2575
+ function Mn(t) {
2497
2576
  var e;
2498
- return !!(j(t) || he(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression) || t instanceof te);
2577
+ return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof ne);
2499
2578
  }
2500
- function he(t) {
2579
+ function fe(t) {
2501
2580
  var e;
2502
- return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === l.NUMERIC_LITERAL;
2581
+ return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2503
2582
  }
2504
- function Mn(t) {
2583
+ function Fn(t) {
2505
2584
  var n;
2506
2585
  if (!(t instanceof Q) || !kt((n = t.op) == null ? void 0 : n.value))
2507
2586
  return !1;
2508
- const e = C(t.expression).unwrap_or(void 0);
2587
+ const e = W(t.expression).unwrap_or(void 0);
2509
2588
  return e !== void 0 && e.length > 0;
2510
2589
  }
2511
2590
  function xt(t) {
2512
- return t instanceof J && t.elementList.every(M);
2591
+ return t instanceof Z && t.elementList.every(M);
2513
2592
  }
2514
- function W(t) {
2593
+ function B(t) {
2515
2594
  var s;
2516
2595
  const e = {}, n = [];
2517
2596
  if (!t)
2518
- return new B({});
2597
+ return new V({});
2519
2598
  for (const i of t.elementList) {
2520
2599
  if (!i.name)
2521
2600
  continue;
@@ -2526,7 +2605,7 @@ function W(t) {
2526
2605
  const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2527
2606
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2528
2607
  }
2529
- return new B(e, n);
2608
+ return new V(e, n);
2530
2609
  }
2531
2610
  class ft {
2532
2611
  constructor(e, n) {
@@ -2539,7 +2618,7 @@ class ft {
2539
2618
  this.ast.body.forEach((s) => {
2540
2619
  if (s.parent = this.ast, s.type === void 0)
2541
2620
  return;
2542
- const i = re(s), r = new i(
2621
+ const i = ae(s), r = new i(
2543
2622
  s,
2544
2623
  this.publicSchemaSymbol.symbolTable,
2545
2624
  this.symbolFactory
@@ -2547,10 +2626,10 @@ class ft {
2547
2626
  e.push(...r.validate());
2548
2627
  });
2549
2628
  const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
2550
- return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2629
+ return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new V(this.ast, e);
2551
2630
  }
2552
2631
  }
2553
- class ae {
2632
+ class oe {
2554
2633
  constructor(e, n) {
2555
2634
  this.declarationNode = e, this.errors = n;
2556
2635
  }
@@ -2574,9 +2653,9 @@ class ae {
2574
2653
  if (!e.body)
2575
2654
  return;
2576
2655
  const { body: n } = e;
2577
- if (n instanceof ne)
2656
+ if (n instanceof J)
2578
2657
  for (const s of n.body)
2579
- if (s instanceof A) {
2658
+ if (s instanceof v) {
2580
2659
  if (!s.type)
2581
2660
  continue;
2582
2661
  const i = St(s);
@@ -2588,7 +2667,7 @@ class ae {
2588
2667
  }
2589
2668
  bindSubfield(e) {
2590
2669
  const n = [e.callee, ...e.args], s = I.last(n);
2591
- s instanceof D && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2670
+ s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2592
2671
  const { argBinderRules: i } = this.subfield.arg;
2593
2672
  for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2594
2673
  i[r].shouldBind && this.scanAndBind(n[r], i[r]);
@@ -2598,11 +2677,11 @@ class ae {
2598
2677
  var s, i;
2599
2678
  if (e)
2600
2679
  if (e instanceof U) {
2601
- if (e.expression instanceof Z && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2680
+ if (e.expression instanceof K && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2602
2681
  return;
2603
2682
  this.bindFragments([e], n);
2604
2683
  } else
2605
- e instanceof q ? Je(e) ? this.bindFragments(fe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2684
+ e instanceof q ? Je(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
2606
2685
  }
2607
2686
  // Bind the fragments of a member access expression
2608
2687
  // which can be a simple expression like v1.User,
@@ -2610,7 +2689,7 @@ class ae {
2610
2689
  bindFragments(e, n) {
2611
2690
  if (e.length === 0)
2612
2691
  return;
2613
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), u = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2692
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), l = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2614
2693
  0,
2615
2694
  r === -1 ? void 0 : r
2616
2695
  );
@@ -2618,26 +2697,26 @@ class ae {
2618
2697
  return;
2619
2698
  const E = [];
2620
2699
  for (; s.length && f.length; ) {
2621
- const h = s.pop(), m = f.pop(), g = V(m).unwrap();
2700
+ const h = s.pop(), m = f.pop(), g = C(m).unwrap();
2622
2701
  E.unshift({
2623
2702
  index: Ve(g, h),
2624
2703
  referrer: m
2625
2704
  });
2626
2705
  }
2627
2706
  for (; f.length; ) {
2628
- const h = f.pop(), m = V(h).unwrap();
2707
+ const h = f.pop(), m = C(h).unwrap();
2629
2708
  E.unshift({
2630
2709
  index: Ve(m, i),
2631
2710
  referrer: h
2632
2711
  });
2633
2712
  }
2634
- return u ? u.elementList.forEach(
2713
+ return l ? l.elementList.forEach(
2635
2714
  (h) => this.resolveIndexStack(
2636
2715
  [
2637
2716
  ...E,
2638
2717
  {
2639
2718
  index: Ve(
2640
- V(h).unwrap(),
2719
+ C(h).unwrap(),
2641
2720
  p
2642
2721
  ),
2643
2722
  referrer: h
@@ -2652,25 +2731,25 @@ class ae {
2652
2731
  resolveIndexStack(e, n) {
2653
2732
  if (e.length === 0)
2654
2733
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2655
- const [s, ...i] = e, r = Ln(s.index, this.declarationNode);
2734
+ const [s, ...i] = e, r = gn(s.index, this.declarationNode);
2656
2735
  if (r === void 0) {
2657
2736
  const { kind: f, name: E } = ie(s.index).unwrap();
2658
2737
  this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
2659
2738
  return;
2660
2739
  }
2661
2740
  r.references.push(s.referrer), s.referrer.referee = r;
2662
- let a = r.symbolTable, { kind: u, name: p } = ie(s.index).unwrap();
2741
+ let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
2663
2742
  for (const f of i) {
2664
2743
  const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
2665
2744
  if (!m) {
2666
2745
  this.logError(
2667
2746
  f.referrer,
2668
- `${u} '${p}' does not have ${E} '${h}'`,
2747
+ `${l} '${p}' does not have ${E} '${h}'`,
2669
2748
  n
2670
2749
  );
2671
2750
  return;
2672
2751
  }
2673
- if (u = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
2752
+ if (l = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
2674
2753
  break;
2675
2754
  a = m.symbolTable;
2676
2755
  }
@@ -2679,7 +2758,7 @@ class ae {
2679
2758
  s || this.errors.push(new c(o.BINDING_ERROR, n, e));
2680
2759
  }
2681
2760
  }
2682
- class Fn extends ae {
2761
+ class Bn extends oe {
2683
2762
  constructor() {
2684
2763
  super(...arguments), this.subfield = {
2685
2764
  arg: {
@@ -2689,7 +2768,7 @@ class Fn extends ae {
2689
2768
  }, this.settingList = {};
2690
2769
  }
2691
2770
  }
2692
- class Bn extends ae {
2771
+ class Vn extends oe {
2693
2772
  constructor() {
2694
2773
  super(...arguments), this.subfield = {
2695
2774
  arg: {
@@ -2699,7 +2778,7 @@ class Bn extends ae {
2699
2778
  }, this.settingList = {};
2700
2779
  }
2701
2780
  }
2702
- class Vn extends ae {
2781
+ class Gn extends oe {
2703
2782
  constructor() {
2704
2783
  super(...arguments), this.subfield = {
2705
2784
  arg: {
@@ -2734,7 +2813,7 @@ class Vn extends ae {
2734
2813
  }, this.settingList = {};
2735
2814
  }
2736
2815
  }
2737
- class Gn extends ae {
2816
+ class Cn extends oe {
2738
2817
  constructor() {
2739
2818
  super(...arguments), this.subfield = {
2740
2819
  arg: {
@@ -2744,7 +2823,7 @@ class Gn extends ae {
2744
2823
  }, this.settingList = {};
2745
2824
  }
2746
2825
  }
2747
- class Cn extends ae {
2826
+ class Xn extends oe {
2748
2827
  constructor() {
2749
2828
  super(...arguments), this.subfield = {
2750
2829
  arg: {
@@ -2754,7 +2833,7 @@ class Cn extends ae {
2754
2833
  }, this.settingList = {};
2755
2834
  }
2756
2835
  }
2757
- class Xn extends ae {
2836
+ class $n extends oe {
2758
2837
  constructor() {
2759
2838
  super(...arguments), this.subfield = {
2760
2839
  arg: {
@@ -2771,7 +2850,7 @@ class Xn extends ae {
2771
2850
  }, this.settingList = {};
2772
2851
  }
2773
2852
  }
2774
- class $n extends ae {
2853
+ class Wn extends oe {
2775
2854
  constructor() {
2776
2855
  super(...arguments), this.subfield = {
2777
2856
  arg: {
@@ -2799,7 +2878,7 @@ class $n extends ae {
2799
2878
  }, this.settingList = {};
2800
2879
  }
2801
2880
  }
2802
- class Wn extends ae {
2881
+ class jn extends oe {
2803
2882
  constructor() {
2804
2883
  super(...arguments), this.subfield = {
2805
2884
  arg: {
@@ -2819,24 +2898,24 @@ class Wn extends ae {
2819
2898
  function St(t) {
2820
2899
  switch (t.type.value.toLowerCase()) {
2821
2900
  case b.Enum:
2822
- return Bn;
2901
+ return Vn;
2823
2902
  case b.Table:
2824
- return $n;
2825
- case b.TableGroup:
2826
2903
  return Wn;
2904
+ case b.TableGroup:
2905
+ return jn;
2827
2906
  case b.Project:
2828
- return Cn;
2829
- case b.Ref:
2830
2907
  return Xn;
2908
+ case b.Ref:
2909
+ return $n;
2831
2910
  case b.Note:
2832
- return Gn;
2911
+ return Cn;
2833
2912
  case b.Indexes:
2834
- return Vn;
2913
+ return Gn;
2835
2914
  default:
2836
- return Fn;
2915
+ return Bn;
2837
2916
  }
2838
2917
  }
2839
- class jn {
2918
+ class Yn {
2840
2919
  constructor(e) {
2841
2920
  this.ast = e, this.errors = [];
2842
2921
  }
@@ -2846,10 +2925,10 @@ class jn {
2846
2925
  const n = St(e);
2847
2926
  new n(e, this.errors).bind();
2848
2927
  }
2849
- return new B(this.ast, this.errors);
2928
+ return new V(this.ast, this.errors);
2850
2929
  }
2851
2930
  }
2852
- class Yn {
2931
+ class zn {
2853
2932
  constructor(e) {
2854
2933
  this.generator = e;
2855
2934
  }
@@ -2857,17 +2936,17 @@ class Yn {
2857
2936
  return new e(n, this.generator.nextId());
2858
2937
  }
2859
2938
  }
2860
- class zn {
2939
+ class Qn {
2861
2940
  constructor(e, n) {
2862
- this.ast = e, this.symbolFactory = new Yn(n);
2941
+ this.ast = e, this.symbolFactory = new zn(n);
2863
2942
  }
2864
2943
  // Analyzing: Invoking both the validator and binder
2865
2944
  analyze() {
2866
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new jn(n).resolve());
2945
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
2867
2946
  }
2868
2947
  // For invoking the validator only
2869
2948
  validate() {
2870
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2949
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
2871
2950
  }
2872
2951
  }
2873
2952
  function pt(t, e) {
@@ -2903,7 +2982,7 @@ function Ot(t) {
2903
2982
  }
2904
2983
  throw new Error("Invalid relation op");
2905
2984
  }
2906
- function v(t) {
2985
+ function A(t) {
2907
2986
  return {
2908
2987
  start: {
2909
2988
  offset: t.startPos.offset,
@@ -2915,20 +2994,20 @@ function v(t) {
2915
2994
  }
2916
2995
  function $e(t) {
2917
2996
  var n;
2918
- const e = (n = fe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2919
- return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
2997
+ const e = (n = pe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2998
+ return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
2920
2999
  }
2921
3000
  function Ie(t) {
2922
- const e = C(t).unwrap();
3001
+ const e = W(t).unwrap();
2923
3002
  return {
2924
3003
  name: e.pop(),
2925
3004
  schemaName: e
2926
3005
  };
2927
3006
  }
2928
- function Rt(t) {
3007
+ function Dt(t) {
2929
3008
  return t.expression.literal.value;
2930
3009
  }
2931
- function Dt(t, e) {
3010
+ function Rt(t, e) {
2932
3011
  if (Array.isArray(t)) {
2933
3012
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
2934
3013
  return i < r ? `${i}-${r}` : `${r}-${i}`;
@@ -2939,12 +3018,12 @@ function Dt(t, e) {
2939
3018
  function Pt(t, e) {
2940
3019
  if (Array.isArray(t)) {
2941
3020
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2942
- return I.zip(i, r).every(([a, u]) => a === u);
3021
+ return I.zip(i, r).every(([a, l]) => a === l);
2943
3022
  }
2944
3023
  const n = t.id, s = e.id;
2945
3024
  return n === s;
2946
3025
  }
2947
- function Ne(t) {
3026
+ function re(t) {
2948
3027
  const e = t.split(`
2949
3028
  `), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
2950
3029
  return n.map((r) => r.slice(i)).join(`
@@ -2955,7 +3034,7 @@ class Ut {
2955
3034
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2956
3035
  }
2957
3036
  interpret() {
2958
- this.table.token = v(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
3037
+ this.table.token = A(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2959
3038
  const e = [
2960
3039
  ...this.interpretName(this.declarationNode.name),
2961
3040
  ...this.interpretAlias(this.declarationNode.alias),
@@ -2980,7 +3059,7 @@ class Ut {
2980
3059
  interpretAlias(e) {
2981
3060
  if (!e)
2982
3061
  return [];
2983
- const n = V(e).unwrap_or(null);
3062
+ const n = C(e).unwrap_or(null);
2984
3063
  return n && (this.env.aliases.push({
2985
3064
  name: n,
2986
3065
  kind: "table",
@@ -2992,16 +3071,16 @@ class Ut {
2992
3071
  }
2993
3072
  interpretSettingList(e) {
2994
3073
  var i, r, a;
2995
- const n = W(e).getValue();
2996
- this.table.headerColor = (i = n.headercolor) != null && i.length ? Rt((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3074
+ const n = B(e).getValue();
3075
+ this.table.headerColor = (i = n.headercolor) != null && i.length ? Dt((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
2997
3076
  const [s] = n.note || [];
2998
3077
  return this.table.note = s && {
2999
- value: z(s == null ? void 0 : s.value).map(Ne).unwrap(),
3000
- token: v(s)
3078
+ value: G(s == null ? void 0 : s.value).map(re).unwrap(),
3079
+ token: A(s)
3001
3080
  }, [];
3002
3081
  }
3003
3082
  interpretBody(e) {
3004
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
3083
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
3005
3084
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3006
3085
  }
3007
3086
  interpretSubElements(e) {
@@ -3010,8 +3089,8 @@ class Ut {
3010
3089
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3011
3090
  case "note":
3012
3091
  return this.table.note = {
3013
- value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ne).unwrap(),
3014
- token: v(n)
3092
+ value: G(n.body instanceof J ? n.body.body[0].callee : n.body.callee).map(re).unwrap(),
3093
+ token: A(n)
3015
3094
  }, [];
3016
3095
  case "indexes":
3017
3096
  return this.interpretIndexes(n);
@@ -3023,85 +3102,85 @@ class Ut {
3023
3102
  return e.flatMap((n) => this.interpretColumn(n));
3024
3103
  }
3025
3104
  interpretColumn(e) {
3026
- var a, u, p, f, E, h, m, g;
3105
+ var a, l, p, f, E, h, m, g;
3027
3106
  const n = [], s = {};
3028
- s.name = V(e.callee).unwrap();
3029
- const i = Qn(e.args[0]);
3030
- s.type = i.getValue(), n.push(...i.getErrors()), s.token = v(e), s.inline_refs = [];
3107
+ s.name = C(e.callee).unwrap();
3108
+ const i = qn(e.args[0]);
3109
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = A(e), s.inline_refs = [];
3031
3110
  const r = e.args.slice(1);
3032
- if (I.last(r) instanceof D) {
3033
- const _ = W(r.pop()).getValue();
3034
- s.pk = !!((a = _.pk) != null && a.length) || !!((u = _["primary key"]) != null && u.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((f = _.unique) != null && f.length), s.not_null = !!((E = _["not null"]) != null && E.length) && !0, s.dbdefault = qn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
3035
- const K = (g = _.note) == null ? void 0 : g.at(0);
3036
- s.note = K && {
3037
- value: z(K.value).map(Ne).unwrap(),
3038
- token: v(K)
3111
+ if (I.last(r) instanceof R) {
3112
+ const _ = B(r.pop()).getValue();
3113
+ s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((f = _.unique) != null && f.length), s.not_null = !!((E = _["not null"]) != null && E.length) && !0, s.dbdefault = Hn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
3114
+ const ee = (g = _.note) == null ? void 0 : g.at(0);
3115
+ s.note = ee && {
3116
+ value: G(ee.value).map(re).unwrap(),
3117
+ token: A(ee)
3039
3118
  };
3040
- const oe = _.ref || [];
3041
- s.inline_refs = oe.flatMap((Y) => {
3042
- const [tt] = $e(Y.value.expression);
3119
+ const ce = _.ref || [];
3120
+ s.inline_refs = ce.flatMap((z) => {
3121
+ const [tt] = $e(z.value.expression);
3043
3122
  if (Pt(tt, e.symbol))
3044
- return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
3045
- const ke = Y.value.op, ee = C(Y.value.expression).unwrap();
3046
- let pe;
3047
- if (ee.length === 1) {
3048
- const [ce] = ee;
3049
- pe = {
3123
+ return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3124
+ const ke = z.value.op, te = W(z.value.expression).unwrap();
3125
+ let de;
3126
+ if (te.length === 1) {
3127
+ const [le] = te;
3128
+ de = {
3050
3129
  schemaName: this.table.schemaName,
3051
3130
  tableName: this.table.name,
3052
- fieldNames: [ce],
3131
+ fieldNames: [le],
3053
3132
  relation: ke.value,
3054
- token: v(Y)
3133
+ token: A(z)
3055
3134
  };
3056
- } else if (ee.length === 2) {
3057
- const [ce, Le] = ee;
3058
- pe = {
3135
+ } else if (te.length === 2) {
3136
+ const [le, Le] = te;
3137
+ de = {
3059
3138
  schemaName: null,
3060
- tableName: ce,
3139
+ tableName: le,
3061
3140
  fieldNames: [Le],
3062
3141
  relation: ke.value,
3063
- token: v(Y)
3142
+ token: A(z)
3064
3143
  };
3065
- } else if (ee.length === 3) {
3066
- const [ce, Le, st] = ee;
3067
- pe = {
3068
- schemaName: ce,
3144
+ } else if (te.length === 3) {
3145
+ const [le, Le, st] = te;
3146
+ de = {
3147
+ schemaName: le,
3069
3148
  tableName: Le,
3070
3149
  fieldNames: [st],
3071
3150
  relation: ke.value,
3072
- token: v(Y)
3151
+ token: A(z)
3073
3152
  };
3074
3153
  } else {
3075
- n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", Y));
3076
- const ce = ee.pop(), Le = ee.pop();
3077
- pe = {
3078
- schemaName: ee.join("."),
3154
+ n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3155
+ const le = te.pop(), Le = te.pop();
3156
+ de = {
3157
+ schemaName: te.join("."),
3079
3158
  tableName: Le,
3080
- fieldNames: [ce],
3159
+ fieldNames: [le],
3081
3160
  relation: ke.value,
3082
- token: v(Y)
3161
+ token: A(z)
3083
3162
  };
3084
3163
  }
3085
- const nt = this.registerInlineRefToEnv(e, tt, pe, Y);
3086
- return n.push(...nt), nt.length === 0 ? pe : [];
3164
+ const nt = this.registerInlineRefToEnv(e, tt, de, z);
3165
+ return n.push(...nt), nt.length === 0 ? de : [];
3087
3166
  });
3088
3167
  }
3089
- return s.pk || (s.pk = r.some((_) => X(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => X(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3168
+ return s.pk || (s.pk = r.some((_) => j(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => j(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3090
3169
  }
3091
3170
  interpretIndexes(e) {
3092
3171
  return this.table.indexes.push(...e.body.body.map((n) => {
3093
- var a, u, p, f, E, h, m;
3172
+ var a, l, p, f, E, h, m;
3094
3173
  const s = { columns: [] }, i = n;
3095
- s.token = v(e);
3174
+ s.token = A(e);
3096
3175
  const r = [i.callee, ...i.args];
3097
- if (I.last(r) instanceof D) {
3098
- const g = W(r.pop()).getValue();
3099
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((u = g.unique) != null && u.length), s.name = z((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3176
+ if (I.last(r) instanceof R) {
3177
+ const g = B(r.pop()).getValue();
3178
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = G((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3100
3179
  const _ = (E = g.note) == null ? void 0 : E.at(0);
3101
3180
  s.note = _ && {
3102
- value: z(_.value).unwrap(),
3103
- token: v(_)
3104
- }, s.type = X((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
3181
+ value: G(_.value).unwrap(),
3182
+ token: A(_)
3183
+ }, s.type = j((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
3105
3184
  }
3106
3185
  return r.flatMap((g) => {
3107
3186
  if (!(g instanceof H))
@@ -3111,24 +3190,24 @@ class Ut {
3111
3190
  _.push(g.argumentList), g = g.callee;
3112
3191
  return _.push(g), _;
3113
3192
  }).forEach((g) => {
3114
- const { functional: _, nonFunctional: K } = Xe(g).unwrap();
3193
+ const { functional: _, nonFunctional: ee } = Xe(g).unwrap();
3115
3194
  s.columns.push(
3116
- ..._.map((oe) => ({
3117
- value: oe.value.value,
3195
+ ..._.map((ce) => ({
3196
+ value: ce.value.value,
3118
3197
  type: "expression",
3119
- token: v(oe)
3198
+ token: A(ce)
3120
3199
  })),
3121
- ...K.map((oe) => ({
3122
- value: V(oe).unwrap(),
3200
+ ...ee.map((ce) => ({
3201
+ value: C(ce).unwrap(),
3123
3202
  type: "column",
3124
- token: v(oe)
3203
+ token: A(ce)
3125
3204
  }))
3126
3205
  );
3127
3206
  }), s;
3128
3207
  })), [];
3129
3208
  }
3130
3209
  registerInlineRefToEnv(e, n, s, i) {
3131
- const r = Dt(e.symbol, n);
3210
+ const r = Rt(e.symbol, n);
3132
3211
  if (this.env.refIds[r])
3133
3212
  return [
3134
3213
  new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
@@ -3147,43 +3226,43 @@ class Ut {
3147
3226
  {
3148
3227
  schemaName: this.table.schemaName,
3149
3228
  tableName: this.table.name,
3150
- fieldNames: [X(e.callee).unwrap()],
3151
- token: v(e),
3229
+ fieldNames: [j(e.callee).unwrap()],
3230
+ token: A(e),
3152
3231
  relation: a[0]
3153
3232
  }
3154
3233
  ]
3155
3234
  }), [];
3156
3235
  }
3157
3236
  }
3158
- function Qn(t) {
3237
+ function qn(t) {
3159
3238
  let e = null;
3160
- t instanceof H && (e = t.argumentList.elementList.map((r) => he(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3239
+ t instanceof H && (e = t.argumentList.elementList.map((r) => fe(r) ? r.expression.literal.value : $(r) ? G(r).unwrap() : j(r).unwrap()).join(","), t = t.callee);
3161
3240
  let n = "";
3162
- for (; t instanceof ue; )
3241
+ for (; t instanceof he; )
3163
3242
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3164
3243
  const { name: s, schemaName: i } = Ie(t);
3165
- return i.length > 1 ? new B(
3244
+ return i.length > 1 ? new V(
3166
3245
  {
3167
3246
  schemaName: i.length === 0 ? null : i[0],
3168
3247
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3169
3248
  args: e
3170
3249
  },
3171
3250
  [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3172
- ) : new B({
3251
+ ) : new V({
3173
3252
  schemaName: i.length === 0 ? null : i[0],
3174
3253
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3175
3254
  args: e
3176
3255
  });
3177
3256
  }
3178
- function qn(t) {
3257
+ function Hn(t) {
3179
3258
  var e, n, s;
3180
3259
  if (t) {
3181
- if (j(t))
3260
+ if ($(t))
3182
3261
  return {
3183
- value: z(t).unwrap(),
3262
+ value: G(t).unwrap(),
3184
3263
  type: "string"
3185
3264
  };
3186
- if (he(t))
3265
+ if (fe(t))
3187
3266
  return {
3188
3267
  type: "number",
3189
3268
  value: Number.parseFloat(t.expression.literal.value)
@@ -3193,14 +3272,14 @@ function qn(t) {
3193
3272
  value: t.expression.variable.value.toLowerCase(),
3194
3273
  type: "boolean"
3195
3274
  };
3196
- if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression)) {
3275
+ if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3197
3276
  const i = Number.parseFloat(t.expression.expression.literal.value);
3198
3277
  return {
3199
3278
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3200
3279
  type: "number"
3201
3280
  };
3202
3281
  }
3203
- if (t instanceof te)
3282
+ if (t instanceof ne)
3204
3283
  return {
3205
3284
  value: (s = t.value) == null ? void 0 : s.value,
3206
3285
  type: "expression"
@@ -3208,12 +3287,12 @@ function qn(t) {
3208
3287
  throw new Error("Unreachable");
3209
3288
  }
3210
3289
  }
3211
- class Hn {
3290
+ class Jn {
3212
3291
  constructor(e, n) {
3213
3292
  this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3214
3293
  }
3215
3294
  interpret() {
3216
- return this.note.token = v(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3295
+ return this.note.token = A(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3217
3296
  ...this.interpretName(this.declarationNode.name),
3218
3297
  ...this.interpretSettingList(this.declarationNode.attributeList),
3219
3298
  ...this.interpretBody(this.declarationNode.body)
@@ -3225,64 +3304,64 @@ class Hn {
3225
3304
  }
3226
3305
  interpretSettingList(e) {
3227
3306
  var s, i, r;
3228
- const n = W(e).getValue();
3229
- return this.note.headerColor = (s = n.headercolor) != null && s.length ? Rt((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3307
+ const n = B(e).getValue();
3308
+ return this.note.headerColor = (s = n.headercolor) != null && s.length ? Dt((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3230
3309
  }
3231
3310
  interpretBody(e) {
3232
- const [n, s] = I.partition(e.body, (i) => i instanceof y);
3311
+ const [n, s] = I.partition(e.body, (i) => i instanceof w);
3233
3312
  return n.length !== 1 || s.length > 0 ? [
3234
3313
  new c(o.INVALID_NOTE, "Invalid note syntax", e)
3235
3314
  ] : [...this.interpretNote(n[0])];
3236
3315
  }
3237
3316
  interpretNote(e) {
3238
3317
  const n = I.get(e, "callee.expression.literal.value", "");
3239
- return this.note.content = Ne(n), [];
3318
+ return this.note.content = re(n), [];
3240
3319
  }
3241
3320
  }
3242
3321
  class Mt {
3243
3322
  constructor(e, n) {
3244
- this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3323
+ this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof v ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3245
3324
  }
3246
3325
  interpret() {
3247
- return this.ref.token = v(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3326
+ return this.ref.token = A(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3248
3327
  }
3249
3328
  interpretName(e) {
3250
- const n = [], s = C(this.declarationNode.name).unwrap_or([]);
3329
+ const n = [], s = W(this.declarationNode.name).unwrap_or([]);
3251
3330
  return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3252
3331
  }
3253
3332
  interpretBody(e) {
3254
- return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
3333
+ return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3255
3334
  }
3256
3335
  interpretField(e) {
3257
3336
  var f, E, h, m;
3258
3337
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
3259
3338
  if (Pt(r, a))
3260
3339
  return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3261
- const u = Dt(r, a);
3262
- if (this.env.refIds[u])
3340
+ const l = Rt(r, a);
3341
+ if (this.env.refIds[l])
3263
3342
  return [
3264
3343
  new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3265
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[u])
3344
+ new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3266
3345
  ];
3267
3346
  if (e.args[0]) {
3268
- const g = W(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3269
- this.ref.onDelete = _ instanceof $ ? Te(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
3270
- const K = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3271
- this.ref.onUpdate = K instanceof $ ? Te(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
3347
+ const g = B(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3348
+ this.ref.onDelete = _ instanceof Y ? Te(_).unwrap_or(void 0) : j(_).unwrap_or(void 0);
3349
+ const ee = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3350
+ this.ref.onUpdate = ee instanceof Y ? Te(ee).unwrap_or(void 0) : j(ee).unwrap_or(void 0);
3272
3351
  }
3273
3352
  const p = Ot(n);
3274
3353
  return this.ref.endpoints = [
3275
3354
  {
3276
3355
  ...pt(s, this.container),
3277
3356
  relation: p[0],
3278
- token: v(s)
3357
+ token: A(s)
3279
3358
  },
3280
3359
  {
3281
3360
  ...pt(i, this.container),
3282
3361
  relation: p[1],
3283
- token: v(i)
3362
+ token: A(i)
3284
3363
  }
3285
- ], this.env.refIds[u] = this.declarationNode, [];
3364
+ ], this.env.refIds[l] = this.declarationNode, [];
3286
3365
  }
3287
3366
  }
3288
3367
  class Ft {
@@ -3291,8 +3370,9 @@ class Ft {
3291
3370
  }
3292
3371
  interpret() {
3293
3372
  const e = [];
3294
- return this.tableGroup.token = v(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3373
+ return this.tableGroup.token = A(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3295
3374
  ...this.interpretName(this.declarationNode.name),
3375
+ ...this.interpretSettingList(this.declarationNode.attributeList),
3296
3376
  ...this.interpretBody(this.declarationNode.body)
3297
3377
  ), e;
3298
3378
  }
@@ -3301,13 +3381,36 @@ class Ft {
3301
3381
  return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3302
3382
  }
3303
3383
  interpretBody(e) {
3384
+ const [n, s] = jt(e.body, (i) => i instanceof w);
3385
+ return [
3386
+ ...this.interpretFields(n),
3387
+ ...this.interpretSubElements(s)
3388
+ ];
3389
+ }
3390
+ interpretSubElements(e) {
3391
+ return e.flatMap((n) => {
3392
+ var s;
3393
+ switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3394
+ case "note":
3395
+ this.tableGroup.note = {
3396
+ value: G(
3397
+ n.body instanceof J ? n.body.body[0].callee : n.body.callee
3398
+ ).map(re).unwrap(),
3399
+ token: A(n)
3400
+ };
3401
+ break;
3402
+ }
3403
+ return [];
3404
+ });
3405
+ }
3406
+ interpretFields(e) {
3304
3407
  const n = [];
3305
- return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
3306
- const i = C(s.callee).unwrap();
3408
+ return this.tableGroup.tables = e.map((s) => {
3409
+ const i = W(s.callee).unwrap();
3307
3410
  i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
3308
- const r = fe(s.callee).unwrap().pop().referee.id;
3411
+ const r = pe(s.callee).unwrap().pop().referee.id;
3309
3412
  if (this.env.groupOfTable[r]) {
3310
- const a = this.env.groupOfTable[r], { schemaName: u, name: p } = this.env.tableGroups.get(a), f = u ? `${u}.${p}` : p;
3413
+ const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), f = l ? `${l}.${p}` : p;
3311
3414
  n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
3312
3415
  } else
3313
3416
  this.env.groupOfTable[r] = this.declarationNode;
@@ -3317,13 +3420,20 @@ class Ft {
3317
3420
  };
3318
3421
  }), n;
3319
3422
  }
3423
+ interpretSettingList(e) {
3424
+ const n = B(e).getValue(), [s] = n.note || [];
3425
+ return this.tableGroup.note = s && {
3426
+ value: G(s == null ? void 0 : s.value).map(re).unwrap(),
3427
+ token: A(s)
3428
+ }, [];
3429
+ }
3320
3430
  }
3321
3431
  class Bt {
3322
3432
  constructor(e, n) {
3323
3433
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3324
3434
  }
3325
3435
  interpret() {
3326
- return this.enum.token = v(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3436
+ return this.enum.token = A(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3327
3437
  }
3328
3438
  interpretName(e) {
3329
3439
  const { name: n, schemaName: s } = Ie(e);
@@ -3331,23 +3441,23 @@ class Bt {
3331
3441
  }
3332
3442
  interpretBody(e) {
3333
3443
  return e.body.flatMap((n) => {
3334
- var u;
3444
+ var l;
3335
3445
  const s = n, i = {};
3336
- i.token = v(s), i.name = X(s.callee).unwrap();
3337
- const a = (u = W(s.args[0]).getValue().note) == null ? void 0 : u.at(0);
3446
+ i.token = A(s), i.name = j(s.callee).unwrap();
3447
+ const a = (l = B(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3338
3448
  return i.note = a && {
3339
- value: z(a.value).map(Ne).unwrap(),
3340
- token: v(a)
3449
+ value: G(a.value).map(re).unwrap(),
3450
+ token: A(a)
3341
3451
  }, this.enum.values.push(i), [];
3342
3452
  });
3343
3453
  }
3344
3454
  }
3345
- class Jn {
3455
+ class Zn {
3346
3456
  constructor(e, n) {
3347
3457
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3348
3458
  }
3349
3459
  interpret() {
3350
- return this.env.project.set(this.declarationNode, this.project), this.project.token = v(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3460
+ return this.env.project.set(this.declarationNode, this.project), this.project.token = A(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3351
3461
  }
3352
3462
  interpretName(e) {
3353
3463
  if (!e)
@@ -3378,16 +3488,16 @@ class Jn {
3378
3488
  }
3379
3489
  case "note":
3380
3490
  return this.project.note = {
3381
- value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ne).unwrap(),
3382
- token: v(s)
3491
+ value: G(s.body instanceof J ? s.body.body[0].callee : s.body.callee).map(re).unwrap(),
3492
+ token: A(s)
3383
3493
  }, [];
3384
3494
  default:
3385
- return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
3495
+ return this.project[s.type.value.toLowerCase()] = G(s.body.callee).unwrap(), [];
3386
3496
  }
3387
3497
  });
3388
3498
  }
3389
3499
  }
3390
- class Zn {
3500
+ class Kn {
3391
3501
  constructor(e) {
3392
3502
  this.ast = e, this.env = {
3393
3503
  schema: [],
@@ -3408,7 +3518,7 @@ class Zn {
3408
3518
  case b.Table:
3409
3519
  return new Ut(n, this.env).interpret();
3410
3520
  case b.Note:
3411
- return new Hn(n, this.env).interpret();
3521
+ return new Jn(n, this.env).interpret();
3412
3522
  case b.Ref:
3413
3523
  return new Mt(n, this.env).interpret();
3414
3524
  case b.TableGroup:
@@ -3416,15 +3526,15 @@ class Zn {
3416
3526
  case b.Enum:
3417
3527
  return new Bt(n, this.env).interpret();
3418
3528
  case b.Project:
3419
- return new Jn(n, this.env).interpret();
3529
+ return new Zn(n, this.env).interpret();
3420
3530
  default:
3421
3531
  return [];
3422
3532
  }
3423
3533
  });
3424
- return new B(Kn(this.env), e);
3534
+ return new V(es(this.env), e);
3425
3535
  }
3426
3536
  }
3427
- function Kn(t) {
3537
+ function es(t) {
3428
3538
  return {
3429
3539
  schemas: [],
3430
3540
  tables: Array.from(t.tables.values()),
@@ -3457,13 +3567,13 @@ function Ae(t) {
3457
3567
  return L.Text;
3458
3568
  }
3459
3569
  }
3460
- function De(t, e) {
3570
+ function Re(t, e) {
3461
3571
  if (!t || Ce(t))
3462
3572
  return !1;
3463
3573
  for (const n of t.trailingTrivia) {
3464
3574
  if (n.start > e)
3465
3575
  break;
3466
- if (n.kind === l.NEWLINE && n.end <= e)
3576
+ if (n.kind === u.NEWLINE && n.end <= e)
3467
3577
  return !1;
3468
3578
  }
3469
3579
  return !0;
@@ -3500,19 +3610,19 @@ class Vt {
3500
3610
  }
3501
3611
  provideCompletionItems(e, n) {
3502
3612
  var E, h;
3503
- const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), u = a === void 0 ? i[0] : i[a + 1];
3613
+ const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
3504
3614
  if ([
3505
3615
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3506
3616
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3507
- ...(u == null ? void 0 : u.leadingTrivia) || []
3508
- ].find((m) => zt(m) && ge(s, m)))
3617
+ ...(l == null ? void 0 : l.leadingTrivia) || []
3618
+ ].find((m) => Qt(m) && ge(s, m)))
3509
3619
  return O();
3510
3620
  if (a === void 0)
3511
3621
  return Tt();
3512
- if ([l.STRING_LITERAL, l.QUOTED_STRING].includes(r.kind) && ge(s, r))
3622
+ if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3513
3623
  return O();
3514
3624
  const p = this.compiler.container.element(s);
3515
- if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
3625
+ if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
3516
3626
  return Tt();
3517
3627
  const f = [...this.compiler.container.stack(s)].reverse();
3518
3628
  for (const m of f)
@@ -3549,13 +3659,13 @@ class Vt {
3549
3659
  else {
3550
3660
  if (m instanceof se)
3551
3661
  return Et(this.compiler, s, m);
3552
- if (m instanceof D)
3662
+ if (m instanceof R)
3553
3663
  return Et(this.compiler, s, m);
3554
- if (m instanceof J)
3555
- return es(this.compiler, s);
3556
- if (m instanceof y)
3664
+ if (m instanceof Z)
3665
+ return ts(this.compiler, s);
3666
+ if (m instanceof w)
3557
3667
  return mt(this.compiler, s, m);
3558
- if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3668
+ if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3559
3669
  return mt(this.compiler, s, void 0);
3560
3670
  }
3561
3671
  return O();
@@ -3563,13 +3673,13 @@ class Vt {
3563
3673
  }
3564
3674
  function dt(t, e, n) {
3565
3675
  const s = t.container.scopeKind(e);
3566
- if ([R.REF, R.TABLE].includes(s)) {
3676
+ if ([D.REF, D.TABLE].includes(s)) {
3567
3677
  const i = Be(t, e, t.container.element(e), [
3568
3678
  T.Table,
3569
3679
  T.Schema,
3570
3680
  T.Column
3571
3681
  ]);
3572
- return De(n.op, e) ? Pe(i) : i;
3682
+ return Re(n.op, e) ? Pe(i) : i;
3573
3683
  }
3574
3684
  return O();
3575
3685
  }
@@ -3581,9 +3691,9 @@ function Be(t, e, n, s) {
3581
3691
  const r = { suggestions: [] };
3582
3692
  for (; i; ) {
3583
3693
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3584
- const { symbol: u } = i;
3694
+ const { symbol: l } = i;
3585
3695
  r.suggestions.push(
3586
- ...t.symbol.members(u).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3696
+ ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3587
3697
  label: p,
3588
3698
  insertText: p,
3589
3699
  insertTextRules: k.KeepWhitespace,
@@ -3593,16 +3703,16 @@ function Be(t, e, n, s) {
3593
3703
  }))
3594
3704
  );
3595
3705
  }
3596
- i = i instanceof A ? i.parent : void 0;
3706
+ i = i instanceof v ? i.parent : void 0;
3597
3707
  }
3598
3708
  return Fe(r);
3599
3709
  }
3600
- function es(t, e) {
3710
+ function ts(t, e) {
3601
3711
  var s;
3602
3712
  switch (t.container.scopeKind(e)) {
3603
- case R.INDEXES:
3713
+ case D.INDEXES:
3604
3714
  return Xt(t, e);
3605
- case R.REF:
3715
+ case D.REF:
3606
3716
  {
3607
3717
  const i = [...t.container.stack(e)];
3608
3718
  for (; i.length > 0; ) {
@@ -3621,29 +3731,29 @@ function es(t, e) {
3621
3731
  }
3622
3732
  function Et(t, e, n) {
3623
3733
  const { token: s } = t.container.token(e);
3624
- if ([l.COMMA, l.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3734
+ if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3625
3735
  const i = Nt(t, e);
3626
- return (s == null ? void 0 : s.kind) === l.COMMA && De(s, e) ? Pe(i) : i;
3736
+ return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
3627
3737
  }
3628
3738
  if (n.name && n.name.start <= e && n.name.end >= e)
3629
3739
  return Nt(t, e);
3630
- if (n.name instanceof $) {
3631
- const i = ts(
3740
+ if (n.name instanceof Y) {
3741
+ const i = ns(
3632
3742
  t,
3633
3743
  e,
3634
3744
  Te(n.name).unwrap_or("")
3635
3745
  );
3636
- return (s == null ? void 0 : s.kind) === l.COLON && De(s, e) ? Pe(i) : i;
3746
+ return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? Pe(i) : i;
3637
3747
  }
3638
3748
  return O();
3639
3749
  }
3640
3750
  function Nt(t, e) {
3641
3751
  const n = t.container.element(e), s = t.container.scopeKind(e);
3642
- if (n instanceof G)
3752
+ if (n instanceof X)
3643
3753
  return O();
3644
3754
  if (n.body && !ge(e, n.body))
3645
3755
  switch (s) {
3646
- case R.TABLE:
3756
+ case D.TABLE:
3647
3757
  return {
3648
3758
  suggestions: [
3649
3759
  {
@@ -3666,7 +3776,7 @@ function Nt(t, e) {
3666
3776
  return O();
3667
3777
  }
3668
3778
  switch (s) {
3669
- case R.TABLE:
3779
+ case D.TABLE:
3670
3780
  return {
3671
3781
  suggestions: [
3672
3782
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
@@ -3692,7 +3802,7 @@ function Nt(t, e) {
3692
3802
  }
3693
3803
  ]
3694
3804
  };
3695
- case R.ENUM:
3805
+ case D.ENUM:
3696
3806
  return {
3697
3807
  suggestions: [
3698
3808
  {
@@ -3704,7 +3814,7 @@ function Nt(t, e) {
3704
3814
  }
3705
3815
  ]
3706
3816
  };
3707
- case R.INDEXES:
3817
+ case D.INDEXES:
3708
3818
  return {
3709
3819
  suggestions: [
3710
3820
  ...["unique", "pk"].map((i) => ({
@@ -3723,7 +3833,7 @@ function Nt(t, e) {
3723
3833
  }))
3724
3834
  ]
3725
3835
  };
3726
- case R.REF:
3836
+ case D.REF:
3727
3837
  return {
3728
3838
  suggestions: ["update", "delete"].map((i) => ({
3729
3839
  label: i,
@@ -3736,7 +3846,7 @@ function Nt(t, e) {
3736
3846
  }
3737
3847
  return O();
3738
3848
  }
3739
- function ts(t, e, n) {
3849
+ function ns(t, e, n) {
3740
3850
  switch (n == null ? void 0 : n.toLowerCase()) {
3741
3851
  case "update":
3742
3852
  case "delete":
@@ -3763,10 +3873,10 @@ function ts(t, e, n) {
3763
3873
  return O();
3764
3874
  }
3765
3875
  function Gt(t, e, n) {
3766
- const s = fe(n).unwrap_or([]);
3876
+ const s = pe(n).unwrap_or([]);
3767
3877
  if (s.pop(), s.some((r) => !M(r)))
3768
3878
  return O();
3769
- const i = s.map((r) => X(r).unwrap());
3879
+ const i = s.map((r) => j(r).unwrap());
3770
3880
  return Fe({
3771
3881
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3772
3882
  label: a,
@@ -3779,20 +3889,20 @@ function Gt(t, e, n) {
3779
3889
  function mt(t, e, n) {
3780
3890
  var i;
3781
3891
  switch (t.container.scopeKind(e)) {
3782
- case R.TABLE:
3783
- return ss(t, e, n);
3784
- case R.PROJECT:
3892
+ case D.TABLE:
3785
3893
  return is(t, e, n);
3786
- case R.INDEXES:
3787
- return as(t, e);
3788
- case R.ENUM:
3789
- return ns(t, e, n);
3790
- case R.REF: {
3894
+ case D.PROJECT:
3895
+ return rs(t, e, n);
3896
+ case D.INDEXES:
3897
+ return os(t, e);
3898
+ case D.ENUM:
3899
+ return ss(t, e, n);
3900
+ case D.REF: {
3791
3901
  const r = Ct(t, e);
3792
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === l.COLON && De(t.container.token(e).token, e) ? Pe(r) : r;
3902
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Re(t.container.token(e).token, e) ? Pe(r) : r;
3793
3903
  }
3794
- case R.TABLEGROUP:
3795
- return rs(t);
3904
+ case D.TABLEGROUP:
3905
+ return as(t);
3796
3906
  default:
3797
3907
  return O();
3798
3908
  }
@@ -3808,14 +3918,14 @@ function Tt() {
3808
3918
  }))
3809
3919
  };
3810
3920
  }
3811
- function ns(t, e, n) {
3921
+ function ss(t, e, n) {
3812
3922
  return n != null && n.callee && et(e, n) === 1 ? Be(t, e, t.container.element(e), [
3813
3923
  T.Schema,
3814
3924
  T.Table,
3815
3925
  T.Column
3816
3926
  ]) : O();
3817
3927
  }
3818
- function ss(t, e, n) {
3928
+ function is(t, e, n) {
3819
3929
  if (!(n != null && n.callee))
3820
3930
  return {
3821
3931
  suggestions: ["Note", "indexes"].map((i) => ({
@@ -3835,9 +3945,9 @@ function ss(t, e, n) {
3835
3945
  kind: L.Keyword,
3836
3946
  range: void 0
3837
3947
  }))
3838
- } : s === 1 ? os(t, e) : O();
3948
+ } : s === 1 ? cs(t, e) : O();
3839
3949
  }
3840
- function is(t, e, n) {
3950
+ function rs(t, e, n) {
3841
3951
  return n != null && n.callee ? et(e, n) === 0 ? {
3842
3952
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3843
3953
  label: i,
@@ -3863,7 +3973,7 @@ function Ct(t, e) {
3863
3973
  T.Column
3864
3974
  ]);
3865
3975
  }
3866
- function rs(t) {
3976
+ function as(t) {
3867
3977
  return Fe({
3868
3978
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3869
3979
  const n = ie(e).unwrap_or(void 0);
@@ -3880,10 +3990,10 @@ function rs(t) {
3880
3990
  })
3881
3991
  });
3882
3992
  }
3883
- function as(t, e) {
3993
+ function os(t, e) {
3884
3994
  return Xt(t, e);
3885
3995
  }
3886
- function os(t, e) {
3996
+ function cs(t, e) {
3887
3997
  return {
3888
3998
  suggestions: [
3889
3999
  ...[
@@ -3968,10 +4078,10 @@ function Xt(t, e) {
3968
4078
  const a = ie(r).unwrap_or(void 0);
3969
4079
  if (a === void 0)
3970
4080
  return [];
3971
- const { name: u } = a;
4081
+ const { name: l } = a;
3972
4082
  return {
3973
- label: u,
3974
- insertText: u,
4083
+ label: l,
4084
+ insertText: l,
3975
4085
  insertTextRules: k.KeepWhitespace,
3976
4086
  kind: Ae(T.Column),
3977
4087
  range: void 0
@@ -3993,9 +4103,9 @@ class $t {
3993
4103
  var a;
3994
4104
  const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
3995
4105
  for (; r.length !== 0; ) {
3996
- const u = r.pop();
3997
- if ((a = u == null ? void 0 : u.referee) != null && a.declaration && [Ee.PRIMARY_EXPRESSION, Ee.VARIABLE].includes(u == null ? void 0 : u.kind)) {
3998
- const { startPos: p, endPos: f } = u.referee.declaration;
4106
+ const l = r.pop();
4107
+ if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
4108
+ const { startPos: p, endPos: f } = l.referee.declaration;
3999
4109
  return [
4000
4110
  {
4001
4111
  range: {
@@ -4021,13 +4131,13 @@ class Wt {
4021
4131
  for (; r.length !== 0; ) {
4022
4132
  const a = r.pop();
4023
4133
  if (a && [
4024
- Ee.ELEMENT_DECLARATION,
4025
- Ee.FUNCTION_APPLICATION,
4026
- Ee.PRIMARY_EXPRESSION
4134
+ Ne.ELEMENT_DECLARATION,
4135
+ Ne.FUNCTION_APPLICATION,
4136
+ Ne.PRIMARY_EXPRESSION
4027
4137
  ].includes(a == null ? void 0 : a.kind)) {
4028
- const { symbol: u } = a;
4029
- if (u != null && u.references.length)
4030
- return u.references.map(({ startPos: p, endPos: f }) => ({
4138
+ const { symbol: l } = a;
4139
+ if (l != null && l.references.length)
4140
+ return l.references.map(({ startPos: p, endPos: f }) => ({
4031
4141
  range: {
4032
4142
  startColumn: p.column + 1,
4033
4143
  startLineNumber: p.line + 1,
@@ -4041,7 +4151,7 @@ class Wt {
4041
4151
  return [];
4042
4152
  }
4043
4153
  }
4044
- const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4154
+ const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4045
4155
  __proto__: null,
4046
4156
  CompletionItemInsertTextRule: k,
4047
4157
  CompletionItemKind: L,
@@ -4049,13 +4159,13 @@ const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4049
4159
  DBMLDefinitionProvider: $t,
4050
4160
  DBMLReferencesProvider: Wt
4051
4161
  }, Symbol.toStringTag, { value: "Module" }));
4052
- var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
4053
- class hs {
4162
+ var D = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(D || {});
4163
+ class fs {
4054
4164
  constructor() {
4055
4165
  this.source = "", this.cache = new Array(
4056
4166
  16
4057
4167
  /* TOTAL_QUERY_COUNT */
4058
- ).fill(null), this.nodeIdGenerator = new Qt(), this.symbolIdGenerator = new Kt(), this.token = {
4168
+ ).fill(null), this.nodeIdGenerator = new qt(), this.symbolIdGenerator = new en(), this.token = {
4059
4169
  invalidStream: this.createQuery(
4060
4170
  6,
4061
4171
  () => this.parse.tokens().filter(vt)
@@ -4070,8 +4180,8 @@ class hs {
4070
4180
  _: this.createQuery(
4071
4181
  0,
4072
4182
  () => {
4073
- const e = new un(this.source).lex().chain((n) => new pn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new zn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4074
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4183
+ const e = new hn(this.source).lex().chain((n) => new dn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4184
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Kn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4075
4185
  }
4076
4186
  ),
4077
4187
  ast: this.createQuery(
@@ -4095,33 +4205,33 @@ class hs {
4095
4205
  stack: this.createQuery(
4096
4206
  10,
4097
4207
  (e) => {
4098
- const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : jt(n, (f) => !f.isInvalid, s);
4208
+ const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : Yt(n, (f) => !f.isInvalid, s);
4099
4209
  if (r === -1)
4100
4210
  return [this.parse.ast()];
4101
4211
  const a = n[r].start;
4102
- let u = this.parse.ast();
4103
- const p = [u];
4212
+ let l = this.parse.ast();
4213
+ const p = [l];
4104
4214
  for (; ; ) {
4105
- const E = ln(u).find((h) => ge(a, h));
4215
+ const E = un(l).find((h) => ge(a, h));
4106
4216
  if (E === void 0 || E instanceof F)
4107
4217
  break;
4108
- p.push(E), u = E;
4218
+ p.push(E), l = E;
4109
4219
  }
4110
- if ((i == null ? void 0 : i.kind) === l.COLON)
4220
+ if ((i == null ? void 0 : i.kind) === u.COLON)
4111
4221
  return p;
4112
4222
  for (; p.length > 0; ) {
4113
4223
  let f = !1;
4114
4224
  const E = it(p);
4115
- if (E instanceof y) {
4225
+ if (E instanceof w) {
4116
4226
  const h = this.parse.source();
4117
4227
  for (let m = E.end; m < e; m += 1)
4118
4228
  h[m] === `
4119
4229
  ` && (p.pop(), f = !0);
4120
4230
  } else
4121
- E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof D ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof J ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof ne ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof $ || E.end < e && (p.pop(), f = !0);
4231
+ E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof R ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof J ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof Y || E.end < e && (p.pop(), f = !0);
4122
4232
  if (f) {
4123
4233
  const h = it(p);
4124
- h instanceof A && h.end <= e && p.pop();
4234
+ h instanceof v && h.end <= e && p.pop();
4125
4235
  }
4126
4236
  if (!f)
4127
4237
  break;
@@ -4144,7 +4254,7 @@ class hs {
4144
4254
  (e) => {
4145
4255
  const n = this.container.stack(e);
4146
4256
  for (let s = n.length - 1; s >= 0; s -= 1)
4147
- if (n[s] instanceof A)
4257
+ if (n[s] instanceof v)
4148
4258
  return n[s];
4149
4259
  return this.parse.ast();
4150
4260
  }
@@ -4158,7 +4268,7 @@ class hs {
4158
4268
  ),
4159
4269
  scopeKind: this.createQuery(15, (e) => {
4160
4270
  var s;
4161
- if (this.container.element(e) instanceof G)
4271
+ if (this.container.element(e) instanceof X)
4162
4272
  return 8;
4163
4273
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4164
4274
  case "table":
@@ -4194,18 +4304,18 @@ class hs {
4194
4304
  if (e.length === 0)
4195
4305
  return [];
4196
4306
  const s = [];
4197
- for (let r = n; r; r = r instanceof A ? r.parent : void 0) {
4307
+ for (let r = n; r; r = r instanceof v ? r.parent : void 0) {
4198
4308
  if (!((i = r.symbol) != null && i.symbolTable))
4199
4309
  continue;
4200
4310
  const { symbolTable: a } = r.symbol;
4201
- let u = [a], p = [];
4311
+ let l = [a], p = [];
4202
4312
  for (const f of e)
4203
- p = u.flatMap(
4204
- (E) => Jt(f).flatMap((h) => {
4313
+ p = l.flatMap(
4314
+ (E) => Zt(f).flatMap((h) => {
4205
4315
  const m = E.get(h), g = ie(h).unwrap_or(void 0);
4206
4316
  return !m || !g ? [] : { ...g, symbol: m };
4207
4317
  })
4208
- ), u = p.flatMap(
4318
+ ), l = p.flatMap(
4209
4319
  (E) => E.symbol.symbolTable ? E.symbol.symbolTable : []
4210
4320
  );
4211
4321
  s.push(...p);
@@ -4232,8 +4342,8 @@ class hs {
4232
4342
  if (r.has(a))
4233
4343
  return r.get(a);
4234
4344
  }
4235
- const u = n(i);
4236
- return i !== void 0 ? r instanceof Map ? r.set(a, u) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, u)) : this.cache[e] = u, u;
4345
+ const l = n(i);
4346
+ return i !== void 0 ? r instanceof Map ? r.set(a, l) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, l)) : this.cache[e] = l, l;
4237
4347
  };
4238
4348
  }
4239
4349
  setSource(e) {
@@ -4251,7 +4361,7 @@ class hs {
4251
4361
  }
4252
4362
  }
4253
4363
  export {
4254
- hs as Compiler,
4255
- ls as serialize,
4256
- us as services
4364
+ fs as Compiler,
4365
+ us as serialize,
4366
+ hs as services
4257
4367
  };