@dbml/parse 3.7.2 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import I, { partition as jt, findLastIndex as Yt, last as it } from "lodash";
1
+ import I, { partition as Yt, findLastIndex as zt, last as rt } from "lodash";
2
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) {
3
+ function Qt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -12,7 +12,7 @@ function zt(t) {
12
12
  return !1;
13
13
  }
14
14
  }
15
- function rt(t) {
15
+ function at(t) {
16
16
  if (!t)
17
17
  return !1;
18
18
  switch (t) {
@@ -33,7 +33,7 @@ function rt(t) {
33
33
  return !1;
34
34
  }
35
35
  }
36
- function at(t) {
36
+ function ot(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
39
  class F {
@@ -44,27 +44,27 @@ class F {
44
44
  return new F(e, n, s, i, r);
45
45
  }
46
46
  }
47
- function bt(t) {
47
+ function It(t) {
48
48
  return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
49
49
  }
50
- function ot(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
50
+ function lt(t, e) {
51
+ return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || It(t);
52
52
  }
53
53
  function Ce(t) {
54
54
  return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
55
55
  }
56
- function It(t) {
57
- return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
58
- }
59
56
  function Lt(t) {
60
- return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
57
+ return t.trailingTrivia.length === 0 ? t.end : Lt(I.last(t.trailingTrivia));
61
58
  }
62
- function Qt(t) {
59
+ function gt(t) {
60
+ return t.leadingTrivia.length === 0 ? t.start : gt(t.leadingTrivia[0]);
61
+ }
62
+ function qt(t) {
63
63
  return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
66
66
  }
67
- class qt {
67
+ class Ht {
68
68
  constructor() {
69
69
  this.id = 0;
70
70
  }
@@ -81,13 +81,13 @@ class x {
81
81
  constructor(e, n, s) {
82
82
  this.id = e, this.kind = n;
83
83
  const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
84
- i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? Lt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? gt(i) : i.fullStart) : (this.startPos = {
85
85
  offset: NaN,
86
86
  column: NaN,
87
87
  line: NaN
88
88
  }, this.fullStart = NaN);
89
89
  const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
- r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? It(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? Lt(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -184,7 +184,7 @@ class R extends x {
184
184
  }, r) {
185
185
  super(r, "<list-expression>", [
186
186
  e,
187
- ...gt(n, s),
187
+ ..._t(n, s),
188
188
  i
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
@@ -198,7 +198,7 @@ class Z extends x {
198
198
  }, r) {
199
199
  super(r, "<tuple-expression>", [
200
200
  e,
201
- ...gt(n, s),
201
+ ..._t(n, s),
202
202
  i
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
@@ -254,7 +254,7 @@ class he extends x {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
256
256
  }
257
- function gt(t, e) {
257
+ function _t(t, e) {
258
258
  if (!t || t.length === 0)
259
259
  return e || [];
260
260
  if (!e || e.length === 0)
@@ -312,7 +312,7 @@ class S {
312
312
  return !0;
313
313
  }
314
314
  }
315
- class y {
315
+ class k {
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 y {
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 y();
326
+ return new k();
327
327
  }
328
328
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
329
329
  map(e) {
330
- return new y();
330
+ return new k();
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 Ht(t) {
359
+ function Jt(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 y();
387
+ }) : new k();
388
388
  }
389
- function Jt(t) {
389
+ function Zt(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 Zt(t) {
396
+ function Kt(t) {
397
397
  return [
398
398
  je,
399
399
  Oe,
@@ -411,7 +411,7 @@ function De(t) {
411
411
  const [e] = t;
412
412
  return e >= "0" && e <= "9";
413
413
  }
414
- function Kt(t) {
414
+ function en(t) {
415
415
  const [e] = t;
416
416
  return De(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
417
417
  }
@@ -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 en {
430
+ class tn {
431
431
  constructor() {
432
432
  this.id = 0;
433
433
  }
@@ -438,37 +438,37 @@ class en {
438
438
  return this.id++;
439
439
  }
440
440
  }
441
- class _t {
441
+ class At {
442
442
  constructor({ symbolTable: e }, n) {
443
443
  this.references = [], this.id = n, this.symbolTable = e;
444
444
  }
445
445
  }
446
- class tn {
446
+ class nn {
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 nn {
451
+ class sn {
452
452
  constructor({ declaration: e }, n) {
453
453
  this.references = [], this.id = n, this.declaration = e;
454
454
  }
455
455
  }
456
- class At {
456
+ class vt {
457
457
  constructor({ symbolTable: e, declaration: n }, s) {
458
458
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
459
459
  }
460
460
  }
461
- class sn {
461
+ class rn {
462
462
  constructor({ declaration: e }, n) {
463
463
  this.references = [], this.id = n, this.declaration = e;
464
464
  }
465
465
  }
466
- class rn {
466
+ class an {
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 an {
471
+ class on {
472
472
  constructor({ declaration: e }, n) {
473
473
  this.references = [], this.id = n, this.declaration = e;
474
474
  }
@@ -497,12 +497,12 @@ class V {
497
497
  return new V(e(this.value), this.errors);
498
498
  }
499
499
  }
500
- function on(t, e, n) {
500
+ function ln(t, e, n) {
501
501
  if (!t || !me(t) || e.length === 0)
502
- return new y();
502
+ return new k();
503
503
  const s = [...e], i = Ge(t).unwrap(), r = s.pop();
504
504
  if (!(r instanceof J))
505
- return new y();
505
+ return new k();
506
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
508
  n.create(v, {
@@ -526,18 +526,18 @@ function on(t, e, n) {
526
526
  attributeList: a,
527
527
  body: r
528
528
  })
529
- ) : new y();
529
+ ) : new k();
530
530
  }
531
- function lt(t) {
531
+ function ut(t) {
532
532
  return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function N(t) {
535
- t && (t instanceof F ? cn(t) : ln(t));
535
+ t && (t instanceof F ? cn(t) : un(t));
536
536
  }
537
537
  function cn(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
539
539
  }
540
- function ln(t) {
540
+ function un(t) {
541
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
543
  else if (t instanceof Y)
@@ -571,13 +571,13 @@ function ln(t) {
571
571
  else
572
572
  throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
573
573
  }
574
- function vt(t) {
574
+ function wt(t) {
575
575
  return !!(t != null && t.isInvalid);
576
576
  }
577
577
  function P(...t) {
578
578
  return t.filter((e) => e !== void 0);
579
579
  }
580
- function un(t) {
580
+ function hn(t) {
581
581
  if (t instanceof X)
582
582
  return P(...t.body, t.eof);
583
583
  if (t instanceof v)
@@ -634,7 +634,7 @@ function un(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 y();
637
+ return M(t) ? new S(t.expression.variable) : new k();
638
638
  }
639
639
  function $(t) {
640
640
  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 y();
656
+ return new k();
657
657
  const e = t.identifiers.map((n) => n.value).join(" ");
658
- return e === "" ? new y() : new S(e);
658
+ return e === "" ? new k() : new S(e);
659
659
  }
660
- class hn {
660
+ class fn {
661
661
  // list of errors during lexing
662
662
  constructor(e) {
663
663
  this.start = {
@@ -767,7 +767,7 @@ class hn {
767
767
  this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
768
768
  break;
769
769
  default:
770
- if (rt(e)) {
770
+ if (at(e)) {
771
771
  this.operator();
772
772
  break;
773
773
  }
@@ -795,13 +795,13 @@ class hn {
795
795
  let e = !0, n = [], s;
796
796
  const i = [];
797
797
  for (const r of this.tokens)
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);
798
+ Qt(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() {
802
802
  let e;
803
803
  const n = [], s = [];
804
- for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
804
+ for (e = 0; e < this.tokens.length && wt(this.tokens[e]); e += 1)
805
805
  s.push(this.tokens[e]);
806
806
  let i = this.tokens[e];
807
807
  for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
@@ -895,7 +895,7 @@ class hn {
895
895
  this.addToken(u.IDENTIFIER);
896
896
  }
897
897
  operator() {
898
- for (; rt(this.peek()); )
898
+ for (; at(this.peek()); )
899
899
  this.advance();
900
900
  this.addToken(u.OP);
901
901
  }
@@ -982,7 +982,7 @@ class hn {
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 fn {
985
+ class pn {
986
986
  constructor() {
987
987
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
988
988
  }
@@ -1048,7 +1048,7 @@ class fn {
1048
1048
  }
1049
1049
  }
1050
1050
  }
1051
- class pn {
1051
+ class dn {
1052
1052
  constructor(e) {
1053
1053
  this.generator = e;
1054
1054
  }
@@ -1061,15 +1061,15 @@ class d {
1061
1061
  this.token = e, this.partialNode = n, this.handlerContext = s;
1062
1062
  }
1063
1063
  }
1064
- class dn {
1064
+ class En {
1065
1065
  constructor(e, n) {
1066
- this.current = 0, this.errors = [], this.contextStack = new fn(), this.synchronizeProgram = () => {
1066
+ this.current = 0, this.errors = [], this.contextStack = new pn(), this.synchronizeProgram = () => {
1067
1067
  const s = this.peek();
1068
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(u.COLON, u.LBRACE, u.LBRACKET))
1072
+ if (ut(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1073
1073
  break;
1074
1074
  N(s), this.advance();
1075
1075
  }
@@ -1115,7 +1115,7 @@ class dn {
1115
1115
  if (!this.check(u.RBRACE))
1116
1116
  for (N(this.advance()); !this.isAtEnd(); ) {
1117
1117
  const s = this.peek();
1118
- if (this.check(u.RBRACE) || ot(this.previous(), s))
1118
+ if (this.check(u.RBRACE) || lt(this.previous(), s))
1119
1119
  break;
1120
1120
  N(s), this.advance();
1121
1121
  }
@@ -1233,7 +1233,7 @@ class dn {
1233
1233
  break;
1234
1234
  N(s), this.advance();
1235
1235
  }
1236
- }, this.tokens = e, this.nodeFactory = new pn(n);
1236
+ }, this.tokens = e, this.nodeFactory = new dn(n);
1237
1237
  }
1238
1238
  isAtEnd() {
1239
1239
  return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
@@ -1324,7 +1324,7 @@ class dn {
1324
1324
  throw new d(s.token, n(), s.handlerContext);
1325
1325
  this.synchronizeElementDeclarationName();
1326
1326
  }
1327
- if (lt(this.peek()))
1327
+ if (ut(this.peek()))
1328
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
@@ -1388,7 +1388,7 @@ class dn {
1388
1388
  }
1389
1389
  /* Parsing any ExpressionNode, including non-NormalExpression */
1390
1390
  expression() {
1391
- const e = { args: [] }, n = () => on(e.callee, e.args, this.nodeFactory).unwrap_or(
1391
+ const e = { args: [] }, n = () => ln(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
1392
  this.nodeFactory.create(w, e)
1393
1393
  );
1394
1394
  try {
@@ -1410,7 +1410,7 @@ class dn {
1410
1410
  return n();
1411
1411
  }
1412
1412
  shouldStopExpression() {
1413
- if (this.isAtEnd() || bt(this.previous()))
1413
+ if (this.isAtEnd() || It(this.previous()))
1414
1414
  return !0;
1415
1415
  const e = this.peek().kind;
1416
1416
  return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
@@ -1424,12 +1424,12 @@ class dn {
1424
1424
  for (; !this.isAtEnd(); ) {
1425
1425
  const s = this.peek();
1426
1426
  if (s.kind === u.LPAREN) {
1427
- const { left: i } = ut(s);
1427
+ const { left: i } = ht(s);
1428
1428
  if (i < e || // When '(' is encountered,
1429
1429
  // consider it part of another expression if
1430
1430
  // it's at the start of a new line
1431
1431
  // and we're currently not having unmatched '(' or '['
1432
- ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1432
+ lt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1433
1433
  break;
1434
1434
  try {
1435
1435
  n = this.nodeFactory.create(H, {
@@ -1456,8 +1456,8 @@ class dn {
1456
1456
  indexer: i.partialNode
1457
1457
  }), new d(i.token, n, i.handlerContext)) : i;
1458
1458
  }
1459
- } else if (at(s)) {
1460
- const i = s, r = ut(i);
1459
+ } else if (ot(s)) {
1460
+ const i = s, r = ht(i);
1461
1461
  if (r.left !== null) {
1462
1462
  if (r.left <= e)
1463
1463
  break;
@@ -1466,7 +1466,7 @@ class dn {
1466
1466
  op: i
1467
1467
  });
1468
1468
  } else {
1469
- const a = Nn(i);
1469
+ const a = mn(i);
1470
1470
  if (a.left === null || a.left <= e)
1471
1471
  break;
1472
1472
  this.advance();
@@ -1491,10 +1491,10 @@ class dn {
1491
1491
  }
1492
1492
  leftExpression_bp() {
1493
1493
  let e;
1494
- if (at(this.peek())) {
1494
+ if (ot(this.peek())) {
1495
1495
  const n = {};
1496
1496
  n.op = this.peek();
1497
- const s = Tn(n.op);
1497
+ const s = bn(n.op);
1498
1498
  if (s.right === null)
1499
1499
  throw this.logError(
1500
1500
  n.op,
@@ -1638,7 +1638,7 @@ class dn {
1638
1638
  this.errors.push(new c(n, s, e));
1639
1639
  }
1640
1640
  }
1641
- const En = {
1641
+ const Nn = {
1642
1642
  "+": { left: 9, right: 10 },
1643
1643
  "*": { left: 11, right: 12 },
1644
1644
  "-": { left: 9, right: 10 },
@@ -1654,10 +1654,10 @@ const En = {
1654
1654
  "!=": { left: 4, right: 5 },
1655
1655
  ".": { left: 16, right: 17 }
1656
1656
  };
1657
- function Nn(t) {
1658
- return En[t.value] || { left: null, right: null };
1657
+ function mn(t) {
1658
+ return Nn[t.value] || { left: null, right: null };
1659
1659
  }
1660
- const mn = {
1660
+ const Tn = {
1661
1661
  "+": { left: null, right: 15 },
1662
1662
  "-": { left: null, right: 15 },
1663
1663
  "<": { left: null, right: 15 },
@@ -1665,14 +1665,14 @@ const mn = {
1665
1665
  "<>": { left: null, right: 15 },
1666
1666
  "!": { left: null, right: 15 }
1667
1667
  };
1668
- function Tn(t) {
1669
- return mn[t.value] || { left: null, right: null };
1668
+ function bn(t) {
1669
+ return Tn[t.value] || { left: null, right: null };
1670
1670
  }
1671
- const bn = {
1671
+ const In = {
1672
1672
  "(": { left: 14, right: null }
1673
1673
  };
1674
- function ut(t) {
1675
- return bn[t.value] || { left: null, right: null };
1674
+ function ht(t) {
1675
+ return In[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 y();
1691
+ return new k();
1692
1692
  }
1693
1693
  }
1694
1694
  function pe(t) {
1695
1695
  if (!Je(t))
1696
1696
  return new S([t]);
1697
1697
  const e = pe(t.leftExpression).unwrap_or(void 0);
1698
- return e ? (e.push(t.rightExpression), new S(e)) : new y();
1698
+ return e ? (e.push(t.rightExpression), new S(e)) : new k();
1699
1699
  }
1700
1700
  function W(t) {
1701
1701
  if (t === void 0)
1702
- return new y();
1702
+ return new k();
1703
1703
  const e = pe(t).unwrap_or(void 0);
1704
1704
  if (!e)
1705
- return new y();
1705
+ return new k();
1706
1706
  const n = [];
1707
1707
  for (const s of e) {
1708
1708
  const i = j(s).unwrap_or(void 0);
1709
1709
  if (!i)
1710
- return new y();
1710
+ return new k();
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 y();
1717
+ return new k();
1718
1718
  const e = pe(t).unwrap_or(void 0);
1719
1719
  if (!e || e.length === 0)
1720
- return new y();
1720
+ return new k();
1721
1721
  const n = [];
1722
1722
  let s;
1723
1723
  if (!M(I.last(e))) {
1724
1724
  const i = e.pop();
1725
- if (xt(i))
1725
+ if (Ot(i))
1726
1726
  s = i.elementList.map(
1727
1727
  (r) => C(r).unwrap()
1728
1728
  );
1729
1729
  else
1730
- return new y();
1730
+ return new k();
1731
1731
  }
1732
1732
  for (const i of e) {
1733
1733
  const r = j(i).unwrap_or(void 0);
1734
1734
  if (!r)
1735
- return new y();
1735
+ return new k();
1736
1736
  n.push(r);
1737
1737
  }
1738
1738
  return new S({
@@ -1741,45 +1741,45 @@ function _e(t) {
1741
1741
  });
1742
1742
  }
1743
1743
  function j(t) {
1744
- return M(t) ? new S(t.expression.variable.value) : new y();
1744
+ return M(t) ? new S(t.expression.variable.value) : new k();
1745
1745
  }
1746
1746
  function Xe(t) {
1747
- if (ht(t))
1747
+ if (ft(t))
1748
1748
  return t instanceof ne ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1749
- if (t instanceof Z && t.elementList.every(ht)) {
1749
+ if (t instanceof Z && t.elementList.every(ft)) {
1750
1750
  const e = t.elementList.filter(
1751
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 y();
1755
+ return new k();
1756
1756
  }
1757
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 y() : new S(e);
1760
+ return e === void 0 ? new k() : new S(e);
1761
1761
  }
1762
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();
1763
+ return $(t) ? t.expression instanceof K ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new k();
1764
1764
  }
1765
- function In(t) {
1765
+ function Ln(t) {
1766
1766
  var e;
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;
1767
+ return !(t instanceof q) || !xt((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 Ln(t) {
1769
+ function gn(t) {
1770
1770
  const e = _e(t.leftExpression), n = _e(t.rightExpression);
1771
1771
  if (!e.isOk() || !n.isOk())
1772
1772
  return !1;
1773
1773
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1774
1774
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1775
1775
  }
1776
- function ht(t) {
1776
+ function ft(t) {
1777
1777
  return t instanceof U && t.expression instanceof K || t instanceof ne;
1778
1778
  }
1779
- function gn(t, e) {
1779
+ function _n(t, e) {
1780
1780
  var i, r, a, l;
1781
1781
  let n = e;
1782
- const s = Jt(t);
1782
+ const s = Zt(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);
@@ -1790,7 +1790,7 @@ function gn(t, e) {
1790
1790
  n = n.parent;
1791
1791
  }
1792
1792
  }
1793
- class _n {
1793
+ class An {
1794
1794
  constructor(e, n, s) {
1795
1795
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1796
1796
  }
@@ -1835,7 +1835,7 @@ class we {
1835
1835
  return this.table.entries();
1836
1836
  }
1837
1837
  }
1838
- class An {
1838
+ class vn {
1839
1839
  constructor(e, n, s) {
1840
1840
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1841
1841
  }
@@ -1846,14 +1846,14 @@ class An {
1846
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
- 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)];
1849
+ return e ? kt(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)];
1850
1850
  }
1851
1851
  validateAlias(e) {
1852
1852
  return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1853
1853
  }
1854
1854
  registerElement() {
1855
1855
  const e = [];
1856
- this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
1856
+ this.declarationNode.symbol = this.symbolFactory.create(nn, { declaration: this.declarationNode, symbolTable: new we() });
1857
1857
  const { name: n } = this.declarationNode, s = W(n);
1858
1858
  if (s.isOk()) {
1859
1859
  const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
@@ -1906,7 +1906,7 @@ class An {
1906
1906
  }
1907
1907
  registerField(e) {
1908
1908
  if (e.callee && M(e.callee)) {
1909
- const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(nn, { declaration: e });
1909
+ const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(sn, { 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 An {
1921
1921
  return [];
1922
1922
  }
1923
1923
  }
1924
- class vn {
1924
+ class wn {
1925
1925
  constructor(e, n, s) {
1926
1926
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1927
1927
  }
@@ -1997,7 +1997,7 @@ class vn {
1997
1997
  });
1998
1998
  }
1999
1999
  }
2000
- class wn {
2000
+ class yn {
2001
2001
  constructor(e, n, s) {
2002
2002
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2003
2003
  }
@@ -2029,7 +2029,7 @@ class wn {
2029
2029
  const n = W(e);
2030
2030
  if (!n.isOk())
2031
2031
  return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2032
- const i = n.unwrap().join("."), r = Ht(i);
2032
+ const i = n.unwrap().join("."), r = Jt(i);
2033
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), []);
2034
2034
  }
2035
2035
  validateAlias(e) {
@@ -2059,7 +2059,7 @@ class wn {
2059
2059
  });
2060
2060
  }
2061
2061
  }
2062
- class yn {
2062
+ class kn {
2063
2063
  constructor(e, n, s) {
2064
2064
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2065
2065
  }
@@ -2098,7 +2098,7 @@ class yn {
2098
2098
  });
2099
2099
  }
2100
2100
  }
2101
- class kn {
2101
+ class xn {
2102
2102
  constructor(e, n, s) {
2103
2103
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2104
2104
  }
@@ -2130,7 +2130,7 @@ class kn {
2130
2130
  return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2131
2131
  const n = [];
2132
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) => {
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));
2133
+ s.callee && !Ln(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !gn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2134
2134
  const i = [...s.args];
2135
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)));
2136
2136
  }), n;
@@ -2143,7 +2143,7 @@ class kn {
2143
2143
  case "delete":
2144
2144
  case "update":
2145
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));
2146
+ Sn(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));
2147
2147
  });
2148
2148
  break;
2149
2149
  default:
@@ -2161,7 +2161,7 @@ class kn {
2161
2161
  });
2162
2162
  }
2163
2163
  }
2164
- function xn(t) {
2164
+ function Sn(t) {
2165
2165
  if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof Y))
2166
2166
  return !1;
2167
2167
  let e;
@@ -2178,7 +2178,7 @@ function xn(t) {
2178
2178
  }
2179
2179
  return !1;
2180
2180
  }
2181
- class Sn {
2181
+ class On {
2182
2182
  constructor(e, n, s) {
2183
2183
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2184
2184
  }
@@ -2189,10 +2189,10 @@ class Sn {
2189
2189
  return this.declarationNode.parent instanceof v ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2190
2190
  }
2191
2191
  validateName(e) {
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)];
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)] : kt(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)];
2193
2193
  }
2194
2194
  validateAlias(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)] : [];
2195
+ return e ? Un(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2196
2196
  }
2197
2197
  validateSettingList(e) {
2198
2198
  const n = B(e), s = n.getErrors(), i = n.getValue();
@@ -2201,7 +2201,7 @@ class Sn {
2201
2201
  switch (r) {
2202
2202
  case "headercolor":
2203
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));
2204
+ St(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2205
2205
  });
2206
2206
  break;
2207
2207
  case "note":
@@ -2217,13 +2217,13 @@ class Sn {
2217
2217
  }
2218
2218
  registerElement() {
2219
2219
  const e = [];
2220
- this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
2220
+ this.declarationNode.symbol = this.symbolFactory.create(vt, { declaration: this.declarationNode, symbolTable: new we() });
2221
2221
  const { name: n, alias: s } = this.declarationNode, i = W(n);
2222
2222
  if (i.isOk()) {
2223
2223
  const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2224
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);
2225
2225
  }
2226
- if (s && ye(s) && !Dn(s.expression.variable.value, i.unwrap_or([]))) {
2226
+ if (s && ye(s) && !Rn(s.expression.variable.value, i.unwrap_or([]))) {
2227
2227
  const r = C(s).unwrap(), a = Oe(r);
2228
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);
2229
2229
  }
@@ -2242,14 +2242,14 @@ class Sn {
2242
2242
  if (!n.callee)
2243
2243
  return [];
2244
2244
  const s = [];
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]));
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] && !Dn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2246
2246
  const i = n.args.slice(1);
2247
2247
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2248
2248
  });
2249
2249
  }
2250
2250
  registerField(e) {
2251
2251
  if (e.callee && M(e.callee)) {
2252
- const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(sn, { declaration: e });
2252
+ const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(rn, { declaration: e });
2253
2253
  e.symbol = i;
2254
2254
  const r = this.declarationNode.symbol.symbolTable;
2255
2255
  if (r.has(s)) {
@@ -2351,7 +2351,7 @@ class Sn {
2351
2351
  return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2352
2352
  }
2353
2353
  }
2354
- function On(t) {
2354
+ function Dn(t) {
2355
2355
  if (!(t instanceof H || Je(t) || t instanceof U || t instanceof he))
2356
2356
  return !1;
2357
2357
  if (t instanceof H) {
@@ -2367,10 +2367,10 @@ function On(t) {
2367
2367
  const e = W(t).unwrap_or(void 0);
2368
2368
  return e !== void 0 && e.length > 0;
2369
2369
  }
2370
- function Dn(t, e) {
2370
+ function Rn(t, e) {
2371
2371
  return e.length === 1 && t === e[0];
2372
2372
  }
2373
- class Rn {
2373
+ class Pn {
2374
2374
  constructor(e, n, s) {
2375
2375
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2376
2376
  }
@@ -2411,7 +2411,7 @@ class Rn {
2411
2411
  }
2412
2412
  registerElement() {
2413
2413
  const { name: e } = this.declarationNode;
2414
- this.declarationNode.symbol = this.symbolFactory.create(rn, { declaration: this.declarationNode, symbolTable: new we() });
2414
+ this.declarationNode.symbol = this.symbolFactory.create(an, { declaration: this.declarationNode, symbolTable: new we() });
2415
2415
  const n = W(e);
2416
2416
  if (n.isOk()) {
2417
2417
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
@@ -2425,12 +2425,18 @@ class Rn {
2425
2425
  const n = B(e), s = n.getErrors(), i = n.getValue();
2426
2426
  return I.forIn(i, (r, a) => {
2427
2427
  switch (a) {
2428
- case "headercolor":
2429
- s.push(...r.map((l) => new c(
2430
- o.INVALID_TABLE_SETTING,
2431
- "'headercolor' is not supported",
2428
+ case "color":
2429
+ r.length > 1 && s.push(...r.map((l) => new c(
2430
+ o.DUPLICATE_TABLE_SETTING,
2431
+ "'color' can only appear once",
2432
2432
  l
2433
- )));
2433
+ ))), r.forEach((l) => {
2434
+ St(l.value) || s.push(new c(
2435
+ o.INVALID_TABLE_SETTING,
2436
+ "'color' must be a color literal",
2437
+ l.value || l.name
2438
+ ));
2439
+ });
2434
2440
  break;
2435
2441
  case "note":
2436
2442
  r.length > 1 && s.push(...r.map((l) => new c(
@@ -2490,7 +2496,7 @@ class Rn {
2490
2496
  }
2491
2497
  registerField(e) {
2492
2498
  if (e.callee && M(e.callee)) {
2493
- const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(an, { declaration: e });
2499
+ const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(on, { declaration: e });
2494
2500
  e.symbol = i;
2495
2501
  const r = this.declarationNode.symbol.symbolTable;
2496
2502
  if (r.has(s)) {
@@ -2505,31 +2511,31 @@ class Rn {
2505
2511
  return [];
2506
2512
  }
2507
2513
  }
2508
- const wt = ["-", "+"];
2514
+ const yt = ["-", "+"];
2509
2515
  function ae(t) {
2510
2516
  switch (t.type.value.toLowerCase()) {
2511
2517
  case b.Enum:
2512
- return An;
2518
+ return vn;
2513
2519
  case b.Table:
2514
- return Sn;
2520
+ return On;
2515
2521
  case b.TableGroup:
2516
- return Rn;
2522
+ return Pn;
2517
2523
  case b.Project:
2518
- return yn;
2519
- case b.Ref:
2520
2524
  return kn;
2525
+ case b.Ref:
2526
+ return xn;
2521
2527
  case b.Note:
2522
- return wn;
2528
+ return yn;
2523
2529
  case b.Indexes:
2524
- return vn;
2530
+ return wn;
2525
2531
  default:
2526
- return _n;
2532
+ return An;
2527
2533
  }
2528
2534
  }
2529
- function yt(t) {
2535
+ function kt(t) {
2530
2536
  return !!W(t).unwrap_or(!1);
2531
2537
  }
2532
- function Pn(t) {
2538
+ function Un(t) {
2533
2539
  return ye(t);
2534
2540
  }
2535
2541
  function ye(t) {
@@ -2547,17 +2553,17 @@ function Ze(t, e, n) {
2547
2553
  throw new Error("Expect a symbol table in a schema symbol");
2548
2554
  } else {
2549
2555
  a = new we();
2550
- const p = n.create(_t, { symbolTable: a });
2556
+ const p = n.create(At, { symbolTable: a });
2551
2557
  s.set(l, p);
2552
2558
  }
2553
2559
  s = a;
2554
2560
  }
2555
2561
  return s;
2556
2562
  }
2557
- function kt(t) {
2563
+ function xt(t) {
2558
2564
  return t === "-" || t === "<>" || t === ">" || t === "<";
2559
2565
  }
2560
- function Un(t) {
2566
+ function St(t) {
2561
2567
  var n;
2562
2568
  if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2563
2569
  return !1;
@@ -2565,7 +2571,7 @@ function Un(t) {
2565
2571
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2566
2572
  return !1;
2567
2573
  for (let s = 1; s < e.length; s += 1)
2568
- if (!Kt(e[s]))
2574
+ if (!en(e[s]))
2569
2575
  return !1;
2570
2576
  return !0;
2571
2577
  }
@@ -2574,7 +2580,7 @@ function ue(t) {
2574
2580
  }
2575
2581
  function Mn(t) {
2576
2582
  var e;
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);
2583
+ return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof ne);
2578
2584
  }
2579
2585
  function fe(t) {
2580
2586
  var e;
@@ -2582,12 +2588,12 @@ function fe(t) {
2582
2588
  }
2583
2589
  function Fn(t) {
2584
2590
  var n;
2585
- if (!(t instanceof Q) || !kt((n = t.op) == null ? void 0 : n.value))
2591
+ if (!(t instanceof Q) || !xt((n = t.op) == null ? void 0 : n.value))
2586
2592
  return !1;
2587
2593
  const e = W(t.expression).unwrap_or(void 0);
2588
2594
  return e !== void 0 && e.length > 0;
2589
2595
  }
2590
- function xt(t) {
2596
+ function Ot(t) {
2591
2597
  return t instanceof Z && t.elementList.every(M);
2592
2598
  }
2593
2599
  function B(t) {
@@ -2607,9 +2613,9 @@ function B(t) {
2607
2613
  }
2608
2614
  return new V(e, n);
2609
2615
  }
2610
- class ft {
2616
+ class pt {
2611
2617
  constructor(e, n) {
2612
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2618
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(At, {
2613
2619
  symbolTable: new we()
2614
2620
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2615
2621
  }
@@ -2658,7 +2664,7 @@ class oe {
2658
2664
  if (s instanceof v) {
2659
2665
  if (!s.type)
2660
2666
  continue;
2661
- const i = St(s);
2667
+ const i = Dt(s);
2662
2668
  new i(s, this.errors).bind();
2663
2669
  } else
2664
2670
  this.bindSubfield(s);
@@ -2689,7 +2695,7 @@ class oe {
2689
2695
  bindFragments(e, n) {
2690
2696
  if (e.length === 0)
2691
2697
  return;
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(
2698
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2693
2699
  0,
2694
2700
  r === -1 ? void 0 : r
2695
2701
  );
@@ -2731,7 +2737,7 @@ class oe {
2731
2737
  resolveIndexStack(e, n) {
2732
2738
  if (e.length === 0)
2733
2739
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2734
- const [s, ...i] = e, r = gn(s.index, this.declarationNode);
2740
+ const [s, ...i] = e, r = _n(s.index, this.declarationNode);
2735
2741
  if (r === void 0) {
2736
2742
  const { kind: f, name: E } = ie(s.index).unwrap();
2737
2743
  this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
@@ -2895,7 +2901,7 @@ class jn extends oe {
2895
2901
  }, this.settingList = {};
2896
2902
  }
2897
2903
  }
2898
- function St(t) {
2904
+ function Dt(t) {
2899
2905
  switch (t.type.value.toLowerCase()) {
2900
2906
  case b.Enum:
2901
2907
  return Vn;
@@ -2922,7 +2928,7 @@ class Yn {
2922
2928
  resolve() {
2923
2929
  for (const e of this.ast.body)
2924
2930
  if (e.type) {
2925
- const n = St(e);
2931
+ const n = Dt(e);
2926
2932
  new n(e, this.errors).bind();
2927
2933
  }
2928
2934
  return new V(this.ast, this.errors);
@@ -2942,14 +2948,14 @@ class Qn {
2942
2948
  }
2943
2949
  // Analyzing: Invoking both the validator and binder
2944
2950
  analyze() {
2945
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
2951
+ return new pt(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
2946
2952
  }
2947
2953
  // For invoking the validator only
2948
2954
  validate() {
2949
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
2955
+ return new pt(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
2950
2956
  }
2951
2957
  }
2952
- function pt(t, e) {
2958
+ function dt(t, e) {
2953
2959
  const { variables: n, tupleElements: s } = _e(t).unwrap();
2954
2960
  return s ? n.length === 0 ? {
2955
2961
  schemaName: e.schemaName,
@@ -2969,7 +2975,7 @@ function pt(t, e) {
2969
2975
  schemaName: n.pop() || null
2970
2976
  };
2971
2977
  }
2972
- function Ot(t) {
2978
+ function Rt(t) {
2973
2979
  switch (t) {
2974
2980
  case "<":
2975
2981
  return ["1", "*"];
@@ -3004,10 +3010,10 @@ function Ie(t) {
3004
3010
  schemaName: e
3005
3011
  };
3006
3012
  }
3007
- function Dt(t) {
3013
+ function Ke(t) {
3008
3014
  return t.expression.literal.value;
3009
3015
  }
3010
- function Rt(t, e) {
3016
+ function Pt(t, e) {
3011
3017
  if (Array.isArray(t)) {
3012
3018
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
3013
3019
  return i < r ? `${i}-${r}` : `${r}-${i}`;
@@ -3015,7 +3021,7 @@ function Rt(t, e) {
3015
3021
  const n = t.id.toString(), s = e.id.toString();
3016
3022
  return n < s ? `${n}-${s}` : `${s}-${n}`;
3017
3023
  }
3018
- function Pt(t, e) {
3024
+ function Ut(t, e) {
3019
3025
  if (Array.isArray(t)) {
3020
3026
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
3021
3027
  return I.zip(i, r).every(([a, l]) => a === l);
@@ -3029,7 +3035,7 @@ function re(t) {
3029
3035
  return n.map((r) => r.slice(i)).join(`
3030
3036
  `);
3031
3037
  }
3032
- class Ut {
3038
+ class Mt {
3033
3039
  constructor(e, n) {
3034
3040
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
3035
3041
  }
@@ -3072,7 +3078,7 @@ class Ut {
3072
3078
  interpretSettingList(e) {
3073
3079
  var i, r, a;
3074
3080
  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;
3081
+ this.table.headerColor = (i = n.headercolor) != null && i.length ? Ke((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3076
3082
  const [s] = n.note || [];
3077
3083
  return this.table.note = s && {
3078
3084
  value: G(s == null ? void 0 : s.value).map(re).unwrap(),
@@ -3116,53 +3122,53 @@ class Ut {
3116
3122
  value: G(ee.value).map(re).unwrap(),
3117
3123
  token: A(ee)
3118
3124
  };
3119
- const ce = _.ref || [];
3120
- s.inline_refs = ce.flatMap((z) => {
3121
- const [tt] = $e(z.value.expression);
3122
- if (Pt(tt, e.symbol))
3125
+ const le = _.ref || [];
3126
+ s.inline_refs = le.flatMap((z) => {
3127
+ const [nt] = $e(z.value.expression);
3128
+ if (Ut(nt, e.symbol))
3123
3129
  return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3124
3130
  const ke = z.value.op, te = W(z.value.expression).unwrap();
3125
3131
  let de;
3126
3132
  if (te.length === 1) {
3127
- const [le] = te;
3133
+ const [ce] = te;
3128
3134
  de = {
3129
3135
  schemaName: this.table.schemaName,
3130
3136
  tableName: this.table.name,
3131
- fieldNames: [le],
3137
+ fieldNames: [ce],
3132
3138
  relation: ke.value,
3133
3139
  token: A(z)
3134
3140
  };
3135
3141
  } else if (te.length === 2) {
3136
- const [le, Le] = te;
3142
+ const [ce, Le] = te;
3137
3143
  de = {
3138
3144
  schemaName: null,
3139
- tableName: le,
3145
+ tableName: ce,
3140
3146
  fieldNames: [Le],
3141
3147
  relation: ke.value,
3142
3148
  token: A(z)
3143
3149
  };
3144
3150
  } else if (te.length === 3) {
3145
- const [le, Le, st] = te;
3151
+ const [ce, Le, it] = te;
3146
3152
  de = {
3147
- schemaName: le,
3153
+ schemaName: ce,
3148
3154
  tableName: Le,
3149
- fieldNames: [st],
3155
+ fieldNames: [it],
3150
3156
  relation: ke.value,
3151
3157
  token: A(z)
3152
3158
  };
3153
3159
  } else {
3154
3160
  n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3155
- const le = te.pop(), Le = te.pop();
3161
+ const ce = te.pop(), Le = te.pop();
3156
3162
  de = {
3157
3163
  schemaName: te.join("."),
3158
3164
  tableName: Le,
3159
- fieldNames: [le],
3165
+ fieldNames: [ce],
3160
3166
  relation: ke.value,
3161
3167
  token: A(z)
3162
3168
  };
3163
3169
  }
3164
- const nt = this.registerInlineRefToEnv(e, tt, de, z);
3165
- return n.push(...nt), nt.length === 0 ? de : [];
3170
+ const st = this.registerInlineRefToEnv(e, nt, de, z);
3171
+ return n.push(...st), st.length === 0 ? de : [];
3166
3172
  });
3167
3173
  }
3168
3174
  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;
@@ -3171,7 +3177,7 @@ class Ut {
3171
3177
  return this.table.indexes.push(...e.body.body.map((n) => {
3172
3178
  var a, l, p, f, E, h, m;
3173
3179
  const s = { columns: [] }, i = n;
3174
- s.token = A(e);
3180
+ s.token = A(i);
3175
3181
  const r = [i.callee, ...i.args];
3176
3182
  if (I.last(r) instanceof R) {
3177
3183
  const g = B(r.pop()).getValue();
@@ -3192,28 +3198,28 @@ class Ut {
3192
3198
  }).forEach((g) => {
3193
3199
  const { functional: _, nonFunctional: ee } = Xe(g).unwrap();
3194
3200
  s.columns.push(
3195
- ..._.map((ce) => ({
3196
- value: ce.value.value,
3201
+ ..._.map((le) => ({
3202
+ value: le.value.value,
3197
3203
  type: "expression",
3198
- token: A(ce)
3204
+ token: A(le)
3199
3205
  })),
3200
- ...ee.map((ce) => ({
3201
- value: C(ce).unwrap(),
3206
+ ...ee.map((le) => ({
3207
+ value: C(le).unwrap(),
3202
3208
  type: "column",
3203
- token: A(ce)
3209
+ token: A(le)
3204
3210
  }))
3205
3211
  );
3206
3212
  }), s;
3207
3213
  })), [];
3208
3214
  }
3209
3215
  registerInlineRefToEnv(e, n, s, i) {
3210
- const r = Rt(e.symbol, n);
3216
+ const r = Pt(e.symbol, n);
3211
3217
  if (this.env.refIds[r])
3212
3218
  return [
3213
3219
  new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
3214
3220
  new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3215
3221
  ];
3216
- const a = Ot(s.relation);
3222
+ const a = Rt(s.relation);
3217
3223
  return this.env.refIds[r] = i, this.env.ref.set(i, {
3218
3224
  name: null,
3219
3225
  schemaName: null,
@@ -3272,7 +3278,7 @@ function Hn(t) {
3272
3278
  value: t.expression.variable.value.toLowerCase(),
3273
3279
  type: "boolean"
3274
3280
  };
3275
- if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3281
+ if (t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3276
3282
  const i = Number.parseFloat(t.expression.expression.literal.value);
3277
3283
  return {
3278
3284
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -3305,7 +3311,7 @@ class Jn {
3305
3311
  interpretSettingList(e) {
3306
3312
  var s, i, r;
3307
3313
  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, [];
3314
+ return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ke((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3309
3315
  }
3310
3316
  interpretBody(e) {
3311
3317
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
@@ -3318,7 +3324,7 @@ class Jn {
3318
3324
  return this.note.content = re(n), [];
3319
3325
  }
3320
3326
  }
3321
- class Mt {
3327
+ class Ft {
3322
3328
  constructor(e, n) {
3323
3329
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof v ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3324
3330
  }
@@ -3335,9 +3341,9 @@ class Mt {
3335
3341
  interpretField(e) {
3336
3342
  var f, E, h, m;
3337
3343
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
3338
- if (Pt(r, a))
3344
+ if (Ut(r, a))
3339
3345
  return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3340
- const l = Rt(r, a);
3346
+ const l = Pt(r, a);
3341
3347
  if (this.env.refIds[l])
3342
3348
  return [
3343
3349
  new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
@@ -3349,22 +3355,22 @@ class Mt {
3349
3355
  const ee = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3350
3356
  this.ref.onUpdate = ee instanceof Y ? Te(ee).unwrap_or(void 0) : j(ee).unwrap_or(void 0);
3351
3357
  }
3352
- const p = Ot(n);
3358
+ const p = Rt(n);
3353
3359
  return this.ref.endpoints = [
3354
3360
  {
3355
- ...pt(s, this.container),
3361
+ ...dt(s, this.container),
3356
3362
  relation: p[0],
3357
3363
  token: A(s)
3358
3364
  },
3359
3365
  {
3360
- ...pt(i, this.container),
3366
+ ...dt(i, this.container),
3361
3367
  relation: p[1],
3362
3368
  token: A(i)
3363
3369
  }
3364
3370
  ], this.env.refIds[l] = this.declarationNode, [];
3365
3371
  }
3366
3372
  }
3367
- class Ft {
3373
+ class Bt {
3368
3374
  constructor(e, n) {
3369
3375
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3370
3376
  }
@@ -3381,7 +3387,7 @@ class Ft {
3381
3387
  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;
3382
3388
  }
3383
3389
  interpretBody(e) {
3384
- const [n, s] = jt(e.body, (i) => i instanceof w);
3390
+ const [n, s] = Yt(e.body, (i) => i instanceof w);
3385
3391
  return [
3386
3392
  ...this.interpretFields(n),
3387
3393
  ...this.interpretSubElements(s)
@@ -3421,14 +3427,17 @@ class Ft {
3421
3427
  }), n;
3422
3428
  }
3423
3429
  interpretSettingList(e) {
3424
- const n = B(e).getValue(), [s] = n.note || [];
3430
+ var i, r, a;
3431
+ const n = B(e).getValue();
3432
+ this.tableGroup.color = (i = n.color) != null && i.length ? Ke((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3433
+ const [s] = n.note || [];
3425
3434
  return this.tableGroup.note = s && {
3426
3435
  value: G(s == null ? void 0 : s.value).map(re).unwrap(),
3427
3436
  token: A(s)
3428
3437
  }, [];
3429
3438
  }
3430
3439
  }
3431
- class Bt {
3440
+ class Vt {
3432
3441
  constructor(e, n) {
3433
3442
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3434
3443
  }
@@ -3471,19 +3480,19 @@ class Zn {
3471
3480
  const s = n;
3472
3481
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3473
3482
  case "table": {
3474
- const r = new Ut(s, this.env).interpret();
3483
+ const r = new Mt(s, this.env).interpret();
3475
3484
  return this.project.tables.push(this.env.tables.get(s)), r;
3476
3485
  }
3477
3486
  case "ref": {
3478
- const r = new Mt(s, this.env).interpret();
3487
+ const r = new Ft(s, this.env).interpret();
3479
3488
  return this.project.refs.push(this.env.ref.get(s)), r;
3480
3489
  }
3481
3490
  case "tablegroup": {
3482
- const r = new Ft(s, this.env).interpret();
3491
+ const r = new Bt(s, this.env).interpret();
3483
3492
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3484
3493
  }
3485
3494
  case "enum": {
3486
- const r = new Bt(s, this.env).interpret();
3495
+ const r = new Vt(s, this.env).interpret();
3487
3496
  return this.project.enums.push(this.env.enums.get(s)), r;
3488
3497
  }
3489
3498
  case "note":
@@ -3516,15 +3525,15 @@ class Kn {
3516
3525
  const e = this.ast.body.flatMap((n) => {
3517
3526
  switch (ve(n).unwrap_or(void 0)) {
3518
3527
  case b.Table:
3519
- return new Ut(n, this.env).interpret();
3528
+ return new Mt(n, this.env).interpret();
3520
3529
  case b.Note:
3521
3530
  return new Jn(n, this.env).interpret();
3522
3531
  case b.Ref:
3523
- return new Mt(n, this.env).interpret();
3524
- case b.TableGroup:
3525
3532
  return new Ft(n, this.env).interpret();
3526
- case b.Enum:
3533
+ case b.TableGroup:
3527
3534
  return new Bt(n, this.env).interpret();
3535
+ case b.Enum:
3536
+ return new Vt(n, this.env).interpret();
3528
3537
  case b.Project:
3529
3538
  return new Zn(n, this.env).interpret();
3530
3539
  default:
@@ -3546,7 +3555,7 @@ function es(t) {
3546
3555
  project: Array.from(t.project.values())[0] || {}
3547
3556
  };
3548
3557
  }
3549
- var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), k = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(k || {});
3558
+ var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
3550
3559
  function Ae(t) {
3551
3560
  switch (t) {
3552
3561
  case T.Schema:
@@ -3578,7 +3587,7 @@ function Re(t, e) {
3578
3587
  }
3579
3588
  return !0;
3580
3589
  }
3581
- function O() {
3590
+ function D() {
3582
3591
  return {
3583
3592
  suggestions: []
3584
3593
  };
@@ -3601,29 +3610,29 @@ function Fe(t) {
3601
3610
  }))
3602
3611
  };
3603
3612
  }
3604
- function Ke(t, e) {
3613
+ function et(t, e) {
3605
3614
  return t.getOffsetAt(e);
3606
3615
  }
3607
- class Vt {
3616
+ class Gt {
3608
3617
  constructor(e, n = []) {
3609
3618
  this.compiler = e, this.triggerCharacters = n;
3610
3619
  }
3611
3620
  provideCompletionItems(e, n) {
3612
3621
  var E, h;
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];
3622
+ const s = et(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];
3614
3623
  if ([
3615
3624
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3616
3625
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3617
3626
  ...(l == null ? void 0 : l.leadingTrivia) || []
3618
- ].find((m) => Qt(m) && ge(s, m)))
3619
- return O();
3627
+ ].find((m) => qt(m) && ge(s, m)))
3628
+ return D();
3620
3629
  if (a === void 0)
3621
- return Tt();
3630
+ return bt();
3622
3631
  if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3623
- return O();
3632
+ return D();
3624
3633
  const p = this.compiler.container.element(s);
3625
- if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
3626
- return Tt();
3634
+ if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
3635
+ return bt();
3627
3636
  const f = [...this.compiler.container.stack(s)].reverse();
3628
3637
  for (const m of f)
3629
3638
  if (m instanceof Q)
@@ -3632,7 +3641,7 @@ class Vt {
3632
3641
  case "<":
3633
3642
  case "<>":
3634
3643
  case "-":
3635
- return dt(
3644
+ return Et(
3636
3645
  this.compiler,
3637
3646
  s,
3638
3647
  m
@@ -3644,13 +3653,13 @@ class Vt {
3644
3653
  case "<":
3645
3654
  case "<>":
3646
3655
  case "-":
3647
- return dt(
3656
+ return Et(
3648
3657
  this.compiler,
3649
3658
  s,
3650
3659
  m
3651
3660
  );
3652
3661
  case ".":
3653
- return Gt(
3662
+ return Ct(
3654
3663
  this.compiler,
3655
3664
  s,
3656
3665
  m
@@ -3658,22 +3667,22 @@ class Vt {
3658
3667
  }
3659
3668
  else {
3660
3669
  if (m instanceof se)
3661
- return Et(this.compiler, s, m);
3670
+ return Nt(this.compiler, s, m);
3662
3671
  if (m instanceof R)
3663
- return Et(this.compiler, s, m);
3672
+ return Nt(this.compiler, s, m);
3664
3673
  if (m instanceof Z)
3665
3674
  return ts(this.compiler, s);
3666
3675
  if (m instanceof w)
3667
- return mt(this.compiler, s, m);
3676
+ return Tt(this.compiler, s, m);
3668
3677
  if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3669
- return mt(this.compiler, s, void 0);
3678
+ return Tt(this.compiler, s, void 0);
3670
3679
  }
3671
- return O();
3680
+ return D();
3672
3681
  }
3673
3682
  }
3674
- function dt(t, e, n) {
3683
+ function Et(t, e, n) {
3675
3684
  const s = t.container.scopeKind(e);
3676
- if ([D.REF, D.TABLE].includes(s)) {
3685
+ if ([O.REF, O.TABLE].includes(s)) {
3677
3686
  const i = Be(t, e, t.container.element(e), [
3678
3687
  T.Table,
3679
3688
  T.Schema,
@@ -3681,12 +3690,12 @@ function dt(t, e, n) {
3681
3690
  ]);
3682
3691
  return Re(n.op, e) ? Pe(i) : i;
3683
3692
  }
3684
- return O();
3693
+ return D();
3685
3694
  }
3686
3695
  function Be(t, e, n, s) {
3687
3696
  var a;
3688
3697
  if (n === void 0)
3689
- return O();
3698
+ return D();
3690
3699
  let i = n;
3691
3700
  const r = { suggestions: [] };
3692
3701
  for (; i; ) {
@@ -3696,7 +3705,7 @@ function Be(t, e, n, s) {
3696
3705
  ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3697
3706
  label: p,
3698
3707
  insertText: p,
3699
- insertTextRules: k.KeepWhitespace,
3708
+ insertTextRules: y.KeepWhitespace,
3700
3709
  kind: Ae(f),
3701
3710
  sortText: Ae(f).toString().padStart(2, "0"),
3702
3711
  range: void 0
@@ -3710,33 +3719,33 @@ function Be(t, e, n, s) {
3710
3719
  function ts(t, e) {
3711
3720
  var s;
3712
3721
  switch (t.container.scopeKind(e)) {
3713
- case D.INDEXES:
3714
- return Xt(t, e);
3715
- case D.REF:
3722
+ case O.INDEXES:
3723
+ return $t(t, e);
3724
+ case O.REF:
3716
3725
  {
3717
3726
  const i = [...t.container.stack(e)];
3718
3727
  for (; i.length > 0; ) {
3719
3728
  const r = i.pop();
3720
3729
  if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3721
- return Gt(
3730
+ return Ct(
3722
3731
  t,
3723
3732
  e,
3724
3733
  r
3725
3734
  );
3726
3735
  }
3727
3736
  }
3728
- return Ct(t, e);
3737
+ return Xt(t, e);
3729
3738
  }
3730
- return O();
3739
+ return D();
3731
3740
  }
3732
- function Et(t, e, n) {
3741
+ function Nt(t, e, n) {
3733
3742
  const { token: s } = t.container.token(e);
3734
3743
  if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3735
- const i = Nt(t, e);
3744
+ const i = mt(t, e);
3736
3745
  return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
3737
3746
  }
3738
3747
  if (n.name && n.name.start <= e && n.name.end >= e)
3739
- return Nt(t, e);
3748
+ return mt(t, e);
3740
3749
  if (n.name instanceof Y) {
3741
3750
  const i = ns(
3742
3751
  t,
@@ -3745,82 +3754,83 @@ function Et(t, e, n) {
3745
3754
  );
3746
3755
  return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? Pe(i) : i;
3747
3756
  }
3748
- return O();
3757
+ return D();
3749
3758
  }
3750
- function Nt(t, e) {
3759
+ function mt(t, e) {
3751
3760
  const n = t.container.element(e), s = t.container.scopeKind(e);
3752
3761
  if (n instanceof X)
3753
- return O();
3762
+ return D();
3754
3763
  if (n.body && !ge(e, n.body))
3755
3764
  switch (s) {
3756
- case D.TABLE:
3765
+ case O.TABLE:
3757
3766
  return {
3758
- suggestions: [
3759
- {
3760
- label: "headercolor",
3761
- insertText: "headercolor: ",
3762
- kind: L.Field,
3763
- insertTextRules: k.KeepWhitespace,
3764
- range: void 0
3765
- },
3766
- {
3767
- label: "note",
3768
- insertText: "note: ",
3769
- kind: L.Field,
3770
- insertTextRules: k.KeepWhitespace,
3771
- range: void 0
3772
- }
3773
- ]
3767
+ suggestions: ["headercolor", "note"].map((i) => ({
3768
+ label: i,
3769
+ insertText: `${i}: `,
3770
+ kind: L.Field,
3771
+ insertTextRules: y.KeepWhitespace,
3772
+ range: void 0
3773
+ }))
3774
+ };
3775
+ case O.TABLEGROUP:
3776
+ return {
3777
+ suggestions: ["color", "note"].map((i) => ({
3778
+ label: i,
3779
+ insertText: `${i}: `,
3780
+ kind: L.Field,
3781
+ insertTextRules: y.KeepWhitespace,
3782
+ range: void 0
3783
+ }))
3774
3784
  };
3775
3785
  default:
3776
- return O();
3786
+ return D();
3777
3787
  }
3778
3788
  switch (s) {
3779
- case D.TABLE:
3789
+ case O.TABLE:
3780
3790
  return {
3781
3791
  suggestions: [
3782
3792
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
3783
3793
  label: i,
3784
3794
  insertText: i,
3785
3795
  kind: L.Property,
3786
- insertTextRules: k.KeepWhitespace,
3796
+ insertTextRules: y.KeepWhitespace,
3787
3797
  range: void 0
3788
3798
  })),
3789
3799
  ...["ref", "default"].map((i) => ({
3790
3800
  label: i,
3791
3801
  insertText: `${i}: `,
3792
3802
  kind: L.Property,
3793
- insertTextRules: k.KeepWhitespace,
3803
+ insertTextRules: y.KeepWhitespace,
3794
3804
  range: void 0
3795
3805
  })),
3796
3806
  {
3797
3807
  label: "note",
3798
3808
  insertText: "note: ",
3799
3809
  kind: L.Property,
3800
- insertTextRules: k.KeepWhitespace,
3810
+ insertTextRules: y.KeepWhitespace,
3801
3811
  range: void 0
3802
3812
  }
3803
3813
  ]
3804
3814
  };
3805
- case D.ENUM:
3815
+ case O.ENUM:
3806
3816
  return {
3807
3817
  suggestions: [
3808
3818
  {
3809
3819
  label: "note",
3810
3820
  insertText: "note: ",
3811
3821
  kind: L.Property,
3812
- insertTextRules: k.KeepWhitespace,
3822
+ insertTextRules: y.KeepWhitespace,
3813
3823
  range: void 0
3814
3824
  }
3815
3825
  ]
3816
3826
  };
3817
- case D.INDEXES:
3827
+ case O.INDEXES:
3818
3828
  return {
3819
3829
  suggestions: [
3820
3830
  ...["unique", "pk"].map((i) => ({
3821
3831
  label: i,
3822
3832
  insertText: i,
3823
- insertTextRules: k.KeepWhitespace,
3833
+ insertTextRules: y.KeepWhitespace,
3824
3834
  kind: L.Property,
3825
3835
  range: void 0
3826
3836
  })),
@@ -3828,23 +3838,23 @@ function Nt(t, e) {
3828
3838
  label: i,
3829
3839
  insertText: `${i}: `,
3830
3840
  kind: L.Property,
3831
- insertTextRules: k.KeepWhitespace,
3841
+ insertTextRules: y.KeepWhitespace,
3832
3842
  range: void 0
3833
3843
  }))
3834
3844
  ]
3835
3845
  };
3836
- case D.REF:
3846
+ case O.REF:
3837
3847
  return {
3838
3848
  suggestions: ["update", "delete"].map((i) => ({
3839
3849
  label: i,
3840
3850
  insertText: `${i}: `,
3841
3851
  kind: L.Property,
3842
- insertTextRules: k.KeepWhitespace,
3852
+ insertTextRules: y.KeepWhitespace,
3843
3853
  range: void 0
3844
3854
  }))
3845
3855
  };
3846
3856
  }
3847
- return O();
3857
+ return D();
3848
3858
  }
3849
3859
  function ns(t, e, n) {
3850
3860
  switch (n == null ? void 0 : n.toLowerCase()) {
@@ -3855,7 +3865,7 @@ function ns(t, e, n) {
3855
3865
  label: s,
3856
3866
  insertText: s,
3857
3867
  kind: L.Value,
3858
- insertTextRules: k.KeepWhitespace,
3868
+ insertTextRules: y.KeepWhitespace,
3859
3869
  range: void 0
3860
3870
  }))
3861
3871
  };
@@ -3865,17 +3875,17 @@ function ns(t, e, n) {
3865
3875
  label: s,
3866
3876
  insertText: `${s}`,
3867
3877
  kind: L.Value,
3868
- insertTextRules: k.KeepWhitespace,
3878
+ insertTextRules: y.KeepWhitespace,
3869
3879
  range: void 0
3870
3880
  }))
3871
3881
  };
3872
3882
  }
3873
- return O();
3883
+ return D();
3874
3884
  }
3875
- function Gt(t, e, n) {
3885
+ function Ct(t, e, n) {
3876
3886
  const s = pe(n).unwrap_or([]);
3877
3887
  if (s.pop(), s.some((r) => !M(r)))
3878
- return O();
3888
+ return D();
3879
3889
  const i = s.map((r) => j(r).unwrap());
3880
3890
  return Fe({
3881
3891
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
@@ -3886,44 +3896,44 @@ function Gt(t, e, n) {
3886
3896
  }))
3887
3897
  });
3888
3898
  }
3889
- function mt(t, e, n) {
3899
+ function Tt(t, e, n) {
3890
3900
  var i;
3891
3901
  switch (t.container.scopeKind(e)) {
3892
- case D.TABLE:
3902
+ case O.TABLE:
3893
3903
  return is(t, e, n);
3894
- case D.PROJECT:
3904
+ case O.PROJECT:
3895
3905
  return rs(t, e, n);
3896
- case D.INDEXES:
3906
+ case O.INDEXES:
3897
3907
  return os(t, e);
3898
- case D.ENUM:
3908
+ case O.ENUM:
3899
3909
  return ss(t, e, n);
3900
- case D.REF: {
3901
- const r = Ct(t, e);
3910
+ case O.REF: {
3911
+ const r = Xt(t, e);
3902
3912
  return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Re(t.container.token(e).token, e) ? Pe(r) : r;
3903
3913
  }
3904
- case D.TABLEGROUP:
3914
+ case O.TABLEGROUP:
3905
3915
  return as(t);
3906
3916
  default:
3907
- return O();
3917
+ return D();
3908
3918
  }
3909
3919
  }
3910
- function Tt() {
3920
+ function bt() {
3911
3921
  return {
3912
3922
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3913
3923
  label: t,
3914
3924
  insertText: t,
3915
- insertTextRules: k.KeepWhitespace,
3925
+ insertTextRules: y.KeepWhitespace,
3916
3926
  kind: L.Keyword,
3917
3927
  range: void 0
3918
3928
  }))
3919
3929
  };
3920
3930
  }
3921
3931
  function ss(t, e, n) {
3922
- return n != null && n.callee && et(e, n) === 1 ? Be(t, e, t.container.element(e), [
3932
+ return n != null && n.callee && tt(e, n) === 1 ? Be(t, e, t.container.element(e), [
3923
3933
  T.Schema,
3924
3934
  T.Table,
3925
3935
  T.Column
3926
- ]) : O();
3936
+ ]) : D();
3927
3937
  }
3928
3938
  function is(t, e, n) {
3929
3939
  if (!(n != null && n.callee))
@@ -3931,42 +3941,42 @@ function is(t, e, n) {
3931
3941
  suggestions: ["Note", "indexes"].map((i) => ({
3932
3942
  label: i,
3933
3943
  insertText: i,
3934
- insertTextRules: k.KeepWhitespace,
3944
+ insertTextRules: y.KeepWhitespace,
3935
3945
  kind: L.Keyword,
3936
3946
  range: void 0
3937
3947
  }))
3938
3948
  };
3939
- const s = et(e, n);
3949
+ const s = tt(e, n);
3940
3950
  return s === 0 ? {
3941
3951
  suggestions: ["Note", "indexes"].map((i) => ({
3942
3952
  label: i,
3943
3953
  insertText: i,
3944
- insertTextRules: k.KeepWhitespace,
3954
+ insertTextRules: y.KeepWhitespace,
3945
3955
  kind: L.Keyword,
3946
3956
  range: void 0
3947
3957
  }))
3948
- } : s === 1 ? cs(t, e) : O();
3958
+ } : s === 1 ? ls(t, e) : D();
3949
3959
  }
3950
3960
  function rs(t, e, n) {
3951
- return n != null && n.callee ? et(e, n) === 0 ? {
3961
+ return n != null && n.callee ? tt(e, n) === 0 ? {
3952
3962
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3953
3963
  label: i,
3954
3964
  insertText: i,
3955
- insertTextRules: k.KeepWhitespace,
3965
+ insertTextRules: y.KeepWhitespace,
3956
3966
  kind: L.Keyword,
3957
3967
  range: void 0
3958
3968
  }))
3959
- } : O() : {
3969
+ } : D() : {
3960
3970
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3961
3971
  label: i,
3962
3972
  insertText: i,
3963
- insertTextRules: k.KeepWhitespace,
3973
+ insertTextRules: y.KeepWhitespace,
3964
3974
  kind: L.Keyword,
3965
3975
  range: void 0
3966
3976
  }))
3967
3977
  };
3968
3978
  }
3969
- function Ct(t, e) {
3979
+ function Xt(t, e) {
3970
3980
  return Be(t, e, t.container.element(e), [
3971
3981
  T.Schema,
3972
3982
  T.Table,
@@ -3974,26 +3984,37 @@ function Ct(t, e) {
3974
3984
  ]);
3975
3985
  }
3976
3986
  function as(t) {
3977
- return Fe({
3978
- suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3979
- const n = ie(e).unwrap_or(void 0);
3980
- if (n === void 0)
3981
- return [];
3982
- const { kind: s, name: i } = n;
3983
- return s !== T.Table && s !== T.Schema ? [] : {
3984
- label: i,
3985
- insertText: i,
3986
- insertTextRules: k.KeepWhitespace,
3987
- kind: Ae(s),
3987
+ return {
3988
+ suggestions: [
3989
+ ...Fe({
3990
+ suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3991
+ const n = ie(e).unwrap_or(void 0);
3992
+ if (n === void 0)
3993
+ return [];
3994
+ const { kind: s, name: i } = n;
3995
+ return s !== T.Table && s !== T.Schema ? [] : {
3996
+ label: i,
3997
+ insertText: i,
3998
+ insertTextRules: y.KeepWhitespace,
3999
+ kind: Ae(s),
4000
+ range: void 0
4001
+ };
4002
+ })
4003
+ }).suggestions,
4004
+ ...["Note"].map((e) => ({
4005
+ label: e,
4006
+ insertText: e,
4007
+ insertTextRules: y.KeepWhitespace,
4008
+ kind: L.Keyword,
3988
4009
  range: void 0
3989
- };
3990
- })
3991
- });
4010
+ }))
4011
+ ]
4012
+ };
3992
4013
  }
3993
4014
  function os(t, e) {
3994
- return Xt(t, e);
4015
+ return $t(t, e);
3995
4016
  }
3996
- function cs(t, e) {
4017
+ function ls(t, e) {
3997
4018
  return {
3998
4019
  suggestions: [
3999
4020
  ...[
@@ -4056,7 +4077,7 @@ function cs(t, e) {
4056
4077
  ].map((n) => ({
4057
4078
  label: n,
4058
4079
  insertText: n,
4059
- insertTextRules: k.KeepWhitespace,
4080
+ insertTextRules: y.KeepWhitespace,
4060
4081
  kind: L.TypeParameter,
4061
4082
  sortText: L.TypeParameter.toString().padStart(2, "0"),
4062
4083
  range: void 0
@@ -4068,10 +4089,10 @@ function cs(t, e) {
4068
4089
  ]
4069
4090
  };
4070
4091
  }
4071
- function Xt(t, e) {
4092
+ function $t(t, e) {
4072
4093
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4073
- if (!((s == null ? void 0 : s.symbol) instanceof At))
4074
- return O();
4094
+ if (!((s == null ? void 0 : s.symbol) instanceof vt))
4095
+ return D();
4075
4096
  const { symbolTable: i } = s.symbol;
4076
4097
  return Fe({
4077
4098
  suggestions: [...i.entries()].flatMap(([r]) => {
@@ -4082,26 +4103,26 @@ function Xt(t, e) {
4082
4103
  return {
4083
4104
  label: l,
4084
4105
  insertText: l,
4085
- insertTextRules: k.KeepWhitespace,
4106
+ insertTextRules: y.KeepWhitespace,
4086
4107
  kind: Ae(T.Column),
4087
4108
  range: void 0
4088
4109
  };
4089
4110
  })
4090
4111
  });
4091
4112
  }
4092
- function et(t, e) {
4113
+ function tt(t, e) {
4093
4114
  if (!e.callee)
4094
4115
  return -1;
4095
4116
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
4096
4117
  return s === -1 ? n.length : s;
4097
4118
  }
4098
- class $t {
4119
+ class Wt {
4099
4120
  constructor(e) {
4100
4121
  this.compiler = e;
4101
4122
  }
4102
4123
  provideDefinition(e, n) {
4103
4124
  var a;
4104
- const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
4125
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
4105
4126
  for (; r.length !== 0; ) {
4106
4127
  const l = r.pop();
4107
4128
  if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
@@ -4122,12 +4143,12 @@ class $t {
4122
4143
  return [];
4123
4144
  }
4124
4145
  }
4125
- class Wt {
4146
+ class jt {
4126
4147
  constructor(e) {
4127
4148
  this.compiler = e;
4128
4149
  }
4129
4150
  provideReferences(e, n) {
4130
- const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
4151
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
4131
4152
  for (; r.length !== 0; ) {
4132
4153
  const a = r.pop();
4133
4154
  if (a && [
@@ -4153,22 +4174,22 @@ class Wt {
4153
4174
  }
4154
4175
  const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4155
4176
  __proto__: null,
4156
- CompletionItemInsertTextRule: k,
4177
+ CompletionItemInsertTextRule: y,
4157
4178
  CompletionItemKind: L,
4158
- DBMLCompletionItemProvider: Vt,
4159
- DBMLDefinitionProvider: $t,
4160
- DBMLReferencesProvider: Wt
4179
+ DBMLCompletionItemProvider: Gt,
4180
+ DBMLDefinitionProvider: Wt,
4181
+ DBMLReferencesProvider: jt
4161
4182
  }, Symbol.toStringTag, { value: "Module" }));
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 || {});
4183
+ var O = /* @__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))(O || {});
4163
4184
  class fs {
4164
4185
  constructor() {
4165
4186
  this.source = "", this.cache = new Array(
4166
4187
  16
4167
4188
  /* TOTAL_QUERY_COUNT */
4168
- ).fill(null), this.nodeIdGenerator = new qt(), this.symbolIdGenerator = new en(), this.token = {
4189
+ ).fill(null), this.nodeIdGenerator = new Ht(), this.symbolIdGenerator = new tn(), this.token = {
4169
4190
  invalidStream: this.createQuery(
4170
4191
  6,
4171
- () => this.parse.tokens().filter(vt)
4192
+ () => this.parse.tokens().filter(wt)
4172
4193
  ),
4173
4194
  // Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
4174
4195
  flatStream: this.createQuery(
@@ -4180,7 +4201,7 @@ class fs {
4180
4201
  _: this.createQuery(
4181
4202
  0,
4182
4203
  () => {
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 })));
4204
+ const e = new fn(this.source).lex().chain((n) => new En(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4184
4205
  return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Kn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4185
4206
  }
4186
4207
  ),
@@ -4205,14 +4226,14 @@ class fs {
4205
4226
  stack: this.createQuery(
4206
4227
  10,
4207
4228
  (e) => {
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);
4229
+ const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : zt(n, (f) => !f.isInvalid, s);
4209
4230
  if (r === -1)
4210
4231
  return [this.parse.ast()];
4211
4232
  const a = n[r].start;
4212
4233
  let l = this.parse.ast();
4213
4234
  const p = [l];
4214
4235
  for (; ; ) {
4215
- const E = un(l).find((h) => ge(a, h));
4236
+ const E = hn(l).find((h) => ge(a, h));
4216
4237
  if (E === void 0 || E instanceof F)
4217
4238
  break;
4218
4239
  p.push(E), l = E;
@@ -4221,7 +4242,7 @@ class fs {
4221
4242
  return p;
4222
4243
  for (; p.length > 0; ) {
4223
4244
  let f = !1;
4224
- const E = it(p);
4245
+ const E = rt(p);
4225
4246
  if (E instanceof w) {
4226
4247
  const h = this.parse.source();
4227
4248
  for (let m = E.end; m < e; m += 1)
@@ -4230,7 +4251,7 @@ class fs {
4230
4251
  } else
4231
4252
  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);
4232
4253
  if (f) {
4233
- const h = it(p);
4254
+ const h = rt(p);
4234
4255
  h instanceof v && h.end <= e && p.pop();
4235
4256
  }
4236
4257
  if (!f)
@@ -4311,7 +4332,7 @@ class fs {
4311
4332
  let l = [a], p = [];
4312
4333
  for (const f of e)
4313
4334
  p = l.flatMap(
4314
- (E) => Zt(f).flatMap((h) => {
4335
+ (E) => Kt(f).flatMap((h) => {
4315
4336
  const m = E.get(h), g = ie(h).unwrap_or(void 0);
4316
4337
  return !m || !g ? [] : { ...g, symbol: m };
4317
4338
  })
@@ -4354,9 +4375,9 @@ class fs {
4354
4375
  }
4355
4376
  initMonacoServices() {
4356
4377
  return {
4357
- definitionProvider: new $t(this),
4358
- referenceProvider: new Wt(this),
4359
- autocompletionProvider: new Vt(this)
4378
+ definitionProvider: new Wt(this),
4379
+ referenceProvider: new jt(this),
4380
+ autocompletionProvider: new Gt(this)
4360
4381
  };
4361
4382
  }
4362
4383
  }